November 23, 2024, 08:01:34 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.


1st Attempt - Prop-1 program

Started by deadhaunts, August 23, 2009, 01:09:40 AM

Previous topic - Next topic

deadhaunts

I originally was going to use the VMusic, but swithced to the Cowlacious sound board on Jon's advise that the VMusic sucks.
Here is what I am attempting to do:

1) turn on a light, sound and popup using PIR sensor
2) activate the pop up (stay up for a period of time)
3) Activate the sound using Cowlacious board (CAR/P300)
4) reset

I've taken previous code written by Jon and modified it the best I can.  Will this work? I don't have the board yet to test it out.

Thanks,


File...... PopUp_Light_CapAudio.bs1
'   Purpose...
'   Author....
'   E-mail....
'
'
'
'   Started...
'   Updated... 22 AUG 2009
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' -- P7 and P6 SETUP jumpers need to be in the UP position
' -- use P5 for CapAudio
' -- use P4 for (active-high) trigger (PIR, mat switch, etc.)



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


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

SYMBOL  RX                    = 7                            ' SETUP = UP, no ULN
SYMBOL  TX                    = 6                            ' SETUP = UP, no ULN
SYMBOL  CapAudio        = PIN5                       ' white->OUT5, black->GND
SYMBOL  Trigger            = PIN4                       ' MUST HAVE ULN

SYMBOL  PopUp            = PIN1                       ' use V+/OUT1
SYMBOL  Light              = PIN0                        ' use V+/OUT0


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

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

SYMBOL  IsUp            = 1
SYMBOL  IsDown       = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  Baud           = OT2400


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' preset IOs (all off)
  DIRS = %00111111                              ' make P0-P5 outputs

  PAUSE 1000                                          ' let CAP initialize


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

Main:
  DEBUG "Ready. "
  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

  DEBUG "Playing...", CR
  GOSUB CAP_Start 
  PAUSE 2000                                          ' adjust for sound

  Light = IsOn
  PopUp = IsUp

  Light = IsOff
  PopUp = IsDown

  PAUSE 20000                                     ' retrigger delay
  GOTO Main


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

CAP_Start:
  CapAudio = IsOn                               ' pull OUTx low
  PAUSE 250                                        ' hold for CAP debounce
  CapAudio = IsOff                              ' release OUTx
  RETURN






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


JonnyMac

Your program compiles but it will not work as you want.  The reason is that you have no delay between activating the outputs and then de-activating.  I started with a clean template and recreated your program for the CAP board.  I also adjusted the CAP start timing pulse -- I have an older board than needs a long pulse; you won't.

Time to order a Prop-1 starter kit so you can start experimenting -- the only real way to learn is with hardware in your hands.


' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2009 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 23 AUG 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  CapAudio        = PIN5                  ' use V+/OUT5 to V-Trig
SYMBOL  PopUp           = PIN1                  ' use V+/OUT1
SYMBOL  Light           = PIN0                  ' use V+/OUT0


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

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

SYMBOL  IsUp            = 1
SYMBOL  IsDown          = 0

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' preset IOs
  DIRS = %00100011                              ' set output pins (1s)


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

  GOSUB CAP_Start                               ' start audio

  Light = IsOn
  PopUp = IsUp

  PAUSE 2000                                    ' adjust for audio

  Light = IsOff
  PopUp = IsDown

  PAUSE 20000                                   ' retrigger delay
  GOTO Main


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

CAP_Start:
  CapAudio = IsOn                               ' pull OUTx low
  PAUSE 50                                      ' hold for CAP debounce
  CapAudio = IsOff                              ' release OUTx
  RETURN

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


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

deadhaunts

Thanks.  It will take a little time for me to get up to speed.  I appreciate the support. 

JonnyMac

As I said before, having actual hardware on hand makes a difference and the starter kit has what you need.  In fact, this program will run with the Prop-1 Trainer (part of the kit) installed and you would have seen the "blip" to the audio board on P5 but probably wouldn't have seen the outputs on P0 or P1 (if you did, it would have been just a super-fast flash).  This would have lead your right to the problem.
Jon McPhalen
EFX-TEK Hollywood Office

deadhaunts

Thanks again.. I have the prop-1 trainer.  Didn't know I could use that to check this.  Now I know. Thanks.