Searching \ for 'About how to display binary numbers' in subject line. ()
Help us get a faster server
Search entire site for: 'About how to display binary numbers'.

Truncated match.
'About how to display binary numbers'
1997\08\06@154218 by

Hi,

I would like convert binary numbers to decimal numbers,
and display them in a LCD display,
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
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:
{Quote hidden}

Larry G. Nelson Sr.
L.Nelsonieee.org
http://www.ultranet.com/~nr
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!

Miguel.

C
--

void Imprime_Decimal(int N)
{
byte RESTO,NUMERO_DIGITO;

NUMERO_DIGITO=1;

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
ACALL DATA_OUT         ; WRITE THE VALUE OF A AT LCD
DJNZ H'00,IMP_DIGITO
POP H'00
POP B
POP ACC
RET

Do you know how to initialize a display?

mIGUEL.

>
> Regards,
> Jose Antonio
At 16:04 6/08/97 -0400, you wrote:
{Quote hidden}

Hi,

Thanks for your information, I will visit parallax web page.

Regards,
Jose Antonio
On Wed, 6 Aug 1997 17:09:04 -0700 WF AUTOMA=?iso-8859-1?Q?=C7=C3O ?=
<wfAMBIENTE.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.
;

org     \$0010   ;Start of user files for 16c84

NumH:   ds      1
NumL:   ds      1
TenK:   ds      1
Thou:   ds      1
Hund:   ds      1
Tens:   ds      1
Ones:   ds      1

Convert:                        ; Takes number in NumH:NumL
; Returns decimal in
; TenK:Thou:Hund:Tens:Ones
swapf   NumH,w
andlw   \$0F             ;*** PERSONALLY, I'D REPLACE THESE 2
addlw   \$F0             ;*** LINES WITH "IORLW 11110000B" -AW
movwf   Thou
movwf   Hund
movwf   Ones

movf    NumH,w
andlw   \$0F
movwf   Tens

swapf   NumL,w
andlw   \$0F

rlf     Tens,f
rlf     Ones,f
comf    Ones,f
rlf     Ones,f

movf    NumL,w
andlw   \$0F
rlf     Thou,f

movlw   \$07
movwf   TenK

; 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.

movlw   \$0A                             ; Ten
Lb1:
decf    Tens,f
btfss   3,0
goto   Lb1
Lb2:
decf    Hund,f
btfss   3,0
goto   Lb2
Lb3:
decf    Thou,f
btfss   3,0
goto   Lb3
Lb4:
decf    TenK,f
btfss   3,0
goto   Lb4

retlw   0
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 ?=
><wfAMBIENTE.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?.

Jose Antonio
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?.

Regards,
Jose Antonio

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...