Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

What's the range of the ADC on the typical microcontroller.

Status
Not open for further replies.

AverageGuy

New Member
I am starting to work on a project, or the idea of a project, to sense the current draw of a 12 DC motor. My thinking is to add a small shunt in the negative lead of the motor and use a microcontroller with an ADC to read the voltage drop, but I was a bit concerned about using an ADC at the extreme range. I wouldn't want to drop the voltage more than a few hundred millivolts so will an ADC read down to the rail? I don't necessarily need accuracy, just repeatability.

A second related question is about controlling the motor. I need to turn it on/off. It draws about 8 amps. I'm toying with using a 2n3055 since I've got a couple around, but wonder if there is something else out there that would do a better job? I know a relay would work but I'm most concerned about how much amplification I'd need to drive either solution.


Thanks,
Jim.
 
Last edited:
How about using an opamp to scale the voltage across the resistor to the full range of the ADC ?

It would be easier if I didn't have to. I only have 12V and no way to get a negative voltage without a dc-dc converter. Too much complexity if it's not necessary.

Jim.
 
Why do you need a negative voltage drop across the shunt resistor or anywhere else for that matter? If the motor isn't reversible, it won't matter since current only flows one way through the resistor, and if it is then an H-bridge will be present and the shunt resistor can just go in series with the one of the H-bridge input power/ground terminals so that the current will always flow one way through the resistor regardless of motor direction.

The "negative" terminal of the motor is actually going to be connected to ground, not a negative voltage. Negative just means less than positive, not less than zero.

ANd yes, op-amp to scale it up if you are using a low-side current sense resistor. At such a low voltage drop you are going to get about 2-bits of resolution if you just use the low end.

My opnion is that a MOSFET would do a better job than an NPN, but the 2n3055 was designed for power so just heatsink it and use it.
 
Last edited:
The ADC range commonly on most uPs is Vss to Vdd, ie 0 to 5V. Some allow rescaling the range to be narrower than the full supply range, but still usually more than 2V. With a 12bit ADC, the step size would be 5V/4096 ≈ 1mV.

With a standard 50mV/10A shunt, you would only get 50 discrete steps...

You could use a high-side current monitor chip as described in this post, and scale your current reading such that full-scale=5V, and thereby utilize the full ADC range.
 
Why do you need a negative voltage drop across the shunt resistor or anywhere else for that matter? If the motor isn't reversible, it won't matter since current only flows one way through the resistor, and if it is then an H-bridge will be present and the shunt resistor can just go in series with the one of the H-bridge input power/ground terminals so that the current will always flow one way through the resistor regardless of motor direction.

The "negative" terminal of the motor is actually going to be connected to ground, not a negative voltage. Negative just means less than positive, not less than zero.

ANd yes, op-amp to scale it up if you are using a low-side current sense resistor. At such a low voltage drop you are going to get about 2-bits of resolution if you just use the low end.

My opnion is that a MOSFET would do a better job than an NPN, but the 2n3055 was designed for power so just heatsink it and use it.

I've only worked with op amps that cannot sense signals rail to rail. The 741 for instance doesn't start seeing any input until it is over a volt, if my memory serves me right. The only way that would work is if I biased the signal more to the center of the input range, hence the need for a negative supply.

I don't have any experience in FET work outside of small signal rf amps. If you or anyone has a sample circuit or can point me to a MOSFET power switch circuit, I'd really rather use that.

Thanks,
Jim.
 
So just use a rail-rail single supply op-amp like the opA364 from texas instruments (really dual supply works too and makes no difference. Just make the difference between ground and +V the same difference as the voltage potential between the dual power supply). WIre it up as a regular non-inverting amplifier to feed into your ADC. Bam! Done!

I am assuming this is for a unidirectional motor. Connect the motor and FET like the following on the right hand side of the schematic:

In case you are curious, the rest of the schematic is to generate a variable PWM control signal for "lossless" variable speed control of the motor.

You also need a fast schottky diode anti-parallel to the motor in order to allow the current from the inductive spike (resulting from abruptly interrupting current flow through an inductive load) otherwise it will form a voltage spike instead and fry the MOSFET. This diode is missing from the circuit.

