12 servos controller low cost

 Building a robot with wheels or with legs needs a design completly different. One of the biggest difference is the type and number of motors.

While for a robot with wheels usually 2 or 4 servos or gear motors are enough, when we speak about a robot with legs, the number of motors increases dramatically. It is not uncommon to see a hexapod robot with 18 servos.
A quadrapod robot has usually 8 or 12 servos, depending on the number of joints. Luckily, compared to robot with wheels, usually are not required servomotors with continuous rotation or gearmotors. Standard servos (0-180 degrees) are enough.
Servomotors are driven with PWM and Arduino 2009 or Arduino Uno have 6 PWM pin. And this is a problem. And if you want to use also other sensors using digital pins, the situation is not good, because the Arduino’s digital pins are only 14, and 2 of wich are used for the serial port communication (pin 0 and 1).
It is possible to use the Arduino Mega, with 14 PWM pin, but it is very expensive (50 euros and more).
Searching in internet, I found a low cost chip, using I2C protocol that can drive 12 servos. First good news, the I2C protocol uses only the analog pins 4 and 5. Second good news is that you can use up to 8 chip, so it is possible to drive up to 8×12=96 servos with only 2 analog pins, the 4 and 5. Third good news is that the chip costs about 4 euros and half. A price that can be accepted by every robot builder.
This is the magic chip:

 

 

It is a DIP chip with 20 pins.The chip is made by Hobbytronics (here).  This is the pins schema:

 

This is the pins usage:

VDD = +5 V
Vss = GND
SDA, SLC are pins I2C that are connected to Arduino’s pins 4 and 5 and also connected to the Arduino +5 V using the pull-up resistors. The value is between 1K and 10K Ohm (I used the 3.3k Ohm).
Address1, 2, 3 are the pins that you can use to change the I2C address of the chip(usually not needed, unless you uses more than one chip, in this case it is necessary to differentiate the addresses).
SERVO01 … SERVO11 are pins connected  to the control pin of the servos (the others are connected to +5 V and GND).
I did a test  and I think it works fine.
Here is a short video I made:

 

 

This is the datasheet.

This is the code used in the video.

Below my code:

// I2C servo controller by www.hobbytronics.co.uk
// written by Alegiaco - July 2011

#include <Wire.h>

const int  servoslave_address=40;   // I2C Address of ADC Chip 
int gradServo[12];

void setup()
{

servo12Setup();

}

void loop()
{
moveServo(5,0); // move servo 5 to 0 degrees
delay(1000);
moveServo(5,90); //move servo 5 to 90 degrees
delay(1000);
moveServo(5,180);  //move servo 5 to 180 degrees
delay(1000);

// move servo 4 and 5 to 100 degrees
gradServo[4]=100;
gradServo[5]=100;
moveServoSet(4,5,gradServo);
delay(1000);

// move servo 4 and 5 to 180 degrees
gradServo[4]=180;
gradServo[5]=180;
moveServoSet(4,5,gradServo);

delay(1000);
}

void servo12Setup(){
 Wire.begin();              // join i2c bus (address optional for master)
  // Optionally set mode to standard 
  // – comment out this section if extended mode required
  Wire.beginTransmission(servoslave_address); // transmit to device
  Wire.send(20);             // servo register address 20
  Wire.send(1);              // 1 = extended mode (0-180 degrees)
  Wire.endTransmission();    // stop transmitting 
  delay(1);
}

void moveServo(int numServo, int deg) {
    Wire.beginTransmission(servoslave_address); // transmit to device
    Wire.send(numServo);               // servo register to start from
    Serial.println(numServo);
    float degre=((deg/180.0)*255.0);    // transform in format compatible with servo controller
    int degree=int(degre);
    Wire.send(degree);           // send 12 bytes of data
    Wire.endTransmission();    // stop transmitting 
    delay(1);                  // waits
  } 

void moveServoSet(int numServoStart, int numServoEnd, int valServo[12]) {
    Wire.beginTransmission(servoslave_address); // transmit to device
    Wire.send(numServoStart);               // servo register to start from
    for (int j=numServoStart;j<=numServoEnd;j++) {
      float degre=valServo[j]/180.0*255.0;
      int degree=int(degre);
      Wire.send(degree);           // send 12 bytes of data
      }
    Wire.endTransmission();    // stop transmitting 
    delay(1);                  // waits 

    }

Tags:

Home made Vacuum Gripper

 

 

