Displaying temperature Setpoints


Closed Thread
Results 1 to 40 of 59

Hybrid View

  1. #1
    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...

  2. #2
    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.

  3. #3
    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...

  4. #4
    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

  5. #5
    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.

  6. #6
    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...

  7. #7
    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?

  8. #8
    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

  9. #9
    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...

  10. #10
    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?

  11. #11
    Join Date
    Oct 2008
    Posts
    47


    Did you find this post helpful? Yes | No

    Default

    should display binary number

  12. #12
    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?

  13. #13
    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

  14. #14
    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!!!"

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