November 21, 2024, 12:01:43 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.


Prop 1 first program

Started by gjnorth, August 08, 2015, 09:31:47 AM

Previous topic - Next topic

gjnorth

Good morning, I am new here to the forum and I am pursuing my first attempt at a program for the Prop 1.
I have attached the program below with a description of the prop it will be operating. I have not installed the
program yet and due to the fact that this is my first attempt I was hoping to have a few of you look it over and
tell me if it looks functional and if so could it be improved.
Thanks in advance for your input.

The Prop: This is a Halloween prop in the form of a electrical breaker box (electrical panel). The panel has a door on the front of it which will be operated by a 12 v solenoid and a pneumatic cylinder. When the prop is triggered via a PIR the door will open and close twice with a short pause between each motion. The door will then open and at the same time 2 flash crackers that are mounted in the breaker box will simultaneously turn on as well as a fog machine and a strobe light. Everything will stay active for 4 seconds then the flash crackers and the fog machine will turn off and the door will shut. At this point after a two second pause an air cannon will fire a momentary blast, the strobe light will turn off and there will be a short delay before the prop can be re-triggered. I will be running two SSR-2 relays which will operate the 2 flash crackers as well as the fog machine blast and the strobe light. The air cannon is operated by a 12 v solenoid and a pneumatic valve.

The Program:
' =========================================================================
'
' File....... Prop-1_Electrical_Box.BS1
' Purpose.... Haunted House Prop
' Author..... Gary North
' E-mail..... gjnorth@gmail.com
' Started.... July 16 2015
' Updated....
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ I/O Definitions ]-------------------------------------------------

SYMBOL   Box           = PIN 0          ' Box Open
SYMBOL   FlashCracker1 = Pin 1          ' Flash Cracker1 Active
SYMBOL   FlashCracker2 = Pin 2          ' Flash Cracker2 Active
SYMBOL   FogMachine    = Pin 3          ' Fog Machine Active
SYMBOL   AirCannon     = Pin 4          ' Air Cannon Blast
SYMBOL   Strobe        = Pin 5          ' Strobe Light Active
SYMBOL   PIR           = Pin 6          ' Movement Detected
'        Unused          Pin 7          ' Unused
'
' -----[ Constants ]-------------------------------------------------------

SYMBOL No = 0
SYMBOL Yes = 1

' -----[ Variables ]-------------------------------------------------------
SYMBOL PIRWAIT    = W1
SYMBOL reps       = W2
' -----[ Initialization ]--------------------------------------------------
Reset:

'        76543210    ' bit positions
DIRS = %00111111    ' make P0 - P5 outputs, P7-P6 inputs
PINS = %00000000    ' all outputs off

' -----[ Program Code ]----------------------------------------------------
Main:

SStartAgain:
PIRWAIT = 0
SLookAgain:
IF PIR = No THEN SStartAgain
PIR = PIR + 1
IF PIR < 50 THEN SLookAgain
                                            ' start the show!
FOR reps = 1 TO 2             ' open and close the box twice
Box = Yes
PAUSE 500
Box = No
PAUSE 500
NEXT
Box = yes                            ' open box
PAUSE 500
FlashCracker1 = Yes           ' turn on flash crackers 1 and 2
FlashCracker2 = Yes
FogMachine = Yes              ' turn on fog machine
Strobe = Yes                  ' turn on strobe light
PAUSE 4000                    ' let everything run for 4 seconds
FlashCracker1 = No            ' turn flash crackers and fog machine off
FlashCracker2 = No
FogMachine = No
Box = No                      ' close box
PAUSE 2000
AirCannon = Yes               ' send a blast from the air cannon
PAUSE 100
AirCannon = No
Strobe = No                   ' turn off the strobe
PAUSE 1000
FStartAgain:
PIRWAIT = 0                   ' delay prior to re-trigger
FLookAgain:
IF PIR = Yes THEN FStartAgain
PIR = PIR + 1
IF PIR <500 THEN FLookAgain
GOTO Main


JonnyMac

August 08, 2015, 02:23:19 PM #1 Last Edit: August 08, 2015, 02:26:00 PM by JonnyMac
Nice first attempt.

I have taken the liberty to reformat your program.

Notes:
-- you can check your program by doing a test compile (use the Syntax Check button)
-- defining constants can make programs easier to follow and self-commenting; notice how I've added IS_ON, IS_OFF, IS_OPEN, and IS_CLOSED
-- don't be afraid to use white space to make listings easier on the eyes (I like to add blank lines after PAUSE as it's a natural break in the program
-- I used our standard PIR code

