lcd menu problems


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    48

    Default lcd menu problems

    helllo

    here is my problem, i got the posttemp variable declared like this

    Code:
    posttemp var byte
    now i want to change the value of the variable like this

    Code:
    if menu = 2 then 
    posttemp=$0AF0
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "28.00 C"
        pause 2000
    endif
    
    if menu = 3 then 
    posttemp=$0BB8
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "30.00 C"
        pause 2000
    endif
    and then compare posttemp like this

    Code:
    if temp >= posttemp then gosub s3
    but this isn't working, program is compiled without erors, everythig is working fine, but my program gosub to s3 ever time, no matter if the condition is true!

    and if i put it this way
    Code:
    if temp >= $0AF0 then gosub s3
    then everything is working just fine but i want to change value $0AF0 like in above not working examplel

    thx in advance

    --
    www.mtskola.com
    Last edited by xxxxxx; - 2nd April 2009 at 19:16.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by xxxxxx View Post
    helllo

    here is my problem, i got the posttemp variable declared like this

    Code:
    posttemp var byte
    <snip>
    if temp >= posttemp then gosub s3
    doesn't work,
    and if i put it this way
    Code:
    if temp >= $0AF0 then gosub s3
    then everything is working just fine but i want to change value $0AF0 like in above not working examplel

    thx in advance
    posttemp sure looks like a word to me. Try changing it to a word variable.

  3. #3
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    posttemp sure looks like a word to me. Try changing it to a word variable.
    i am going to try it so you say

    posttemp var word

    oh my God i didn't see that.....temp is var word

    --
    www.mtskola.com
    Last edited by xxxxxx; - 2nd April 2009 at 20:20.

  4. #4
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    posttemp sure looks like a word to me. Try changing it to a word variable.
    and its working just fine

    THX a lot

    --
    www.mtskola.com
    Last edited by xxxxxx; - 2nd April 2009 at 19:17.

  5. #5
    Join Date
    Mar 2009
    Posts
    48


    Did you find this post helpful? Yes | No

    Default

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2009 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 24/02/2009                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    
    '
    'pic defines
    '------------------------------------------------------------------------
    	@ DEVICE pic16F887, WDT_OFF        ' Watchdog Timer
    	@ DEVICE pic16F887, PWRT_ON        ' Power-On Timer
    	@ DEVICE pic16F887, MCLR_ON        ' Master Clear Options (Internal)
    	@ DEVICE pic16F887, BOD_ON         ' Brown-Out Detect
    	@ DEVICE pic16F887, LVP_OFF        ' Low-Voltage Programming
    	@ DEVICE pic16F887, CPD_OFF        ' Data Memory Code Protect
    	@ DEVICE pic16F887, PROTECT_OFF    ' Program Code Protection
    '
    'konfigurisi AN pinove kao digital I/O, portd kao I
    '------------------------------------------------------------------------
    ansel=$00
    anselh=$00
    TRISD=$00
    portd=$00
    '
    ' Definisanje hser-a (transmit-recive) i lcd-a u 4 bitnom modu
    '------------------------------------------------------------------------ 
    define OSC 4
    DEFINE HSER_SPBRG 25
    DEFINE HSER_TXSTA 24h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 9600
    DEFINE HSER_CLROERR 1
    DEFINE LCD_BITS 4
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 4
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 5
    DEFINE LCD_LINES 2
    '
    'definisanje varijabli
    '------------------------------------------------------------------------
    
    SYMBOL sel = PORTA.0 ' Sw 1 "select"
    SYMBOL enter = PORTA.2 ' Sw 3 "ENTER"
    
    T1 VAR BYTE
    T1=20
    
    
    
    '----------------------------------------------------------------
    ' promjenjive
    '----------------------------------------------------------------
    
    MENU VAR BYTE ' zeljeni MENU
    POSI VAR BYTE ' Pozicija na LCD
    temp Var Word			' temperatura kao word
    cr Var Byte			    ' ostatak
    cpc Var	Byte			' broji po stepenu C
    ow	Var	PORTE.2			' One-wire data pin
    i var byte              ' brojac
    posttemp var word 
    
    '----------------------------------------------------------------
    ' incijalizacija 
    '----------------------------------------------------------------
    low portc.6
    low porte.2
    PAUSE 300       ' LCD inicijalizacija
    LCDOUT $FE,1    ' ocisti LCD
    
    MENU = 1        ' Inicijalizacija variablli
    
    
    LCDOUT $FE,130," DOBRO DOSLI"
    lcdout $FE,$c0,128, "izaberite temp "
    '-------------------------------------------------------------------------------------
    ' meni switc select temp
    '-------------------------------------------------------------------------------------
    izbor:
    
    PAUSE T1
    
    IF sel = 1 THEN
    
     LCDOUT $FE,1'ocisti lcd
        MENU = MENU + 1
        gosub amenu    
        pause 200
     endif
        IF MENU = 5 THEN MENU = 1
        
       ' for i = 1 to 4
        if menu = 1 and enter=1 then gosub sc
        if menu = 2 and enter=1 then gosub sc
        if menu = 3 and enter=1 then gosub sc
        if menu = 4 and enter=1 then gosub sc
       ' next i
    GOTO izbor
    
    '----------------------------------------------------------------------
    'odabir za prikaz na displeju
    '----------------------------------------------------------------------
    AMENU:
    
    SELECT CASE MENU
    
    CASE 2
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"1."," 28.00" , " C"
    POSI = 193 : LCDOUT $FE,POSI,"2."," 30.00" , " C" 
    
    
    CASE 3
    
    
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"2."," 30.00" , " C"
    POSI = 193 : LCDOUT $FE,POSI,"3."," 32.00" , " C" 
    CASE 4
    
    
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"3."," 32.00", " C"
    POSI = 193 : LCDOUT $FE,POSI,"4."," 34.00" , " C" 
    CASE 5
    
                                                                               
    POSI = 129 : LCDOUT $FE,128,">" : LCDOUT $FE,POSI,"4."," 34.00", " C"
    POSI = 193 : LCDOUT $FE,POSI,"1."," 28.00", " C"
    
    END SELECT
    RETURN
    
    
    '
    'provjera temperature
    '---------------------------------------------------------------------
    sc:
    'ovdje probati napraviti select case  
    if menu = 2 then 
    posttemp=$0AF0' postemp = 2800
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "28.00 C"
        pause 2000
    endif
    
    if menu = 3 then 
    posttemp=$0BB8
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "30.00 C"
        pause 2000
    endif
    
    if menu = 4 then 
    posttemp=$0C80
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "32.00 C"
        pause 2000
    endif
    
    if menu = 1 then 
    posttemp=$0D48
        LCDOUT $FE,1, "Max temperatura:"
        lcdout $FE,$c0,128, "34.00 C"
        pause 2000
    endif
    
    goto sc1
    sc1:
    
       OWOut ow, 1, [$CC, $44]       ' pocni temp konverziju
    
    wc: 
       OWIn ow, 4, [cr]	' provjeri da'l se jos konvertuje
       If cr = 0 Then wc
       OWOut ow, 1, [$CC, $BE]		' ocitaj temp
       OWIn ow, 0, [temp.LOWBYTE, temp.HIGHBYTE, Skip 4, cr, cpc]
       ' izracunaj temp u C na 2 decimale
      temp = (((temp >> 1) * 100) - 25) + (((cpc - cr) * 100) / cpc)
       
       Lcdout $fe, 1," temp:",DEC (temp / 100), ".", DEC2 temp, " C"' prikazi temp
       
       
                if temp >= posttemp then gosub s3    ' ako je veca od izabrane salji poruku!
              
                
       pause 2000
      goto sc1
    
    s3:
    
    high portb.6
    
    pause 2000
    
    low portb.6
    
    return
    
    End
    so u have a simple lcd menu and two switch, porta.0 seleect switch and porta.2 enter switch, if temp(from ds18B20) >= posttem (selected temperature form lcd menu) take action gosub s3

    --
    www.mtskola.com
    Last edited by xxxxxx; - 2nd April 2009 at 19:16.

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  3. Sending menu to PC from PIC16F876A
    By joseph Degorio in forum Serial
    Replies: 2
    Last Post: - 12th November 2007, 07:03
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30

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