May 20, 2024, 07:06:30 AM

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.


Garage of Evil Greeter -- JonnyMac Code Update

Started by JonnyMac, September 28, 2008, 01:28:32 PM

Previous topic - Next topic

JonnyMac

Today I got a tech support call for someone using the GOE Greeter code; as this wasn't the first I had a look at the code and have recoded it, EFX-TEK style, so that the problems go away.  You can find the original project here:

http://www.garageofevil.com/projects/tot_greeter.php

Item 1: The ULN is fussy and usually interferes with serial comms to the AP-8 and other boards.  For this reason we always use P7 for serial IO as removing the ULN influence from this pin is easier (see: http://www.efx-tek.com/php/smf/index.php?topic=130.0).

Item 2: We've seen too many customers have problems with false triggers when not debouncing the PIR/trigger input -- our bad for not showing you how to debounce inputs from the beginning.  The update below uses my standard debounce loop that works fine for any active-high input (PIR, mat switch, etc.).

Let me just say for the record that we appreciate GOE and their support of our products.  Their project worked, I'm sure, because they got a little lucky with the ULN installed in the board -- they happened to get one that allows serial comms to work properly (I've had a few, too, but never count on it).  Note, too, that my version has all AP-8 jumpers (Baud, A1, A0) removed.

' =========================================================================
'
'   File...... GOE_Greeter.BS1
'   Purpose...
'   Author.... Garage of Evil
'              (c) 2007 Garage of Evil
'   E-mail.... evildoers@garageofevil.com
'   Started...
'   Updated... 28 SEP 2008 (reformated by Jon Williams, EFX-TEK)
'
'   {$STAMP BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

SYMBOL  Sio             = 7                     ' SETUP = out; no ULN
SYMBOL  PIR             = PIN6                  ' SETUP = DN


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs

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


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

Main:
  timer = 0                                     ' reset timer
  DEBUG "Waiting for TOT", CR

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

  DEBUG "Triggered!", CR

Play_Sound:
  SEROUT Sio, Baud, ("!AP8", %00, "P", 0)

  PAUSE 60000                                   ' delay 60 seconds
  GOTO Main


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


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


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