May 18, 2024, 09:32:01 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Toxic barrel Program-can you check it

Started by dacostasr, September 08, 2007, 04:07:22 PM

Previous topic - Next topic

dacostasr

Jon,

This is what I came up with for my toxic barrel...it seems to work with all my test LED attached...I'm learning as I go.  I printed the manual and help files; this is my first one, be gentle...lol

I scavanged some of the code from other projects, the help files, and from the code you sent me.

If this one is good I can start on the other one I just received for my body slinger. 

Both are using pneumatic cylinders.

This is what is supposed to happen (and seems to happen):

1.  Blue room light is on
2.  motion detector is set off
3.  Blue room light goes off
4.  Pause (in darkness for effect)
5.  Rotating Beacon comes on
6.  Pause (for effect again)
7.  Toxic Guy comes up (garden valve used 24v)
8.  Pause to allow for full extension
9.  SPITS (garden valve used 24v)
10. Pause for full siphon from spit tank
11. Quit SPIT
12. Head still up
13. Quit Head
14. Pause to exit room
15. Rotating Beacon off
16. Blue Light ON
17. Pause (Long, so prop can't trigger again while we leave)

and there it is.

Thanks in advance.

Dennis


' {$STAMP BS1}
SYMBOL  Sio             = 7
SYMBOL pir              = PIN6                     ' I/O Pin For PIR Sensor


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

SYMBOL  Baud            = OT2400
SYMBOL  Addr            = %00                          ' %00 - %11

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL No = 0
SYMBOL  id0             = B0                           ' version string
SYMBOL  id1             = B1
SYMBOL  id2             = B2
                                    '
SYMBOL Head = 0                                       ' head is connected to P0
SYMBOL Spitter = 1
' -----[ Variables ]-------------------------------------------------------

                                   ' spiter is connected to P1

Main:

SEROUT Sio, OT2400, ("!RC4", %00, "R", 1,1)           ' BLUE LIGHT on

IF PIR = No THEN Main                                 ' wait for "victim"

SEROUT Sio, Baud, ("!RC4", Addr, "V")                 ' get version

SERIN  Sio, Baud, id0, id1, id2
                                                      ' RC-4 OFF
SEROUT Sio, OT2400, ("!RC4", %00, "X",1,0)            ' BLUE LIGHT off

PAUSE 3000

SEROUT Sio, OT2400, ("!RC4", %00, "R", 2,1)            ' BEACON on

PAUSE 3000

HIGH Head                                             ' turn Head on

PAUSE 1500                                            ' hold for 1.5 seconds

HIGH Spitter                                          ' turn spitter on

PAUSE 2500                                            ' hold for 2.5 seconds

LOW Spitter                                           ' turn spiiter off

PAUSE 2000                                            '

LOW Head                                              ' turn Head off

PAUSE 4000                                            ' Pause to get out of room

SEROUT Sio, OT2400, ("!RC4", %00, "X", 2,0)           ' BEACON off

SEROUT Sio, OT2400, ("!RC4", %00, "X", 2,0)

SEROUT Sio, Baud, ("!RC4", Addr, "X")                 ' all off

PAUSE 3000

SEROUT Sio, OT2400, ("!RC4", %00, "R", 1,1)           ' BLUE LIGHT on

PAUSE 30000                                           ' Quiet time 30 seconds

GOTO MAIN


JonnyMac

September 08, 2007, 05:59:01 PM #1 Last Edit: September 08, 2007, 06:03:47 PM by JonnyMac
Good job, Dennis.  Let me show you some advanced code tricks that make the program easier to read and save code space.  Also, note how I use just one SEROUT in the program -- this saves a lot of space (this prop doesn't need it, but others will; learn to be stingy with code space).

You'll see that I moved the 30-second delay to the reset section; this allows the PIR to warm-up when you first turn on the prop.


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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Spitter         = PIN1
SYMBOL  Head            = PIN0


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

SYMBOL  IsOn            = 1
SYMBOL  IsOff           = 0

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  AllOff          = %00000000


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

SYMBOL  relays          = B0
SYMBOL   BlueLight      = BIT0
SYMBOL   Beacon         = BIT1
SYMBOL   UnusedK3       = BIT2
SYMBOL   UnusedK4       = BIT3

SYMBOL  timer           = B2                    ' for PIR debouncing


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

Reset:
  PINS = AllOff
  DIRS = %00000011                              ' head and spitter are outs

  relays = AllOff
  BlueLight = IsOn
  GOSUB Update_RC4

  PAUSE 30000                                   ' quiet time
  timer = 0                                     ' clear PIR timer


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' update timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  BlueLight = IsOff
  GOSUB Update_RC4
  PAUSE 3000

  Beacon = IsOn
  GOSUB Update_RC4
  PAUSE 3000

  Head = IsUp
  PAUSE 1500

  Spitter = IsOn
  PAUSE 2500

  Spitter = IsOff
  PAUSE 2000

  Head = IsDown
  PAUSE 4000

  relays = AllOff
  GOSUB Update_RC4
  PAUSE 3000

  GOTO Reset


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

Update_RC4:
  SEROUT Sio, OT2400, ("!RC4", %00, "S", relays)
  RETURN


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

dacostasr

September 09, 2007, 09:08:41 AM #2 Last Edit: September 09, 2007, 11:47:54 AM by dacostasr
Jon,

THANKS!  One prop done....moving on to my other one now.  I wish I would have tried these 2 years ago.  My plan will be to design my props using the Prop 1...

Although I'm still learning,  these are quite easier ( with your help) than I thought they would be.

THANKS again.  ;D

Dennis