November 23, 2024, 03:21:05 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.


Program to Test a Prop-1, DC-16, AP-8, and RC-4

Started by Spooky Dad, August 03, 2010, 09:41:45 PM

Previous topic - Next topic

Spooky Dad

JonnyMac - I was hoping to get some help in creating a program that will test the "brains" for my haunt set up, made up of a Prop-1, DC-16, AP-8, and RC-4.  I would like for the following actions to happen, whenever the respective input pin is tripped (done with motion detectors).  You helped me out last year with a program that is helping me control a number of props in my haunted house (http://www.efx-tek.com/php/smf/index.php?topic=707.0), but by the end of the haunt, the haunt was not reliably working, so I want to rule out the hardware.  Thanks!

Input 0 tripped - Prop-1 Outputs 0 - 7 activated one after each other for 5 seconds each (in serial)
Input 1 tripped - AP-8 sound locations 1 to 4 played in order
Input 2 tripped - AP-8 sound locations 5 to 8 played in order
Input 3 tripped - DC-16 low bits all activated one after each other for 5 seconds each (in serial)
Input 4 tripped - DC-16 high bits all activated one after each other for 5 seconds each (in serial)
Input 5 tripped - RC-4 outputs K1 and K2 are activated for 5 seconds each (in serial)
Input 6 tripped - RC-4 outputs K3 and K4 are activated for 5 seconds each (in serial)

JonnyMac

Please refer to item #11 in our guidelines -- these forums are intended to be a group thing; please allow others to help, too.

That said, we have test code for all of our products; we can create custom test code, but it's really not a great use of anyone's time.  If that's what you want I have to ask: is this one big test program (sounds like what you're asking) or is it a set of test programs.
Jon McPhalen
EFX-TEK Hollywood Office

Spooky Dad

As I have been a way for a while, I went and reread the guidelines to keep out of the penalty box.  This is one of the best communities I know of, and would welcome any other members assistance.

Yes, one big test program so that I can quickly troubleshoot and rule out the physical inputs and outputs of my haunt brains, so as to speed up any troubleshooting of wiring or the devices that are either providing the inputs (motions and break beams) or the devices being controlled.  I will work on the program through the use of / modification to the test code, and then ask for specific help if and when I encounter any problems. 

JonnyMac

Okay, it's not the best use of my time (as test programs exist), but I'll do it.   That said, it's going to be two programs; one for the local outputs, the other to do the remote stuff.  Give me a day or so to round everything up.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's the program for testing the Prop-1 outputs (OUT0 through OUT6); make sure you have something (LED, etc.) connected between V+ and the OUTx terminals, and that the power switch is in position 2.

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


' -----[ Program Description ]---------------------------------------------
'
' Quick test of Prop-1 outputs, OUT0 - OUT6
' -- ensure P6 SETUP jumper is DN


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


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

SYMBOL  Trigger         = PIN7                  ' SETUP = DN


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

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


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

SYMBOL  timer           = B2
SYMBOL  thePin          = B3


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %01111111                              ' make P0-P6 outputs


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

Main:
  timer = 0                                     ' reset timer

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

  FOR thePin = 0 TO 6                           ' loop through pins
    HIGH thePin                                 ' output on
    PAUSE 5000                                  ' hold 5 secs
    LOW thePin                                  ' output off
  NEXT

  GOTO Reset


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


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


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

JonnyMac

Here's the other.  Note that I had to cut the number of tests down to one per device to fit the program into the Prop-1.

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


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = UP; no ULN
SYMBOL  Trigger6        = PIN6                  ' SETUP = DN
SYMBOL  Trigger5        = PIN5
SYMBOL  Trigger4        = PIN4
SYMBOL  Trigger3        = PIN3
SYMBOL  Trigger2        = PIN2
SYMBOL  Trigger1        = PIN1
SYMBOL  Trigger0        = PIN0

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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400


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

SYMBOL  status          = B0
SYMBOL   playing        =  BIT7

SYMBOL  triggers        = B2
SYMBOL  timer           = B3
SYMBOL  idx             = B4


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

Reset:
  SEROUT Sio, Baud, ("!!!!!!")                  ' re-sync stream
  SEROUT Sio, Baud, ("!AP8", %00, "X")          ' kill AP-8
  SEROUT Sio, Baud, ("!DC16", %00, "X")         ' kill DC-16
  SEROUT Sio, Baud, ("!RC4", %00, "X")          ' kill RC-4


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

Main:
  triggers = %00000111                          ' arm all triggers
  FOR timer = 1 TO 20                           ' delay = ~100ms
    PAUSE 5                                     ' debounce delay
    triggers = triggers & PINS                  ' scan inputs
  NEXT

  IF triggers = %00000001 THEN Test_AP8         ' P0 trigger
  IF triggers = %00000010 THEN Test_DC16        ' P1 trigger
  IF triggers = %00000100 THEN Test_RC4         ' P2 trigger
  GOTO Main


Test_AP8:
  DEBUG CLS, "AP-8 Test", CR, CR
  FOR idx = 0 TO 7
    DEBUG "Playing: ", #idx, CR
    GOSUB Play_AP8
    GOSUB Wait_AP8
    PAUSE 500
  NEXT
  GOTO Main


Test_DC16:
  DEBUG CLS, "DC-16 Test", CR, CR
  FOR idx = 1 TO 16
    DEBUG "Testing: ", #idx, CR
    SEROUT Sio, Baud, ("!DC16", %00, "P", idx, 1)
    PAUSE 5000
    SEROUT Sio, Baud, ("!DC16", %00, "X")
  NEXT
  GOTO Main


Test_RC4:
  DEBUG CLS, "RC-4 Test", CR, CR
  FOR idx = 1 TO 4
    DEBUG "Testing: ", #idx, CR
    SEROUT Sio, Baud, ("!RC4", %00, "R", idx, 1)
    PAUSE 5000
    SEROUT Sio, Baud, ("!RC4", %00, "X")
  NEXT
  GOTO Main


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

' Put segment number (0 to 7) into 'idx' before calling

Play_AP8:
  SEROUT Sio, Baud, ("!AP8", %00, "P", idx)     ' play segment
  RETURN

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

' Holds program until AP-8 is finished playing current segment

Wait_AP8:
  PAUSE 25
  SEROUT Sio, Baud, ("!AP8", %00, "G")          ' get status
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Wait_AP8
    RETURN


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

Spooky Dad