Page 1 of 1

How to convert the mV to V (Integer value to float)

Posted: Fri Jun 26, 2015 9:11 am
by Capture
Hello Everyone

I wrote the program for measuring the supply Voltage then after compiling, it is displaying the output by default in mV(3253mV) but i want to see the output interms of voltage so i did this in the libary function td.measure.c (setpoint = ((setpoint * 3 * 1250) / 4096);) after that it is displaying the round off value (3v) and also i tried to change the datatype of setpoint to float eventhough am not able to see the output like (3.2v) so can anyone suggest me the best possible solution to see the output interms of voltage.

tfp_printf("Battery Meas:%d mV\r\n",
TD_MEASURE_VoltageTemperatureExtended(false));

Best regards
Prabhu

Re: How to convert the mV to V (Integer value to float)

Posted: Fri Jun 26, 2015 10:25 am
by lcheminade
Hi,

This is just common C.

uint32_t mv = TD_MEASURE_VoltageTemperatureExtended(false);

uint8_t volt = mv /1000;

uint32_t decimal = mv - (volt*1000);


tfp_printf("Voltage %d.%03d\r\n, vold,decimal);


Loïc