November 23, 2024, 10:33:17 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.


So I've perused all the coding for the typical Casa Fear Ground Breaker...

Started by nfmmalice, October 19, 2011, 04:03:40 PM

Previous topic - Next topic

bsnut

This basic program should get you started and if something is missing let me know. This program uses the RC-4 to control your flood light, a relay for your fog machine hack and a solenoid for the box.

' =========================================================================
'
'   File......Casa Fear Ground Breaker.bs1
'   Purpose...Control a Casa Fear Ground Breaker Prop
'   Author....
'   E-mail....
'   Started...Oct 20, 2011
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

'Upon Triggering, I hoped TO have the Prop 1 do these things, in this order:
'Turn on the Light.
'Blast Fog FOR 2 OR 3 Seconds.  (Was hoping TO hack the Fog Remote Switch
'into the RC-4 FOR this trigger)
'Play one of 3 Audio Tracks.
'Cycle the Solenoid "thrasher" routine.

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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  FogCtrl         = PIN1                  ' fog control relay
SYMBOL  Box             = PIN0                  ' to valve

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

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

SYMBOL  Baud            = OT2400
SYMBOL  Addr            = %00
SYMBOL  Addr1           = %11

SYMBOL  MinJump         = 100                   ' timing for lid/box jumps
SYMBOL  MaxJump         = 250
SYMBOL  BoxRun          = 10000                 ' box is 10s

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

SYMBOL  timer           = B2                    ' debounce timer
SYMBOL  etimer          = W4                    ' event timer
SYMBOL  delay           = W5                    ' run delay
SYMBOL  lottery         = W6                    ' random #

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

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

  SEROUT Sio, Baud, ("!RC4", Addr, "x")         'Turn off all RC4 Outputs

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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Check_Trigger             ' wait for 0.2 sec input

Show_Start:
  SEROUT Sio, Baud, ("!RC4", Addr, "r", 0, 1)   'turn on K1 on the RC-4
  FogCtrl = IsOn                                'turn on fogger control relay
  SEROUT Sio, Baud, ("!AP8", Addr1, "p", 0)     'play audio track "0"
  PAUSE 3000
  FogCtrl = IsOff

Thrash:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing
  Box = IsOn - Box                              ' toggle cylinder
  PAUSE delay                                   ' hold
  etimer = etimer + delay                       ' update run timer
  IF etimer < BoxRun THEN Thrash                ' if not done, go again
  Box = IsOff
  SEROUT Sio, Baud, ("!RC4", Addr, "x")         'Turn off all RC4 Outputs

  GOTO Main


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


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


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


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


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


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


' -----[ User Data ]-------------------------------------------------------
William Stefan
The Basic Stamp Nut

JackMan

QuoteAfter much thought on the subject, I have decided for the sake of ease in programming... I think I will just drop back to Unpleasant Street's Fog Switch Hack with the Relay on the Switch, triggered straight to the prop-1.

I've never seen the hack you mentioned but I have my fogger remote set up with a relay wired to the 2 leads that go to the manual button. The only drawback is that you have to make sure the fogger is warmed up and ready when the Prop-1 triggers the relay.

bsnut

I agree with this point.
QuoteThe only drawback is that you have to make sure the fogger is warmed up and ready when the Prop-1 triggers the relay.
If needed, I can add in a delay at the begining of the program in initialization section to allow for fogger warmup. This will prevent the Prop-1 from seeing any triggers when the fogger isn't ready.
William Stefan
The Basic Stamp Nut

nfmmalice


As far as whether or not the pause is necessary at the beginning, I guess my question would be:

What would happen if the routine is triggered and the fog machine is NOT ready?  If it's basically the same as pressing the button when the fog machine is not ready, and no fog comes out, then I guess it's no problem.  If it's actually going to cause DAMAGE to the Fog machine, then I guess either adding in the Pause, or having whoever is controlling the prop pay attention to it.  LoL.

So far the Routine looks great...  Except that there are two solenoids to control.

I was looking to basically copy the Casa Fear "Thrasher" routine that has been done a few times here already (With Randomized Lottery style controls for each shoulder) but adding in the Light and the AP-8 controls instead of the VMusic modules others were using.

nfmmalice



I guess I'm looking to incorporate this routine instead of the single solenoid routine?

===========================================
Jump:
  PINS = %00000011                              ' both shoulders on
  PAUSE 1000

Thrasher:
  FOR idx = 1 TO 3                              ' big stir
    RANDOM lottery
  NEXT
  valves = lottery & %00000011

  IF valves = last THEN Thrasher                ' no repeats
    last = valves                               ' save for next cycle

  PINS = valves                                 ' update should outputs
  RANDOM lottery                                ' restir
  delay = lottery // 251 + 100                  ' delay 100 to 350 ms
  PAUSE delay
  timer = timer + delay                         ' update timer
  IF timer < ThrashTime THEN Thrasher                ' thrash for 10 seconds
    GOTO Reset
============================================================


nfmmalice


