November 23, 2024, 06:11:06 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-16+ with Prop-1 Light Program

Started by megaplay, July 29, 2010, 09:33:34 PM

Previous topic - Next topic

megaplay

Hello,
I received my AP-16+ recently and have started working on the program that it was purchased for.  Unfortunately because of lack of time and lack of knowledge I am not getting too far.  I was seeing if it was possible to get a starting point and guidance.  Here is the basic of what I am looking to do:
1. Plug in controller and it immediately starts and ambient program that will have one output of the Prop-1 going to a relay for a light.  We will say this light is red to try an keep everything straight.  This ambient program will continue unless:
a. Button one is triggered which does three things.  Turns off red ambient light (red), turns on output two of the Prop-1 for a second light (yellow), and begins sound track one on the AP-16+.  This continues till the sound track is done and then everything returns to ambient light (red)
b. Button two is triggered which does the same thing as "a." above but instead turns on output three (green light), and begins sound track two.
When button 1 or 2 is triggered it will continue until the sound track is complete and cannot be interrupted by either activating the other button nor start over by activating the same button.  It must return to ambient state (red light) before the buttons are active again.

If you have a starting point on this type of program that would be great.  If more detail is needed please let me know of any questions.  Thank you.

JonnyMac

I can write you a program (I did) but you need to understand how to connect things -- the notes in the listing should will guide you.  Your normally-open buttons will connect to PIN5 (button 1) and PIN6 (button 2); the button goes between the R and W terminals.  Use OUT0 for red, OUT1 for yellow, and OUT2 for green.

On the AP-16+ you need AMBIENT.WAV (light is red), SFX1.WAV (light is yellow), and SFX2.WAV (light is green).

I tried not to be too tricky with the code but using two triggers with BRANCH the way I did may require a little study on your part if you want to understand it and change it later.

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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Btn2            = PIN6                  ' SETUP = DN
SYMBOL  Btn1            = PIN5                  ' ULN is pull-down

SYMBOL  GrnLight        = PIN2
SYMBOL  YelLight        = PIN1
SYMBOL  RedLight        = PIN0


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

SYMBOL  Baud            = OT2400                ' baud jumper out

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  status          = B0                    ' status (B0 for bit access)
SYMBOL   Playing        = BIT7                  ' 0 = idle, 1 = playing

SYMBOL  triggers        = B1
SYMBOL   tr2            = BIT14
SYMBOL   tr1            = BIT13

SYMBOL  idx             = B2


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

Power_Up:
  PAUSE 2000                                    ' let AP-16+ power-up
  SEROUT Sio, Baud, ("!AP16", %00, "X")         ' stop if playing now

Reset:
  PINS = %00000001                              ' Red light on
  DIRS = %00000111                              ' set outputs


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

Main:
  triggers = %01100000                          ' arm both triggers
  FOR idx = 1 TO 20                             ' debounce
    PAUSE 5
    triggers = triggers & PINS                  ' scan triggers
  NEXT

  triggers = triggers / 32                      ' setup for BRANCH
  BRANCH triggers, (Main, Yellow, Green, Main)  ' handle inputs

Yellow:
  SEROUT Sio, Baud, ("!AP16", %00, "PS", 1, 1)  ' play SFX01.WAV
  PINS = %00000010                              ' yellow light on
  GOSUB Wait_Play                               ' let file finish
  GOTO Reset

Green:
  SEROUT Sio, Baud, ("!AP16", %00, "PS", 2, 1)  ' play SFX02.WAV
  PINS = %00000100                              ' green light on
  GOSUB Wait_Play                               ' let file finish
  GOTO Reset


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

' Waits until AP-16+ is finished playing current file

Wait_Play:
  PAUSE 21
  SEROUT Sio, Baud, ("!AP16", %00, "G")         ' get status
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Wait_Play
    RETURN


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


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

megaplay

Wow thank you so much!  You don't even want to see the huge program I had been working on and it seems so simple once seen done right.  I will hook it up this weekend and let  you know the results.  I am hoping this never needs changing but will be sure to study the code in detail.