November 17, 2024, 06:42:58 AM

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-1 & RC-4

Started by HauntAK, June 26, 2008, 04:57:55 PM

Previous topic - Next topic

HauntAK

I have a Prop-1 w/ a PIR trigger controlling an RC-4.
I need a program to do the following.

When the PIR senses motion I want the Prop-1 to activate the RC-4 turning on my prop for 3 seconds.  After 3 seconds I want the prop to turn off and not be allowed to activate for another 30 seconds.

I have the PIR hooked to P-6 on the Prop-1
I have the RC-4 hooked to the P-7 on the Prop-1
The relay is in K-1 on the RC-4
Baud, A1 & A0 are all off on the RC-4
I have the ULN2803A on the Prop-1

Thanks for you help!!  Let me know if you need any more details.



JonnyMac

Here you go -- this program debounces the PIR and gives you lots of room to grow.  Make sure you head the warning about the ULN2803 as discussed in this thread: http://www.efx-tek.com/php/smf/index.php?topic=130.0

' =========================================================================
'
'   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 BS1}
'   {$PBASIC 1.0}
'
' =========================================================================


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


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


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

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


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

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

SYMBOL  Baud            = OT2400


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

SYMBOL  relays          = B0
SYMBOL   K1             = BIT0
SYMBOL   K2             = BIT1
SYMBOL   K3             = BIT2
SYMBOL   K4             = BIT3

SYMBOL  timer           = B2


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

Reset:
  PINS = %00000000                              ' clear all outputs
  DIRS = %00000000                              ' no direct outputs (yet)

  relays = IsOff
  SEROUT Sio, Baud, ("!!!!!RC4", %00, "X")      ' clear RC-4 outputs

  PAUSE 30000                                   ' let PIR warm-up/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

  K1 = IsOn
  GOSUB Update_RC4                              ' activate relay(s)
  PAUSE 3000                                    ' hold 3 seconds

  GOTO Reset


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

Update_RC4:
  SEROUT Sio, Baud, ("!RC4", %00, "S", relays)
  RETURN

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


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


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


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


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


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

HauntAK

That worked perfectly.  Thanks Jon!!!

You guys know what customer service is!