November 22, 2024, 03:11:10 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Prop1 program

Started by Eddie, October 23, 2011, 10:40:04 PM

Previous topic - Next topic

Eddie

Hi All,
I would really appreciate it someone could look over the program below, and critique it.
Basically will it work or blow up.

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


' -----[ Program Description ]---------------------------------------------


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN

SYMBOL  Solenoid1        = PIN0                  ' V+/OUT0

SYMBOL  Solenoid2        = PIN1                  ' V+/OUT1

SYMBOL  Solenoid3        = PIN2                  ' V+/OUT2

SYMBOL  Solenoid4        = PIN3                  ' V+/OUT3

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

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

SYMBOL  AllOn           = %1111

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   Police         =  BIT0                 ' RC-4, K1
SYMBOL   Strobe1        =  BIT1                 ' RC-4, K2
SYMBOL   Strobe2        =  BIT2                 ' RC-4, K3
SYMBOL   Fogger         =  BIT3                 ' RC-4, K4


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

Power_Up:
  PAUSE 2000                                    ' let AP-16+ power up

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  relays = IsOff
  GOSUB Set_RC4


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

T_00:
  PAUSE 20000                                   ' let ambient.wav play


T_20:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "talking", 13, 0)
  relays = AllOn
  GOSUB Set_RC4
  Solenoid1 = IsOn
  PAUSE 1250
T_2125:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "talking", 13, 0)
  relays = AllOn
  GOSUB Set_RC4
  Solenoid2 = IsOn
  PAUSE 1250
T_2225:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "talking", 13, 0)
  relays = AllOn
  GOSUB Set_RC4
  Solenoid3 = IsOn
  PAUSE 1250
T_2325:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "talking", 13, 0)
  relays = AllOn
  GOSUB Set_RC4
  Solenoid4 = IsOn
  PAUSE 1250

T_25:
  Fogger = IsOff
  GOSUB Set_RC4
  PAUSE 4927


T_30:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "laugh", 13, 0)
  PAUSE 4940


T_35:
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 4927


T_40:
  SEROUT Sio, Baud, ("!AP16", %00, "X")                 ' back to ambient
  relays = IsOff
  GOSUB Set_RC4
  Solenoid1 = IsOff
  Solenoid2 = IsOff
  Solenoid3 = IsOff
  Solenoid4 = IsOff

  PAUSE  19944

  GOTO T_00


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

' -------------------------------------------------------------------------


' -----[ User Data ]-------------------------------------------------------

JackMan

October 24, 2011, 06:15:34 AM #1 Last Edit: October 24, 2011, 06:20:50 AM by JackMan
Well, this is too much code for the BS1, it won't fit into the eeprom. Good news is you have a lot of redundant code that can be removed. The first 3 lines of T_20: don't need to be repeated until something changes. Your "talking" file will loop until another command is sent. Ditto with the relays AllOn. Try this out.



'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------


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


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

SYMBOL  Sio              = 7                     ' SETUP = UP; no ULN
SYMBOL  Solenoid1        = PIN0                  ' V+/OUT0
SYMBOL  Solenoid2        = PIN1                  ' V+/OUT1
SYMBOL  Solenoid3        = PIN2                  ' V+/OUT2
SYMBOL  Solenoid4        = PIN3                  ' V+/OUT3

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

SYMBOL  IsOn            = 1                     ' for active-high in/out
SYMBOL  IsOff           = 0
SYMBOL  AllOn           = %1111
SYMBOL  Baud            = OT2400

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

SYMBOL  relays          = B0
SYMBOL   Police         =  BIT0                 ' RC-4, K1
SYMBOL   Strobe1        =  BIT1                 ' RC-4, K2
SYMBOL   Strobe2        =  BIT2                 ' RC-4, K3
SYMBOL   Fogger         =  BIT3                 ' RC-4, K4

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

Power_Up:
  PAUSE 2000                                    ' let AP-16+ power up

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

  relays = IsOff
  GOSUB Set_RC4


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

T_00:
  PAUSE 20000                                   ' let ambient.wav play

T_20:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "talking", 13, 0)
  relays = AllOn
  GOSUB Set_RC4
  Solenoid1 = IsOn
  PAUSE 1250

T_2125:
  Solenoid2 = IsOn
  PAUSE 1250

T_2225:
  Solenoid3 = IsOn
  PAUSE 1250

T_2325:
  Solenoid4 = IsOn
  PAUSE 1250

T_25:
  Fogger = IsOff
  GOSUB Set_RC4
  PAUSE 4927

T_30:
  SEROUT Sio, Baud, ("!AP16", %00, "PW", "laugh", 13, 0)
  PAUSE 4940

T_35:
  Fogger = IsOn
  GOSUB Set_RC4
  PAUSE 4927

T_40:
  SEROUT Sio, Baud, ("!AP16", %00, "X")                 ' back to ambient
  relays = IsOff
  GOSUB Set_RC4
  Solenoid1 = IsOff
  Solenoid2 = IsOff
  Solenoid3 = IsOff
  Solenoid4 = IsOff
  PAUSE  19944

  GOTO T_00


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

Eddie

Thank you very much JackMan, I will run it and follow up with results/

Eddie

Hi All,
The above program worked fine after I tweaked it a little.
I needed the Solenoids to shut off after the pause, by moving the respective Solenoid numbers after the pause all worked just fine.
Mucho Thanks to JackMan and his assistance.

Thank You