November 22, 2024, 04:03:55 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.


Large crypt popup with doors, lights, & fog

Started by gatesofterror, February 05, 2009, 04:33:20 PM

Previous topic - Next topic

gatesofterror

John,
I am working on a new project which uses the Prop 1 controller, PIR sensor for activation, RC-4 for the fogger, and lights, and AP8 for sound.
1- These are operated through the RC-4
    Lights come on
    fog is triggered

2- Door solenoid 4 way- 12v DC 400mA operating 2 double action cylinders.
    Want the doors to open slightly and bang shut about 5 times
    Then doors open and hold open

3- Prop solenoid 4 way- 12v DC 400mA operating 1 double action cylinder
    When doors are opening 1 sec. delay then Main prop is activated and stays up for about 3 sec.
    AP8is activated for sound

4- sound stops
    lights go out
    fog stops
    Main prop lowers allow 2 seconds to clear doors

5- 45 second delay before it will start over

There is a simular program for the BAPU Crypt except you have to manually start each pocess. I want it to run automatically.
Here is the simular program.

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

SYMBOL Door1        = 6

SYMBOL Door2        = 4

SYMBOL Prop         = 5

SYMBOL IsOn         = 1

SYMBOL IsOff        = 0

SYMBOL Baud         = OT2400

SYMBOL AP8Addr      = %00

SYMBOL RC4Addr      = %10

SYMBOL Serial       = 7

SYMBOL Trigger1     = PIN0

SYMBOL Trigger2     = PIN1

SYMBOL Trigger3     = PIN2

SYMBOL Trigger4     = PIN3

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

SYMBOL IDX   = B2

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

Main:

IF Trigger1 = IsOn THEN Door_Slam

IF Trigger2 = IsOn THEN Fog

IF Trigger3 = IsOn THEN Crypt_Pop

GOTO Main


Door_Slam:

FOR IDX = 1 TO 7

  SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 1)

  HIGH Door1

  HIGH Door2

PAUSE 100

  LOW Door1

  LOW Door2

PAUSE 100

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 0)

NEXT

GOTO Main


Fog:

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 1, 1)

PAUSE 1000

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 1, 0)

GOTO Main


Crypt_Pop:

FOR IDX = 1 TO 7

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 3, 1)

PAUSE 50

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 3, 0)

PAUSE 150

NEXT


SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 1)

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 1, 0)

HIGH Door1

PAUSE 70  'pause to synch door open

HIGH Door2

PAUSE 100 'pause for door open

HIGH Prop

SEROUT Serial, Baud, ("!AP8", AP8Addr, "P", 1)

FOR IDX = 1 TO 20 ' flash lights

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 1)

PAUSE 75

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 0)

NEXT

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 1, 0)

LOW Prop

PAUSE 550 ' pause for prop drop

LOW Door1

PAUSE 50  'pause to synch door close

LOW Door2

SEROUT Serial, Baud, ("!RC4", RC4Addr, "R", 2, 0)

GOTO Main


   

JonnyMac

February 05, 2009, 05:05:30 PM #1 Last Edit: February 11, 2009, 02:01:44 PM by JonnyMac
Give this a look; I'm on my way out so it's a quickie, but I tried to spice it up with a bit of randomizing.

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  Extender        = PIN3                  ' On OUT3
SYMBOL  Doors           = PIN0                  ' On OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


SYMBOL  Baud            = OT2400                ' B/R jumper removed


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

SYMBOL  relays          = B0
SYMBOL   lights         = BIT0                  ' K1
SYMBOL   fog            = BIT1                  ' K2

SYMBOL  status          = B1
SYMBOL   playing        = BIT15

SYMBOL  timer           = B2
SYMBOL  slams           = B3

SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00001001                              ' set outputs


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

Main:
  timer = 0                                     ' reset timer

Check_Trigger:
  RANDOM lottery                                ' stir random #
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * Trigger                   ' update timer
  IF timer < 100 THEN Check_Trigger             ' wait for 0.1 sec input

Slam_Doors:
  lights = IsOn
  fog = IsOn
  GOSUB Set_RC4
  slams = lottery // 3 + 3                      ' 3 to 5 slams

Slam_Again:
  RANDOM lottery                                ' restir
  timer = lottery // 101 + 150                  ' 100 to 250ms
  Doors = IsOn
  PAUSE timer
  Doors = IsOff
  PAUSE timer
  slams = slams - 1
  IF slams > 0 THEN Slam_Again

Pop_Out:
  Doors = IsOn
  PAUSE 1000                                    ' allow fully open
  Extender = IsOn

Play_Sound:
  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)

Wait_Sound:
  PAUSE 100
  SEROUT Sio, OT2400, ("!AP8", %00, "G")
  SERIN  Sio, OT2400, status
  IF playing = Yes THEN Wait_Sound

  relays = IsOff
  GOSUB Set_RC4
  Extender = IsOff
  PAUSE 2000

  GOTO Reset


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

Set_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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

JonnyMac

Quick note: I deliberately separated the solenoid output pins; running 400ma per pin means a lot of current which means a lot of heat build up -- separating keeps the chip from getting too hot in one area.
Jon McPhalen
EFX-TEK Hollywood Office

gatesofterror

Thanks John,
I'm not sure what I'm doing wrong. I loaded the program and using the Prop 1 trainer PO light flashes random and then solid for the doors. Then P3 comes on and stays on also and that's it. Nothing else happens and the lights P0 and P3 do not go out.
Jim ???

BigRez

It's probably because while the trainer is on the device, you don't have the AP-8 (nor RC4) plugged in.  So when the code gets down to the portion to play the sound and wait for it to end, it never gets that signal and thus continues to loop at Wait_Sound.

