November 17, 2024, 11:49:51 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.


simple prop trigger

Started by gwarboy2000, May 14, 2008, 12:14:44 PM

Previous topic - Next topic

gwarboy2000

i need a program to simply activate a solenoid when someone walks in front of a sensor.

JonnyMac

The devil is in the details:

1) What kind of sensor? How does it [want to] connect to the Prop-1
2) How long is the output supposed to stay on?
Jon McPhalen
EFX-TEK Hollywood Office

gwarboy2000

its this kind of sensor. it uses the io pins http://www.radioshack.com/product/index.jsp?productId=2906724&cp=&sr=1&origkw=pir+sensor&kw=pir+sensor&parentPage=search. it doesnt matter how long it stays up. maybe 5  or 10 seconds.

JonnyMac

We sell that sensor too (it's made by our friends at Parallax) -- and ours comes with a 12" cable.  You can connect it right to the P6 header; just make sure the P6 SETUP jumper is out or in the DN position.  We have a long cable (http://www.efx-tek.com/topics/ext_cable_68.html) now that allows you to have a bit of distance between the sensor and the controller.

Here's a program that will activate one output for 10 seconds when movement is detected:

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


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


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN (or out)
SYMBOL  Ctrl1           = PIN0                  ' P0 or OUT0


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

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


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

SYMBOL  timer           = B2                    ' for PIR debouncing


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

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

  PAUSE 20000                                   ' let PIR warm-up/reset


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

Main:
  timer = 0                                     ' reset timer

Check_PIR:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 200 THEN Check_PIR                 ' wait for 0.2 sec input

  Ctrl1 = IsOn
  PAUSE 10000
  Ctrl1 = IsOff

  GOTO Reset                                    ' reset everything


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


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


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

gwarboy2000

what if i want to add a cowlacios sound board to the program. also is their any easier documentation on how to write pbasic code. the manuals ive found are kinda hard to understand. also what is the prop 1 trainer used for, like what can it be used for in applications?.

JonnyMac

Adding a Cowlacious audio board is pretty simple: You connect the OUTx terminal of your choice to the trigger input, and the GND terminal to the ground side of the power supply of the Cowlacious board.  By making the output HIGH for about 25 milliseconds you can trigger the Cowlacious board.

PBASIC probably seems a little difficult now because you're new to it -- like anything else, that will pass.  That said, let me check with Parallax (I have a meeting with them next week) to see if we can republish the original BASIC Stamp 1 manual (we'll do it as a PDF) as that is easier to work with than the present manual which covers every BASIC Stamp they have.

Here's an update of your program to trigger a Cowlacious board:

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


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


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN (or out)
SYMBOL  CowAudio        = PIN5                  ' for Cowlacious audio
SYMBOL  Ctrl1           = PIN0                  ' P0 or OUT0


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

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


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

SYMBOL  timer           = B2                    ' for PIR debouncing


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

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

  PAUSE 20000                                   ' let PIR warm-up/reset


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

Main:
  timer = 0                                     ' reset timer

Check_PIR:
  PAUSE 5                                       ' loop pad
  timer = timer + 5 * PIR                       ' update timer
  IF timer < 200 THEN Check_PIR                 ' wait for 0.2 sec input

  CowAudio = IsOn                               ' start audio
  PAUSE 25                                      ' short blip is all
  CowAudio = IsOff                              ' release to prevent looping

  Ctrl1 = IsOn
  PAUSE 10000
  Ctrl1 = IsOff

  GOTO Reset                                    ' reset everything


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


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


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





Jon McPhalen
EFX-TEK Hollywood Office

gwarboy2000

ok thanks. so what is the prop 1 trainer used for? im really confused on it.

JonnyMac

It's for... training.  You can plug it into your Prop-1 (or -2 or -SX) and have six LED circuits, a button input circuit, and a potentiometer circuit for experimenting with.  If you download our Prop-1 Programming Basics presentation all of the programs contained (except one, I think) can be run on the trainer.  This is a great way to play with the Prop-1 without connecting anything else.
Jon McPhalen
EFX-TEK Hollywood Office

gwarboy2000

the program works great, its just the time from when the cylinder goes down the motion takes to long to activate the solenoid again when someone walks in front of it.

JonnyMac

The point of using a programmable controller is that you can make adjustments to suit.  You could reduce the warm-up/re-cycle delay but then you might cause the program too frequently.  You make the call.
Jon McPhalen
EFX-TEK Hollywood Office

gwarboy2000

May 16, 2008, 02:18:13 PM #10 Last Edit: May 16, 2008, 02:46:39 PM by gwarboy2000
it seems like it takes ALOT of movement just to trip it. also the program seems to trip itself automaticly without anyone in front of the sensor. ive tried to remove the sensor and it still repeatedly cycles.

JonnyMac

Make sure you have the P6 SETUP jumper in the DN position so that you don't get false triggering.  It's important no to let input pins "float" -- they should be pulled up or down, depending on the type of input you're expecting.
Jon McPhalen
EFX-TEK Hollywood Office