November 17, 2024, 04:51:26 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.


This is my first attempt at programing a Trashcan Trauma

Started by Shotzie, June 19, 2008, 10:03:35 PM

Previous topic - Next topic

Shotzie

Hey Jon,

I was wondering if you could answersome questions I have please.  First here is my code.  Could you check it over and let me know if there are anychanges to be made?

' =========================================================================
'
'   File....... 02 - Triggered Prop.BS1
'   Purpose.... Activate prop on trigger input
'   Author..... EFX-TEK, (c) 2006 - All Rights Reserved
'   E-mail..... teamefx@efx-tek.com
'   Started....
'   Updated.... 01 JUN 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


SYMBOL  MatSw       = PIN6
SYMBOL  Light       = 0
SYMBOL  Valve       = 1
SYMBOL  Fog         = 2
SYMBOL  Strobe      = 3
SYMBOL  Voice       = 4
SYMBOL  SmallLight  = 5

SYMBOL  No          = 0

Main:
  HIGH Light                                    ' light on
  IF MatSw = No THEN Main                       ' wait for "victim"
  HIGH Fog                                      ' fogger on for 3 sec
  PAUSE 3000                                    ' 3 second pre-delay
  LOW Light                                     ' light off at prop activation
  HIGH SmallLight                               ' pumpkin light on
  HIGH Valve                                    ' lift prop
  HIGH Voice                                    ' speakers on - scream
  HIGH Strobe                                   ' strobe on
  LOW Fog                                       ' fogger off
  PAUSE 5000                                    ' hold for 5 seconds
  LOW Valve                                     ' retract prop
  LOW Voice                                     ' speakers off
  LOW SmallLight                                ' pumpkin light off
  LOW Strobe                                    ' strobe off
  HIGH Light                                    ' light on
  PAUSE 30000                                   ' 20 second post-delay
  GOTO Main                                     ' back to Main

What it should do (and it does per the trainer) a scene light is constantly on until the mat is triggered.  The fogger starts to fog for 3 secs.  Fogger stops, Light goes out, cylinder fires, strobe comes on, light in pumpkin turns on.  5 secs later everything stops and scene light comes back on.

Is there a special setting in order for the scene light to stay on until triggered?
I assume my mat switch goes into P6 but which pins and how should it be configured?


Thanks for an awsome product!

Paul

JonnyMac

I'm a tad confused... the lights are correct on the trainer, but doesn't work in the real world?  What are the connections to the outside world?
Jon McPhalen
EFX-TEK Hollywood Office

Shotzie

I was just mainly wanting to be sure there wasn't a better way to work it before I connect it physically.  I am connecting everything through the OUTX connectors to relays.  I figured out that the relays have NO and NC connections.  I changed the program to open the connection for the lights when activated.  I am connecting the scene lights to the NC of the relay so the Prop-1 isn't always with power running through it.  I have gotten past most of my uneasiness with the programming but I am still leery with the actual connections.  I also need to know which two pins to connect my mat switch to.

I was also wondering what the benefit of the GOSUB Timer over just a pause command?

Thanks!

JonnyMac

There's nothing wrong with your program.  You might consider debouncing the mat switch input to prevent false triggering -- this can happen in electrically-noisy environments; the Prop-1 is considered fairly slow as controllers go, but it's still fast enough to catch an electrical glitch (caused by an outside source) when doing simple scanning as you're doing.

Connect your mat switch between P6.W and P6.R.  Make sure that the P6 SETUP jumper is in the DN position.
Jon McPhalen
EFX-TEK Hollywood Office

Shotzie


JonnyMac

Here you go.  Debouncing is checking an input multiple times during a given period to make sure that it has stabilized.  Note, too, that I use a slightly different code style that makes much of the listing self-commenting.

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


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


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


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

SYMBOL  MatSw       = PIN6                      ' SETUP = DN
SYMBOL  SmallLight  = PIN5
SYMBOL  Voice       = PIN4
SYMBOL  Strobe      = PIN3
SYMBOL  Fog         = PIN2
SYMBOL  Valve       = PIN1
SYMBOL  Light       = PIN0


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

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


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

SYMBOL  timer           = B2


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

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


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

Main:
  timer = 0                                     ' reset timer

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

  Fog = IsOn                                    ' fogger on for 3 sec
  PAUSE 3000

  Fog = IsOff
  Light = IsOff                                 ' light off at prop activation
  SmallLight = IsOn                             ' pumpkin light on
  Valve = IsOn                                  ' lift prop
  Voice = IsOn                                  ' speakers on - scream
  Strobe = IsOn
  PAUSE 5000                                    ' hold for 5 seconds

  Valve = IsOff                                 ' retract prop
  Voice = IsOff
  SmallLight = IsOff
  Strobe = IsOff
  Light = IsOn
  PAUSE 30000                                   ' 30 second post-delay

  GOTO Main                                     ' back to Main


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


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


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


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


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


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


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

Jon McPhalen
EFX-TEK Hollywood Office

Shotzie

Alright, thank you very much.  Making the outputs P0-P5 will the OUT0-OUT5 still work?

One last thing please.  What is the benefit of the timer subroutine over a PAUSE command?

JonnyMac

The OUTx pins are connected directly to the I/O, so when P0-P7 are made high, the corresponding OUTx pin is active (pulled to ground).

I have used a timer subroutine in the past to increase the length of delays at the sacrifice of resolution -- small price to pay as we usually don't need 1 millisecond resolution with basic prop control.
Jon McPhalen
EFX-TEK Hollywood Office

Shotzie