lpcware

Conversion ADC value

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by drvrh on Wed Jul 15 00:12:42 MST 2015
Hello,

I have a problem with a conversion ADC value, I get ADC value (int) from my ADC, but when I would like convert to voltage (float) I cannot.
I have get 0 after calculate and conversion.
ADC value get int number at 0 to 255.


int iValue = 0;
int vrednostADC = 0;
float fVrednost = 0;
char vrednsotADC1[] = "";
char vredADC[] = "";

ADCInit(4400000);    //set 4.4MHz

    while (1) {

    vrednostADC = ADCRead(5);
    fVrednost = vrednostADC * (3.3 / 4096);             //calculate voltage of ADC

    iValue=(int)fVrednost;                       //convert form int to float

    itoa(iValue, vrednsotADC1, 10);
    itoa(vrednostADC, vredADC, 10);

    PotisniChar(16, 5, 1, vrednsotADC1);                       //look conversion value
    PotisniChar(16, 6, 1, vredADC);                                //look value from ADC (int)
    //LCDPocisti();
    }

Outcomes