Decoding variable into 4 digits of BCD, are there simple ways to this?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    It all depends on how the hardware is configured. Is the design optimized for minimal code? With out a schematic it's hard to say...
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    Feb 2013
    Posts
    1,122


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    Well, there is no hardware yet I plan to use PIC16F887. The modules itself have A-B-C-D inputs of CD4543BE connected in paralel, and latch pins are also available on connector.

  3. #3
    Join Date
    Feb 2013
    Posts
    1,122


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    If you mean hooking up A to PORTC.0, B to PORTC.1, C to PORTC.2 and D to PORTC.3, to be able to directly address them, then yes, I can do that.

  4. #4
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    Schematic...... Not some wild a** guess... Definitive schematic Please...
    Dave Purola,
    N8NTA
    EN82fn

  5. #5
    Join Date
    Feb 2013
    Posts
    1,122


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    Schematic of what?

  6. #6
    Join Date
    Feb 2013
    Posts
    1,122


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    Here is simple counter code I've made. It just counts from 0 to 99. But it is far from perfection.

    Code:
    marcato:
    tato=0
    FOR KAKO=0 TO 99
    XAXO=KAKO DIG 0
    high latch 'enable write ones
    low latch2 'disable write tens
    gosub decoder 'display ones
    if xaxo=0 and kako dig 1<>0 then 'if count is above 10
    low latch 'disable ones
    high latch2 'enable tens
    'tato=tato+1
    xaxo=kako dig 1
    gosub decoder
    xaxo=0
    endif
    
    if xaxo=0 and kako dig 1=0 then     'reset leading 0
    low latch
    high latch2
    xaxo=0
    gosub decoder
    endif
    
    PAUSE 300
    NEXT 
    goto marcato
    END
    
    decoder:
    IF XAXO=0 THEN GOSUB ZERO 
    IF XAXO=1 THEN GOSUB ONE
    IF XAXO=2 THEN GOSUB TWO
    IF XAXO=3 THEN GOSUB THREE
    IF XAXO=4 THEN GOSUB FOUR
    IF XAXO=5 THEN GOSUB FIVE
    IF XAXO=6 THEN GOSUB SIX
    IF XAXO=7 THEN GOSUB SEVEN
    IF XAXO=8 THEN GOSUB EIGHT
    IF XAXO=9 THEN GOSUB NINE
    return
    
    ZERO:
    LOW A: LOW B: LOW C: LOW D
    RETURN
    ONE:
    HIGH A: LOW B: LOW C: LOW D
    RETURN
    TWO:
    LOW A: HIGH B: LOW C: LOW D
    RETURN
    THREE:
    HIGH A: HIGH B: LOW C: LOW D
    RETURN
    FOUR:
    HIGH C: LOW A: LOW B: LOW D
    RETURN
    FIVE:
    HIGH C: HIGH A: LOW B: LOW D
    RETURN
    SIX:
    HIGH C: HIGH B: LOW A: LOW D
    RETURN
    SEVEN:
    HIGH A: HIGH B: HIGH C: LOW D
    RETURN
    EIGHT:
    HIGH D: LOW A: LOW B: LOW C
    RETURN
    NINE:
    HIGH D: HIGH A: LOW B: LOW C
    RETURN

  7. #7
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Decoding variable into 4 digits of BCD, are there simple ways to this?

    Choose a port (A,B, or C). Connect the low 4 pins of the port to carry the number you want to display and connect those to the data pins of the CD4543BE. Then connect the 4 pins of the high byte to the latches. to write "2" to the first digit, send "12" to the port. to write 9 to the second digit send "29" to the port. Write 6 to the 3rd port with "46" and so on.

Similar Threads

  1. Best way or ways?
    By Ramius in forum General
    Replies: 9
    Last Post: - 1st August 2013, 02:01
  2. Ways to make code easily reviewable and extendable
    By Ted's in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 23rd August 2008, 00:10
  3. Array to simple Variable converting
    By mrx23 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd September 2006, 16:44
  4. Showing numbers in diffrent ways?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th July 2005, 15:57
  5. PIC problem, ways to do reset
    By lab310 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th May 2005, 14:31

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts