Maker Pro
Maker Pro

Need help with Arduino Atmel project

Need help with a few things. I am new to microcontrollers but i feel i need to get a grasp of this stuff. I am still only able to do simple stuff like write my name in a lcd or run leds and switches. I am trying to do a project where i display the volts,ohms,amps,watts of a external regulator.The regulator is not the one running the arduino. I am using a 5v 16mz arduino pro mini btw .

I think that accomplishing this will have to do with using the internal analogtodigital or analog reference and converting it to a voltage,Im not sure how to do this yet.

Do i connect the output of the adjustable regulator to a pin on the arduino ? Do i connect the output of the reg to a voltage divider first before going to the arduino. ?

The regulator im trying to read the output on is a adjustable regulator 3.3-6v up to 3A . Main thing i need is to display what voltage its set at on the arduino controlled lcd.Then from there get the watts ,ohms and amps its outputting. I have a acs712 amp sensor coming in the mail soon for that

Everything is running of li-ion batteries

Hopefully someon can help me with this project . Thanks
 
Hi

Warning I'm a S/W engineer by trade so my understanding in H/W is only improving.

The arduino pro mini can except 5 - 12 V (5V model). you would only need a voltage divider if your voltage source is larger then 12 volts.

There is 6 analogue input pins. You will need 1 for managing the the voltage input which will be need to be between 0 and vcc which is 5 volts in your model. (http://arduino.cc/en/Main/ArduinoBoardProMini)

Another analogue input will need to be connected VIOUT from the ACS712 where you will need to map the current to the VIOUT using the tables in the ACS712 datasheet. I thought the table 'Output Voltage versus Sensed Current' might be all you need, though I might be over simplifying it.

Its my understanding ohms is irreverent.
V = IR. you know V and I. W = VI, again you know V and I.
 
The arduino pro mini can except 5 - 12 V (5V model). you would only need a voltage divider if your voltage source is larger then 12 volts.

This is only the suggested range of the supply voltage for the onboard voltage regulator chip to keep it running reasonably cool... They used to rate them for higher input but dropped the levels due to issues and complaints of excess heat build up...

The AVR chip will run from 2.7V - 5.5V @ 10MHz or 4.5V - 5.5V @ 20MHz (There are many instances where people have run them in the 3.3V range @ 20MHZ and they have performed just fine, but your mileage may vary) if you want to run at those varying voltages you would bypass or replace the onboard regulator...

Input into any pin is generally held at the chosen VCC voltage to keep things simple, if using the ADC it should be limited to VCC + 0.3V ...
 
Hi



Its my understanding ohms is irreverent.
V = IR. you know V and I. W = VI, again you know V and I.

It is relevent to my project because the hardware that the output of the seperate reg comes in different ohm coils that screw on so i wanted it to read the ohms of the hardware attached.

When i know 2 of either volts/amp, volts/watts etc i know ohms law would tell me what the ohms are but how can i read them through the arduino .

Is there a code to be able to calculate the 2 readings and convert it to ohms to be displayed on the arduinos lcd? Sort of like a accurate ohms law calculator?

Also how would i determine the resistors i would need for the voltage divider that would read the seperate adjustable regulator output volts which would be between 3v-6v ?Is it possible for someone to give me a sample code of how i would code it to do this. Im not sure how to set up a table that can convert numbers to the accurate output voltage to display on a lcd

Thanks for the help.
 
http://arduino.cc/en/Tutorial/AnalogReadSerial

My quick hack. warning I have never touched an arduino though I'm going to order one when i can. I can't comment on a voltage divider circuit though this may be a good starting point : http://en.wikipedia.org/wiki/Voltage_divider. All I know is that you can account for the ratio in software once the voltage divider is known.

int ratio = 2 ; placemarker for voltage divider ratio;
int voltageSensorValue = analogRead(A0); Assuming A voltage devider input so that the maximum voltage into A0 is 5 volts.
int voltage = voltageSensorValue/1024 * 5 ; if A0 has 5 volts, voltageSensorValue will be 1024. 1024/1024 = 1 * 5 = 5
voltage = voltage * ratio; mutiply that extra voltage that the voltage divider took out.

int currentSensorValue = analogRead(A1);
currentSensorValue = currentSensorValue /1024 * 5;

// If 1.5v means the current is at -5 amps, and 3.5 volts means its at +5 amps.
//it looks linear, so its just y = mx + c
//take some points and find varibles. when x = 0, y = 2.5 therfore c = 2.5
// if y = 1.5 c= 2.5 x = -5 . by my calculations m = 0.2.
// current = x, voltage at ADC (currentSensorValue) = y m = 0.2, c = 2.5 Though only thing you don't know is current. x = (y-c) / 0.2, x = (y-c) * 5
int current = (currentSensorValue - 2.5) * 5

// please note this is rough and is what i'll do to get get started in your situation the datasheet is much more complex when it comes to accounting for temperture.
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
I am trying to do a project where i display the volts,ohms,amps,watts of a external regulator. The regulator is not the one running the arduino.
Yes, you will need to use an ADC. An ADC measures the voltage on its input, and convert it to a number that represents the position of that voltage on a scale between the negative and positive reference voltages that are fed into the ADC. Usually the negative reference is the 0V (ground) rail of the ADC's circuit, and the positive reference voltage may be 5V or some other voltage such as 4V, 2.5V etc, from a reference voltage generator.
The regulator im trying to read the output on is a adjustable regulator 3.3-6v up to 3A . Main thing i need is to display what voltage its set at on the arduino controlled lcd.
Yes, you can measure the voltage coming out of your regulator, IF the regulator's 0V rail is connected to the ADC's 0V rail. (That means, connected to the Arduino's 0V rail as well.) Since the regulator output voltage is higher than the ADC input voltage, all you need is a voltage divider made from two resistors, as you mentioned in your post. This will convert the voltage range from the regulator (0~6V) to the correct voltage range that the ADC expects (e.g. 0~2.5V, 0~4V, 0~5V or whatever - this will be described on the ADC data sheet).

The digital value you read from the ADC will represent the voltage directly. For example, for an 8-bit ADC, a full scale value of 255 represents the maximum regulator voltage, 6V in this example, and a value of 0 will represent 0V regulator output.

Your regulator may not go below 3.3V but it's simplest to use 0V as the bottom of scale. You can convert a 3.3~6.0V range so that it uses the full input range of the ADC, and this will give you better resolution, but it will require an op-amp and an offset adjustment. If you don't need the extra resolution, it's simpler to avoid that hassle.

Then from there get the watts ,ohms and amps its outputting. I have a acs712 amp sensor coming in the mail soon for that

OK, I'm glad you mentioned the ACS712 because it tells me how you intend to measure the regulator output current. The ACS712 is a cute little device made by Allegro that uses the Hall effect to measure current flow. You connect it in series with your regulator output, and it produces an output voltage that is centered on half its supply voltage, or 2.5V nominally, when the measured current is zero, and increases (or decreases depending on which way round the input is connected) according to the current it is measuring in the regulator output circuit. If you've chosen the 5A version, the device output changes by 185 mV for every amp in the measurement path. I'll assume that you've connected it so the output voltage will increase in response to regulator output current.

Since you want to measure 0~3A your ACS712 will produce an output of 2.5V at 0A, and 3.055V at maximum output current. Assuming the ADC has an input range of 0~5V, you won't be using much of the ADC's input range, so you will get less resolution than the ADC is capable of. If this is a problem, you'll need an op-amp circuit to amplify the voltage from the ACS712 and apply an offset, just as for the voltage. This may require an op-amp with rail-to-rail output capability. I can give you more details if you can tell me what voltage rails are available, and what the ADC's reference voltage is. See my questions at the end of this post.

As for the power, if you're talking about the total load power on the regulator, you can calculate this in software on the Arduino by multiplying the regulator's output voltage and output current together, once you have those values coming in from the ADC.

"Ohms" is not a parameter that directly relates to regulators. If you're talking about the resistance of the LOAD that is connected ACROSS the output of the regulator, then again you can calculate that in software, from the regulator's output voltage and current, using Ohm's law, R = V / I, as you said. You will need to find some code to perform division since the AVR doesn't have hardware division capability.

The next two paragraphs relate to the measurement accuracy.

The ACS712 will need an accurate 5V supply, because its output with no measured current is half its supply voltage, and you need this to be accurate. Normally an ADC would have a separate reference voltage generator, for accuracy, but its positive reference voltage input may be connected to the +5V supply too, in which case this rail will also need to be regulated accurately. If the ACS712 is powered from the same supply that provides the reference voltage to the ADC, any error will cancel out and you will get a half-scale raw value for zero current measured, but the current scaling will be wrong, because the ACS712 output is 185 mV per amp measured, and 185 mV will be a different fraction of the full scale voltage if the full scale voltage is not exactly 5V. Also the voltage measurement will be affected.

If the ADC uses the Arduino's 5V supply, and that supply is well regulated and stable, you would be able to power the ACS712 from it, and use hardware and/or software calibration to compensate for any error caused by the 5V rail not being exactly right. Software calibration would be needed for the current measurement, so you might as well use software calibration for the voltage measurement as well, to avoid trimpots in your circuit. Your calibration values should be stored in EEPROM in the AVR, which shouldn't be socketed, since the calibration values relate to the 5V regulator, which is presumably on the Arduino board, and the ACS710, whose output accuracy is not especially good. You should make sure that there's no significant variable load on the 5V supply, since this will affect its voltage.

It would be helpful if you could provide information on:

1. The regulator - a reference to a data sheet
2. The ADC - ditto. Is the ADC internal to the Arduino AVR device? What is its resolution (in bits)? What reference voltage is being fed into it?
3. A system diagram showing how each part of the system is powered and what voltage rails are available
4. What accuracy and resolution are you expecting for each of the quantities?
 
Last edited:
The digital value you read from the ADC will represent the voltage directly. For example, for an 8-bit ADC, a full scale value of 255 represents the maximum regulator voltage

Note for my last post. In my code there is a magic number 1024. This is 2^10 which is the number of discrete values that can be sampled with an 10 bit ADC.
 
Top