PIC for sensing motor current?

Status
Not open for further replies.

Hank Fletcher

New Member
I'm just kind of thinking out loud here, but is it possible to use a 16F88 to sense the current of a small motor like this:
https://www.goldmine-elec-products.com/prodinfo.asp?number=G2110

Presuming the load resulted in something no greater than 1/2 an amp, could I use the 16F88 to cut the power to the motor when the current goes above that? Somehow I know the obvious answer is yes, but I'm just trying to figure out the best way to do that.

I'm not looking for any code, or even schematics, but if you think it'd be helpful, by all means I'll take a look. Even just a description of the best way to do this would be great. Powering the motor with the PIC I'm okay with, I'm just looking for the best way to sense the current, so any tips would be greatly appreciated!
 
This is how a lot of the modern stepper motor controllers do it. Check out some of the stepper controllers at Allegro - they have some great docs on how it works. They use a sense resistor in series on the ground side of the coils. This is used to feed a comparator and the comparator output enables the MOSFET drivers. When the current reaches a pre-set level the comparator turns off and cuts the MOSFET driver(s). This way, you can drive a motor at a much higher voltage than it's rated for. I'm not sure you would want to use the comparator in the PIC, depending on it's speed. You could use a digital pot to control the ref input of the comparator.

A cruder way to do this is to calculate the pulse width needed to drive at a higher voltage. Then code that into you PIC program. Instead of varying the PWM duty cycle, you keep the pulse width constant and vary the PWM frequency. I suppose you could use the ADC to determine the supply voltage and compute pulse width from that. Hmmm, that might actually work pretty well. You might also be able to use the ADC to measure current but that's going to be a bit trickier - worth a closer look though.
 
Last edited:
Sense resistors are often called shunts because they're just really low value resistors. Often you have to pass the 'output' of a shunt through an opamp to get it to a high enough level to measure. Most shunts are valued in order to provide 200mv's or so of signal at it's full rated load to reduce wasted power. A lot of cheap charge circuits and feedback circuits where power dissipation isn't critical use 1ohm shunts, but it depends greatly on the total resistance of the circuit.
 
As long as you are running the motor at its specified voltage, it should not go past its safe current rating. Why exactly would you need to measure this? In a stalled motor situation?
In any case, these are low power motors and you might be able to get away with using a 1% 1ohm resistor and an op-amp to amplify the voltage across it, as Sceadwian mentioned.

You could use a pnp transistor and a PIC output(low to activate transistor) to turn the motor on or off, and the A/D converter for the voltage from the op-amp.
 
Last edited:

How about from here- turns on the comparators and in turn sends a high (or low) to the PIC interrupt and turns off the motor.

 
Ambient said:
As long as you are running the motor at its specified voltage, it should not go past its safe current rating.

That would be a dream motor everybody wants.

Motor current depends on external mechanical loading. If one overloads the motor, then motor current increases. The motor itself will not limit its operating current.
 
Hi Hank,

for protect and verify any current in my applications like motors or other loads, i used a very smart component: VN610SP (manufacturer ST)
Advantages is a current mirror accessible in the status pin, so you can measured with accuracy the consomption and detect any default like load disconnect or short circuit.
It's an high side Mos driver, very easy to connect at any µC.
It works well up to 42V and accept until 45Amps, package is SOPOWER-10, no cooler needed just PCB copper for I>10A (Rds(on)=0.01), price is 5.47$ for 1 item at digikey by example.

Only 2 resistors around this and your application will be very robust, and quickly protect.
Try it and you elect it.
Good luck.
 
Last edited:
eblc1388 said:
That would be a dream motor everybody wants.

Motor current depends on external mechanical loading. If one overloads the motor, then motor current increases. The motor itself will not limit its operating current.

Well I should have specified that then. I was thinking along the lines of a motor that was in a controlled situation, like in a fan unit. I do know about the load causing more current. I geared an 8-turn double wind motor too high once. I had a great battery pack so the motor ended up de-soldering itself lol.
 
Wingmax said:
How about from here- turns on the comparators and in turn sends a high (or low) to the PIC interrupt and turns off the motor.

well for one there is going to be some amount of latency in that. but more importantly, why not just use the comparator output to control the drive transistor (mosfet). seems a lot simpler.

the second approach was an attempt to eliminate the comparators and just use the micro.
 
Thanks for all the advice.

The idea was to sense the current for the purpose of being able to cut the power to the motor whenever the motor stalled. That presumes that the only time the current spikes, the motor is stalled, which seems reasonable, I think.

With that being (to my mind, at least) a most practical thing to want to do, I guess I thought the solution would be more obvious. I'm going to have to think about the options for a bit, but keep those tips coming!
 
philba said:
well for one there is going to be some amount of latency in that. but more importantly, why not just use the comparator output to control the drive transistor (mosfet). seems a lot simpler.


Yes, that would be much simpler but the controller has to be aware that something's wrong and take appropriate action as well.

 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…