May 15, 2024, 03:12:39 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.


Shakey servo movement with Vixen

Started by datbates, August 25, 2007, 11:43:31 PM

Previous topic - Next topic

datbates

What am I doing wrong I'm using a Keyspan USB to Serial converter connected to my Prop 2 with a trainer and 4 servos connected.  The trainer LEDs work perfectly, but the servos are posessed.  They shake and do odd things like they are not getting refreshed enough.  Servo 1 seems to have a twitch when I move servo 3.  There seems to be some corelation with my programing, but it is questionable.   I think I have set everthing to 9600 baud and 40 ms event time like your sample.  What am I doing wrong?

I switched my Keyspan to compatible mode, but it didn't seem to matter. 

Looking at your Prop 2 stamp code I see that you just wait for SERIN, and it appears that if the data doesn't come fast enough, the servos will not get refreshed.  Could this be my problem?   Is there a way to do multi threading in Basic Stamp so that I can refresh the servos while I wait for data to arrive?  Why do servos have such a short timeout anyway?  Too bad they don't just stay where you put them!  ;)

JonnyMac

Your USB adapter may be hosing you here -- I know it'll cost you $20 (with cable), but I think you'd be better served to use the Parallax USB adapter.  That was developed (by my partner John) because Parallax needed a rock-solid USB adapter for BASIC Stamp modules.  It is.  It passes all signals through the connection; others may not, and because of that you Prop-2 may be misbehaving. 

Before you spend any money, though, double check your Vixen settings to make sure that you're sending frame data every 40 ms or less.