You could comment out the SEROUT, SERIN, and IF statement for your initial testing and then uncomment them when the AP-8 is connected.

gatesofterror

OK, I have reviewed all the setup documentations again and am having trouble programing the AP-8. I have a 5 sec. clip setup in Audacity. I can listen to the clip with headphones on the computer but It either is not recording to the AP-8 or not playing back. No other componets seem to be affected so I am assuming that it is not recording. I have 2 AP-8s one is hooked up on my project board with the Prop 1, RC4, and 2 solenoid valves. I have a second AP-8 I have tried to program as a stand alone when I was having trouble getting the project board to work. Since neither is working I must be doing something wrong in the recording process.
I connect the transformer to the board. 8 ohm speaker to the speaker screws. All jumpers removed. Set the switch to lo. Plug the computer speaker out to the AP-8 jack. Move the jumper to record. I get the red record light. I have tried the toggles on oxxx, xxxx, oooo,xooo. None seems to make any diffrence. I hold the record button whle playing the sound track. Move the jumper to play, get the green light. press play on the stand alone AP-8 or activate P6 on the Prop 1 but neither one has any output.
I have gone through every configeration I can safetly think of without doing something that may damage the board.
Jim ???

JonnyMac

As I told you on the phone last night, Jim, the AP-8 takes a little time to get used to; once you get it it will seem easy.

Setup for your project:
-- remove Baud jumper
-- remove A0 and A1 jumpers

To record to slot 0
-- close switches 0, 1, and 2 (part of DIP switch in lower-left corner of board)
-- move play/record jumper to Record position (red LED)
-- get clip ready in Audacity; move cursor to start of clip
-- connect earphone output of computer to line-in input of AP-8 (jack on lower-right corner)

Tricky bit:
  -- click Play button in Audacity, immediately press and HOLD Play/Record button on AP-8 until clip finishes
  -- release Play/Record button
  -- move Play/Record jumper back to Play (green LED)
  -- Press Play button; you should hear your sound; re-record if too low (noisy) or too high (distorted)

To use with Prop-1 program:
  -- set 0, 1, 2 DIP switches back to Open (off)
     * this looks like you've got segment 7 selected but is required for SX chip to change addresses in ISD chip


Note: If you were recording to slot 7 (0, 1, 2 switches open) and recorded past the end you'll need to reset the ISD chip by cycling the power (this is an ISD thing).


Tip: I use the Generate Silence function in Audacity to create a couple seconds of silence at the end of my clip.  By doing this I can release the Play/Record button while the clip is silent; this seems to minimize pops at the end of the clip.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Over coffee I created this cheat sheet -- it should help with the DIP switch settings.

www.efx-tek.com/downloads/ap-8_cheat_sheet.pdf
Jon McPhalen
EFX-TEK Hollywood Office

gatesofterror

Good news, Bad news. I changed the AP-8 board and now have sound. YEA!! The solenoid valves were not working soI got another Prop 1 board and reprogramed it and now the solenoids and sound work. Now for the bad part. The RC-4 is not responding ?

gatesofterror

RC-4 all jumpers removed, white wire is towards the center of the board on the SER terminals.

JonnyMac

If all else fails, download and run the RC-4 demo program (you can find it on our main site ) -- you should always test basic connections before integrating components into a working system (I do, anyway).
Jon McPhalen
EFX-TEK Hollywood Office

gatesofterror

OK, I downloaded and ran the RC-4 Test program with no response to the RC-4. Do I need to order another board.
Thanks for all your help.

JonnyMac

Double-check everything -- we test our products before shipping and can count on one-hand the number of problems that have slipped through.  You may have broke the connector wire between the RC-4 and Prop-1, or (more likely) have one of connectors on backward (use the W R B guides on each board).
Jon McPhalen
EFX-TEK Hollywood Office

gatesofterror

Good morning Jon,
I had been over this setup dozens of times and could not find any setup or wiring problems so I ordered another RC-4 board thinking that there has to be a problem with the board. I ordered another board, it never hurts to have more boards. The new board arrived this morning. I hooked up the new board checked the wiring, removed the jumpers and nothing. I have spent the past couple of days reading and trying to understand the programing. I revised some timing with the doors changing the slams to 5 to 9 times, adjusted the timer so the doors open a little further making them slam louder. I reduced the pause for the pop out to react quicker, and reduced the wait sound to come on sooner, all these changes seem to work well. I did all these changes on another Prop 1 so as not to change the original one, so I still have the original one with your program. The RC-4 is still not working with either Prop 1. I am at a loss of ideas. Another thing I noticed was that when the PIR is hooked up if there is an movement while the doors are open the pop out lowers, then the doors start banging at the high end and the pop out comes back out. I also need to add a delay at the end so the prop will not turn back on for 20 seconds, so it dosen,t keep recycling as people walk by.
I apologize for using so much of your time but computer language and programing is Greek to me and i am having trouble understanding so of the terminology.

BigRez

Curious...  In the latest post of the code, the address for the AP-8 and RC-4 are both set at   %00  but they must be different. 

Quote
Play_Sound:
  SEROUT Sio, OT2400, ("!AP8", %00, "P", 0)

Set_RC4:
  SEROUT Sio, Baud, ("RC-4", %00, "S", relays)

Also put an exclamation point in front of the RC-4 as in:
     SEROUT Sio, Baud, ("!RC-4", %00, "S", relays)

You say that all jumpers are removed from the RC-4 which makes the address %00.  Double-check that the AP-8 and RC-4 have different addresses.  Put the jumper on A0 to make the address  %01 or on A1 to make the address %10 and make appropriate changes to the code.

Also, double-check the 120v connections into the RC-4 and to the devices.  I once had those connections wrong and took a while to figure that out.