Need help Temp and 7segment led display


Closed Thread
Results 1 to 9 of 9
  1. #1
    mastero's Avatar
    mastero Guest

    Default Need help Temp and 7segment led display

    Hello all,

    I am having difficulty in a project which i am working on.

    I require temperature reading on two 7 segement LED display.

    Using 16f72 and LM34 as sensor

    Does anyone know of a program which will read the temp from LM34 and display it on two LED segment display something like this

    h**p://www.geocities.com/hagtronics/thermometer.html

    I can program the LM34 to read temp and display on LCD but not 7 segment LED display.

    Anyhelp is good

    Cheers
    Mastero

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Check out the 7segment.pbp sample program at meLabs

    http://www.melabs.com/resources/samples.htm

    HTH,
      Darrel

  3. #3
    mastero's Avatar
    mastero Guest


    Did you find this post helpful? Yes | No

    Default

    I have already checked it out and others.. the problem is putting the temp reading on LED

    ************************************************** ******
    DEVICE 16F72
    DEFINE osc 4 ' 4 MHz oscillator
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
    Dim digit As Byte 'input variable for GETMASK subroutine
    Dim digit1 As Byte 'current digit1
    Dim digit2 As Byte 'current digit2
    Dim mask As Byte 'output variable from GETMASK subroutine
    Dim mask1 As Byte 'current digit1 mask
    Dim mask2 As Byte 'current digit2 mask
    Dim temp As Word 'Temperature storage

    Dim samples As WORD ' Multiple A/D sample accumulator
    Dim sample As BYTE ' Holds number of samples to take

    Symbol d1enable = PORTC.7 'enable line for display1
    Symbol d2enable = PORTC.6 'enable line for display2

    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %00000011 ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
    TRISB = %00000000 'set PORTB pins as outputs
    TRISC.7 = 0 'set RD4 pin as output
    TRISC.6 = 0 'set RD5 pin as output

    LOW d1enable
    LOW d2enable
    mask1 = 0 ' Clear samples accumulator on power-up
    mask2 = 0 ' Clear samples accumulator on power-up
    samples = 0 ' Clear samples accumulator on power-up

    PAUSE 250 ' Wait .5 second

    loop:

    FOR sample = 1 TO 20 ' Take 20 samples
    ADCIN 0, temp ' Read channel 0 into temp variable
    samples = samples + temp ' Accumulate 20 samples
    PAUSE 250 ' Wait approximately 1/4 seconds per loop
    NEXT sample
    temp = samples/20

    digit1 = temp / 10 'get current digit1
    temp = temp // 10
    digit2 = temp 'get current digit2
    digit = digit1

    Gosub getmask 'get mask for digit1
    mask1 = mask
    digit = digit2

    Gosub getmask 'get mask for digit2
    mask2 = mask

    Gosub show1 'display new mask
    Gosub show2 'display new mask

    pause 500
    samples = 0 ' Clear old sample accumulator

    Goto loop

    End

    getmask: 'get appropriate 7-segment mask for input digit
    mask = Lookupl digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], digit
    Return

    show1: 'show digit1 on its display
    LOW d1enable
    LOW d2enable
    PORTB = mask1
    HIGH d1enable
    Return

    show2: 'show digit2 on its display
    LOW d1enable
    LOW d2enable
    PORTB = mask2
    HIGH d2enable
    Return
    ************************************************** *******

    Someone please check the above and let me know if there is any errors...?

    Cheers
    Mastero

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Well, this is a problem

    mask = Lookupl digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], digit

    Try this instead ...

    Lookup digit,[$40,$79,$24,$30,$19,$12,$02,$78,$00,$18], mask

    HTH

    P.S. You'll need to speed up the loop for it to display properly.

  5. #5
    mastero's Avatar
    mastero Guest


    Did you find this post helpful? Yes | No

    Default

    Is there a way i can have this whole process of reading the temp and displaying on the LEDs working in the background ? and the PIC is executing other commands.

    Will HPWM work here as i have one ccp pin on 16f72

    Thanks for your help

    Mastero

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    That's what I get for making a quick reply from work.

    After looking again, it appears that your program is written for Proton.

    Are you sure you're using PicBasic Pro?

    If so then yes to your interrupt question.

    If not, then you might want to try this forum.
    http://www.picbasic.org/forum/
    <br>
    DT

  7. #7
    mastero's Avatar
    mastero Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor
    That's what I get for making a quick reply from work.

    After looking again, it appears that your program is written for Proton.

    Are you sure you're using PicBasic Pro?

    If so then yes to your interrupt question.

    If not, then you might want to try this forum.
    http://www.picbasic.org/forum/
    <br>
    Now i am confused here

    Will check and let you know

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


    Did you find this post helpful? Yes | No

    Default

    Don't worry Darrel.. there's a mix of 2 PICBASIC compiler in there...
    Code:
    DEVICE 16F72
    not valid in PBP neither in PROTON

    Code:
    DEFINE osc 4 ' 4 MHz oscillator
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
    PBP

    Code:
    Dim digit As Byte 'input variable for GETMASK subroutine
    .
    .
    .
    .
    Proton

    Code:
    PAUSE 250 ' Wait .5 second
    PBP native but now accepted by PROTON with a warning... well the last time i used it

    Now Mastero is on PROTON forum with the same code...
    Steve

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

  9. #9
    mastero's Avatar
    mastero Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    Don't worry Darrel.. there's a mix of 2 PICBASIC compiler in there...
    Code:
    DEVICE 16F72
    not valid in PBP neither in PROTON

    Code:
    DEFINE osc 4 ' 4 MHz oscillator
    DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
    DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
    DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
    PBP

    Code:
    Dim digit As Byte 'input variable for GETMASK subroutine
    .
    .
    .
    .
    Proton

    Code:
    PAUSE 250 ' Wait .5 second
    PBP native but now accepted by PROTON with a warning... well the last time i used it

    Now Mastero is on PROTON forum with the same code...

    Yes its proton i am using.

    Cheers
    Mastero

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