If you are switching the MOSFET at high frequency (ie. for PWM in the kHz range or higher) then you will need a gate driver IC. It provides a fast current pulse to quickly charge/discharge the gate capacitor of the MOSFET to make it switch on/off faster. MOSFETs dissipate little power when fully off or fully on, but as they transition between on/off they dissipate a lot of heat. Switching at high frequency makes you spend more time in this region increasing heat, so you decrease this transition time as you increase switching frequency to keep losses/heating low.

But since you referred to a relay as an alternative, I suspect you are only doing low speed switching. In which case you need nothing more than a voltage that is high enough to turn on the gate off the MOSFET (usually around ~10V, 3-5V for logic-level MOSFETs). THe switching rate is very low so the time spent transitioning is very low so the heating is negligible. Once the capacitance charges up, once the MOSFET gate basically draws no current, so current supply capability of the driver isn't an issue. Only voltage.
 
Last edited:
The ADC range commonly on most uPs is Vss to Vdd, ie 0 to 5V. Some allow rescaling the range to be narrower than the full supply range, but still usually more than 2V. With a 12bit ADC, the step size would be 5V/4096 ≈ 1mV.

With a standard 50mV/10A shunt, you would only get 50 discrete steps...

You could use a high-side current monitor chip as described in this post, and scale your current reading such that full-scale=5V, and thereby utilize the full ADC range.

That's exactly what I've been looking for!

Thanks,
Jim.
 
Even the old LM324/LM358s have a common mode input range from (Vss-0.3) to (Vdd-1.5V). They can be used to sense the current in a grounded shunt without using a negative power supply.
 
Even the old LM324/LM358s have a common mode input range from (Vss-0.3) to (Vdd-1.5V). They can be used to sense the current in a grounded shunt without using a negative power supply.

I wasn't aware of that. Nice to know for the future. Will make my life a bit easier. And just for clarification, 'cause I don't really know. Did you really mean Vss-0.3. If that's true, I'm really impressed.

Thanks again,
Jim.
Oh and I apologize for this being late. The moderators are blocking me until I get some posts under my belt. I'm trying to respond in a timely manner.
 
Yes, I meant 0.3V below ground :D. Download the spec sheet **broken link removed**, and read note 10.
 
So just use a rail-rail single supply op-amp like the opA364 from texas instruments (really dual supply works too and makes no difference. Just make the difference between ground and +V the same difference as the voltage potential between the dual power supply). WIre it up as a regular non-inverting amplifier to feed into your ADC. Bam! Done!
Sounds simple enough. I can handle op-amp design, I've done a few of them. Suprisingly enough, most of them worked.

I am assuming this is for a unidirectional motor. Connect the motor and FET like the following on the right hand side of the schematic:

In case you are curious, the rest of the schematic is to generate a variable PWM control signal for "lossless" variable speed control of the motor.

You also need a fast schottky diode anti-parallel to the motor in order to allow the current from the inductive spike (resulting from abruptly interrupting current flow through an inductive load) otherwise it will form a voltage spike instead and fry the MOSFET. This diode is missing from the circuit.
Correct, it's a pump motor. Turn it on, watch for the current draw to drop indicating all the water has been pumped out, or xxx seconds to prevent a runaway. It has a conventional level switch/pump as a backup at a higher level.

If you are switching the MOSFET at high frequency (ie. for PWM in the kHz range or higher) then you will need a gate driver IC. It provides a fast current pulse to quickly charge/discharge the gate capacitor of the MOSFET to make it switch on/off faster. MOSFETs dissipate little power when fully off or fully on, but as they transition between on/off they dissipate a lot of heat. Switching at high frequency makes you spend more time in this region increasing heat, so you decrease this transition time as you increase switching frequency to keep losses/heating low.
I've worked with CMOS enough to understand that problem, but it's not a consideration here.

