xxxxxx
- 2nd April 2009, 16:01
helllo
here is my problem, i got the posttemp variable declared like this
posttemp var byte
now i want to change the value of the variable like this
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
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
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 (http://www.mtskola.com)
ScaleRobotics
- 2nd April 2009, 16:14
helllo
here is my problem, i got the posttemp variable declared like this
posttemp var byte
<snip>
if temp >= posttemp then gosub s3
doesn't work,
and if i put it this way
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.
xxxxxx
- 2nd April 2009, 18:36
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 (http://www.mtskola.com)
xxxxxx
- 2nd April 2009, 18:50
posttemp sure looks like a word to me. Try changing it to a word variable.
and its working just fine :D
THX a lot
--
www.mtskola.com (http://www.mtskola.com)
xxxxxx
- 2nd April 2009, 19:00
'************************************************* ***************
'* 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
:D 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 :D
--
www.mtskola.com (http://www.mtskola.com)
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.