November 24, 2024, 01:16:24 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Prop-1, PIR, AP-8, relay powered wiper motors

Started by uncle, September 26, 2007, 11:00:45 AM

Previous topic - Next topic

uncle

John-

I have had my Prop-1 and AP-8 for a year and am just now attempting to use them.  I have managed to get the AP-8 to play a 60 second sound clip (I think that is the maximum length it will hold), and am now thinking of using the Prop-1 to trigger it and a relay which will activate a couple wiper motors.  The relay will be between a modified computer power supply and the wiper motors so the Prop-1 will only be powering the relay itself.

Basically, I want the PIR to have the Prop-1 activate both the wiper motors and AP-8 at about the same time for the full length of the sound clip, then turn off and not allow activation for about 5 minutes (time to let the next group of trick or treaters arrive).

I have tried to figure a program and programming in general from the existing programs listed in the forum, and can say that I am just confused!  Any help you could give me in this would be greatly appreciated.

JonnyMac

September 26, 2007, 12:39:56 PM #1 Last Edit: September 26, 2007, 12:42:42 PM by JonnyMac
Uhncle ( there's no h in my name, either  ;D ),

The listing below shows how I'd do it.  Please read the Prop-1 and AP-8 documentation carefully before you get going.  In this program the AP-8 is queries during the prop run and when the audio stops the motor will stop.

Things you need to do:
-- swap the ULN2303 for a ULN2003 or do a bit of chip surgery (see this thread for details: http://www.efx-tek.com/php/smf/index.php?topic=130.0)
-- remove the SETUP jumper from P7
-- move the P6 SETUP jumper to the DN position
-- On the AP-8, remove the B/R, A1, and A0 jumpers (on older boards these may be marked ID2, ID1, and ID0)
-- connect the AP-8 to P7 using a 3-pin jumper cable -- be very careful with polarity

Take your time; it's easy once you figure things out

One last note: Try not to record past the end of the memory on the AP-8.  The ISD chip has this weird "feature" that causes it not to tell the AP-8 processor the audio is finished when you do this -- this will let you play a sound once, but not a second time without recycling power (you don't want to do that).  So, double check the length of your sound and carefully time it; I usually recommend a maximum sound segment of 55 seconds -- this gives you lots of time to release the rcord button.  Also, make sure that you have the AP-8 segments witches set to zero (2, 1, and 0 switches are "closed" or "on") when recording, then open when you're ready to accept commands from the Prop-1.

' =========================================================================
'
'   File...... Uhncle.BS1
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'   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  PIR             = PIN6                  ' SETUP = DN
SYMBOL  MotorCtrl       = PIN0                  ' relay to OUT0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud            = OT2400                ' for Prop-1


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

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

SYMBOL  timer           = B2
SYMBOL  secs            = B3
SYMBOL  mins            = B4


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00000001                              ' set outputs

  SEROUT Sio, Baud, ("!!!!!!AP8", %00, "X")     ' kill audio on reset


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

Main:
  timer = 0

Wait_For_Victim:
  PAUSE 10
  timer = timer + 10 * PIR                      ' update PIR timer
  IF timer < 250 THEN Wait_For_Victim           ' wait for valid signal

  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' start audio
  MotorCtrl = IsOn

Check_Sound:
  PAUSE 100                                     ' check every 0.1 secs
  SEROUT Sio, Baud, ("!AP8", %00, "G")
  SERIN  Sio, Baud, status
  IF playing = Yes THEN Check_Sound

  MotorCtrl = IsOff

Long_Delay:
  FOR mins = 1 TO 5
    FOR secs = 1 TO 60
      PAUSE 1000
    NEXT
  NEXT

  GOTO Main


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


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


Jon McPhalen
EFX-TEK Hollywood Office

uncle

Thanks Jon! (and I don't know why I added that "h"!  I knew better!!)

uncle

Jon-

When you get a moment, would you please explain the syntax for SEROUT.  I have the rest of the program figured out (I think), but I haven't been able to find this syntax in any of the information I have sought out in regards to PBASIC programming.

JonnyMac

September 27, 2007, 04:01:02 PM #4 Last Edit: September 27, 2007, 04:05:08 PM by JonnyMac
I could... but then I'd just be regurgitating the manual that you can find online.  The BASIC Stamp editor is smart; double-click on the word SEROUT to select it, then press the [F1] key to jump into that place in the help file.

Be sure to review the AP-8 docs as well -- that's where you'll find the command syntax for it (as used in the program above).
Jon McPhalen
EFX-TEK Hollywood Office