November 22, 2024, 05:24:48 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.


Prop-1 4pirs, 2 leds, 1 servo will this work

Started by Dmac, February 25, 2009, 01:27:58 PM

Previous topic - Next topic

Dmac

I just got my prop 1 and found out that I know even less that I thought!   Depressing:(

basicaly i would like the head to rotate to the pir that is triggered and turn on the leds, then rotate back to facing forward

I would like to position my 4 pirs at 90 degree intervails so that is the

pir1 is triggered the sevro will rotate counter clockwise 90 degrees and turn on the leds
pir2 is triggered   looking forward servo default position turn on leds
pir3 is triggered rotate clockwise 90 degrees turn on leds
pir3 is triggered rotate clockwise 180 degrees turn on leds

I do not have my pirs yet and do have the servo moving from my prop 1, and would really appreciate any help!


JonnyMac

You realize, of course, that you're going to have to put "snoots" (tubes) on the PIRs to cut down their field-of-view, right? 

You also realize that you servos only swing 180 degrees (if that) so you're not going to be able to use PIR #4 -- seems like you want the device to turn around backward (not possible). 

Servo processing while monitoring inputs is a little tricky as servos have to be refreshed constantly; give me a little time to think and I'll come up with a 3-PIR version.
Jon McPhalen
EFX-TEK Hollywood Office

JonnyMac

Here's something to start with -- again, this is just a start.

You'll need to arrange your PIRs such that the can see a little wider that 90 degrees and have coverage like this (PIR1 = red, PIR2 = green, PIR3 = blue).



Here's the code that is desinged to move the servos with the PIR. 

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


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


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


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

SYMBOL  Leds            = PIN5
SYMBOL  Servo           = 4

SYMBOL  PIR3            = 2
SYMBOL  PIR2            = 1
SYMBOL  PIR1            = 0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0


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

SYMBOL  sensors         = B0
SYMBOL   P1             =  BIT0
SYMBOL   P2             =  BIT1
SYMBOL   P3             =  BIT2

SYMBOL  pos             = B1                    ' servo position
SYMBOL  idx             = B2
SYMBOL  check           = B3

SYMBOL  delay           = W5


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

Reset:
  PINS = %00000000                              ' clear all
  DIRS = %00110000                              ' set outputs

  pos = 150
  delay = 20000                                 ' let PIRs warm up
  GOSUB Servo_Pause


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

Main:
  sensors = %00000111                           ' assume active
  FOR idx = 1 TO 5
    sensors = sensors & PINS                    ' scan inputs
    PULSOUT Servo, pos
    PAUSE 18
  NEXT

  IF sensors = %000 THEN Main                   ' nothing detected

Align_Servo:
  READ sensors, pos
  GOTO Main


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

' Use in place of PAUSE
' -- put timing in "delay" before calling

Servo_Pause:
  IF delay < 20 THEN SP_Exit
    PULSOUT Servo, pos
    PAUSE 18
    delay = delay - 20
    GOTO Servo_Pause

SP_Exit:
  RETURN


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

' convert sensor inputs to servo position
' -- illegal inputs default to 150 (center)

Sensor_Pos:
  EEPROM  (150, 100, 150, 125, 200, 150, 175, 150)
Jon McPhalen
EFX-TEK Hollywood Office