November 23, 2024, 12:37:51 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.


Prop1 Controller Help

Started by mikeyscuda, October 07, 2009, 10:43:45 AM

Previous topic - Next topic

mikeyscuda

Can you provide me with some code. I'm so frustrated I've nuked all my code. Please Help. This is what I have PIR for input Prop1 controller & cowlacious CAR/P 300 board.
PIR for input to turn on a 12vdc solenoid for say 5 seconds then turn off the solenoid for 5 seconds, then turn on the CAR/P300 for say 20 seconds to play message, turn off CAR/P300. Then Not be triggered for 3 minutes, Then once triggered starts sequence again.

Thanks

JonnyMac

You cannot turn off the CAR/P-300 from the Prop-1 -- you'll need to record a 20-second message.  This code does what you want.  For connection details, please see the Prop-1 docs, the CAR/P-300 docs (from Cowlacious) and our Audio section, specifically, this thread:

http://www.efx-tek.com/php/smf/index.php?topic=1246.0

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


' -----[ Program Description ]---------------------------------------------
'
' Sio     :: Serial IO to EFX-TEK accessories (RC-4, FC-4, etc.)
'            -- clip pin 1 of ULN2803 or replace with ULN2003
'
' Trigger :: Parallax-compatible PIR or N.O. button (mat switch, etc.)
'            -- connect N.O. button between P6.W and P6.R


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


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

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


' -----[ 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  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00111111                              ' set output pins

  PAUSE 30000                                   ' PIR warm-up


' -----[ 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

Run_Valve:
  Valve = IsOn
  PAUSE 5000                                    ' 5 seconds
  Valve = IsOff
  PAUSE 5000

Start_Audio:                                    ' pulse to start CAR/P-300
  CARP = IsOn
  PAUSE 100
  CARP = IsOff
  PAUSE 20000                                   ' audio run time (20 secs)

Pgm_Delay:
  FOR timer = 1 TO 3
    PAUSE 60000                                 ' 1 min x 3
  NEXT

  GOTO Main


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


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

mikeyscuda

Thank you,

I other quick question, how does the Carp/300 get triggered again when the routine restarts or does the audio keep playing after the first trigger?

I'm sorry I'm new at this


livinlowe

Mike-
No worries! We were all new once , till the next halloween! In Jon's program:

Pgm_Delay:
  FOR timer = 1 TO 3
    PAUSE 60000                                 ' 1 min x 3
  NEXT

  GOTO Main

This will Delay the prop 1 for 3 minutes, or 180000 seconds. The next line sends the program back to the beginning, which waits for the PIR sensor to get triggered, which will send another pulse to the CARP/300 which will start playing again.

Hope this helps
Shawn
Scaring someone with a prop you built -- priceless!

JonnyMac

And as I suggested in my initial response, if you want just 20 seconds of audio that's all you should record.  When it's finished the CAR/P will re-arm itself and wait for the next cycle.
Jon McPhalen
EFX-TEK Hollywood Office

mikeyscuda

Thank you, you are awesome
:)

mikeyscuda

 ??? I have a couple of questions about the code you wrote, just so I understand what is going on. Under I/O Definitions you have symbol Sio =7 what is that? Also SETUP = UP; no ULN & SETUP = DN. are these jumper settings or what? Also under constants you have  SYMBOL  Baud = OT2400 ' B/R jumper removed, is this for communication to the CARP? and what is B/R jumper removed. Please help I just want to understand

Thank you,

JonnyMac

The SETUP is a jumper on the board -- it is to the left of the P7 TTL headers.  For ULN configuration, see this thread:

http://www.efx-tek.com/php/smf/index.php?topic=130.0

OT2400 is a built-in constant for serial communicaitons -- you would use that with our DC-16, FC-4, RC-4, etc., but not with the CAR/P which uses a pulse start. 

I have my editor setup with a standard template; you can get it here:

-- http://www.efx-tek.com/php/smf/index.php?topic=4.0

Not all items in the template are used by all programs; but I don't delete thing becuase, more than I can remember, I am asked to update programs which would require me to replace the previously deleted items. 

Be careful not to get too wrapped around the axle... it's easy to get lost in the weeds that aren't growning your garden, so to speak.  Start with the code at Setup and follow it; symbols used from there down are the ones you'll want to concern yourself with.  Also, you can learn about a PBASIC keyword by double-clicking to select and then pressing the F1 key (the help file will open to the selected keyword).

Finally, for an easy programming primer you should read this:

-- http://www.efx-tek.com/downloads/prop-1_programming_basics.pdf

PBASIC 1 has about 31 keywords, but we rarely use more than 10 in a prop control application.
Jon McPhalen
EFX-TEK Hollywood Office