Searching \ for '[PIC]: 8-Bit Binary to 2 Digit LED display HELP NE' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/displays.htm?key=led
Search entire site for: '8-Bit Binary to 2 Digit LED display HELP NE'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: 8-Bit Binary to 2 Digit LED display HELP NE'
2002\12\22@165344 by F.A.C.T. / Vladimir M Skrbic

flavicon
face
Hello dear friends,

My name is Vladimir and I'm from Yugoslavia. I am working on a
Thermometer/thermostat project based on a PIC 16F84. I am using a Dallas
DS1821 temperature sensor and since I don't have enough pins I decided
to use 4511 BCD to 7 Segment LED Driver IC. Now I am writing my code in
Pic Basic Pro and I'm not certain how to convert 8 bit binary data
coming out from the sensor to a 4 bit BCD (B0-B3 pins -> D,C,B,A) in
order to drive the 4511. Can you give me a hand, please? Thank you in
advance.

--
 Sincerest regards,

 Vladimir M Skrbic          *     F.A.C.T.
 General Manager            *     Ilariona Ruvarca 5/c
 Phone: +381 63 520364      *     21000 Novi Sad
 Fax: +1 775 245 4870       *     Vojvodina, Serbia
 E-mail: spam_OUTatomskiTakeThisOuTspamEUnet.yu   *     Yugoslavia,
 HAM callsign: YZ7REA       *     Europe



--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu>

2002\12\22@174026 by Josh Koffman

flavicon
face
Check out the piclist.com website (http://www.piclist.com) specifically
www.piclist.com/techref/microchip/math/radix/index.htm
The code is in assembler, but perhaps it will be of some help.

Josh
--
A common mistake that people make when trying to design something
completely foolproof is to underestimate the ingenuity of complete
fools.
       -Douglas Adams

"F.A.C.T. / Vladimir M Skrbic" wrote:
> My name is Vladimir and I'm from Yugoslavia. I am working on a
> Thermometer/thermostat project based on a PIC 16F84. I am using a Dallas
> DS1821 temperature sensor and since I don't have enough pins I decided
> to use 4511 BCD to 7 Segment LED Driver IC. Now I am writing my code in
> Pic Basic Pro and I'm not certain how to convert 8 bit binary data
> coming out from the sensor to a 4 bit BCD (B0-B3 pins -> D,C,B,A) in
> order to drive the 4511. Can you give me a hand, please? Thank you in
> advance.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu>

2002\12\22@192450 by Drew Vassallo

picon face
>I'm not certain how to convert 8 bit binary data
>coming out from the sensor to a 4 bit BCD (B0-B3 pins -> D,C,B,A)

The code below should do the conversion.  Begin with W containing your 8bit
binary value that you want to convert.  The two 4-bit BCD results are held
in Temp (high byte) and Temp2 (low byte) at the end of the routine.  This
routine is limited to converting a maximum HEX number of 0x63 (or 99
decimal).

Hex2BCD
               movwf   Temp
               clrw
               btfsc   Temp, 4
               addlw   0x16
               btfsc   Temp, 5
               addlw   0x32
               addlw   0x06
               skpdc
               addlw   -0x06
               btfsc   Temp, 6
               addlw   0x64
               addlw   0x06
               skpdc
               addlw   -0x06
               movwf   Temp2
               movf    Temp, 0
               andlw   0x0F
               addwf   Temp2, 0
               skpndc
               addlw   0x06
               addlw   0x06
               skpdc
               addlw   -0x06
               movwf   Temp
               swapf   Temp, 0
               movwf   Temp2
               movlw   0x0F
               andwf   Temp, 1
               andwf   Temp2, 1

--Andrew

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*.
join.msn.com/?page=features/featuredemail&xAPID=42&PS=47575&PI=7324&DI=7474&SU=
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_addphotos_3mf

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu>

2002\12\23@010259 by F.A.C.T. / Vladimir M Skrbic

flavicon
face
Drew Vassallo wrote:
{Quote hidden}

Andrew,

Here's how things are. The sensor sends out 8-bit binary data every time
it's queried. The data is in the following format:

(Temp)    (Binary)   (Hex)

+125°C* = 0111 1101 = 7Dh
  +85°C = 0101 0101 = 55h
  +25°C = 0001 1001 = 19h
    0°C = 0000 0000 = 00h
   -1°C = 1111 1111 = FFh
  -25°C = 1110 0111 = E7h
  -55°C = 1100 1001 = C9h

This means that 0-126 is the temperature above zero from 0 to 126*C and
127-201 is representing temperatures below zero -1 to -55*C (202-255
not supported) where bit7 is the sign bit. Since I'm gonna be using this
thermometer/thermostat indoors I'm only interested in values between
00-99 degrees Celsius. I can always write Lo and Hi or something like
that if the temp is put of this range ;)

And another thing... When I convert binary to BCD and store it in a
variable how do I brake it down to single bits in order to send the BCD
combination via 4-bit(PORTB.0-PORTB.3) parallel bus to the 4511's, tens
to the first led display and ones to second led display, respectively?
I plan on using 2 CD4511 and 2 LE pins in order to drive the displays.
You probably guess why ;) I'm pretty new to pic programming and I don't
know how to use interrupts... so the only solution is to keep the leds
lit all the time right ;)

What do you think? Waiting for your answer patiently.


--   Sincerest regards,

 Vladimir M Skrbic          *     F.A.C.T.
 General Manager            *     Ilariona Ruvarca 5/c
 Phone: +381 63 520364      *     21000 Novi Sad
 Fax: +1 775 245 4870       *     Vojvodina, Serbia
 E-mail: EraseMEatomskispam_OUTspamTakeThisOuTEUnet.yu   *     Yugoslavia,
 HAM callsign: YZ7REA       *     Europe

       

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2002\12\23@100414 by Drew Vassallo

picon face
>Since I'm gonna be using this
>thermometer/thermostat indoors I'm only interested in values between
>00-99 degrees Celsius. I can always write Lo and Hi or something like
>that if the temp is put of this range ;)

So it sounds like you can use the conversion I provided, right?

>And another thing... When I convert binary to BCD and store it in a
>variable how do I brake it down to single bits in order to send the BCD
>combination via 4-bit(PORTB.0-PORTB.3) parallel bus to the 4511's, tens
>to the first led display and ones to second led display, respectively?

I'm not sure what you're using for your other PORTB pins (4-7), but one
clean way of doing it is to create a shadow register of PORTB: Read PORTB
into a temporary holding register, clear the lower 4 bits, then "OR" each of
the temperature BCD registers with the shadow register, then finally just
write each digit back to the port.

Another way would be to sample each of the lower 4 BCD register bits and set
each PORTB pin accordingly.  This would require more code, but might be
easier to program if you're not confident with the first method.

--Andrew

_________________________________________________________________
MSN 8 with e-mail virus protection service: 3 months FREE*.
join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU=
http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_eliminateviruses_3mf

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

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