Have fun!

' =========================================================================
'
'   File....... Prop-1_Electrical_Box.BS1
'   Purpose.... Haunted House Prop
'   Author..... Gary North
'   E-mail..... gjnorth@gmail.com
'   Started.... July 16 2015
'   Updated....
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  UnusedP7        = 7                     ' not used
SYMBOL  PIR             = PIN6                  ' Movement Detected
SYMBOL  Strobe          = PIN5                  ' Strobe Light Active
SYMBOL  AirCannon       = PIN4                  ' Air Cannon Blast
SYMBOL  FogMachine      = PIN3                  ' Fog Machine Active
SYMBOL  FlashCracker2   = PIN2                  ' Flash Cracker2 Active
SYMBOL  FlashCracker1   = PIN1                  ' Flash Cracker1 Active
SYMBOL  Box             = PIN0                  ' Box Open


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPEN         = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1


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

SYMBOL  timer           = B2
SYMBOL  reps            = B3


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

Reset:
'         76543210
  DIRS = %00111111                              ' P7-P6 ins, P5-P0 outs
  PINS = %00000000                              ' all outputs off

  PAUSE 30000                                   ' pir warm-up / re-trigger

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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF PIR = No THEN Main                         ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  FOR reps = 1 TO 2
    Box = IS_OPEN
    PAUSE 500
    Box = IS_CLOSED
    PAUSE 500
  NEXT

  Box = IS_OPEN
  PAUSE 500

  FlashCracker1 = IS_ON
  FlashCracker2 = IS_ON
  FogMachine = IS_ON
  Strobe = IS_ON
  PAUSE 4000

  FlashCracker1 = IS_OFF
  FlashCracker2 = IS_OFF
  FogMachine = IS_OFF
  Box = IS_CLOSED
  PAUSE 2000

  AirCannon = IS_ON
  PAUSE 100

  AirCannon = IS_OFF
  Strobe = IS_OFF
  PAUSE 1000

  GOTO Reset
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Once you get the basic code working let us know; then we'll show you how to add random behavior to it.
Jon McPhalen
EFX-TEK Hollywood Office

gjnorth

I finally got around to putting this prop together and tried it out for the  first time today. For the  first run I had the solenoid for the air piston wired up as well as the fog machine and the two flash crackers. I did not attach the strobe or air cannon as of yet. The first run worked perfectly and I set it off several times and adjusted the position of the PIR. I then shut everything down. I re-powered it tonight and cycled it and now the program seemed to be messed up, the door would open and close however it would not stay open the assigned 2.5 seconds. In addition to this the flash crackers only sputtered and the fog machine did not fire at all. I turned everything off and re-powered however I ended up with the same result. I ended up re-installing the program on the prop 1 and this time disconnected V+ wire and 0 wire from the block so the solenoid (for the air piston) would not fire. Now when I triggered the device the flash crackers and fog machine seemed to be working fine and staying on an appropriate amount of time. So I re-connected V+ and the wire to 0 on the block (for the air cylinder solenoid) and triggered the prop again. This time it was back to not working exactly as it was before.
It seems as though connecting the solenoid seems to screw up the SSR-2 function for the 110 V devices????
However it is weird that it worked perfectly the first time I powered it up.

Any thoughts and or advice from the forum would be greatly appreciated.
Thanks in advance
Gary

gjnorth

This is the current version of the program as I am running it on the Prop-1...

' =========================================================================
'
'   File....... Prop-1_Electrical_Box.BS1
'   Purpose.... Haunted House Prop
'   Author..... Cameron North/Gary North
'   E-mail..... gjnorth@gmail.com
'   Started.... July 16 2015
'   Updated.... January 26 2016
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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

SYMBOL  UnusedP7        = 7                     ' not used
SYMBOL  PIR             = PIN6                  ' Movement Detected
SYMBOL  AirCannon       = PIN5                  ' Air Cannon Blast
SYMBOL  Strobe          = PIN4                  ' Strobe Light Active
SYMBOL  FogMachine      = PIN3                  ' Fog Machine Active
SYMBOL  FlashCracker2   = PIN2                  ' Flash Cracker2 Active
SYMBOL  FlashCracker1   = PIN1                  ' Flash Cracker1 Active
SYMBOL  Box             = PIN0                  ' Box Open


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

SYMBOL  NO              = 0
SYMBOL  YES             = 1

SYMBOL  IS_CLOSED       = 0
SYMBOL  IS_OPEN         = 1

SYMBOL  IS_OFF          = 0
SYMBOL  IS_ON           = 1


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

SYMBOL  timer           = B2
SYMBOL  reps            = B3


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

Reset:
'         76543210
  DIRS = %00111111                              ' P7-P6 ins, P5-P0 outs
  PINS = %00000000                              ' all outputs off

  PAUSE 30000                                   ' pir warm-up / re-trigger

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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  PAUSE 5                                       ' scan delay
  IF PIR = No THEN Main                         ' check trigger input
    timer = timer + 5                           ' update timer
  IF timer < 100 THEN Check_Trigger             ' check timer

  FOR reps = 1 TO 2
    Box = IS_OPEN
    PAUSE 500
    Box = IS_CLOSED
    PAUSE 500
  NEXT

  Box = IS_OPEN
  PAUSE 500

  FlashCracker1 = IS_ON
  FlashCracker2 = IS_ON
  FogMachine = IS_ON
  Strobe = IS_ON
  PAUSE 2000

  AirCannon = IS_ON
  PAUSE 200
  AirCannon = IS_OFF
  PAUSE 1000

  FlashCracker1 = IS_OFF
  FlashCracker2 = IS_OFF
  FogMachine = IS_OFF
  Box = IS_CLOSED
  PAUSE 2000

  Strobe = IS_OFF
  PAUSE 1000

  GOTO Reset

livinlowe

How do you have everything powered?
Shawn
Scaring someone with a prop you built -- priceless!

gjnorth

The solenoid is powered from the prop-1 board. The fog machine and the 2 flash crackers are plugged into 110 V and are triggered by the SSR-2 Amigo boards.

JonnyMac

What is the load rating of the solenoid?
Jon McPhalen
EFX-TEK Hollywood Office

gjnorth

Printed on the solenoid is  DC12V   4.8W
so the load would be 0.4 A.

JackMan

That's your problem. That solenoid is drawing close to the limit the ULN can handle. The very first part of your program works because it's just operating the solenoid, when the program progresses, more devices are on simultaneously and the ULN can't handle the load. Try using a small relay for the solenoid instead of connecting it directly to the Prop-1.

gjnorth

JackMan, thanks for your response! When you say run a small relay are you referring to connecting the solenoid through one of the SSR-2 slots?
The other question I had is could I power the solenoid with a 12 v wall wort and then run it through the Prop 1 on the main block?
Sorry for the basic nature of my questions....I am fairly new at this.
Thanks
Gary

JackMan

January 31, 2016, 08:49:15 AM #11 Last Edit: January 31, 2016, 04:13:32 PM by JackMan
If you have an unused relay on your Amigo boards, yes, use that. (not the SSR-2, those are for AC loads only) You can't use a wall wart as you described.

gjnorth

So other possible options would be to run a 12 V transformer and purchase a RC-2 relay board to switch it?
Or use a solenoid with less amp draw?

JackMan

Quote from: gjnorth on January 31, 2016, 09:15:34 AM
So other possible options would be to run a 12 V transformer and purchase a RC-2 relay board to switch it?
Or use a solenoid with less amp draw?

You don't necessarily need a separate 12V transformer or power supply, you just need to route the power to that solenoid thru a relay so the load is removed from the ULN on the Prop-1. A small relay such as these will work or an RC-2.
http://www.ebay.com/itm/10pcs-SRD-12VDC-SL-C-12V-DC-SONGLE-Power-Relay-PCB-Type-SPDT-High-Quality-5-Pins-/201512422945?hash=item2eeb138e21:g:XqAAAOSwwE5WZ8Ts

livinlowe

January 31, 2016, 09:46:34 AM #14 Last Edit: January 31, 2016, 10:20:12 AM by livinlowe
Quote from: JackMan on January 31, 2016, 09:33:11 AM
Quote from: gjnorth on January 31, 2016, 09:15:34 AM
So other possible options would be to run a 12 V transformer and purchase a RC-2 relay board to switch it?
Or use a solenoid with less amp draw?

You don't necessarily need a separate 12V transformer or power supply, you just need to route the power to that solenoid thru a relay so the load is removed from the ULN on the Prop-1. A small relay such as these will work or an RC-2.
http://www.ebay.com/itm/10pcs-SRD-12VDC-SL-C-12V-DC-SONGLE-Power-Relay-PCB-Type-SPDT-High-Quality-5-Pins-/201512422945?hash=item2eeb138e21:g:XqAAAOSwwE5WZ8Ts

I can't remember where I got them (I'm thinking allelectronics.com), but I got some 12V automotive relays for pretty dang cheap which would work as well.
Shawn
Scaring someone with a prop you built -- priceless!