PIC 16F84A and 7segment LED dispay


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2007
    Posts
    3

    Default PIC 16F84A and 7segment LED dispay

    hello,

    I have one small problem with routine for PIC 16F84A. Program must drive 7 segment LED display with comm. cathode. On output B port are PNP transistors via 4k7 for each segment.
    problem is following:
    RS232 values are ok and display lighted only 0. What is wrong here?

    porta.3 is serial input and value for B5 are 0-10. Var from LOOKUP are value for LED segment

    here is rotine:

    DEFINE OSC 16
    INCLUDE "MODEDEFS.BAS"

    dp var portb.0
    c var portb.1
    d var portb.2
    e var portb.3
    g var portb.4
    f var portb.5
    a var portb.6
    b var portb.7
    SDA VAR PORTA.3 'pin2
    b0 var byte
    b1 var byte
    b2 var byte
    b3 var byte
    b4 var byte
    b5 var byte

    trisa=%11111111
    trisb = %00000000

    clear
    START:

    serin sda,0,b2,b3,b4,b5
    lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
    PORTB=B1
    GOTO START

    end

    Similar routine i have write for a LCD display. Instead LOOKUP command is LCDOUT $fe,$80, #b5 and working ok.

    Thanks
    Sam

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    it's more a matter of how the data is sent. You may try to change b5 to #b5 in SERIN line.

    doesn't work? comment out the SERIN line and use b5=3, it should display 3 on your 7 segment... right?
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    hi Steve,

    I was trying with #b5 and display light allways 8 (all pins are low). The simple loop program, working ok and count normaly from 0 to 9

    here is a this sample1 (B5 count on LED display 0-9)

    start: for B5=0 to 9
    lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
    pause 500
    portb=b1
    next B5
    goto start

    sample 2 Instead lookup2 command have lcdout command. (working ok. B5 count 0 to 9 on LCD)

    start: serin SDA,0,b2,b3,b4,b5
    lcdout $fe,1,$80,#b5
    pause 100
    goto start


    sample 3. this sample show allways 0 on display. (B5 read lookup2 command and show 0 allways)

    dp var portb.0
    c var portb.1
    d var portb.2
    e var portb.3
    g var portb.4
    f var portb.5
    a var portb.6
    b var portb.7
    SDA VAR PORTA.3 'pin2
    b0 var byte
    b1 var byte
    b2 var byte
    b3 var byte
    b4 var byte
    b5 var byte

    trisb = %00000000

    start: serin SDA,0,b2,b3,b4,b5

    lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
    portb=b1
    goto start


    i was changed LOOKUP2 with LOOKUP and LED showing 8

    I have not anymore ideas

    regards
    Sam
    Attached Images Attached Images  
    Last edited by select; - 21st November 2007 at 09:54.

  4. #4
    Join Date
    Nov 2007
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    hi again,

    How read ASCII value from lookup command?

    regards,
    Sam
    Last edited by select; - 21st November 2007 at 09:58.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,806


    Did you find this post helpful? Yes | No

    Default

    How do you send the number to be displayed? By Hyperterminal for example and pressing the key '0'?

    Ioannis

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i'll repeat what i told in previous post...
    Code:
    start: serin SDA,0,b2,b3,b4,#b5
    
    lookup2 B5,[238,130,220,214,178,118,126,194,254,246,108],B1
    portb=b1
    goto start
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 1

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