This gripper uses an inexpensive syringe as the vacuum source. A gripper is the final part of a robot and usually is used to grab an object. It is also called “end-effector” and can be of different kinds: magnet, clamp, vacuum, welding electrode. But there are many others.
I thought to make a gripper wich can hold the things and carry them around. The gripper approaches the object to the suction cup, it create a vacuum and the object remains attached to the suction cup. At this point it can moved where you want. Eliminating the depression the object falls for gravity.The gripper will pickup any small light object that has a smooth exterior finish. On the market there are very few solutions that are affordable for a hobbyist. Some components of Lego or Fischertechnik but they cost a lot of money.

The solution I present is based on an idea from Lynxmotion and it is very cheap. The gripper uses a simple and inexpensive servo (in my case the Futaba S3003 a) that costs around 10 euros. The other things are: a rectangle of PVC foam, a pipe and a connector for micro-irrigation that cost a few cents and a 20 cc syringe which costs about 10 cents. Some screw and clamps. The suction cup is made from an arrow. Having a baby has advantages, such as I can reuse his toys! We are quietly under 15 euros, an interesting result for a device of this type.
Surely we can not define the gripper as a force of nature, basically using a simple syringe and a servo to go up and down, but does its job. It can hold comfortably 200 grams for a long time.
There are no particular complications, mechanical or electronic, so I leave the word to photos and video. Note that the cutting of PVC is made with a cutter and the holes are made on the PVC with a screw.

 

 

 



Tags:

Arduino and real time charts in Excel

One of the most important things in the robot design is the possibility to check and control the values feeded by the analogic sensors, i.e. accelerometers, gyros, IR sensors.
In order to view the sensor values you can use the Serial Port that can be displayed in the Serial Monitor inside the Arduino IDE environment.
But it isn’t possible to show charts or save the data read from the sensors.
There are several software that allow to show the graphs derived from the sensors data, and I published in the past a tutorial (here).
Usually you use Processing or similar language that require always to write some code. You have to write code to change the charts or to implement new lines in the graphs.
I thought that the ideal situation would be to use a software that everyone knows: Microsoft Excel.

If it were possible to use Excel to receive the data from the serial port, it would be easy to make very nice and user friendly charts.
I searched in Google and i found a sw that allows easily to view the serial port values in Excel.
The sw is made by a competitor of Arduino, Parallax, the company that sells the Boe-Bot and the Propeller, wich are in direct competition with Arduino.

The sw is called PLX-DAQ and it is a free software. You can download it here. It works only in Windows, sorry.
In practice it is a little sw in VBA that adds some features to Excel to receive and elaborate real time data. If the data are in Excel it is also possible to save them in a file and it is possible to use the amazing function library already present in the spreadsheet software. The documentation about PLX-DAQ is complete and clear.

The PLX-DAQ takes commands in uppercase and every data row have to end with a ‘carriage return’. The serial port speed required by PLX-DAQ is particular, because it derives from Parallax world. In any case the rate is from 9600 bit/sec to 128.000 bit/sec. The speed of 128.000 bit/sec works fine in the Arduino!!

The main commands are:

  • LABEL used to define the column headings. The command format is:  Serial.println (“LABEL, INT_COLUMN”);
  • DATE, TIME that allows the serial port to send data to Excel. The first field is always TIME, then the fields of interest (val). The command format is:  Serial. print (“DATE, TIME,”);  Serial.println (val)
  • ROW, SET, k,  allows you to define the next line to write. It is useful if you want to plot n data and then go back to first row and cycle. For example, you can plot 1000 data on the chart and then start again from the first position, in order to avoid a graph too large. The command format is: Serial.println (ROW, SET, 2) put the cursor in the second line next step.

Here’s an example that shows Excel function sin (x).

The Arduino code:

 

int x = 0;
int row = 0;
void setup() {
  Serial.begin(128000); // opens serial port, sets data rate to 128000 bps
  Serial.println("CLEARDATA");
  Serial.println("LABEL,Time,x,sin(x)");
}

void loop() {
  Serial.print("DATA,TIME,"); Serial.print(x); Serial.print(","); Serial.println(sin(x*PI/180));
  row++;
  x++;
  if (row > 360) 
   {
    row=0;
    Serial.println("ROW,SET,2");
   }
  delay(100);
}

 

PLX-DAQ enable a more complex interaction with Excel. It can take the cell values from Excel, it can read and write check box. You can see the PLX-DAW documentation for other details.

Tags: , ,