May 16, 2024, 11:26:59 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.


AP-8 to Cowlacious

Started by ryagl, September 25, 2009, 09:33:44 PM

Previous topic - Next topic

ryagl

I previously had a program with the ap-8 for audio.  My nephew stepped on the ap-8 and destroyed it.   I now have a cowlacious and I'm needing a program that replaces the ap-8.  My previous program triggered and played the audio for 5 seconds prior to starting the sequence of the program and continued for 5 seconds after the sequence, but  I now want the program to start and end at the same time as the audio, making the sequence longer than it was.  The old program follows.  Thank you.



'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


' -----[ 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   Solenoid       =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2
SYMBOL   Light          =  BIT2                 ' on K3
SYMBOL   Light2             =  BIT3           ' on K4

SYMBOL  idx             = B1                    ' loop controller
SYMBOL  sfx             = B2                    ' sound segment

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00000000                              ' no outputs

  PAUSE 250                                     ' let AP-8 power up
  GOSUB Kill_Audio                              ' stop AP-8
  relays = %0000
  GOSUB Set_Relays                              ' clear relays


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

Main:
  timer = 0                                     ' reset timer

Light2 = IsOn

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

Start_Audio:
  sfx = 0                                       ' play segment 0
  GOSUB Play_Audio
  PAUSE 5000                                    ' wait 5 secs

  timer = 5000                                  ' set to 0:05 mark

Shake_It:
  RANDOM lottery
  Solenoid = lottery                            ' randomize Solenoid
  RANDOM lottery
  Light = lottery                               ' randomize Light
  GOSUB Set_Relays
  PAUSE 69                                      ' 100 - 29
  timer = timer + 100                           ' update timer

Check_Fog_Start:
  IF timer < 10000 THEN Shake_It
    Fogger = IsOn

Check_Fog_Stop:
  IF timer < 12000 THEN Shake_It
    Fogger = IsOff

Check_Chair:
  IF timer < 25000 THEN Shake_It
    relays = %0000                              ' all off
    GOSUB Set_Relays

Wait_Audio:
  PAUSE 30000                                   ' audio finish + loop delay

Light2 = IsOff

  GOTO Main


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

' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud

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

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

Kill_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "X")
  RETURN

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

Play_Audio:
  SEROUT Sio, Baud, ("!AP8", %00, "P", sfx)
  RETURN


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

ryagl

Figured I would add this so that my timing is correct.

Audio: start at T00.0 and ends around T30.0
Fog: start at T05.0 and ends around T10.0
Chair: start at T00.0 and ends at T30.0
Light: start at T00.0 and ends at T30.0

Ryan

JonnyMac

September 25, 2009, 11:27:05 PM #2 Last Edit: September 27, 2009, 10:07:56 AM by JonnyMac
I *think* this is what you want.  Keep in mind that even though I wrote the original program for you, I tend to forget all about it after the job is done -- I haven't lived with it like you have.  So... I'm at a bit of a disadvantage, even going back in.  Hopefully, I decoded your request properly.

Updated: 27 SEP 2009

'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger         = PIN6                  ' SETUP = DN
SYMBOL  CARP            = PIN5                  ' V+/OUT5 to V-Trig


' -----[ 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   Solenoid       =  BIT0                 ' on K1
SYMBOL   Fogger         =  BIT1                 ' on K2
SYMBOL   Light          =  BIT2                 ' on K3
SYMBOL   Light2         =  BIT3                 ' on K4

SYMBOL  idx             = B1                    ' loop controller

SYMBOL  timer           = W4
SYMBOL  lottery         = W5                    ' random #


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

Reset:
 PINS = %00000000                              ' clear all
 DIRS = %00100000                              ' set CARP to output

 relays = %0000
 GOSUB Set_RC4                                 ' clear relays

  PAUSE 20000
 

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

Main:
 timer = 0                                     ' reset timer

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

Start_Audio:
 CARP = IsOn
 PAUSE 50
 CARP = IsOff

 timer = 0                                     ' set to T00.0

Shake_It:
 RANDOM lottery
 Solenoid = lottery                            ' randomize Solenoid
 RANDOM lottery
 Light = lottery                               ' randomize Light
 GOSUB Set_RC4
 PAUSE 69                                      ' 100 - 29
 timer = timer + 100                           ' update timer

