which is the correct voltage on that pin. But if i upload again the code above but with the commented code uncommented the serial monitor now prints this:
Motor Voltage: 5.3935856736 Battery Voltage: 4.2165012285
And no the actual voltage did not change, even in the function the only variable that changes is the analogRead, so something is happening there. I also could not simply offset it again because i do not know the situations when it can happen or not happen .
I don't know about the Due, but successive analogRead()s on different pins on AVR based boards needs settling time between the reads. The usual solution suggested is to read the value from the same pin twice and discard the first value.
UKHeliBob:
I don't know about the Due, but successive analogRead()s on different pins on AVR based boards needs settling time between the reads. The usual solution suggested is to read the value from the same pin twice and discard the first value.
Reading the pin twice worked ! but not when using a delay (even 1 second delay).
Is there something wrong with how analogRead function is handled that arduino never got the chance to fix?
Is there something wrong with how analogRead function is handled that arduino never got the chance to fix?
On AVR based boards there is only one ADC which is switched between inputs as required, hence the time needed to do it. My bet is that the ADC is not connected to the pin until required hence a delay() between reads on different pins has no effect
UKHeliBob:
On AVR based boards there is only one ADC which is switched between inputs as required, hence the time needed to do it. My bet is that the ADC is not connected to the pin until required hence a delay() between reads on different pins has no effect
It would seems that the arm chip that the uses is the same way.
UKHeliBob:
On AVR based boards there is only one ADC which is switched between inputs as required, hence the time needed to do it. My bet is that the ADC is not connected to the pin until required hence a delay() between reads on different pins has no effect
Also i have am loosing some accuracy (though this can be fix by adjusting the offset) i am loosing 0.06v of accuracy when i am double reading.
John41234:
Also i have am loosing some accuracy (though this can be fix by adjusting the offset) i am loosing 0.06v of accuracy when i am double reading.