November 23, 2024, 11:14:11 AM

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.


Program Help

Started by dullom, October 11, 2009, 06:42:27 PM

Previous topic - Next topic

dullom

October 11, 2009, 06:42:27 PM Last Edit: October 11, 2009, 10:01:57 PM by dullom
Hi Jon,

Can you help me write a really simple program?


I am making a simple pop up prop using a Prop-1, EFX-TEK PIR, a Cowlacious Chipcorder 2500, and a 12v pneumatic solenoid.

This is the sequence of events.

1. The audio on pin1 starts the chipcorder and runs for 22 seconds.

2. The 12v solenoid for the pneumatic cylinder on pin3 activates at the same time as the audio, and stays on for the same duration of time as the audio.

3. Everything shuts off at the end of 22 seconds, and there is at least a 30 second pause before it can be triggered by the PIR again.


Seems simple enough to write, but the program I wrote is having issues, so I thought I would ask for your help with a new program, so it works as I would like it to. Thanks for your help. -Dave


PS, Could you also write the same program, only this time use a AP8 in the place of the Cowlacious Chipcorder 2500? I have both, but have never used the AP8 as of yet, and would like to try it, to see how much better it sounds.



JonnyMac

I don't have a Chipcorder 2500 so I don't know how to start it -- I'm working on the assumption that it uses a push-button input; please consult Carl for details.

Here's the Cowlacious version of the program:

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$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  Valve           = PIN3
SYMBOL  Cowlacious      = PIN1


' -----[ 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/reset delay


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

  Cowlacious = IsOn
  Valve = IsOn

  PAUSE 100
  Cowlacious = IsOff                            ' prevent looping

  PAUSE 22000                                   ' adjust for duration

  GOTO Reset


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


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


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



Here's the AP-8 version -- note that the AP-8 uses P7 and you have to modify the ULN; there is a lot of information in our forums about this.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$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  Valve           = PIN3


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

  SEROUT Sio, Baud, ("!AP8", %00, "X")          ' kill audio if playing

  PAUSE 30000                                   ' pir warm-up/reset delay


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

  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)       ' play segment 0

  Valve = IsOn
  PAUSE 22000                                   ' adjust for duration

  GOTO Reset


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


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


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

dullom

Thanks Jon.

The Chipcorder 2500 is an old ISD recorder/player board that I bought a few years ago, probably around 2005. I don't think they even make it any more, but I bought a few of them at the time, so I wanted to use them up. Here's the link to it from Cowlacious http://www.cowlacious.com/SupportDocs/Cowlacious%20ISD%20Recorder-Player%20Board%202005.pdf

Anyway, here's the code I used to trigger it, and turn it off:

SYMBOL Audio  = PIN1 ' OUT1/V+ to audio

Audio = IsOn

Audio = IsOff

The code to trigger the 2500 worked fine, but my main problem was getting my PIR working correctly. The prop kept activating randomly with no movement at all in front of it. So that's why I asked for some help. I'm sure your program(s) will work flawlessly, as always. Thanks again for your help Jon! -Dave

JonnyMac

I have my standard debouncing code in the program -- you should be fine.  That said, the Parallax PIRs (in fact, all low-cost PIRs) can be twitchy.  I have found that the debounce code tends to prevent false starts and cleans up any twitchiness.
Jon McPhalen
EFX-TEK Hollywood Office