### Author Topic: Measure current with microcontroller  (Read 3129 times)

0 Members and 1 Guest are viewing this topic.

#### Jdog

• Robot Overlord
• Posts: 259
##### Measure current with microcontroller
« on: July 05, 2010, 09:50:45 AM »
Hello. I have a microcontroller that is powered by batteries that are recharged by solar panels. I want to be able to measure the current output of the solar panels that are powering it, to see if one of them gets damaged, covered with something, etc. I have seen this: http://www.societyofrobots.com/sensors_currentsensor.shtml but I am not so sure that those sensors are what I want. Does anyone know of a circuit I could use with an ADC port on the microcontroller to do this?

#### Soeren

• Supreme Robot
• Posts: 4,672
##### Re: Measure current with microcontroller
« Reply #1 on: July 05, 2010, 12:09:43 PM »
Hi,

You left out the important details...
Min. and max. current?
Min. and max. Voltage?
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Engineering is based on numbers - not adjectives

#### TrickyNekro

• Contest Winner
• Supreme Robot
• Posts: 1,207
• 1.6L Peugeot 307 tuner
##### Re: Measure current with microcontroller
« Reply #2 on: July 05, 2010, 01:05:00 PM »
Google for resistor based current sensors....

All you typically need is a very small resistor and a high gain amplifier...

How high is the gain is depended on your current demands and the value of the resistor,

The gain is easily adjustable so it's recommended over the resistor change.

You SHOULD by the way calculate the wattage of the resistor, which is the current that goes through multiplied by the voltage drop on the resistor.

By judging using as a power supply the solar panels, you shouldn't need "big" resistors (wattage)...

Some AVRs have a 100x gain on some ADC channels (see the datasheet)
You may be able to get away with it, if the current demands aren't great ;-)
For whom the interrupts toll...

P.S. I've been inactive for almost a year... Don't give promises but I'll try to complete my tutorials. I'll let you know when..

Cheers!

#### Jdog

• Robot Overlord
• Posts: 259
##### Re: Measure current with microcontroller
« Reply #3 on: July 05, 2010, 08:07:03 PM »
All you typically need is a very small resistor and a high gain amplifier...

How high is the gain is depended on your current demands and the value of the resistor,

The gain is easily adjustable so it's recommended over the resistor change.

You SHOULD by the way calculate the wattage of the resistor, which is the current that goes through multiplied by the voltage drop on the resistor.

By judging using as a power supply the solar panels, you shouldn't need "big" resistors (wattage)...

Some AVRs have a 100x gain on some ADC channels (see the datasheet)
You may be able to get away with it, if the current demands aren't great ;-)

I am using a PIC micro controller, to be specific the PIC16F1827. I don't quite understand how a resistor and high gain amplifier could be used to measure current though. Could you explain?

Here are the specs for the panels:

Peak Power (Pmax,W): 270 W
Power Tolerance (%): ±3%
Max Power Voltage (Vmp): 35.5 V
Max Power Current (Imp): 7.61 A
Open Circuit Voltage (Voc): 44.5 V
Short Circuit Current (Isc): 8.30 A

#### waltr

• Supreme Robot
• Posts: 1,904
##### Re: Measure current with microcontroller
« Reply #4 on: July 05, 2010, 09:08:58 PM »
Quote
I don't quite understand how a resistor and high gain amplifier could be used to measure current though. Could you explain?

Ohm's Law, E = I*R
Make R small so that E is small (voltage drop) then amplify E to get into the range of the ADC input.

#### Soeren

• Supreme Robot
• Posts: 4,672
##### Re: Measure current with microcontroller
« Reply #5 on: July 05, 2010, 09:36:29 PM »
Hi,

Here are the specs for the panels:

Peak Power (Pmax,W): 270 W
Power Tolerance (%): ±3%
Max Power Voltage (Vmp): 35.5 V
Max Power Current (Imp): 7.61 A
Open Circuit Voltage (Voc): 44.5 V
Short Circuit Current (Isc): 8.30 A

With these numbers, I'd go for a Hall Effect current sensor in a solar setup.
Digi-Key should be able to sell you such a beast.
Regards,
Søren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Engineering is based on numbers - not adjectives

#### Jdog

• Robot Overlord
• Posts: 259
##### Re: Measure current with microcontroller
« Reply #6 on: July 06, 2010, 09:21:00 AM »
Quote
I don't quite understand how a resistor and high gain amplifier could be used to measure current though. Could you explain?

Ohm's Law, E = I*R
Make R small so that E is small (voltage drop) then amplify E to get into the range of the ADC input.

Ahh, I understand now, thank you.

With these numbers, I'd go for a Hall Effect current sensor in a solar setup.
Digi-Key should be able to sell you such a beast.

That looks perfect. I just have one question though. On the site, where it says primary nominal value, is that the minimum current it can read? And then it also says the secondary signal is in mV so I would then have to amplify that to logic levels right?