Arduino and Pololu Micro Serial 8 Servo Controller
With Arduino you can build a lot of cool projects regarding domotics and robotics and manage servo motors is one of the most important stuff to enter in the home automation world.
As we saw in previous articles we can move and manage servos using your own microcontroller but naturally they have a limited number of analog pins.
So, what’s a servo controller? It’s another board that extends your microcontroller with new servo dedicated ports. In this article we’ll see the power of the Micro Serial 8 Servo Controller Kit applied to Arduino Duemilanove.
Watch the video to understand its power…
As i often wrote in my articles i’m not a guru in electronic stuff, i’m an Adobe Flex/Flash Developer, but since i love this new world i bought a lot of devices, servos, sensors, motors, robotics stuff and so on.
So what’s problem? My Arduino Duemilanove boards has only 6 analog ports but I need to connect a lot of stuff!!!! What can I do now if I would like to connect 3 analog joysticks (they use 2 pots to manage 2 axis, so 6 analog ports are required) and other 6-8 servo motors?
The solutions are:
1) buy another board (for example Arduino Diecimila: cost about $50/60 but I don’t like it because it’s too big; buy Phidgets boards or other microcontrollers)
2) buy a servo controller.
I have choosed the second option and I bought a Pololu Micro Serial 8 Servo Controller Kit.
I spent about 2 nights to understand the connections…. the documentation and google don’t provide a lot of explanations for beginners like me ; )
But when I fixed it (and a nice greed LED turned ON to notify me that everything was ok with the servo controller) I spent other time to find the best way to move servo motors by code.
What’s my target? If you have watched the video you understood that you can move and manage servo and motors with a joystick.
My goal are simply create home automation projects or little robots to accomplish some tasks managed from sensors, input devices, wireless or bluetooch.
For example if nobody is at home I would like to automatically close all the windows.
Or use an RFID reader to automatically open the door putting a card near the door, or everything else you have in the mind.
Naturally you can provide data from any kind of input devides (touchscreens, pots, IR remote controls, Wi-fi and Bluetooth devices and so on) and use any kind of servos: i have used six servo HITEC HS-422 (about 20 euro each one) and some cool robotics kit from Lynx Motion (20-40 euro each one) but there a lot of cool and more expensive stuff in the market.
NOTE: i had some problems to manage cheap HITEC servos (< 10 euro - weight < 15grams).
Required Hardware:
- An Arduino (Duemilanove) microcontroller
- Analog Thumb Joystick (but you could use potentiometers, sensors or simply managing movement by wiring/processing code)
- A breadboard
- Pololu Micro Serial 8 Servo Controller Kit
- 6v battery pack
- 1 or more Servo motors (I have used Hitec HS-422)
Connections
HARDWARE: critical stuff and suggestions
You have to exatly follow my pictures to connect your arduino board with servo controller, so check the video and the images I provided but I would like also you pay attention to following stuff:
- In the pictures you’ll see I built a joystick protoboard because I’m using it in different projects. You don’t need to build it and you can use your own input analog device.
Buttons aren’t used in this project.
- You need to supply your servo controller with a 6v battery pack (I spent a lot of hours before understand it ; )
- The connection between Arduino reset pin and the microcontroller reset pin (one of the black wires) is optional but I suggest to do it, so when you’ll reset your Arduino board, you’ll also reset the microcontroller
- Remove the protocol selection jumper from your servo controller.
- Remember to connect each servo ground to the micro controller following my pictures or you will risk to damage them (never happened to me)
THE CODE
Following you’ll find the full-commented code and I think it’s so simple that doesn’t require explanation.
I’m not the creator of the put() and servoSetSpeed() functions. They are the best and easy functions I found using Google and you can quickly reuse them in your own application to set servo speed and position.
<strong>/* Manage 6 servo motors with Pololu Servo controller Read two analog input pins from a joystick (vertical and horizotal axis) and set servo position (from 500 to 5500) in according with the joystick position (from 0 to 1023) The circuit: Check www.fabiobiondi.com/blog for video and images. created 04 december 2009 by Fabio Biondi - http:www.fabiobiondi.com */ const int joyH = 0; const int joyV = 1; void setup()// run once, when the sketch starts { Serial.begin(9600); } void loop() //Main program loop, executes forever after setup() { // Move servo motors connected to Servo Controllers pins: 1, 4 and 5 // in according with the analog joystick value int output = map(analogRead(joyV), 0, 1023, 500, 5200); // Avoid to set servo position > 4500 (but you can modify this condition to fix your needs) if (output>4500) output = 4500; put(1,output); put(4,output); put(5,output); // Move servo motors connected to Servo Controllers pins: 2, 3 and 6 // in according with the analog joystick value output = map(analogRead(joyH), 0, 1023, 500, 5200); // Avoid to set servo position > 4500 (but you can modify this condition to fix your needs) if (output>4500) output = 4500; put(2,output); put(3,output); put(6,output); // Wait 100 ms delay(100); } /* Move Servo */ void put(int servo, int angle) { //servo is the servo number (typically 0-7) //angle is the absolute position from 500 to 5500 unsigned char buff[6]; unsigned int temp; unsigned char pos_hi,pos_low; //Convert the angle data into two 7-bit bytes temp=angle&0x1f80; pos_hi=temp>>7; pos_low=angle & 0x7f; //Construct a Pololu Protocol command sentence buff[0]=0x80; //start byte buff[1]=0x01; //device id buff[2]=0x04; //command number buff[3]=servo; //servo number buff[4]=pos_hi; //data1 buff[5]=pos_low; //data2 //Send the command to the servo controller for(int i=0;i<6;i++){ Serial.print(buff[i],BYTE); } } /* * Set Servo Speed (not used in this sketch) */ void servoSetSpeed(int servo, int speed){ //servo is the servo number (typically 0-7) //speed is servo speed (1=fastest, 127=slowest) //set speed to zero to turn off speed limiting unsigned char buff[5]; unsigned char speedcmd; speedcmd=speed&0x7f;//take only lower 7 bits of speed buff[0]=0x80;//start byte buff[1]=0x01;//device id buff[2]=0x01;//command number buff[3]=servo;//servo number buff[4]=speed;//data1 for(int i=0;i<5;i++){ Serial.print(buff[i],BYTE); } } </strong>
What do you think? Isn’t very cool? I love to see a lot of stuff moving on my desk ; )
Like Adobe Developer usually I only see animations on my screen and naturally I’m already thinking to manage my servocontroller from a touchscreen Flash/Flex domotic application (thinking also to Flash on IPhone next year ; ).
RELATED CONTENT:
- Arduino: manage two servos using a joystick and create multiple movements with the Lynx Tilt Kit
- Arduino: control a LED and one servo motor using a joystick















looks great!
could you comment more about the issues with the cheap servos ? thanks!
I didn’t test a lot them because I got many problems and I immediatly decided to buy better servos : )
Sorry
Leave your response!
Archives
Categories
Blogs
3D ActionScript Adobe AIR Arduino Binding Bitmap Chat Chrome Cocomo ComboBox drawHighlightIndicator drawSelectionIndicator Effects Emitter FLARToolkit Flash Flex Font FullScreen Gmap Google Map HSlider HTTPService Infrared itemRenderer Joystick Loader Papervision Particle PHP rawChildren Servo singleton Skin Skinning Slider Snippet Repo Browser Static TextField TileList Tween URLLoader URLRequest VSlider
WP Cumulus Flash tag cloud by Roy Tanck requires Flash Player 9 or better.