I need a 'float' because I have to display a voltage for example of = 41.5V. The following part of my program show=B4s the A/D- conversion and the mathematic operations that I need (a voltage range of 0-5V form the = A/D- result is conform to voltage range of 0-50V) void ermittleDigitalenWert() { digitalwert =3D 0;=20 digitaleAnzeige =3D 0; spannungsZehner =3D 0; spannungsEiner =3D 0; spannungsKomma =3D 0; stromZehner =3D 0; stromEiner =3D 0; stromKomma =3D 0; anzeigeSpannung =3D 0; anzeigeStrom =3D 0; =09 digitalwert =3D ADRESH; digitalwert |=3D (digitalwert << 8); digitalwert |=3D ADRESL; digitaleAnzeige =3D (float)(digitalwert * 5 / 1023.0); =09 ADRESH =3D 0; ADRESL =3D 0; } void main(void) { init(); InitLCD(); =09 while(1) { if(anzeigeAD =3D=3D TRUE) { /************************A/D- Wandlung auf Kanal 0********************/ /*********************Spannung der ersten Halbbruecke*****************/ ADCON0 =3D 0b10000001; ADGO =3D 1; while(ADGO =3D=3D 1); ermittleDigitalenWert(); spannung_HB1 =3D (digitaleAnzeige * 60.94) / 6.04; DelayS(1); =09 /************************A/D- Wandlung auf Kanal 1********************/ /********************Spannung der zweiten Halbbruecke*****************/ ADCON0 =3D 0b10001001; ADGO =3D 1; while(ADGO =3D=3D 1); ermittleDigitalenWert(); spannung_HB2 =3D (digitaleAnzeige * 60.94) / 6.04; =09 if(spannung_HB2 > spannung_HB1) { anzeigeSpannung =3D spannung_HB2 - spannung_HB1; spannungPositiv =3D FALSE; } else {=09 anzeigeSpannung =3D spannung_HB1 - spannung_HB2; spannungPositiv =3D TRUE; } anzeigeSpannung =3D spannung_HB1; spannungsZehner =3D (unsigned char)(anzeigeSpannung / 10); spannungsEiner =3D (unsigned char)(anzeigeSpannung - (spannungsZehner * 10)); spannungsKomma =3D (unsigned char)((anzeigeSpannung - (spannungsZehner * 10) =09 - spannungsEiner) * 10); =09 =09 /****************************Spannungsanzeige*************************/ WriteInstrToLCD(Set_DDRAM_Address + 0x42); WriteCharToLCD(' '); =09 if(spannungPositiv =3D=3D TRUE) { WriteCharToLCD('+'); } else { WriteCharToLCD('-'); } WriteCharToLCD(0x30 + spannungsZehner); WriteCharToLCD(0x30 + spannungsEiner); WriteCharToLCD('.'); WriteCharToLCD(0x30 + spannungsKomma); spannung_HB1 =3D 0; spannung_HB2 =3D 0; DelayS(1); =09 -----Urspr=FCngliche Nachricht----- Von: Rick Regan [mailto:rdrdr2k@YAHOO.COM] Gesendet: Donnerstag, 8. Mai 2003 17:09 An: PICLIST@MITVMA.MIT.EDU Betreff: Re: AW: AW: [PIC]:Floating point > No, that4s not the problem.....after the A/D- > conversion I make a type cast > from "integer" to "float". And if I try to show at > first the value of the > variable "voltage_HB1" on the display and then the > value of "voltage_HB2", > then I get the right values for both A/D- channels. Since A/D results are integer, could you explain why you need to make them 'float' to compare and display them? __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics