November 23, 2024, 07:50:11 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.


Help Prop-1, AP-8, PIR, 5 Solenoid Banger - BS1 Prog Randomizer of 5 Solenoids

Started by TheHauntStore, September 25, 2010, 09:54:02 PM

Previous topic - Next topic

TheHauntStore

Hi All - Jon Especially  ::) ,
So I was working on a routine using the following items:
Prop-1, AP-8, PIR, 5 Solenoids
(I have a bunch of Prop-1's so I figured I best start using them)

I started creating the BS1 file and then realized I am going to do a whole lot of repeating code that will just be silly to do unless there is a cool JonnyMac way to work in a routine that will act like ferocious random banging of 4 Solenoids (SYMBOL  Valve5, SYMBOL  Valve3, SYMBOL  Valve2, SYMBOL  Valve1) for about 7-10 seconds. Each one having a different banging sequence.
Then I unleash the Last Bang (SYMBOL  Valve4) that also has an Air Cannon and triggers audio on the AP-8.

Any ideas would be greatly appreciated from anyone especially Jon, the JonnyMac of EFX-TEK!

Here is the BS1 Program I have started (Any other corrections are welcome as well since I am not an avid programmer :-) :
I alos Attached the Prop-1 & AP-8 hookup I am using.



' =========================================================================
'
'   File......Prop1_AP8_PIR_5Solenoids.BS1
'   Purpose...Program a Prop-1, AP-8, PIR, 5 Solenoid banger 1 w/Air Canon
'   Author....Jason Thompson
'   E-mail....thehauntstore@gmail.com
'   Started...19/25/2010
'   Updated...
'
'   {$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  timer           = B3

SYMBOL  delay           = 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 warmup and prop reset; 30sec


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  FOR idx = 1 TO 20
    PAUSE 5
    timer = timer + 5 * PIR                     ' update activity timer
    RANDOM lottery                              ' stir random #t
  NEXT
Solenoid Banger:
'(need some kind of randomizer [If even possible in a prop-1] for Valves 1, 2, 3, & 5 to achieve a possessed banging for 7-10sec
' All I have now is just an on off which will get real tiring and a very long page of on/off's)
  Valve1 = IsOn               ' turn on solenoid valve1
  PAUSE 250                                     ' wait for .25 seconds
  Valve1 = IsOff            ' turn off solenoid valve1
  PAUSE 500                                     ' wait for .5 seconds
  Valve2 = IsOn               ' turn on solenoid valve2
  PAUSE 250                                     ' wait for .25 seconds
  Valve2 = IsOff            ' turn off solenoid valve2
  PAUSE 500                                     ' wait for .5 seconds
  Valve3 = IsOn               ' turn on solenoid valve3
  PAUSE 250                                     ' wait for .25 seconds
  Valve3 = IsOff            ' turn off solenoid valve3
  PAUSE 500                                     ' wait for .5 seconds
  Valve5 = IsOn               ' turn on solenoid valve5
  PAUSE 250                                     ' wait for .25 seconds
  Valve5 = IsOff            ' turn off solenoid valve5
  PAUSE 10000                                   ' wait for 10 seconds

  Valve4 = IsOn               ' turn on solenoid valve4+Cannon
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)     ' play AP-8 audio
  PAUSE 1000                                    ' wait for 1 seconds
  Valve4 = IsOff            ' turn on solenoid valve4+Cannon
  PAUSE 250                                     ' wait for .25 seconds
  Valve4 = IsOn               ' turn on solenoid valve4+Cannon
  PAUSE 1000                                    ' wait for 1 seconds
  Valve4 = IsOff            ' turn on solenoid valve4+Cannon

  PAUSE 30000                                   ' prop hold time for PIR non-retrigger; 30sec

  GOTO Reset               ' reset everything

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


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


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


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


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


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


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


END OF LINE...

~JAy
The Haunt Store (TM)
The Haunt Store(TM)
"Free Screams With Every Order, Upon Request"

JonnyMac

(Jay and I happen to live in the same neighborhood so I check in on his haunt and asked him about this program.)

This is another case where RANDOM is our best friend; we use it to randomize the "banging" time, the active outputs for banging, as well as the bang time -- this will give you what you're looking for.  We use a mask (not the wearable kind) to select just the outputs that we want to bang with this line of code

 PINS = lottery & %00010111

Lottery is random, and the 1 bits in the mask are the only ones that get used, the 0 bits in the mask will always be off.

Here's the updated version:

' =========================================================================
'
'   File...... Prop1_AP8_PIR_5Solenoids.BS1
'   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 & %00010111                    ' 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
 Valve4 = IsOn                                 ' activate cannon
 PAUSE 1000
 Valve4 = IsOff
 PAUSE 250                                     ' short "off"
 Valve4 = IsOn
 PAUSE 1000
 Valve4 = IsOff


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


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


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


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

TheHauntStore

Jon,
This code works RANDOMLY perfect I am very thankful you were able to show the RANDOM.
Saves a load of typing a lot of on and off. As well the MASK feature, that's a really handy dandy piece of code.

It seems the Prop-1 wont trigger the AP-8 (its a revb board, if that matters)
I noticed the AP-8 was set at %11 so I set it to match what was in the code %00.
I still have no activation of the AP-8 through the Prop-1 Pin7 (which is setup like the previous attached picture).

I might note that when I plug in the AP-8 it plays through all of the sounds (0-7) and then stops after the last one.
So I placed all of the dip Switches to OPEN "7", I read in audio the forums that DIP switches (0, 1, and 2) need to be in the OFF or OPEN position

Any ideas on what my prop-1 triggering the AP-8 might be the issue? 
The Haunt Store(TM)
"Free Screams With Every Order, Upon Request"

JonnyMac

Have you run the AP-8 test program to verify communications with the AP-8?  Have you reprogrammed the AP-8 with a just one sound in slot 0?  Once programmed, the AP-8 does need to be in slot 7 for serial commands to work.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Just a thought: make sure the SETUP jumper on P7 is in the UP position.
Jon McPhalen
EFX-TEK Hollywood Office

TheHauntStore

Yes, Prop-1 SETUP jumper on P7 is in the UP position, and ULN leg7 is removed.
AP-8 is connected in slot 7 for serial commands from the Prop1 P7 to the lower BRW pins (Like in the picture)
I noticed that my AP-8 revB doesn't say (under Serial) "B/R" its ID2 along with ID1, ID0.
Also if I press the play button nothing plays.
I can see everything working with the Trainer board on the prop-1, just no way to verify that a serial command is sending.

Where can I find the routine for the AP-8 test program?

The AP-8 is an older board so maybe its on its last legs?

The Haunt Store(TM)
"Free Screams With Every Order, Upon Request"

JonnyMac

Below you'll find the original test code (pasted here since AP-8 page is gone).


QuoteI noticed that my AP-8 revB doesn't say (under Serial) "B/R" its ID2 along with ID1, ID0.

ID2 = B/R, ID1 = A1, ID0 = A0
-- as we got better we started using friendlier labels on boards


QuoteThe AP-8 is an older board so maybe its on its last legs?

Not likely -- electronic devices don't wear out like you and I do.

' =========================================================================
'
'   File....... AP-8_Test.BS1
'   Purpose.... AP-8 Features Test
'   Author..... EFX-TEK
'   E-mail..... teamefx@efx-tek.com
'   Started....
'   Updated.... 01 JUN 2006
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' Demonstration program for the AP-8 Audio Player Board.  All commands are
' send to the AP-8 through a serial link at 2400 baud (OT2400 baudmode).
' The use of the open baudmode allows boards to be daisy-chained for up to
' 32 sounds from one I/O pin.
'
' Command syntax: "!AP8", address, cmd {, data}
' -- where 'address' is %00 to %11
' -- 'cmd' is a single character
' -- optional 'data' is a byte
'
' Valid commands:
'
'   "!AP8", address, "V"
'     -- requests version string from AP-8
'     -- should be followed by SERIN to receive three-byte string
'
'   "!AP8", address, "G"
'     -- retrieves current AP-8 status
'     -- should be followed by SERIN to receive one-byte status
'     -- status byte is bit-mapped:
'        * BIT7 : 1 = playing, 0 = idle
'        * BIT6 : 1 = soft looping (version 1.2+)
'        * BIT5 : 1 = single-shot play, 0 = hard loop select
'        * BIT4 : 1 = Record mode, 0 = Play mode
'        * BIT3 : reserved
'        * BIT2 : Segment switch 2
'        * BIT1 : Segment switch 1
'        * BIT0 : Segment switch 0
'
'   "!AP8", address, "P", segment
'     -- plays selected segment (0 - 7)
'     -- returns status (same as "G" command) -- may be ignored
'
'   "!AP8", address, "X"
'     -- stops AP-8 (if playing) at selected address
'
'
' Note: If ULN2803 interferes with serial transmission to RC-4, remove and
'       replace with ULN2003 (7 channels), leaving P7 contacts open.


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


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

SYMBOL  Sio             = 7


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

SYMBOL  Baud            = OT2400
SYMBOL  Addr            = %00


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

SYMBOL  id0             = B0                    ' also used to status
SYMBOL  id1             = B1
SYMBOL  id2             = B2
SYMBOL  segment         = B3                    ' loop control
SYMBOL  switches        = B4                    ' board switch settings
SYMBOL  ctrlChar        = B5                    ' used for Debug Home


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


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

Reset:
 DEBUG CLS
 ctrlChar = 1                                  ' home


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

Main:
 SEROUT Sio, Baud, ("!AP8", Addr, "V")         ' get version
 SERIN  Sio, Baud, id0, id1, id2               ' receive ID string

Chec_Version:
 IF id2 = "2" THEN Demo_Error                  ' check version

Show_Version:
 DEBUG "AP-8 Version ", #@id0, #@id1, #@id2    ' display it
 PAUSE 2000
 DEBUG CLS

 FOR segment = 0 TO 7
   SEROUT Sio, Baud, ("!AP8", Addr, "P", segment)
   SERIN  Sio, Baud, id0                       ' clear auto status byte

Get_Status:
   SEROUT Sio, Baud, ("!AP8", Addr, "G")       ' get status
   SERIN  Sio, Baud, id0

   IF BIT4 = 1 THEN Mode_Error                 ' AP-8 in record mode

   switches = id0 & %00000111                  ' isolate switch bits
   IF switches <> %111 THEN Switch_Error       ' error if any closed

Show_Status:
   DEBUG #@ctrlChar                            ' home cursor
   DEBUG "Segment #", #segment, CR             ' show board status
   DEBUG CR
   DEBUG "Playing / Idle... ", #BIT7, CR
   DEBUG "Single / Loop.... ", #BIT5, CR
   DEBUG "Record / Play.... ", #BIT4, CR
   DEBUG "Segment Sw2...... ", #BIT2, CR
   DEBUG "Segment Sw1...... ", #BIT1, CR
   DEBUG "Segment Sw0...... ", #BIT0, CR

   IF BIT7 = 1 THEN Get_Status                 ' allow to finish
   PAUSE 1000
 NEXT

 DEBUG CLS, "Demo complete."
 END


Switch_Error:
 DEBUG CLS
 DEBUG "Please set AP-8 segment select", CR
 DEBUG "switches to OPEN, then restart", CR
 DEBUG "the program."
 END


Mode_Error:
 DEBUG CLS
 DEBUG "AP-8 is set to Record mode; please", CR
 DEBUG "move PLAY/REC jumper to PLAY."
 END


Demo_Error:
 DEBUG CLS
 DEBUG "Please use AP-8_Test_v1x2.BS1"
 END
Jon McPhalen
EFX-TEK Hollywood Office

TheHauntStore

Ok great thanks for that.
I was a searching and searching...

So just ran it and here are the results:

AP-8 Version 1.1

Segment #0

Playing / idle... 0
Single / Loop... 1
Record / Play... 0
Segment Sw2...1
Segment Sw1...1
Segment Sw0...1

Then Playing / idle... 0
changes to this
Playing / idle... 1

then just sits there with this on the screen:
Playing / idle... 1
Single / Loop... 1
Record / Play... 0
Segment Sw2...1
Segment Sw1...1
Segment Sw0...1

so what does that now tell us?

I assume since it knows the version that its talking to the AP-8, that's good.

My setting for the power switch is in the LO.

JAy

The Haunt Store(TM)
"Free Screams With Every Order, Upon Request"

JonnyMac

Looks like your loop switch is closed -- it should be open (off) which will read back as "1"

Give that a try.
Jon McPhalen
EFX-TEK Hollywood Office