November 22, 2024, 01:16:01 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.


Programing in a remote reset

Started by goober, June 28, 2008, 04:49:35 PM

Previous topic - Next topic

goober

Is there a way to reset a program with out physically pushing the reset button? I would like to reset my prop with a remote if its had a false trigger. I'm using X10 sensors, remote & a tranciever to opperate prop.

JonnyMac

The only way to force a full internal reset is to cycle the power or press the reset button.  That said, you simulate a hard reset in code and jump to that section if some condition is met.  Remember that the BASIC Stamp clears all variables and the IOs on a reset condition.

Here's a template program where the first bit of code is called Faux_Hard_Reset -- this uses a bit of coding trickery to clear the RAM (all of it) and the IO.  Note that this is the ONLY time I ever consider using internal variable names valid.  This trick works because the BS2 treats its RAM like one big array.

' =========================================================================
'
'   File......
'   Purpose...
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2008 EFX-TEK
'              Some Rights Reserved
'              -- see http://creativecommons.org/licenses/by/3.0/
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated...
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


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


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


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

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


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

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


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

timer           VAR     Byte


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

Faux_Hard_Reset:
  FOR B0 = 25 TO 0                              ' clear RAM
    B0(B0) = 0
  NEXT
  DIRS = $0000                                  ' clear I/O
  OUTS = $0000

Setup:
  OUTS = %00000000                              ' clear all outputs
  DIRS = %00111111                              ' make P0-P5 outputs


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

  ' prop code here

  GOTO Main


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


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


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


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


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


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


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


Jon McPhalen
EFX-TEK Hollywood Office