Go Down

Topic: A0 voltage not reaching 5V *Answered* (Read 445 times) previous topic - next topic

chartreusejoker

Oct 21, 2019, 07:27 pm Last Edit: Oct 21, 2019, 09:49 pm by chartreusejoker
Answered by DrAzzy -

Per the schematic, the Vin input on that board (the barrel jack one) goes through a schottky diode to the "5v" rail, schottky diodes have a drop of ~0.3v. ...
--------------------------------------------------------------------------------------------------

I am using a 4duino from 4D systems that is being powered by a 4.5v to 5.5v power supply


Currently the only wires I have hooked to the board are +V (from +5VDC on the MW), GND (from the -VDC on the MW), and the 5V on the board running to a blank terminal block (nothing connected to the other side.)

Originally I had the A0 input hooked up across a potentiometer to simulate the sensor and when I set the supply to 5.009v as measured by a multimeter (fluke 117) the A0 input would reach 1023 at 4.66 VDC and I would lose the range from 4.66-5v.

The potentiometer was hooked as follows: supply to +DC from psu; GND to -DC from psu; and reference running back to A0 on 4duino.


I then tried switching the input to the potentiometer from the psu to the 5v pin on the 4duino and noticed that the max the potentiometer would read at this point was 4.66V (the psu still measured 5.009V with no noticeable fluctuation)

I then turned the voltage on the psu down to 4.663V and noticed the A0 pin would only read up to ~4.35V and the 5v pin measured ~4.35V as well. After noticing that the 5V pin followed the max that the analog pin was reading I disconnected the everything except the power to the board and the 5V pin wire and with some trial and error found that if I set the voltage on the supply to ~5.363 then the 5V pin will actually read 5.000V and my A0 will actually be able to read 0-5VDC.

Am I missing something here or is this intended usage and I will just need to supply 5.36V to the board to read the full range?

 

DrAzzy

Per the schematic, the Vin input on that board (the barrel jack one) goes through a schottky diode to the "5v" rail, schottky diodes have a drop of ~0.3v.

So that sounds as expected - this is a pretty common practice; often you can get away without doing anything special (so the 5v rail is 4.7v instead of 5v - if your pot is connected between the "5v" rail and ground, it doesn't matter. Of course, when measuring analog voltages that aren't relative to the power rails, one has to take account of it.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

DVDdoug

#2
Oct 21, 2019, 08:28 pm Last Edit: Oct 21, 2019, 08:32 pm by DVDdoug
The default reference is Vcc (nominally 5V) so you should read 1023 when the analog input is equal to (or maybe slightly above*) Vcc.

If you need better accuracy, you can optionally use an external reference or the internal 1.1V reference (with a voltage divider).   The internal reference is stable, but there is a tolerance so you may have to calibrate.


* Don't go too far over Vcc as the maximum allowable on an input pin is Vcc+ 0.5V.  And, there is a +/- 1 count tolerance so there's a chance  of reading 1022 with Vcc applied.

chartreusejoker

Per the schematic, the Vin input on that board (the barrel jack one) goes through a schottky diode to the "5v" rail, schottky diodes have a drop of ~0.3v.

So that sounds as expected - this is a pretty common practice; often you can get away without doing anything special (so the 5v rail is 4.7v instead of 5v - if your pot is connected between the "5v" rail and ground, it doesn't matter. Of course, when measuring analog voltages that aren't relative to the power rails, one has to take account of it.
Unfortunately the sensor I am going to be using is powered separately and provides a 0-5v signal so I need the input to read 0-5V. I am not using the barrel jack at the moment but based on how the board behaves it seems like the VIN pin also goes through a diode (possibly the same one).


The default reference is Vcc (nominally 5V) so you should read 1023 when the analog input is equal to (or maybe slightly above*) Vcc.

If you need better accuracy, you can optionally use an external reference or the internal 1.1V reference (with a voltage divider).   The internal reference is stable, but there is a tolerance so you may have to calibrate.


* Don't go too far over Vcc as the maximum allowable on an input pin is Vcc+ 0.5V.  And, there is a +/- 1 count tolerance so there's a chance  of reading 1022 with Vcc applied.
I am not sure I am fully understanding the point you are making here, sorry. The resolution is plenty for my application it just seems to be maxing out (VCC voltage) at less than 5V unless my supply is set to 5.36V. As far as I can tell that is more to do with the board functionality than the resolution of the input.

Thank you for the warning about going over voltage of VCC though I will make sure the external sensor doesn't go too far over

DrAzzy

I think the correct solution is to feed your board with 5.36v to get 5v after the diode - assuming you can't find a way to run the sensor off the same "5v" as the board. Particularly when you have a sensor that outputs a voltage proportional to it's supply voltage, you really want the sensor and board measuring the voltage running off the same supply.

When there are two independent supplies powering different parts of the same circuit, you get into dangerous territory, because you can damage things if one of them is on, and the other isn't, and the one that is on tries to apply a voltage to a pin on the one that isn't powered. If that situation can happen, you need to take countermeasures (a 10k or 4.7k resistor between them is sufficient for most signals, as this limits the maximum current that could flow into the pin of the unpowered chip, while keeping the impedance low enough that the ADC won't have trouble reading it). This also saves you if the voltages aren't exactly matched (and they never are) - though it doesn't help with the fact that you can't measure the whole range of possible voltages if the thing you're measuring can go slightly higher than the supply voltage on the thing doing the measuring).
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

JCA34F

#5
Oct 22, 2019, 04:27 am Last Edit: Oct 22, 2019, 04:49 am by JCA34F
Or a voltage divider: If AREF = 4.65V ->  ADCval = 4.58 * 1024 / AREF = 1008, volts = ADCval * AREF / 1024.

chartreusejoker

I think the correct solution is to feed your board with 5.36v to get 5v after the diode - assuming you can't find a way to run the sensor off the same "5v" as the board. Particularly when you have a sensor that outputs a voltage proportional to it's supply voltage, you really want the sensor and board measuring the voltage running off the same supply.

When there are two independent supplies powering different parts of the same circuit, you get into dangerous territory, because you can damage things if one of them is on, and the other isn't, and the one that is on tries to apply a voltage to a pin on the one that isn't powered. If that situation can happen, you need to take countermeasures (a 10k or 4.7k resistor between them is sufficient for most signals, as this limits the maximum current that could flow into the pin of the unpowered chip, while keeping the impedance low enough that the ADC won't have trouble reading it). This also saves you if the voltages aren't exactly matched (and they never are) - though it doesn't help with the fact that you can't measure the whole range of possible voltages if the thing you're measuring can go slightly higher than the supply voltage on the thing doing the measuring).

I appreciate the insight, thank you. The power supply is easily enough configured that adjusting the supply to get the appropriate 5V range on the 4Duino is an easy solution.
I do have to run two different power circuits for this project (24V and 5V) and the sensor power is pulled from the 24. I do have the ability to isolate all inputs to the board (A, Di, and Do) using a relay which will ensure no inputs reach the board when it is powered off.

Go Up