10 bit A-D, to 4x 7 segment LED display.

YT2095
2012-05-15
2013-05-30
  • YT2095

    YT2095 - 2012-05-15

    here`s something I`v been working on that may be usefull to someone, it reads the AN0 pin and displays this as a 4 digit number on 7 segment displays, it`s only my third project, and quite simple, but it seems to work quite well, and can be easily adapted to display much Larger numbers over more displays.

    ;Chip Settings
    #chip 16F877A,20
    #config BODEN=OFF, WDT=OFF, OSC=HS

    ;Variables
    Dim SysCalcTempX As word
    Dim Number As word

    ;Data tables
    Table display
    b'01111110'
    b'00110000'
    b'01101101'
    b'01111001'
    b'00110011'
    b'01011011'
    b'01011111'
    b'01110000'
    b'01111111'
    b'01110011'
    End Table

    Dir PORTA.0 In
    dir portd out
    dir portb out
    Do Forever
    Number= ReadAD10(AN0)
    num1=0
    If Number >= 1000 Then
    Num1 = Number / 1000
    Number = SysCalcTempX
    End If
    If Number >= 100 Then
    Num2 = Number / 100
    Number = SysCalcTempX
    End If
    If Number >= 10 Then
    Num3 = Number / 10
    Number = SysCalcTempX
    End If
    num4=number
    Repeat 100
    readtable display,num1+1,temp
    portb = 254
    portd = temp
    wait 1 ms
    readtable display,num2+1,temp
    portb = 253
    portd = temp
    wait 1 ms
    readtable display,num3+1,temp
    portb = 251
    portd = temp
    wait 1 ms
    readtable display,num4+1,temp
    portb = 247
    portd = temp
    wait 1 ms
    end repeat
    loop

     
  • YT2095

    YT2095 - 2012-05-15

    a Tidied up and Improved version that won`t cause any potential lockup at extreme A/D values:

    ;Chip Settings
    #chip 16F877A,20
    #config CP=OFF, BODEN=OFF, WDT=OFF, OSC=HS

    ;Variables
    Dim SysCalcTempX As word
    Dim Number As word

    ;Data tables
    Table display
    b'01111110'
    b'00110000'
    b'01101101'
    b'01111001'
    b'00110011'
    b'01011011'
    b'01011111'
    b'01110000'
    b'01111111'
    b'01110011'
    End Table

    Dir PORTA.0 In
    dir portd out
    dir portb out
    Do Forever
    Number= readad10(an0)
    num1=0
    If Number >= 1000 Then
    Num1 = Number / 1000
    Number = SysCalcTempX
    End If
    num2=0
    If Number >= 100 Then
    Num2 = Number / 100
    Number = SysCalcTempX
    End If
    num3=0
    If Number >= 10 Then
    Num3 = Number / 10
    Number = SysCalcTempX
    End If
    num4=number

                repeat 10
    readtable display,num1+1,temp
    portb = 254
    portd = temp
    wait 5 ms
    readtable display,num2+1,temp
    portb = 253
    portd = temp
    wait 5 ms
    readtable display,num3+1,temp
    portb = 251
    portd = temp
    wait 5 ms
    readtable display,num4+1,temp
    portb = 247
    portd = temp
    wait 5 ms
    end repeat
    loop

     

Log in to post a comment.