Invalid number of parameters error
DJFX
Posts: 15
Here is the code that I am working with.· Every time I try to compile it I get an error "Invalid number of parameters" because of the 3 conditions in the IF statement.· Any help in correcting this problem would be greatly appreciated.
'
' Device Settings
'
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Gas········ VAR·RB.6
Flow······· VAR·RB.5
Temp······· VAR·RB.4
Solenoid··· VAR·RC.0
Fan········ VAR·RC.1
Alarm······ VAR·RC.2
'
' Main
'
PROGRAM Start
Start:
IF·Gas = 1 AND Flow·= 0 AND Temp = 0 THEN Check
·LOW·RC.0·· 'Solenoid
·HIGH·RC.1· 'Fan
·HIGH·RC.2· 'Alarm
·GOTO Start
Check:
·HIGH·RC.0· 'Solenoid
·LOW· RC.1· 'Fan
·LOW· RC.2· 'Alarm
·GOTO Start
'
' Device Settings
'
DEVICE········· SX28, OSCXT2, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Gas········ VAR·RB.6
Flow······· VAR·RB.5
Temp······· VAR·RB.4
Solenoid··· VAR·RC.0
Fan········ VAR·RC.1
Alarm······ VAR·RC.2
'
' Main
'
PROGRAM Start
Start:
IF·Gas = 1 AND Flow·= 0 AND Temp = 0 THEN Check
·LOW·RC.0·· 'Solenoid
·HIGH·RC.1· 'Fan
·HIGH·RC.2· 'Alarm
·GOTO Start
Check:
·HIGH·RC.0· 'Solenoid
·LOW· RC.1· 'Fan
·LOW· RC.2· 'Alarm
·GOTO Start
Comments
Start:
· LOW Solenoid
· LOW Fan
· LOW Alarm
Main:
· temp1 = RB & %01110000
· IF temp1 = 0 THEN
··· Solenoid = 1
··· Fan = 0
··· Alarm = 0
· ELSE
··· Solenoid = 0
··· Fan = 1
··· Alarm = 1
· ENDIF
· GOTO Main
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
tempBit = flow OR temp
tempBit = tempBit AND gas
if tempBit = 1 then...
else...
endif
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
engineer, fireman, bowler, father, WoW addict [noparse];)[/noparse]
'
' Program Description
'
'
' Device Settings
'
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'
' IO Pins
'
Gas VAR RC.1
Flow VAR RC.2
Temp VAR RC.3
Solenoid VAR RB.0
Fan VAR RB.1
Alarm VAR RB.2
tempbit VAR bit
temp2 VAR bit
temp1 VAR BYTE
'
' Main
'
Start:
LOW Solenoid
LOW Fan
LOW Alarm
Main:
tempbit = Flow OR Temp
if tempbit = 0 THEN
temp2 = tempbit OR Gas
else
end if
IF temp2 = 1 THEN
Solenoid = 0
Fan = 1
Alarm = 1
ELSE
Solenoid = 1
Fan = 0
Alarm = 0
ENDIF
GOTO Main
Your making it too hard on yourself. Try this:
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
Post Edited (Bean (Hitt Consulting)) : 12/5/2005 10:55:29 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
'
' Program Description
'
'
' Device Settings
'
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'
' IO Pins
'
Gas VAR RC.1
Flow VAR RC.2
Temp VAR RC.3
Solenoid VAR RB.0
Fan VAR RB.1
Alarm1 VAR RB.2
Alarm2 VAR RB.3
temp0 VAR Byte
temp3 VAR Byte
'
' Main
'
Start:
· LOW Solenoid
· LOW Fan
· LOW Alarm1
· LOW Alarm2
Main:
· temp0 = Flow + Temp
· temp0 = temp0 + ~Gas
·' temp0 can ONLY be 0 if Flow=0, Temp=0, and Gas=1 alarm dange level
· temp3 = Flow & Temp
· temp3 = temp3 &· Gas
·' temp1 can ONLY be 1 if Flow=1, Temp=1, and Gas=1 alarm dang level rising
·
·
· IF temp0 = 0 THEN
··· Solenoid = 0
··· Fan = 1
··· Alarm1 = 1
··· Alarm2 = 0
·IF temp3 = 1 THEN
···· Solenoid = 1
···· Fan = 0
···· Alarm1 = 0
···· Alarm2 = 1
··ENDIF
··· Solenoid = 1
··· Fan = 0
··· Alarm1 = 0
··· Alarm2 = 0
· ENDIF
·
· GOTO Main
Any Help is greatly appreciated.
Post Edited (DJFX) : 12/6/2005 9:29:50 PM GMT
· temp3 = RC & %00001110··· ' mask unused bits
· temp3 = temp3 >> 1······· ' remove unused zero-bit
· IF temp3 = %000 THEN
··· ' do something
· ENDIF
· IF temp3 = %001 THEN
··· ' do something else
· ENDIF
· IF temp3 = %010 THEN
··· ' do yet something else
· ENDIF
· ' more IF-THEN structures (like above) as required
It may seem a little verbose but I think it's cleaner and less error-prone that what you're currently attempting.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
You CANNOT use AND or OR with bit variables. That means "&" and "|" too.
You also have your IF...ENDIF boogered up.
Just add the bit together like this:
temp3 = Flow + Temp
temp3 = temp3 + Gas
' temp3 can ONLY be 3 if Flow=1, Temp=1, and Gas=1 alarm dang level rising
IF temp3 = 3 THEN
' whatever
ENDIF
Keep working on it, and keep posting. We'll steer you in the right direction.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
Those that would give up freedom for security will have neither.
·