Go Down

Topic: Measuring generator voltage with arduino (Read 918 times) previous topic - next topic

polishdude20

have this small DC motor most likely from a drill. I have tested it by hooking up an LED to it and connecting the generator shaft to a cordless drill. I pushed the drills button fully on the low setting and the LED did not burn out. So I was wondering how can I set up the arduino (Uno) so I can measure the voltage coming from the generator and see it on my computer screen?

polishdude20


Start by measuring the peak voltage (at maximum RPM) with a volt meter. Then use a voltage divider (two resistors) to divide that peak voltage down to a voltage that is safe for the Arduino (i.e never greater than 5V).

If you don't already have a digital multi-meter (for measuring volts, amps, ohms. etc.) you should have one if you are going to do any experimenting with electronic circuits.  They can be found for as little as $5 if you shop carefully.


Ok and after that what do I do? I mean with the code and hookup?

CrossRoads

After you determine that your voltage will be below 5V, or can be divided down to remain under 5v, than you can connect it to one of the analog inputs,
read it
value = analogRead (A0);
for example,  and then send it via serial/usb connection to the PC and see it on the serial monitor in the IDE:
Serial.print("motor value ");
Serial.print (value, DEC);   // result will be a number from 0 to 1023 with 1 = ~4.89mV (or, 5V/1023).
If you want it as a voltage, multiply it out, see FLOAT type variables in the reference section
float voltage = ((value/1023)*5); // does the math with decimal places
Serial.print (voltage, 2); // prints  a number with 2 decimal places, ex 4.35   

This presumes you have the basics of your sketch setup also, which I didn't go into.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

polishdude20


After you determine that your voltage will be below 5V, or can be divided down to remain under 5v, than you can connect it to one of the analog inputs,
read it
value = analogRead (A0);
for example,  and then send it via serial/usb connection to the PC and see it on the serial monitor in the IDE:
Serial.print("motor value ");
Serial.print (value, DEC);   // result will be a number from 0 to 1023 with 1 = ~4.89mV (or, 5V/1023).
If you want it as a voltage, multiply it out, see FLOAT type variables in the reference section
float voltage = ((value/1023)*5); // does the math with decimal places
Serial.print (voltage, 2); // prints  a number with 2 decimal places, ex 4.35   

This presumes you have the basics of your sketch setup also, which I didn't go into.


man thanks alot for this! Well I've got the gist of making a voltage divider but so far for the basic sketch setup I don't have a clue. I mean I know how to make an LED blink and set it up to do it without any help but how can I setup the sketch for this project?

BTW thanks TONS for this your really putting some effort into helping me and I appreciate it.

CrossRoads

Follow the same sketch format.
Define the pins you're going to use
Declare the variable types

In void setup, use pinMode to define your inputs  & outputs
setup serial.begin with the speed your using, use the same speed in the serial monitor

in void loop, do the analog.read of the pin and the serial.print of what to display.

See the Reference section on the home page for formatting if needed.

Try putting some code together, post it here using
[ code ] and [ /code ] (without spaces) so we can help you out more.

There's probably a tutorial even on reading the analog inputs.
Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Go Up