November 23, 2024, 11:10:59 AM

News:

Got VSA?  Want to use your Prop-SX?  Now you can!  See the VSA section of the Library forum for Prop-SX code that works with VSA.


Need Of Help

Started by robbob, September 24, 2009, 08:30:46 PM

Previous topic - Next topic

robbob

I have this program i need some help.   The problem i only get one valve that will open and close.
' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL Sio                  =7
SYMBOL PIR                  =PIN6
SYMBOL Valve1             =PIN2
SYMBOL Valve2             =PIN1
SYMBOL Valve3             =PIN0
SYMBOL IsOn                = 1
SYMBOL IsOff                = 0
Symbol pirTimer            = B2
Reset:
PINS %00000000
DIRS %00000111
SEROUT Sio, OT2400, ("!!!!!!!RC4",0,"X","!AP8",0,"X")
PAUSE 20000
pirTimer = 0
MAIN:
PAUSE 10
pirTimer = pirTimer + 10* PIR
IF pirTimer  < 250 THEN Main
Valve1 = IsOn
PAUSE 3000
Valve3 = IsOn
SEROUT Sio, OT2400, ("!AP8",0,"P",0)
SEROUT Sio, OT2400, ("!RC4",O,"S",%0011)
PAUSE 3000
SEROUT Sio, OT2400, ("!RC4",0,"X")
Valve3 = IsOff
PAUSE 1000
Valve2 = IsOn
PAUSE 6000
Valve2 = IsOff
GOTO Reset


Please help?

livinlowe

try this:



' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL Sio                  =7
SYMBOL PIR                  =PIN6
SYMBOL Valve1             =PIN2
SYMBOL Valve2             =PIN1
SYMBOL Valve3             =PIN0

SYMBOL IsOn                = 1
SYMBOL IsOff                = 0
SYMBOL pirTimer            = B2

Reset:
DIRS = %00000111
SEROUT Sio, OT2400, ("!!!!!!!RC4",0,"X","!AP8",0,"X")
PAUSE 20000
pirTimer = 0

MAIN:
PAUSE 10
pirTimer = pirTimer + 10* PIR

IF pirTimer  < 250 THEN Main
Valve1 = IsOn
PAUSE 3000
Valve3 = IsOn
SEROUT Sio, OT2400, ("!AP8",0,"P",0)
SEROUT Sio, OT2400, ("!RC4",0,"S",%0011)
PAUSE 3000
SEROUT Sio, OT2400, ("!RC4",0,"X")
Valve3 = IsOff
PAUSE 1000
Valve2 = IsOn
PAUSE 6000
Valve2 = IsOff
GOTO Reset


Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

I found a couple syntax errors but after they were fixed the program seems to work as you intend.

FWIW... the Editor doesn't care if your formatting is messy, but it's hard on the eyes of humans when looking for possible bugs.  Here's my "pretty" version of your program.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


' -----[ Revision History ]------------------------------------------------


' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL Sio              = 7
SYMBOL PIR              = PIN6
SYMBOL Valve1           = PIN2
SYMBOL Valve2           = PIN1
SYMBOL Valve3           = PIN0


' -----[ Constants ]-------------------------------------------------------

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' B/R jumper removed


' -----[ Variables ]-------------------------------------------------------

SYMBOL  timer           = B2


' -----[ Initialization ]--------------------------------------------------

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000111                              ' set output pins

  SEROUT Sio, Baud, ("!RC4", %00, "X", "!AP8", %00,"X")
  PAUSE 20000


' -----[ Program Code ]----------------------------------------------------

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

  Valve1 = IsOn
  PAUSE 3000

  Valve3 = IsOn
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)
  SEROUT Sio, Baud, ("!RC4", %00, "S", %0011)
  PAUSE 3000

  SEROUT Sio, Baud, ("!RC4", %00, "X")
  Valve3 = IsOff
  PAUSE 1000

  Valve2 = IsOn
  PAUSE 6000

  GOTO Reset


' -----[ Subroutines ]-----------------------------------------------------


' -----[ User Data ]-------------------------------------------------------
Jon McPhalen
EFX-TEK Hollywood Office

robbob

Thanks for the program help, everything works great now. The problem was with the valves ,rust in the system shut down the valves.