KuntzBrewing
Well-Known Member
I'm using Atmega Studio 6 and an ATmega328P on an arduino board. I've coded an Analog to Digital converter and can successfully read analog inputs on a scale of 0-1023 (10bit memory space is fixed)
I made a voltage splitter (voltage divider circuit) that halves my input of 5Vcc, but for some reason I cannot convert my adc value to a voltage. Which sounds simple (adcvalue*5000mV/1023) to get a value saved in an unsigned 16bit value. My result is 0 or some invalid answer. I tried saving this as a float in a regular voltage (*5V not *5000Mv) but using print(%f, voltagevalue) returns a "?", using %d yields "0"
I thought it was an overflow issue (adc of 512 * 5000 gives 2.5Million+ return) I went as far as saving it as a unit64_t. Didn't work. I want to make sure my values are correct so I use printf and read them on a hyper terminal using serial communication between board and computer. I even printed a hex number (showed 0xFC78) which wouldn't be correct.
Has anyone ran into this problem or can anyone come up with a solution.
The whole reason behind this is to read a thermistor, but I'm using a voltage divider to test the values for now. Grounding gives me a reading of 0 full on gives 1023. Circuit reads 512 (which is about half) so I know its right
I made a voltage splitter (voltage divider circuit) that halves my input of 5Vcc, but for some reason I cannot convert my adc value to a voltage. Which sounds simple (adcvalue*5000mV/1023) to get a value saved in an unsigned 16bit value. My result is 0 or some invalid answer. I tried saving this as a float in a regular voltage (*5V not *5000Mv) but using print(%f, voltagevalue) returns a "?", using %d yields "0"
I thought it was an overflow issue (adc of 512 * 5000 gives 2.5Million+ return) I went as far as saving it as a unit64_t. Didn't work. I want to make sure my values are correct so I use printf and read them on a hyper terminal using serial communication between board and computer. I even printed a hex number (showed 0xFC78) which wouldn't be correct.
Has anyone ran into this problem or can anyone come up with a solution.
The whole reason behind this is to read a thermistor, but I'm using a voltage divider to test the values for now. Grounding gives me a reading of 0 full on gives 1023. Circuit reads 512 (which is about half) so I know its right