April 27, 2024, 06:18:33 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Prop-2 Programming Template

Started by JonnyMac, February 12, 2007, 07:36:50 PM

Previous topic - Next topic

JonnyMac

February 12, 2007, 07:36:50 PM Last Edit: October 17, 2009, 10:20:41 PM by JonnyMac
Here's a useful template for keeping your Prop-2 programs organized.  The template includes code for debouncing the input to prevent false starts -- especially important when using a PIR sensor.

' =========================================================================
'
'   File......
'   Purpose...
'   Author....
'   E-mail....
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

Sio             PIN     15                      ' SETUP = UP; no ULN
Trigger         PIN     14                      ' SETUP = DN


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

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

#SELECT $STAMP
  #CASE BS2, BS2E, BS2PE
    T2400       CON     396
    T38K4       CON     6
  #CASE BS2SX, BS2P
    T2400       CON     1021
    T38K4       CON     45
  #CASE BS2PX
    T2400       CON     1646
    T38K4       CON     84
#ENDSELECT

Open            CON     $8000
Baud            CON     Open + T38K4            ' B/R jumper installed


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

timer           VAR     Word


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

Reset:
  OUTH = %00000000 : OUTL = %00000000           ' preset IOs
  DIRH = %00000000 : DIRL = %00000000           ' set outputs (1s)


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

Main:
  timer = 0                                     ' reset timer
  DO WHILE (timer < 100)                        ' wait for 0.1 sec input
    PAUSE 5                                     ' loop pad
    timer = (timer + 5) * Trigger               ' update timer
  LOOP

  ' prop code here

  GOTO Reset


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


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


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


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


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


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