November 22, 2024, 08:28:23 PM

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.


Haunted Mansion Raven-2 servos w/ random movement & LED Eyes on a Prop1?

Started by halloweenrick, January 30, 2009, 07:18:58 PM

Previous topic - Next topic

halloweenrick

Hey Jon and all,
This time I've decided to try my first prop with servos!  (Groans from the audience.)  I've always liked the ravens in the Haunted Mansion ride at Disney World near Madame Leota's crystal ball.  The ones with the red eyes that move and spread their wings. I'd like to attempt to create that on a much less grander scale.  I have a HS-311 HiTec servo that I'd like to have serve as the base movement.  I have a 4" wheel to mount on top of the servo with a servo hub.  I'm using the program in the Prop1 servo direct example and it works great.  Now on to the hard stuff.  I've got these foam birds that weigh hardly anything that I'd like to place on the wheel, and have random movement the whole display time.  No trigger, no PIR, just moving around randomly.  Now I'd like to couple that with a Hitec B-8 micro servo that I've got to make the beak move randomly as well, just open and close.  And for my final request, have the Prop1 power a pair of Red LED's in the eyes, and possibly have it blink randomly? Whew!  A lot to ask for, and I once again beg the Oracle assistance in writing code.  If some of it can't be doable, I completely understand. Thank you for all you guys do for us prop builders.
Rick

JonnyMac

The devil is in the details... you have to define "random" in terms of this prop, e.g., what are the movement limits for the servo, timing between movements (min to max), etc.  RANDOM is a very powerful part of PBASIC programming but it does in fact place a great deal of responsibility on us.

I did an owl program once that randomly moved turned the head, hooted (AP-8) and blinked -- I can probably help you with your program once you define it beyond "random."  ;)
Jon McPhalen
EFX-TEK Hollywood Office

halloweenrick

The base HS-311 servo can only go 90 degrees clockwise, and I'd like to see the base servo move approx every 10-20 seconds. Just enough so the kids can think, " Hey did I see that thing move?"  If we can make the B-8 servo power the beak, I'd like to see that open every 10-20 seconds as well.  The B-8 is also a 90 degree max movement counterclockwise. The LED's I'd like to see blink every 20-30 seconds.   Please let me know what other inforamtion you may need. Thanks again!
Rick

JonnyMac

It's not going to be an easy program so let me think about it a while. 
Jon McPhalen
EFX-TEK Hollywood Office

halloweenrick

Take all the time you need.  I didn't order the 5/40 screws for the servo hub and can't find them locally anywhere, so I've got to place another order.  Thanks!
Rick

JonnyMac

I've got a little X/Y servo mechanism and an LED hooked up and this *seems* to work -- give it a try.  Note, though, that ALL of the variables are used up so adjustments, while they can be made, have to be done so carefully.

' =========================================================================
'
'   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  Eyes            = 2
SYMBOL  Beak            = 1
SYMBOL  Base            = 0


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

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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  BeakOpen        = 170
SYMBOL  BeakClosed      = 130


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

SYMBOL  posBase         = B0                    ' servo positions
SYMBOL  posBeak         = B1

SYMBOL  idx1            = B2                    ' loop controllers
SYMBOL  idx2            = B3

SYMBOL  timer1          = W2                    ' base timer
SYMBOL  timer2          = W3                    ' beak timer
SYMBOL  timer3          = W4                    ' blink timer
SYMBOL  lottery         = W5                    ' random #


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

Reset:
  PINS = %00000100                              ' eyes on
  DIRS = %00000111                              ' set outputs

  posBase = 150
  posBeak = BeakClosed

  timer1 = 1000                                 ' must preset > 20
  timer2 = 2000
  timer3 = 2500


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

Main:
  RANDOM lottery                                ' stir random #
  GOSUB Refresh_Servos


Check_Base:
  timer1 = timer1 - 20                          ' update timer
  IF timer1 > 20 THEN Check_Beak                ' expired?

Turn_Base:
  RANDOM lottery                                ' re-stir
  posBase = lottery // 101 + 100                ' 100 to 200
  RANDOM lottery
  timer1 = lottery // 10001 + 10000             ' 10 to 20 seconds


Check_Beak:
  timer2 = timer2 - 20                          ' update timer
  IF timer2 > 20 THEN Check_Blink               ' expired?

Chirp:
  FOR idx1 = 1 TO 4
    posBeak = BeakOpen
    FOR idx2 = 1 TO 3                           ' 3 x 20ms = 60ms
      GOSUB Refresh_Servos
    NEXT
    posBeak = BeakClosed
    FOR idx2 = 1 TO 3
      GOSUB Refresh_Servos
    NEXT
  NEXT
  RANDOM lottery
  timer2 = lottery // 10001 + 10000             ' 10 to 20 seconds


Check_Blink:
  timer3 = timer3 - 20                          ' update timer
  IF timer3 > 20 THEN Main                      ' expired?

Blink_Eyes:
  FOR idx1 = 1 TO 6                             ' must be EVEN #
    TOGGLE Eyes                                 ' invert eye status
    FOR idx2 = 1 TO 5                           ' 5 x 20ms = 100ms
      GOSUB Refresh_Servos
    NEXT
  NEXT
  RANDOM lottery
  timer3 = lottery // 10001 + 20000             ' 20 to 30 seconds
  GOTO Main


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

' Refreshes servos
' -- uses ~20 milliseconds

Refresh_Servos:
  PULSOUT Base, posBase
  PULSOUT Beak, posBeak
  PAUSE 16
  RETURN

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


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

halloweenrick

Got my 2 servos working great!  Now to hook up the bird and see how it goes.  Thanks Jon!!