Sonsivri

Electronics => Pic Basic Languages => Topic started by: malibus on January 04, 2009, 09:11:12 21:11



Title: PIC18 Simulator IDE division
Post by: malibus on January 04, 2009, 09:11:12 21:11
Hi,
I am working on a voltmeter, in PIC18 Simulator IDE.
How make a division of two integers, and get the 2 numbers after the decimal point?
If this possible?



Title: Re: PIC18 Simulator IDE division
Post by: pickit2 on January 05, 2009, 03:42:28 15:42
me thinks you need to read up on maths, integers are whole numbers, you can't have a decimal place.
I can't see what you are trying to do with above problem. to use a pic as a voltmeter = one analoge input. and a display, be it leda or lcd.


Title: Re: PIC18 Simulator IDE division
Post by: malibus on January 06, 2009, 03:46:38 15:46
Yes, i can measure a tension,  in milivolts the result is ok. For example 18235.
How put to the lcd this value, but expressed in V  ( 18.235V) without division on 1000?



Title: Re: PIC18 Simulator IDE division
Post by: mbandala on January 06, 2009, 06:47:59 18:47
I don't suppose you are using assembler. That shouldn't be difficult using C for instance. If you don't want to divide just convert "18235" into BCD notation (0x18235, note: such a big number cannot be held by an "int" use "unsigned short long" instead) and then send nibble by nibble to the LCD. You can position the decimal point accordingly this way.