0

Another project complete?

Posted by Chris on Friday, May 15, 2009 in , ,
My hands are shaking as I type this, as I think I've finished yet another project. Yet another? Ok, maybe this is my first, fully-finished, nothing-more-left-to-do project. But I think it's done.

It helps that it's mostly software based: a PIC controller with 12 independently controllable servo channels, which uses EITHER serial communications OR USB.
It also allows you to set the pulse width (the servos I'm working with seem to need a signal anywhere between 0.6ms and 2.2ms wide, to get them to move through the full 180 degrees).
Data is sent to the PIC using two-byte instructions - a letter to indicate which servo number (A-L correspond to servos 1-12, where A=1, B=2 etc.) followed by a number representing the percentage movement required.
So for example, A50 means move servo number one 50%.

Two special instructions are also included:
Y = set min pulse length (where 100=1ms, 60=0.6ms etc)
Z = set pulse length for 100% movement (where 100=1ms, 80=0.8ms)

So in my case, using servos that require a pulse from 0.6 to 2.2ms I set up the controller by sending

Y60

If sending this data via USB, I then poll the 8-byte USB data/io report.
This is because the device, on receiving a USB data "packet" (8-byte data buffer is populated) I set byte(7) of the buffer to zero.
After the device has updated the necessary internal values, it sets this last byte to 0xFF (255 decimal) to say that it's ready for the next packet of data.
So polling this last byte value lets me know at the PC end when the device is ready to receive the next instruction which is

Z160

(after a pulse of 0.6ms, the maximum time before the signal should go low is 1.6ms, making a total pulse length of 0.6 + 1.6 = 2.2ms)

Using this approach, "standard" servo commands can be set, using Y100, Z100 (pulse length 1ms-2ms) but non-standard servos can also be used, by setting the "on" and "off" servo timings. Because different pulse lengths can be used, movement is achieved by sending a servo pin number/letter and the amount of movement required as a percentage (0-100). So to move a standard servo on pin3 through 50% we would use the command

C50

Easy huh?
Steve over at botbuilder.co.uk is working on turning this into a shield/daughter board for the Arduino, so that it can be used to provide up to 14 servo controllers (2 built-in to the Arduino + 12 on the board).

0 Comments

Post a Comment

whos.amung.us

Copyright © 2009 .Nerd Club All rights reserved. Theme by Laptop Geek. | Bloggerized by FalconHive Supported by Blogger Templates.