Displaying temperature Setpoints


Closed Thread
Page 1 of 2 12 LastLast
Results 1 to 40 of 59
  1. #1
    Join Date
    Oct 2008
    Posts
    47

    Red face Displaying temperature Setpoints

    Hi Guys. I'm pretty new to picbasic pro. I've tried to create a temperature control system but having endless dead-ends. I've tried my best with the code and so far I managed to get the program to display the temperature. Adding in buttons though is what's giving me problems. Below is a copy of my program. Please help me somebody.


    /Define LCD_DREG PORTB
    Define LCD_DBIT 0
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 5
    Define LCD_EREG PORTB
    Define LCD_EBIT 4
    dEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    adval var word ' Create adval to store result
    tempc var word ' Create tempc to store result
    Setpoint var word
    sethigh var byte
    setlow var byte

    Temp_Up var PORTC.0
    Temp_Down var PORTC.1
    High_sp var PORTC.2
    Low_sp VAR PORTC.3
    Main_disp VAR PORTC.4


    TRISC = %11111111 ' Set PORTC to all input
    TRISA = %11111111 ' Set PORTA to all input
    ADCON1 = %10000010 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %11000001 ' Configure and turn on A/D Module
    Pause 100 ' Wait 0.1 second

    START:
    if High_sp = 1 then gosub Set_High
    IF Low_sp = 1 then gosub Set_Low
    IF Main_disp = 1 then gosub Main
    pause 10 '????????????? debounce how?

    Keypress:
    if Temp_Up = 1 then gosub Up_Loop
    if Temp_Down = 1 then gosub Down_Loop


    GOTO START

    Main: ADCON0.2 = 1 ' Start Conversion

    AGAIN: Pause 1

    If ADCON0.2 = 1 Then AGAIN ' Wait for low on bit-2 of ADCON0, conversion finished

    adval.highbyte = ADRESH ' Move HIGH byte of result to adval
    adval.lowbyte = ADRESL ' Move LOW byte of result to adval

    Lcdout $fe, 1 ' Clear screen
    tempc=50*adval ' Conversion to Degrees
    tempc=tempc/100
    Lcdout "Temp = ",DEC tempc,$DF,"C" ' Display the value of temp

    if Tempc > 100 then
    lcdout "Out of range!"
    endif
    if Tempc < 0 then
    lcdout "Out of Range!"
    endif
    Pause 1000 ' Wait 1 second

    Goto Main ' Do it forever

    Up_Loop:
    If Temp_Up = 1 Then
    Setpoint = Setpoint + 1
    if Setpoint>100 then SetPoint=0
    lcdout $fe, 1, "Setpoint = ", Setpoint
    Pause 10
    Else
    Goto Keypress
    Endif
    Goto Up_Loop

    Down_Loop:
    If Temp_Down = 1 Then
    Setpoint = Setpoint - 1
    if Setpoint>0 then SetPoint=100
    lcdout $fe, 1, "Setpoint = ", Setpoint
    Pause 10
    Else
    Goto Keypress
    Endif
    Goto Down_Loop

    Set_High: '?????????? Im trying to store the value
    gosub Keypress '?????????? from the Temp_Up/Temp_Down.
    write sethigh, Keypress '??????????

    Set_Low: '?????????? Im trying to store the value
    gosub Keypress '?????????? from the Temp_Up/Temp_Down.
    write setlow, Keypress '??????????

    end
    Last edited by Kalind; - 15th October 2008 at 17:08.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Looking good.

    Now go back here http://www.picbasic.co.uk/forum/showthread.php?t=9741
    and re-read how to store and read the value.

    If there is a part you do not understand ask a specific question, it will make it easier to help you.
    Dave
    Always wear safety glasses while programming.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Don't know what PIC you're using...so don't really know if that PIC has onchip eeprom or not...or what...
    Code:
    Define	LCD_DREG	PORTB
    Define	LCD_DBIT	0
    Define	LCD_RSREG	PORTB
    Define	LCD_RSBIT	5
    Define	LCD_EREG	PORTB
    Define	LCD_EBIT	4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    mode var byte : keyin var byte : adval var word : tempc var word
    highpt var byte : lowpt var byte : up var portc.0 : down var portc.1
    sethighp var portc.2 : setlowp var portc.3 : maindisp var portc.4
    trisc=$ff : trisa=$ff : adcon1=$82 : adcon0=$c1 : pause 100
    mode = 1 : lcdout $fe , 1 : goto main
    getkey:  pause 50 : keyin = portc : return
    gettemp:  adcon0.2=1 : pause 1
    checkdone: if adcon0.2=1 then checkdone
    adval.highbyte=adresh : adval.lowbyte=adresl : tempc=(50*adval)/100 : return
    main:  gosub gettemp : gosub getkey
    if maindisp = 1 then
         write 0 , sethighp : pause 10 : write 1 , sethighp : mode = 1
    endif
    if sethighp = 1 then mode = 2
    if setlowp = 1 then mode = 3
    select case mode
    case 1
    lcdout $fe , $80 , "Temp = ", DEC3 tempc , $DF , "C"
    case 2
    lcdout $fe , $80 , "High Pt=" , $fe , $c0 , highpt
    if up = 1 then highpt = highpt + 1
    if down = 1 then highpt = highpt - 1
    case 3
    lcdout $fe , $80 , "Low Pt=" , $fe , $c0 , lowpt
    if up = 1 then lowpt = lowpt + 1
    if down = 1 then lowpt = lowpt - 1
    end select
    goto main
    If that doesn't give you some ideas...nothing will...
    But remember, I SUCK! DUDE!

    P.S. Your program has been COLONized! In the process of De-COLONizing the code above and figuring out what goes where, you might learn something...
    Last edited by skimask; - 15th October 2008 at 17:38.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Looking good.
    ????????????????????????????????????????????????

    Code:
    if Tempc < 0 then
    lcdout "Out of Range!"
    endif
    
    That looks REAL good! for one thing...

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    ????????????????????????????????????????????????

    Code:
    if Tempc < 0 then
    lcdout "Out of Range!"
    endif
    
    That looks REAL good! for one thing...
    Well maybe I should have said looking better? At least the OP has code that looks like he wrote.
    Dave
    Always wear safety glasses while programming.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    At least the OP has code that looks like he wrote.
    Now, I'll admit, sometimes there's only one way to do something, and sometimes there are hundreds of ways of doing something...but...
    http://www.picbasic.co.uk/forum/show...ight=down_loop
    See anything in there?

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Now, I'll admit, sometimes there's only one way to do something, and sometimes there are hundreds of ways of doing something...but...
    http://www.picbasic.co.uk/forum/show...ight=down_loop
    See anything in there?
    There goes the benefit of doubt.
    Dave
    Always wear safety glasses while programming.

  8. #8
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    what's post #3 all about ski? Im using a 16f873.
    Last edited by Kalind; - 15th October 2008 at 19:02.

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    what's post #3 all about ski? Im using a 16f873.
    Wow....first I've seen of it here...unlike those other 6 threads...

  10. #10
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Exclamation

    well, this is what i managed to do. i hooked it up to my circuit but the program isnt doing what i wanted it to do. Skimask?

    /code

    Define LCD_DREG PORTB
    Define LCD_DBIT 0
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 5
    Define LCD_EREG PORTB
    Define LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    mode var byte
    keyin var byte
    adval var word
    tempc var word
    highpt var byte
    lowpt var byte
    up var portc.0
    down var portc.1
    sethighp var portc.2
    setlowp var portc.3
    maindisp var portc.4
    trisc=$ff
    trisa=$ff

    adcon1=$82
    adcon0=$c1
    pause 100

    mode = 1
    lcdout $fe , 1
    goto main

    getkey:
    pause 50
    keyin = portc
    return

    gettemp:
    adcon0.2=1
    pause 1

    checkdone:
    if adcon0.2=1 then checkdone

    adval.highbyte=adresh
    adval.lowbyte=adresl
    tempc=(50*adval)/100
    return

    main:

    gosub gettemp

    gosub getkey

    'saving part
    if maindisp = 1 then
    write 0 , sethighp
    pause 10
    write 1 , sethighp
    mode = 1

    endif

    if sethighp = 1 then mode = 2
    if setlowp = 1 then mode = 3

    select case mode

    case 1
    lcdout $fe , $80 , "Temp = ", DEC3 tempc , $DF , "C"

    case 2
    lcdout $fe , $80 , "High Sp=" , $fe , $c0 , highpt
    if up = 1 then highpt = highpt + 1
    if down = 1 then highpt = highpt - 1

    case 3
    lcdout $fe , $80 , "Low Pt=" , $fe , $c0 , lowpt
    if up = 1 then lowpt = lowpt + 1
    if down = 1 then lowpt = lowpt - 1
    end select
    goto main
    Last edited by Kalind; - 20th October 2008 at 13:02.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    well, this is what i managed to do.
    Looks like it's pretty much what I managed to do...

    i hooked it up to my circuit but the program isnt doing what i wanted it to do.
    It might help for you to tell us exactly what it IS or isn't doing...

  12. #12
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Unhappy

    taking your advice with the program, i hooked it up and on the lcd it prompts the user to enter a LOW SP. upon the use of the increment decrement buttons, on the second line of the lcd are characters which are being displayed. when the 'main' button is pressed, it does not go to the main display and also when the HighSp button is pressed, it does not go to that screen. im so lost with this whole thing

  13. #13
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Put yours subrouteenes at the end of your code, never at the beginning!

    Modify your If then in the following manner:

    if maindisp = 1 then
    write 0 , sethighp
    pause 10
    write 1 , sethighp
    mode = 1
    maindisp = 0 ' reset flag
    endif

    Otherwise it will write at every cycle and in this case you do not need the " IF Then " statement. Set your flag to 1 when writing is needed

    Yours code for reading key:

    getkey:
    pause 50
    keyin = portc
    return

    You read the status of the all 8 inputs, than you need to decode to find which key has been pressed.


    More:

    Are you pulling up your inputs using normally closed switches? otherwise with this code you have to pull down your inputs.
    Al.
    Last edited by aratti; - 20th October 2008 at 14:23.

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Ok, are you sure all of your buttons are working properly?

  15. #15
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Put yours subrouteenes at the end of your code, never at the beginning!
    Disagree 100%, ok maybe 99%
    If using a PIC16 (or 12,or 10) series PIC, if you are able to keep the 'subroutines' in the first bank of code space, you'll save code space due to the fact that the BANK Select registers don't need to be changed, and at the same time save instruction cycles. And if your subroutines are at the beginning, they're the first thing to get seen while skimming thru the code, makes them harder to forget them (I guess more of a brain thing there).

    At any rate, there's one more small bug in your If/Then correction above (post #13)...a small one...actually two small bugs...one matters, the other doesn't really matter...

  16. #16
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    yup. They connected from +5v to ground using a 10K

  17. #17
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    yup. They connected from +5v to ground using a 10K
    No, what I mean is, how do you know the PIC and/or your code is actually recognizing the buttons as pressed or not-pressed.
    Again, just 'cause you want it doesn't mean it...
    And what do you mean from +5v to ground using 10K? Leaves a bit to the imagination...

  18. #18
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    check the button pic. that is how i connected it ski
    Last edited by Kalind; - 20th October 2008 at 14:28.

  19. #19
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    check the button pic. that is how i connected it ski
    button pic...hmmm...what button pic?

  20. #20
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Humour me for a bit...
    Code:
    Define	LCD_DREG	PORTB
    Define	LCD_DBIT	0
    Define	LCD_RSREG	PORTB
    Define	LCD_RSBIT	5
    Define	LCD_EREG	PORTB
    Define	LCD_EBIT	4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2
    keyin var byte : trisc=$ff : pause 1000 : lcdout $fe,1
    main:   keyin = portc : lcdout $fe, $80, BIN8 keyin : goto main
    end
    Push the buttons, what happens?

  21. #21
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    should display binary number

  22. #22
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    should display binary number
    And does it?

  23. #23
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    i dont know..this isnt the main concern...lets get back to reality

  24. #24
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Thumbs down I tried...I give up...

    Quote Originally Posted by Kalind View Post
    i dont know..this isnt the main concern...lets get back to reality
    Not the main concern? Where are you at? Happy-ville where everything works the 1st time according your wishes?
    That little 'display a binary number' program would verify that all of your buttons actually work and change states. If your buttons don't work in the first place, which you're not 100% sure they do, you just say they do because they're connected, how do you expect the rest of the program to follow suit?
    Get back to reality? Here's a bit of reality for you... I was all set to lead you from one place to the next to the end, with a ready-made program, and figured you might learn a little bit of something along the way.
    Here's the reality part...How about you finish this project on your own? Then let us know how that goes for you?
    Maybe somebody else with a bigger heart will come along, write the code to exactly watch your specifications and your hardware, debug it, test it under all known conditions, then drop by your house some weekend, with a finished PCB, a CD with all of the code on it, fully commented and explained in a long long video, and might even bring a 6-pack of your favorite beverage, and a large pizza from the local vendor.
    As Dennis Miller used to say on Saturday Night Live back in the day "That's the news, and I am outta here!!!"

  25. #25
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Exclamation

    myself. Sticking to the basics.

  26. #26
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Unhappy Final Attempt

    Does this make any sense? (Well to me it does) At the moment, nothing appears on the LCD. Please could somebody tell me what I need to add/delete to obtain success from this code.

    Define LCD_DREG PORTB
    Define LCD_DBIT 0
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 5
    Define LCD_EREG PORTB
    Define LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    tempc var word
    tempc1 var word
    Conv1 Con 4
    Conv2 Con 82/100
    mode var byte
    keyin var byte
    adval var word
    highpt var byte
    lowpt var byte
    up var portc.0
    down var portc.1
    sethighp var portc.2
    setlowp var portc.3
    maindisp var portc.4
    trisc=$ff
    trisa=$ff

    adcon1=$82
    adcon0=$c1
    pause 100

    main:

    gosub checkdone

    gosub getkey

    checkdone:
    if adcon0.2=1 then checkdone

    adval.highbyte=adresh
    adval.lowbyte=adresl
    Lcdout $fe, 1
    tempc = adval * Conv1
    tempc1 = adval * Conv2
    tempc = tempc + tempc1
    pause 1000
    return

    getkey:
    pause 50
    keyin = portc
    return

    if maindisp = 1 then
    write 0 , sethighp
    pause 10
    write 1 , sethighp
    LCDOut "TEMP = ", dec(tempc / 10), ".", dec1 (tempc // 100), $DF , "C"
    endif

    if maindisp = 1 then
    write 2 , setlowp
    pause 10
    write 3 , setlowp
    LCDOut "TEMP = ", dec(tempc / 10), ".", dec1 (tempc // 100), $DF , "C"
    endif

    if sethighp = 1 then gosub setsetpointh
    if setlowp = 1 then gosub setsetpointl

    setsetpointh:

    lcdout $fe , $80 , "High Sp=" , $fe , $c0 , dec highpt
    if up = 1 then highpt = highpt + 1
    if down = 1 then highpt = highpt - 1
    return

    setsetpointl:

    lcdout $fe , $80 , "Low Pt=" , $fe , $c0 , dec lowpt
    if up = 1 then lowpt = lowpt + 1
    if down = 1 then lowpt = lowpt - 1
    return

    goto main

  27. #27
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Cool Still not paying attention...

    Quote Originally Posted by Kalind View Post
    Does this make any sense? (Well to me it does) At the moment, nothing appears on the LCD. Please could somebody tell me what I need to add/delete to obtain success from this code.
    i dont know..this isnt the main concern...lets get back to reality
    The reality is that you don't read and/or follow thru your own code (or somebody else's code for that matter)...
    If you did, you'd find at least 2 hard 'breaks' and 5 'bugs'...
    Last edited by skimask; - 21st October 2008 at 14:08.

  28. #28
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Red face

    i've read thru it many times. im no programmer. i'll admit to taking snips from others and to me it makes sense. the main temperature measurement part is mine. the button fuctions is not but i tried to make sense of it all. please just guide me to eliminating the errors

  29. #29
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    please just guide me to eliminating the errors
    Gimme this...gimme that...gimme gimme gimme...I got a kid on the way and I figured I'd have to wait about 2-3 years before I got to listen to that. Apparently not...

    I tried to do the guiding thing. You told me to get back to reality, so I did...

  30. #30
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Angry

    what joy do u get out of being spiteful? all im askin for is guidance..

  31. #31
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    all im askin for is guidance..
    If you are wanting to learn, then go back to post #2,3 and 20.
    If you are wanting someone to do the project for you just say so. It will save us all a lot of time.
    Dave
    Always wear safety glasses while programming.

  32. #32
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Wink

    just want to apologise for asking too much. i manage to get the thing working. just have to try tweak here and there...

  33. #33
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    just want to apologise for asking too much. i manage to get the thing working. just have to try tweak here and there...
    And what ended up fixing the problem?

  34. #34
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    well, the button where connected incorrectly. that being my partners fault. also a few things in the program which where so obvious.. now im gona add in buzzer for high/low and also relays to switch loads at certain temps.

  35. #35
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Exclamation

    BIG PROMLEM!!! After adding on all the extra's (relay code, leds...etc), the pic is operating at snails pace!!! What do i do about this now??

  36. #36
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    BIG PROMLEM!!! After adding on all the extra's (relay code, leds...etc), the pic is operating at snails pace!!! What do i do about this now??
    Did you DEFINE the OSC or mes with the configs?

    Post you code so we can take a look.
    Dave
    Always wear safety glasses while programming.

  37. #37
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    im using a 4mhz crystal oscillator. I did define it in ADCON0. Bit 6-7 as 11. i would also like to know what difference would there be if i had to amplify the output signal from the LM35. and if i did, please explain to me whether i'd be getting more accurate results? N.B. 16F873

    Define LCD_DREG PORTB
    Define LCD_DBIT 0
    Define LCD_RSREG PORTB
    Define LCD_RSBIT 5
    Define LCD_EREG PORTB
    Define LCD_EBIT 4
    DEFINE LCD_BITS 4
    DEFINE LCD_LINES 2

    mode var byte
    keyin var byte
    adval var word
    tempc var word
    highpt var byte
    lowpt var byte
    highled var porta.1
    lowled var porta.2
    relayhigh var porta.3
    relaylow var porta.4
    buzzer var porta.5
    up var portc.0
    down var portc.1
    sethighp var portc.2
    setlowp var portc.3
    maindisp var portc.4
    highpt = 100
    lowpt = 0
    trisc= %00011111
    trisa=%00000001
    adcon1=%11110010
    adcon0=%11000001

    pause 100

    lcdout $fe , 1
    mode = 1
    goto main

    getkey:
    pause 50
    keyin = portc
    return

    gettemp:
    adcon0.2=1
    pause 1

    checkdone:
    if adcon0.2=1 then checkdone

    adval.highbyte=adresh
    adval.lowbyte=adresl

    tempc=50*adval
    tempc=tempc/100

    If tempc>=highpt then
    gosub high_flash
    SOUND buzzer, [60, 100, 23, 200]
    relayhigh = 1
    else
    relaylow = 0
    lowled = 0
    buzzer = 0
    endif

    If tempc<=lowpt then
    gosub low_flash
    SOUND buzzer, [20, 100, 23, 200]
    relaylow = 1
    else
    relayhigh = 0
    highled = 0
    buzzer = 0
    endif

    return

    main:
    gosub gettemp
    gosub getkey

    if maindisp = 0 then mode = 1
    pause 50
    if sethighp = 0 then mode = 2
    pause 50
    if setlowp = 0 then mode = 3
    pause 50

    select case mode

    case 1
    write 0 , sethighp
    pause 10
    write 1 , setlowp
    lcdout $fe , 1
    Lcdout "TEMP = ",DEC tempc,$DF,"C"

    case 2
    lcdout $fe , 1
    lcdout $fe , $80 , "High Setpoint:" , $fe , $c0 , dec highpt, $DF , "C"
    if up = 0 then highpt = highpt + 1
    if down = 0 then highpt = highpt - 1
    if highpt>100 then highpt=0

    case 3
    lcdout $fe , 1
    lcdout $fe , $80 , "Low Setpoint:" , $fe , $c0 , dec lowpt, $DF , "C"
    if up = 0 then lowpt = lowpt + 1
    if down = 0 then lowpt = lowpt - 1
    if lowpt>100 then lowpt=0
    end select
    goto main

    high_flash:
    HIGH highled
    PAUSE 350
    LOW highled
    PAUSE 350
    RETURN

    low_flash:
    HIGH lowled
    PAUSE 350
    LOW lowled
    PAUSE 350
    RETURN
    Last edited by Kalind; - 23rd October 2008 at 09:40.

  38. #38
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    im using a 4mhz crystal oscillator. I did define it in ADCON0. Bit 6-7 as 11. i would also like to know what difference would there be if i had to amplify the output signal from the LM35. and if i did, please explain to me whether i'd be getting more accurate results? N.B. 16F873
    You define the oscillator
    Code:
    DEFINE OSC 4
    but PB defauts to 4 so you should be good there.

    The LM35 does not need amplification. If it is giving a fluctuation on the reading a capacitor between the signal and 0 volts (ground) will fix that.

    Still looking through you code...
    When it gets to the LED blinking, do they blink at the correct speed? Or are you seeing slow running some place else?
    Dave
    Always wear safety glasses while programming.

  39. #39
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    there entire device has slowed down. temperature changes used to be instantaneous. going into the different menu's were instantaneous. for some odd reason every has slowed down.

    About the amplification, wouldnt it affect the resolution of the measurement?

  40. #40
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Kalind View Post
    there entire device has slowed down. temperature changes used to be instantaneous. going into the different menu's were instantaneous. for some odd reason every has slowed down.
    So when you press a button it takes a bit for anything to happen?

    I do not see anything obvious in you code other than it is doing a lot of things now that take time. Takes a little time to get back to the button. To make the buttons react faster you will want to explore interrupts.
    About the amplification, wouldnt it affect the resolution of the measurement?
    No.
    The resolution is controlled by the ADC, 8 or 10 bit, and the VREF (voltage reference)
    This link goes to a volt meter
    http://rentron.com/serial.htm
    but that is all a LM35 is (sort of)
    Bruce has a good explanation about how to read a voltage and display it.
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Write Onewire data toa I2C memory / read ASCI
    By Eugeniu in forum mel PIC BASIC Pro
    Replies: 67
    Last Post: - 16th November 2008, 19:19
  2. Displaying temperature using a -40 to 185F??
    By jblackann in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th January 2008, 18:45
  3. Conversion problem
    By eva in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 15th March 2007, 18:21
  4. Help for decimal conversion
    By eva in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th March 2007, 18:20
  5. Serout "onewire.bas"
    By puru in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 6th July 2005, 00:14

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