Check_Fog_Start:
 IF timer < 5000 THEN Shake_It
   Fogger = IsOn                               ' fog on at T05.0

Check_Fog_Stop:
 IF timer < 10000 THEN Shake_It
   Fogger = IsOff                              ' fog off at T10.0

Check_Chair:
 IF timer < 15000 THEN Shake_It

 GOTO Reset                                    ' quit at T15.0


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

' Update RC-4 with "relays"
' -- takes 29ms @ 2400 baud

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


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

ryagl

Thank you.  I know you're not completely familiar with the car/p 300 but I have a hook up question.  Do I hook up the cowlacious from the v-trig on the car/p to the serial header on the rc-4.   The rc-4 has a three wire hook up red black and white and the car/p has a two wire hook up, black and white.   Do I use the two wire hook up that comes with car/p or the 3 wire hook that comes with your controllers.  Sorry so many questions, I just dont want to blow anything up, lol.

Ryan

JonnyMac

I do know how to connect to the CAR/P.

The V-Trig header has two pins; connect one to V+ and the other to OUT5 (polarity is not a concern).  Make sure you set the V-Trig voltage jumper to the one that says 9-12v. 

You will not use the Prop-1 TTL headers for the CAR/P at all.
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

The program works fine, but I made a little adjustment to the program.  I wanted to shorten the entire thing to around 15 seconds, so I changed the GOTO reset/quit time to 15.0.  This did what I wanted it to, but the sensor now goes off immediately after the program is off ,if it is tripped.  There is no delay time in between the sequence, so a kid could trip it every 15 seconds.  Did I do this wrong or do I just need to tweak it a bit more.  Thanks

Start_Audio:
  CARP = IsOn
  PAUSE 50
  CARP = IsOff

  timer = 0                                     ' set to T00.0

Shake_It:
  RANDOM lottery
  Solenoid = lottery                            ' randomize Solenoid
  RANDOM lottery
  Light = lottery                               ' randomize Light
  GOSUB Set_RC4
  PAUSE 69                                      ' 100 - 29
  timer = timer + 100                           ' update timer

Check_Fog_Start:
  IF timer < 5000 THEN Shake_It
    Fogger = IsOn                               ' fog on at T05.0

Check_Fog_Stop:
  IF timer < 10000 THEN Shake_It
    Fogger = IsOff                              ' fog off at T10.0

Check_Chair:
  IF timer < 30000 THEN Shake_It

  GOTO Reset                                    ' quit at T15.0

JonnyMac

September 27, 2009, 10:02:31 AM #6 Last Edit: September 27, 2009, 10:08:50 AM by JonnyMac
Two things:

1) Changing a comment (as you did) does not change the program.  You have to change the 30000 in the timer comparison line to 15000.

2) You need a bit of delay after everything runs to let the sensor clear -- I think I left this out; sorry.  

See the corrected listing (above).
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

Jon

I have recorded my desired sound to the car/p and have hooked up to the prop 1 controller as you stated, but the controller is not starting up the sound board as it should.  I have it wired to the 2 pin header on the vtrig on the car/p and is wired into v+ and out5.  I have to pin set correctly on the car/p. The voltage header is set to 9-12v.   Are there any pin headers that need to be changed on the prop1 controller. 

thank you

JonnyMac

No, in fact, there no SETUP header on P5.  You just have to make sure that you've got the power swtich to P2 so that you have a voltage on V+ that can be switched through the ULN on OUT5.  You might extend the PAUSE in the Start_Audio section; I don't know what the exact value should be as I don't have a CAR/P board (with a V-Trig input) to test.  Try 100ms.
Jon McPhalen
EFX-TEK Hollywood Office

ryagl

I believe you answered my question.  I have the power setting to 1 not 2.  I will try this.  The p2 setting will allow the out5 and the rc-4 to be activated right. 

thank you

Ryan

JonnyMac

P2 allows V+ to be "hot" which is the positive side of circuits completed by the OUTx terminals.

The RC-4 gets its power from the TTL serial cable and will work in P1 or P2.
Jon McPhalen
EFX-TEK Hollywood Office