Standard servos your analog circuity that needs constant refreshing (it's an RC circuit that discharges).  The new (expensive) digital servos measure the pulse coming in and then just duplicate it until they get a different pulse width.
Jon McPhalen
EFX-TEK Hollywood Office

datbates

Thanks Jon.  I am still worried because I will eventually not be using USB at all.  I plan to use the TTL in.

I guess what I am worried about is the fact that the SERIN command seems to have no buffer, but it just blocks until it sees ?VXN?.  Is that the case?

If so I assume that when you say your USB adaptor ?passes all signals through the connection," you mean that it is careful with the flow control, which is fine for RS232.  But the TTL connection basically has no flow control (single line), so the Prop 2 is basically guaranteed to miss a lot of commands unless I space them carefully.  And if I don?t transmit them quickly so it can get the servos refreshed I will be in trouble. 

Am I understanding the complexities properly?   How should I resolve this and protect myself from issues?  Can I put a timeout on the SERIN or something so I can go refresh the servos if I run out of time?  I guess I could just repeat the commands over and over again as fast as I can so that it will at least see a full command as soon as possible when it is ready.   

Thanks for your help Jon!!

JonnyMac

Mea culpa, mea culpa, mea culpa.

After getting the program working I apparently "cleaned it up" to the point not working without knowing so.  I replaced a long, verbose list of variables with the STR function -- this, apparently, hosed things.  I just reloaded the program and got the same jerky servos as you (boy was I surprised).  When I changed the program back to the verbose list it started work.

Please accept my apology for the mistake.  I'll test better after future code "clean ups."

Try this version in your Prop-2:

' =========================================================================
'
'   File...... Vixen.BS2
'   Purpose... Simple Vixen interface for Prop-2_8s8d.DLL driver
'   Author.... Jon Williams, EFX-TEK
'              Copyright (c) 2007 EFX-TEK
'   E-mail.... jwilliams@efx-tek.com
'   Started...
'   Updated... 27 AUG 2007
'
'   {$STAMP BS2}
'   {$PBASIC 2.5}
'
' =========================================================================


' -----[ Program Description ]---------------------------------------------
'
' This program serves as a slave interface to Vixen (www.vixenlights.com),
' when using the Prop-2_8s8d.DLL driver.
'
' Connect to PC using the Prop-2 programming port.
'
' Note: Set the Vixen Prop-2 driver baud rate to 9600 (this is the fastest
' practical baud for using the WAIT modifier of SERIN which is required
' to maintain sync with Vixen packets).
'
' Note: The best Vixen Event Period (Tools\Preferences\EventPeriod) is
' 40 ms; periods shorter will cause some packets to be missed by the Prop-2
' while periods longer may result in "rough" servo movement.
'
' Remove the SETUP jumpers from P12..P15.


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


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

RX              CON     16                      ' use programming port

DigOuts         VAR     OUTH                    ' use P8..P15
Servos          VAR     OUTL                    ' use P0..P7

Servo8          CON     7
Servo7          CON     6
Servo6          CON     5
Servo5          CON     4
Servo4          CON     3
Servo3          CON     2
Servo2          CON     1
Servo1          CON     0


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

T2400           CON     396
T9600           CON     84                      ' recommended baud rate

SevenBit        CON     $2000
Inverted        CON     $4000
Open            CON     $8000

Baud            CON     T9600                   ' use 9600!


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

idx             VAR     Byte                    ' servo index

pos1            VAR     Byte                    ' servo position values
pos2            VAR     Byte
pos3            VAR     Byte
pos4            VAR     Byte
pos5            VAR     Byte
pos6            VAR     Byte
pos7            VAR     Byte
pos8            VAR     Byte


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

Reset:
  OUTS = $0000                                  ' clear all pins
  DIRS = $FFFF                                  ' all outputs

  FOR idx = 0 TO 7                              ' center servos to start
    pos1(idx) = 150
  NEXT
  GOTO Refresh_Servos


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

Main:
  SERIN RX, Baud, 40, Refresh_Servos,
    [WAIT ("VXN"), DigOuts, pos1, pos2, pos3, pos4, pos5, pos6, pos7, pos8]

Refresh_Servos:
  PULSOUT Servo1, (pos1 * 5)
  PULSOUT Servo2, (pos2 * 5)
  PULSOUT Servo3, (pos3 * 5)
  PULSOUT Servo4, (pos4 * 5)
  PULSOUT Servo5, (pos5 * 5)
  PULSOUT Servo6, (pos6 * 5)
  PULSOUT Servo7, (pos7 * 5)
  PULSOUT Servo8, (pos8 * 5)
  GOTO Main
Jon McPhalen
EFX-TEK Hollywood Office

datbates

Thanks Jon, I just tried it, and it still didn't work.  I then unplugged all my servos, and plugged them back in and it works fine now.  I am worried that one of my servos wasn't on the pins right...  Sorry!!!  Maybe when you tested yours were plugged in wrong too  ;D

So for your knowledge I tested both the old version and the new version of your code and it seems they both work just fine.

Now for my other question, I read up more about the stamp controller and found that the 40 or 50 in your program is the serial command timeout, so I see now that they will at least get refreshed nicely.   Now if I can just get my other stuff to work! 

Thanks again.  Sorry for the wild goose chase!  I'll stop posting now...  ::)

JonnyMac

I'm glad you got it working.  KC is updating the driver so that it will work at 19.2K and 38.4K -- I think the code posted above might just work at 19.2K which will be very helpful with refresh speed.  The Prop-SX will work at 38.4K.
Jon McPhalen
EFX-TEK Hollywood Office

datbates

John.  HELP!!  I think I have figured out what is causing the shake.  I've got my whole animatronic engineered, and each servo works just fine individually, but when I try to move more than one at a time it resets the prop-2.  I assume my 5 servos (mostly standard and one large winch servo) are drawing waaaay too much power.  How can I increase the power?  I assume I can use the external connection block for a second power supply and cut off my nice connectors I just made and connect there for some of the servos.  Can I jack up the amperage of the primary power supply?   How is this supposed to be done... 

Thanks!  I love the prop 2.  I have my stamp code all custom to give the maximum resolution to each of the servos and limit their movement too.  Can't do that with a standard servo controller.  I also have my audio to serial board working, and my custom software that uses the vixen comunication protocol.  The press comes to see our show Tuesday morning.  Send any positive energy you can my way.

R2... Try to increase the power!!! 

JonnyMac

Dahve,

Sounds like your servos don't want to play nice -- they're sucking more power out of the Prop-2 than the [somewhat beefy] regulator can provide.  You're right, you need to go to external power.  Make sure that you connect the negative side of the external supply to the GND terminal (or one of the Px.B pins) so that you establish a common ground; without this, the servo pulses won't work.

Here's how to connect everything:

Jon McPhalen
EFX-TEK Hollywood Office

datbates

Thanks John.  You are amazing.  Even on a Saturday.  Didn't expect that you had already responded.  Anyway, one more question.  How much power is too much?  I have a 2.5 amp 5 volt transformer for the external supply.   Is that going to blow the ULNs or something worse?  What would be the best?  Thanks!

Also thanks for the diagram, but I just want to make sure since my electronic skills are barely getting by on this, and I am not sure what you mean by "W" and B".  The servos all have red, black and white connectors (yellow on Hitek servos). So on the prop 2 this will look like the following connections on the block connectors:

Prop 2 block connectors:

GND goes to the negative on the external power supply AND all of the servo's black leads.

+5 on the block can go to the positive on the external power supply (as long as I don't flip the prop 2 power switch to position 2) and all the servo's red leads.

OUTX goes to the servo's white/yellow lead where X is the desired output.

Do I get it?

JonnyMac

Dahve,

Have a look at the servo headers on the Prop-2; notice how they're marked W, R, and B?  That's what I meant by that.  Go to a local hobby store and get servo extenders that have a female connection on one end (this connects to the Prop-2), and male connections on the other (this is where you plug in your servo).  Cut the red wire from the female (Prop-2) end and then tie them together; connect his group to the positive side of your external supply.  Connect the negative side of the external supply to the GND terminal (lower right corner of the board).  You might want to use a battery to be safe; perhaps a 6v motorcycle battery or something with similar juice to last the length of your show.

The ULNs are NOT involved; their output is ground or floating, they do not have the ability to provide a valid servo signal. 

Please, be very careful.  If you're not skilled with electronics circuits then get help from a friend that is -- you don't want to damage a $100 controller for being in a rush.
Jon McPhalen
EFX-TEK Hollywood Office

datbates

Sorry Jon I was talking terminal block and you were talking the normal servo connectors.  I just couldn't see how there were different B connectors for each servo, but on the normal connectors that makes sense. 

I will cut the positive voltage wire from each servo and wire them together to the external supply... I already made my own extensions.  Oh, and I'll connect my supply to the GND terminal on the terminal block.

I am not horrible with electronics.  Just on a different page. 

I can't use a battery, I need the show to run for a month or so.   Is 2.5 amps at 5 volts too much for my external supply?

Can the terminal block and ULNs ever be used for servos (just so i understand what they are capable of)?

JonnyMac

You can have too much voltage (you don't), but you can't have too many available amps.
Jon McPhalen
EFX-TEK Hollywood Office

datbates

It works!!   Very nice!  No problem with power now.   Now I have one more question on this issue for the future: 

If I wanted to use the terminal block in the future for connecting servos, is it possible?  I really am starting to hate those little connectors.  ;)  I am thinking if I did that I could simply use a single 5v power supply to power both the prop2 and the terminal block at 5 volts.  This seems like it would look more professional and save me a lot of effort.  Your thoughts?

JonnyMac

It can be done but I would never do it, nor tell any one else how -- it makes the controller vulnerable to serious problems with the V+ line (some will argue with me on this point, but save your breath, that's just my opinion -- and I've been doing this long enough to break a lot of circuits....  ;D ).

You can build custom cables that go onto the servo headers, I do this all the time and they always look neat and clean.  I've listed the part numbers (from Jameco) in a couple posts (search on Jameco).  That is my best advice: learn to build custom pin-header cables.

BTW, I'm thrilled that you got your system working.  I'm going to visit with my partner, John; perhaps there is a way for us to allow an external voltage to be applied to the R pins of the servo headers (this would require an extra connector and jumper on our prop controllers).
Jon McPhalen
EFX-TEK Hollywood Office

datbates

That would be really cool!  Thanks I will stick with 2 power supplies.  I have been building the cables, but they are irritating.   They would be more fun if I was using a real crimper instead of my needlenose pliers  ;D.  Ouch my fingers...