Here is a very rudimentary idea of what it is supposed to look like:



I'm sorry if I wasn't clear enough when I first tried to explain it. 

JackMan

QuoteWhat would happen if the routine is triggered and the fog machine is NOT ready?

Nothing at all, it won't hurt anything, you just won't get any fog. Adding a PAUSE to the Initialization section of the code will give the fogger time to warm up but most foggers go into a temporary "not ready mode" when inactive for too long, so there is a chance that the prop could be triggered during one of the "not ready" cycles.

QuoteI was looking to basically copy the Casa Fear "Thrasher" routine that has been done a few times here already (With Randomized Lottery style controls for each shoulder) but adding in the Light and the AP-8 controls instead of the VMusic modules others were using

Yep, that's all you need to do.

bsnut

Your picture helped a lot and I fixed the program for based that drawing. I also tested this program and works.

' =====================================================================
'
'   File......Casa Fear Ground Breaker.bs1
'   Purpose...Control a Casa Fear Ground Breaker Prop
'   Author....
'   E-mail....
'   Started...Oct 20, 2011
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}

=====================================================================


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

'Upon Triggering, I hoped TO have the Prop 1 do these things, in this order:
'Turn on the Light.
'Blast Fog FOR 2 OR 3 Seconds.  (Was hoping TO hack the Fog Remote Switch
'into the RC-4 FOR this trigger)
'Play one of 3 Audio Tracks.
'Cycle the Solenoid "thrasher" routine.

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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN

SYMBOL  Valve2          = PIN2                  ' to arm valve
SYMBOL  Valve1          = PIN1                  ' to arm valve
SYMBOL  FogCtrl         = PIN0                  ' fog control relay

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

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

SYMBOL  Baud            = OT2400
SYMBOL  Addr            = %00
SYMBOL  Addr1           = %11

SYMBOL  MinJump         = 100                   ' timing for lid/box jumps
SYMBOL  MaxJump         = 250
SYMBOL  ThrashTime      = 10000                 ' box is 10s


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

SYMBOL  jump            = B2                    ' for cylinders
SYMBOL  valves          = B3
SYMBOL  last            = B4
SYMBOL  timer           = W4                    ' event timer
SYMBOL  delay           = W5                    ' run delay
SYMBOL  lottery         = W6                    ' random #

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

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

  SEROUT Sio, Baud, ("!RC4", Addr, "x")         'Turn off all RC4 Outputs

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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 200 THEN Check_Trigger             ' wait for 0.2 sec input

Show_Start:
  SEROUT Sio, Baud, ("!RC4", Addr, "r", 0, 1)   'turn on K1 on the RC-4
  FogCtrl = IsOn                                'turn on fogger control relay
  SEROUT Sio, Baud, ("!AP8", Addr1, "p", 0)     'play audio track "0"
  PAUSE 3000
  FogCtrl = IsOff

  timer = 0

Thrash:
  RANDOM lottery                                ' re-stir
  delay = MaxJump - MinJump + 1                 ' get span
  delay = lottery // delay + MinJump            ' calc jump timing

  jump = lottery & %00000110                    ' new cylinder ouputs
  PINS = PINS &/ %00000110 | jump               ' update cylinders

  PAUSE delay                                   ' hold
  timer = timer + delay                         ' update run timer
  IF timer < ThrashTime THEN Thrash               ' if not done, go again
  GOTO Reset

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



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


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



' -----[ User Data ]-------------------------------------------------------
William Stefan
The Basic Stamp Nut

nfmmalice



Awesome!

Thank you very much.  Hopefully I'll be able to drop it in my Prop 1 Tonight or tomorrow and double check it.  =)

nfmmalice

Well...

It seems that it has been a LOT longer than I thought since I have programmed a Prop1...

NOTHING I have has a Serial Port.

LoL.

It's gonna be a hair longer until I can test this.

nfmmalice


Okay.. Finally yanked out an OLD laptop with a Serial port and got the Prop1 Programmed.

Now I have a couple of questions about the program.

I note that the Cylinders are located on PIN1 and PIN2 and the Fog Trigger on PIN0.

On the two other props I have, the Solenoids are triggered on the OUTs, Not the PINs.

If I am Running 24vdc Solenoids, can I power them through the prop1 (using a 24vdc adapter) on the PINs or the OUTs?

I'm a bit confused.

JackMan

It's just the program I/O definitions that list them as PINs, your wiring connections go to V+ and OUTx, (PIN0 = OUT0 etc.)
You can power the Prop-1 with 24v with the switch in position 2 and it will control your 24 solenoids.

nfmmalice

Awesome.

So Just replace PINx with OUTx, and I'm good to go?

And run the Prop1 on Switch 2.

Will work on that when I get home from work tomorrow.

JackMan

QuoteSo Just replace PINx with OUTx, and I'm good to go?

Don't change the wording of the program, just use OUTx for your connections.


nfmmalice

Just one more clarification...

If I run it on position 2....  To power the 24vdc solenoids...  Will that affect the fog trigger?