November 23, 2024, 10:51:53 PM

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.


thrashing zombie

Started by matwel, October 03, 2011, 04:56:28 PM

Previous topic - Next topic

matwel

THis progarm works good for me but i am trying to add one more cyclinder to make the zombie to come out of the wall.  not sure how to make cyclinder 6 pop out  start thrashing,  then when done retracts.
'   
Purpose... Program a Prop-1, AP-8, PIR, 5 Solenoid banger 1 w/Air Canon
'   Author.... Jason Thompson (updated by "the JonnyMac)
'   E-mail.... thehauntstore@gmail.com
'   Started... 19/25/2010
'   Updated... 26 SEP 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, AP-8, Etc.)
'            -- clip pin 1 (P7 area) 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             = PIN7          ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6          ' SETUP = DN
SYMBOL  Valve5          = PIN4          ' soleniod valve 5; Claws
SYMBOL  Valve4          = PIN3          ' soleniod valve 4; Top Right + Cannon
SYMBOL  Valve3          = PIN2          ' soleniod valve 3; Center Top
SYMBOL  Valve2          = PIN1          ' soleniod valve 2; Bottom Left
SYMBOL  Valve1          = PIN0          ' soleniod valve 1; Top Left

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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400        ' B/R jumper removed


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

SYMBOL  idx             = B2

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

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

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

  PAUSE 30000                                  ' PIR warm-up/reset, 30s


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

Main:
  timer = 0                                     ' reset timer

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


  timer = lottery // 3001 + 7000                ' 7 to 10 seconds

Solenoid_Banger:
  RANDOM lottery                                ' re-stir
  PINS = lottery & %00111111                    ' randomize 5, 3, 2, & 1
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 100 to 250ms
  IF delay > timer THEN Quiet                   ' exit if timer expeired
    PAUSE delay
    timer = timer - delay
    GOTO Solenoid_Banger

Quiet:
  PINS = IsOff
  PAUSE 10000

Cannon_Fire:
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' play segment 0
  Valve1 = IsOn                                 ' activate cannon
  PAUSE 303pwa000
  Valve1 = IsOff
  PAUSE 250                                     ' short "off"
  Valve4 = IsOn
  PAUSE 1000
  Valve4 = IsOff


  PAUSE 60000                                   ' create 60s show delay (30+30)
  GOTO Reset


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


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


' -----[ EEPROM Data ]-------------


' -----[ EEPROM Data ]-------------}

bsnut

Jason,

Can you tell me what cyclinder 6 does? Is, it part of the randomizing of these cyclinders 5, 3, 2, & 1 that is currently in your program? When does the zombie to come out of the wall? Details like help us understand what you want to do.
William Stefan
The Basic Stamp Nut

matwel

When  it is triggered cyclinder 6 would be activated  and then shuts off when random is done.   not sure how to add it in the program.   it is currently not in it.

JonnyMac

Here's how I would do it.

' =========================================================================
'
'   Purpose... Program a Prop-1, AP-8, PIR, 5 Solenoid banger 1 w/Air Canon
'   Author.... Jason Thompson (updated by "the JonnyMac)
'   E-mail.... thehauntstore@gmail.com
'   Started... 19/25/2010
'   Updated... 03 OCT 2010
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, AP-8, Etc.)
'            -- clip pin 1 (P7 area) 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             ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6          ' SETUP = DN
SYMBOL  Valve6          = PIN5          ' solenoid valve 6; Pop out
SYMBOL  Valve5          = PIN4          ' soleniod valve 5; Claws
SYMBOL  Valve4          = PIN3          ' soleniod valve 4; Top Right + Cannon
SYMBOL  Valve3          = PIN2          ' soleniod valve 3; Center Top
SYMBOL  Valve2          = PIN1          ' soleniod valve 2; Bottom Left
SYMBOL  Valve1          = PIN0          ' soleniod valve 1; Top Left

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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400        ' B/R jumper removed


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

SYMBOL  idx             = B2

SYMBOL  delay           = W3
SYMBOL  timer           = W4
SYMBOL  lottery         = W5


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

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

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

  PAUSE 30000                                  ' PIR warm-up/reset, 30s


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

Main:
  timer = 0                                     ' reset timer

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

  Valve6 = IsOn                                 ' extend
  PAUSE 1000                                    ' adjust for extension

  timer = lottery // 3001 + 7000                ' 7 to 10 seconds

Solenoid_Banger:
  RANDOM lottery                                ' re-stir
  PINS = lottery & %00111111 | %00100000        ' randomize 5, 3, 2, & 1; 6 on
  RANDOM lottery
  delay = lottery // 151 + 100                  ' 100 to 250ms
  IF delay > timer THEN Quiet                   ' exit if timer expeired
    PAUSE delay
    timer = timer - delay
    GOTO Solenoid_Banger

Quiet:
  PINS = IsOff
  PAUSE 10000

Cannon_Fire:
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' play segment 0
  Valve1 = IsOn                                 ' activate cannon
  PAUSE 1000
  Valve1 = IsOff
  PAUSE 250                                     ' short "off"
  Valve4 = IsOn
  PAUSE 1000
  Valve4 = IsOff

  PAUSE 30000                                   ' create 60s show delay (30+30)
  GOTO Reset


BTW... you had some "glitches" in your post so you may need to check timing in he cannon section.
Jon McPhalen
EFX-TEK Hollywood Office