November 23, 2024, 11:55:01 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.


Servo Doll Head Rotations

Started by jmcatal, September 12, 2011, 10:21:31 AM

Previous topic - Next topic

jmcatal

Hi there, hoping someone can help me.  I am attaching the program that is suppose to use a trigger to make the baby dolls so all 6 turn their heads and follow you through the room.  When I load the prop1 and when I hooked up the dolls the trigger moves the first head about a 1/4 of a turn and that is all that happens.  I tried just to remove the trigger and have the heads repetitively rotate, reset and start every 15 seconds but it didn't work either.  I'm getting nervous now we open in 2 weeks. Any suggestions?

JonnyMac

I don't think there's anything wrong with the program (didn't we demo it with a servo at Midwest?).  I looked at it again and it seems just fine.

I believe the problem is power consumption by the servos.  Check your Prop-1 inventory to see if you have one of the newer Rev E boards.  They're easy to spot as they have a silver box just to the left of the power input jack and below the power switch (this is a self-resetting fuse).  One of the [free!] upgrades with did with that revision is switched to a regulator capable of handling 5A of power.  If you're using an older Prop-1 it's possible that the power used by the servos in the cycle is causing the regulator to shut down which will reset the controller.

Servos consume more power than you can believe, especially as they get near their midpoint (we measured this at Parallax).  With so many people wanting to use multiple servos with the Prop-1 we made the regulator update at the same time we were adding the fuse and a couple other goodies to help improve production.
Jon McPhalen
EFX-TEK Hollywood Office

jmcatal

Yes we did demo it I just couldn't figure out why it wasn't working now.   I will look to see which prop-1 I have it loaded on.   I have both old and new prop-1 so I will try it on a new one tonight.  Thanks.

JackMan

I would have to agree with Jon on the power issue. Powering 6 servos all at the same time is a huge current draw, the voltage regulator is most likely shutting down. If neither Prop-1 will work you can use a seperate 5v power supply for the servos. Here's a simple diagram. Don't connect any of the red servo leads to the Prop-1.

jmcatal

I double checked and I am using the new prop-1 unit.   I only hooked up 2 heads and it would not turn it.   Then I hooked up just 1 head and it turned it very jerkally (is that a word?) but never reset just kept trying to do a full circle.  I am using the extension cable from efx-tek to run and power the servos, is that my problem?  I am at a loss.   Also, i can't figure out how to remove the trigger so they will just cycle thru the program and reset every 15 sec.  As of right now I am only going to have 3 heads per prop-1 turning. thanks.

JonnyMac

September 15, 2011, 08:05:14 AM #5 Last Edit: September 16, 2011, 03:46:48 PM by JonnyMac
It does sound like you have an electrical issue.  That said, we don't know what kind of servos you have and what they're doing, so you may have to use external power as Jack illustrated above.

Here's a variation of your program that skips the trigger section and adds a 15 second delay at the end -- you can use this for testing.  You need to modify two lines (they're indicated in comments) to get back to normal operation.

Code fixed 16 SEP 2011

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


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


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


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

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

SYMBOL  Servo6          = 5
SYMBOL  Servo5          = 4
SYMBOL  Servo4          = 3
SYMBOL  Servo3          = 2
SYMBOL  Servo2          = 1
SYMBOL  Servo1          = 0


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

SYMBOL  Yes             = 1
SYMBOL  No              = 0

SYMBOL  TrOn            = 1                     ' active-high trigger
SYMBOL  TrOff           = 0

SYMBOL  IsOn            = 1                     ' active-high I/O
SYMBOL  IsOff           = 0

SYMBOL  ServoMin        = 60                    ' endpoint 1
SYMBOL  ServoCenter     = 150
SYMBOL  ServoMax        = 240                   ' endpoint 2


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

SYMBOL  servopin        = B2

SYMBOL  pos             = B3
SYMBOL  speed           = B4

SYMBOL  timer           = W4
SYMBOL  delay           = W5


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

Reset:
  PINS = %00000000                              ' all off
  DIRS = %00111111                              ' P0-P5 as output

  FOR pos = ServoCenter TO ServoMin STEP -1     ' move to start position
    FOR speed = 1 TO 5                          ' very slow
      GOSUB Update_Servos
    NEXT
  NEXT

  GOTO Run_Cycle                                ' REMOVE AFTER TESTING


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

Main:
  timer = 0                                     ' reset debounce timer

Check_Trigger:
  GOSUB Update_Servos
  IF Trigger = TrOff THEN Main                  ' check trigger input
    timer = timer + 20                          ' update timer
  IF timer < 200 THEN Check_Trigger             ' check timer

Run_Cycle:
  FOR pos = ServoMin TO ServoMax STEP 1         ' to
    FOR speed = 1 TO 2                          ' slowly
      GOSUB Update_Servos
    NEXT
  NEXT

  FOR pos = ServoMax TO ServoMin STEP -1        ' fro
    FOR speed = 1 TO 2
      GOSUB Update_Servos
    NEXT
  NEXT

  ' GOTO Main                                   ' RESTORE AFTER TESTING

  timer = 15000

Hold:
  IF timer < 20 THEN Run_Cycle
    GOSUB Update_Servos
    timer = timer - 20
    GOTO Hold

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

Update_Servos:
  PULSOUT Servo1, pos
  PULSOUT Servo2, pos
  PULSOUT Servo3, pos
  PULSOUT Servo4, pos
  PULSOUT Servo5, pos
  PULSOUT Servo6, pos


  delay = pos * 60                              ' 10us x 6 servos
  delay = 20000 - delay                         ' update frame
  delay = delay + 500 / 1000                    ' convert to milliseconds
  PAUSE delay                                   ' finish 20ms servo frame
  RETURN


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


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

JackMan

Jon,
       I'm not sure where but I think there might be a problem with this code. I tried both versions with just a single Hitec servo and only get a small movement about every 10 seconds, 4 or 5 times and then nothing.

JonnyMac

To be honest, that was code we developed at a show and I haven't tried it in my office since.  Thanks, Jack, I'll clear my workspace and run it.
Jon McPhalen
EFX-TEK Hollywood Office

jmcatal

I am horrible at explaining what it was doing but that is exactly it except sometimes it just didn't move at all.  Not sure if it will help but the servo info:  lynxmotion HS-422 (57 oz. in.) Standard Servo.  Thanks.

JonnyMac

Jack was right, the problem was in the code -- the the red area of the listing above.  This is one of those subtle errors that can be tough to see, even when looking at it.  There was a line missing that converts microseconds (time used to refresh servos) to milliseconds for PAUSE.
Jon McPhalen
EFX-TEK Hollywood Office

JackMan

That was it.

jmcatal,
      I ran this program with 6 servos on a Rev E Prop-1 and it works fine, trigger works also. Keep in mind this was a bench test and the servos had zero load. I don't know what kind of load your prop heads are putting on the servos but if it's light, you should be OK.