November 22, 2024, 08:38:18 AM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


PIR program - need simple assistance

Started by bpenman, October 23, 2007, 01:50:25 AM

Previous topic - Next topic

bpenman

I need a program that uses the prop-1 and a PIR to trigger a solenoid for 1 thousandth of a second, and then wait 15 seconds before being able to be triggered again. I am no good at the language of programming, and any help would be awesomely appreciated. Thanks!

JonnyMac

Are you sure about the solenoid timing?  1/1000 of a second (one millisecond) is very short and I don't think the solenoid will actually open -- you will probably need to adjust the PAUSE statement in the program that handles the solenoid timing.

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


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


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


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

SYMBOL  PIR             = PIN6                  ' SETUP = DN
SYMBOL  Solenoid        = PIN0


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

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


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

SYMBOL  timer           = B2                    ' for PIR debouncing


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

Reset:
  PINS = %00000000                              ' clear outputs
  DIRS = %00000001                              ' set output pins (P0)

  PAUSE 15000                                   ' warm-up/inter-show delay
  timer = 0                                     ' clear for PIR debounce


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

Main:
  PAUSE 10
  timer = timer + 10 * PIR                      ' advance/clear timer
  IF timer < 250 THEN Main                      ' wait for valid signal

  Solenoid = IsOn
  PAUSE 1                                       ' adjust here
  Solenoid = IsOff

  GOTO Reset


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


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


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

bpenman

Thanks Jon! I am using a sprinkler solenoid/valve and it seems that anything longer than a fraction of a second is too long.

bpenman

So, I just tried the program on both of my Prop-1 Controllers with the Parallax PIR, and it is not triggering... not with the PIR anyway. I have the Trainer, and pressing the button gets the program to activate but not the PIR. Is there something I need to do to make this work?

Thanks!

JonnyMac

You need to make sure the PIR is connected properly.  Did you follow guidelines in our PIR doc?
Jon McPhalen
EFX-TEK Hollywood Office

bpenman

I have read and completed the instructions in the documentation, but I am not getting any kind of triggering from the PIR.

bpenman

I now have a new problem... one of my PIRs constantly causes my prop-1 to trigger. What should I do?

JonnyMac

If you're absolutely positive that you're connecting everything correctly you can send the PIR back to us for a replacement.
Jon McPhalen
EFX-TEK Hollywood Office