I would like convert binary numbers to decimal numbers,
and display them in a LCD display,
Please, could you help me?.
How could I convert binary numbers to decimal numbers,
and display them in a LCD display?.
Please, could you help me with a little source code about how to do this?.
The Microchip web site has application notes on math routines. You can use
the binary to BCD routines to get the digits you want. You then should use
a lookup table to convert the digit into the segment drive information to
drive the LEDs. If you are using an LCD display with an internal character
generator you can use the lookup table to gibe you the ascii code you need
to send to the LCD for display. If you look at the information on the
Parallax site they have some details on the lookup tables and driving the
LED display.
>Hi,
>
>I would like convert binary numbers to decimal numbers,
>and display them in a LCD display,
>Please, could you help me?.
>How could I convert binary numbers to decimal numbers,
>and display them in a LCD display?.
>Please, could you help me with a little source code about how to do this?.
>
>Regards,
>Jose Antonio
>
>
Jose Antonio Noda wrote:
>
> Hi,
>
> I would like convert binary numbers to decimal numbers,
> and display them in a LCD display,
> Please, could you help me?.
Yes i do!
> How could I convert binary numbers to decimal numbers,
> and display them in a LCD display?.
Which language?
> Please, could you help me with a little source code about how to do this?.
You must to sucessive divisions by 10 and hold the remainder of each division
in a temporary memory, until the quocient is 0.
See:
214/10 = 21 and the remainder is 4
21/10 = 2 and the remainder is 1
2/10 = 0 and the remainder is 2
^
|
|
look the remainders: are the digits for
display at LCD.
You must to add 48 (ASCII CODE OF "0") and
them you will have a printable caracter!
Here two samples for you! One in C and other for 8051 assembly!
while(!((N/10)==0)) /* ROTINA PARA IMPRIMIR NUMEROS COM */
{ /* MAIS DE 1 DIGITO */
RESTO= N % 10;
DIGITOS[NUMERO_DIGITO]=RESTO;
N = N / 10;
NUMERO_DIGITO++;
}
RESTO= N % 10;
DIGITOS[NUMERO_DIGITO]=RESTO;
if(NUMERO_DIGITO==1)
Data_Out('0');
for(RESTO=NUMERO_DIGITO;RESTO>0;RESTO--)
Data_Out(DIGITOS[RESTO]+0x30); /* TABELA ASCII NUMEROS */
} /* + 0x30 */
Assembly
----------
IMP_BYTE_lcd:
PUSH ACC
PUSH B
PUSH H'00
MOV H'00,#0
NAO_FIM:
MOV B,#D'10
DIV AB
INC H'00
PUSH B
CJNE A,#0,NAO_FIM
IMP_DIGITO:
POP B
MOV A,B
ADD A,#H'30
ACALL DATA_OUT ; WRITE THE VALUE OF A AT LCD
DJNZ H'00,IMP_DIGITO
POP H'00
POP B
POP ACC
RET
>The Microchip web site has application notes on math routines. You can use
>the binary to BCD routines to get the digits you want. You then should use
>a lookup table to convert the digit into the segment drive information to
>drive the LEDs. If you are using an LCD display with an internal character
>generator you can use the lookup table to gibe you the ascii code you need
>to send to the LCD for display. If you look at the information on the
>Parallax site they have some details on the lookup tables and driving the
>LED display.
>
>
>
>
>At 03:40 AM 8/6/97 +0200, you wrote:
>>Hi,
>>
>>I would like convert binary numbers to decimal numbers,
>>and display them in a LCD display,
>>Please, could you help me?.
>>How could I convert binary numbers to decimal numbers,
>>and display them in a LCD display?.
>>Please, could you help me with a little source code about how to do this?.
>>
>>Regards,
>>Jose Antonio
>>
>>
>Larry G. Nelson Sr.
>.....L.NelsonKILLspam@spam@ieee.org
>http://www.ultranet.com/~nr
>
Hi,
Thanks for your information, I will visit parallax web page.
On Wed, 6 Aug 1997 17:09:04 -0700 WF AUTOMA=?iso-8859-1?Q?=C7=C3O ?=
<wfKILLspamAMBIENTE.COM.BR> writes:
>You must to sucessive divisions by 10 and hold the remainder of each
>division
>in a temporary memory, until the quocient is 0.
If displaying to an LCD module based the HD44780, you can set the
controller to autodecrement (move the cursor right to left), then output
the remainders (as ASCII) directly to the LCD as they are calculated.
The digits of the number will appear on the screen in correct order.
This makes the successive division method rather practical (certainly
RAM-efficient, though it may be necessary to store a copy of the number
since the division process will destroy it). An N/8 bit division is easy
to expand to a large number of bits (one more shift instruction and 8
more loops for each byte). If the input number is only 8 or 16 bits some
of the other methods discussed previously may be better.
Some times ago, Andrew W. gave me these. It works really fine, I am
using this to send 16bit number to LCD. Don't forget to add 0x30 (ASCII
'0') to each number before sending to the LCD (don't use table read). I
have got the code to drive LCD if you need.
David
-------------------------------------------------------------------
;
; Binary-to-BCD. Written by John Payson.
;
; Enter with 16-bit binary number in NumH:NumL.
; Exits with BCD equivalent in TenK:Thou:Hund:Tens:Ones.
;
; At this point, the original number is
; equal to
; TenK*10000+Thou*1000+Hund*100+Tens*10+Ones
; if those entities are regarded as two's
; complement binary. To be precise, all of
; them are negative except TenK. Now the number
; needs to be normalized, but this can all be
;done with simple byte arithmetic.
At 01:08 7/08/97 -0400, you wrote:
>On Wed, 6 Aug 1997 17:09:04 -0700 WF AUTOMA=?iso-8859-1?Q?=C7=C3O ?=
><.....wfKILLspam.....AMBIENTE.COM.BR> writes:
>
>>You must to sucessive divisions by 10 and hold the remainder of each
>>division
>>in a temporary memory, until the quocient is 0.
>
>If displaying to an LCD module based the HD44780, you can set the
>controller to autodecrement (move the cursor right to left), then output
>the remainders (as ASCII) directly to the LCD as they are calculated.
>The digits of the number will appear on the screen in correct order.
>
>This makes the successive division method rather practical (certainly
>RAM-efficient, though it may be necessary to store a copy of the number
>since the division process will destroy it). An N/8 bit division is easy
>to expand to a large number of bits (one more shift instruction and 8
>more loops for each byte). If the input number is only 8 or 16 bits some
>of the other methods discussed previously may be better.
>
Yes, I use a HD44780 LCD based module.
I want to use a PIC in a project, and the PIC receive binary numbers,
and then I have to convert the binary numbers in ASCII numbers?.
At 09:02 7/08/97 +0200, you wrote:
>Some times ago, Andrew W. gave me these. It works really fine, I am
>using this to send 16bit number to LCD. Don't forget to add 0x30 (ASCII
>'0') to each number before sending to the LCD (don't use table read). I
>have got the code to drive LCD if you need.
>
>David
>-------------------------------------------------------------------
>
>;
>; Binary-to-BCD. Written by John Payson.
>;
>; Enter with 16-bit binary number in NumH:NumL.
>; Exits with BCD equivalent in TenK:Thou:Hund:Tens:Ones.
>;
[code]
Thanks very much for your code
I'll use it to convert 16-bit binary number.
Now to each number I have to add 0x30 and send to LCD?.