But since you referred to a relay as an alternative, I suspect you are only doing low speed switching. In which case you need nothing more than a voltage that is high enough to turn on the gate off the MOSFET (usually around ~10V, 3-5V for logic-level MOSFETs). THe switching rate is very low so the time spent transitioning is very low so the heating is negligible. Once the capacitance charges up, once the MOSFET gate basically draws no current, so current supply capability of the driver isn't an issue. Only voltage.
So a conventional MOSFET with a 2N3906 collector tied to a 20:1 voltage divider (a 1k to the Vdd (+12V) and a 20k to GND tied to the gate would fire it? I haven't run the numbers to see what it would take to drive the circuit or if it might be better to sink rather than source the base. And it will depend on the processor I select as to what state the output pins come up, perhaps, but I've been here before so that's not a big deal.

What kind of current rating is needed for the diode? I assume a 1N400x isn't adequate?

Thanks,
Jim.
 
The ADC range commonly on most uPs is Vss to Vdd, ie 0 to 5V. Some allow rescaling the range to be narrower than the full supply range, but still usually more than 2V. With a 12bit ADC, the step size would be 5V/4096 ≈ 1mV.

With a standard 50mV/10A shunt, you would only get 50 discrete steps...

You could use a high-side current monitor chip as described in this post, and scale your current reading such that full-scale=5V, and thereby utilize the full ADC range.

I did post a reply thanking you for this advice. For some reason the system held it for moderation, however I've posted two replies since that when through immediately.

Thanks for the tip. This may be a duplicate eventually.

Jim.
 
Here is a simple sim I cobbled up:
 

Attachments

  • IV.jpg
    IV.jpg
    254.6 KB · Views: 151
Sounds simple enough. I can handle op-amp design, I've done a few of them. Suprisingly enough, most of them worked.


Correct, it's a pump motor. Turn it on, watch for the current draw to drop indicating all the water has been pumped out, or xxx seconds to prevent a runaway. It has a conventional level switch/pump as a backup at a higher level.


I've worked with CMOS enough to understand that problem, but it's not a consideration here.


So a conventional MOSFET with a 2N3906 collector tied to a 20:1 voltage divider (a 1k to the Vdd (+12V) and a 20k to GND tied to the gate would fire it? I haven't run the numbers to see what it would take to drive the circuit or if it might be better to sink rather than source the base. And it will depend on the processor I select as to what state the output pins come up, perhaps, but I've been here before so that's not a big deal.

What kind of current rating is needed for the diode? I assume a 1N400x isn't adequate?

Thanks,
Jim.

You just need to the diode peak current rating in this case, not continuous since the diode isn't conducting all the time- Just when the motors shuts off. Peak current of diode = maximum current of motor is a good way to go (assuming the peak current ratings of the diode are on the right time scale for the inductuve spike. It's all pretty hard to predict though so just ballpark it.)
I wouldn't worry about it too much unless the diode is unreasonably small. BUt the diode has to be fast, and preferably low voltage drop like a schottky diode. The 1N00x is not sufficient. The 1N4148/1N4448 is faster, but it's peak current handling is too low.

The ~10V gate voltage required for most MOSFETs to turn on is just that. It is NOT the max voltage the gate can handle. Usually the max is 20V, sometimes even 30V. MOSFETs that require gate voltages of 3-5V to turn on will have lower maximum gate voltages. So you you could just connect the gate to +12V through a pull-up resistor and connect the BJT to the gate as a pull-down transistor.

BJT switch off = MOSFET on, BJT switch on = MOSFET OFF.
 
Last edited:
You just need to the diode peak current rating in this case, not continuous since the diode isn't conducting all the time- Just when the motors shuts off. Peak current of diode = maximum current of motor is a good way to go (assuming the peak current ratings of the diode are on the right time scale for the inductuve spike. It's all pretty hard to predict though so just ballpark it.)
I wouldn't worry about it too much unless the diode is unreasonably small. BUt the diode has to be fast, and preferably low voltage drop like a schottky diode. The 1N00x is not sufficient. The 1N4148/1N4448 is faster, but it's peak current handling is too low.

The ~10V gate voltage required for most MOSFETs to turn on is just that. It is NOT the max voltage the gate can handle. Usually the max is 20V, sometimes even 30V. MOSFETs that require gate voltages of 3-5V to turn on will have lower maximum gate voltages. So you you could just connect the gate to +12V through a pull-up resistor and connect the BJT to the gate as a pull-down transistor.

BJT switch off = MOSFET on, BJT switch on = MOSFET OFF.

It's scary, but I understand what you said. I'll probably bias the BJT on and let microcontroller switch it off to start the motor. I'm sure I can find a chip with an open collector output or two. If not I can always add a second transistor or a zener to get an acceptable voltage.

Thanks for all the help.

Jim.
 
Why not just use a Logic level FET like the IRLZ44, etc?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top