Category Archives: Motor Servo

Controlling Many Servo(s) Using IC TLC5940

by : Antonius (@sw0rdm4n)
http://www,ringlayer.net

Tlc5940 is a 16 channel led driver.  Since this IC has pwm control ability we can use this IC for controlling up to 16 servo(s).

Below is tlc5940 datasheet:
http://www.ti.com/lit/ds/symlink/tlc5940.pdf

TLC5940 pins:

tlc5940pinouts

out0 – out15 pin will be used for pwm controller on each servo. In this tutorial, we will control 5 motor servos using tlc5940 and arduino uno.

Requirements:

  • 1 arduino uno
  • 1 tlc5940
  • 1 half + breadboard
  • 5 resistor 2,2 k
  • male to male jumper wires
  • arduino uno
  • 5 tower pro micro servos

Schematic:

tlc5940_schematic

Actually It’s better to use external power source to power multiple servo.

20141216_061627

 

Here’s the code for arduino:

#include "Tlc5940.h"
#include "tlc_servos.h"
void setup()
{
  tlc_initServos();  
}
void loop()
{
  int i;
  
  for (i = 1;i <= 5; i++) {
    tlc_setServo(i, 0);
    Tlc.update();
    delay(300);
    tlc_setServo(i, 180);
    Tlc.update(); 
    delay(300);
  }
  
}

On success, we can control our 5 servo(s), just like in this video:

Advertisements

Infrared Sensor to Detect Range and Kinect Actuator

Fritzing

rear_front

This is simple and basic guide to detect object using infrared sensor. Hardware requirements : – an arduino or any arduino compatible board ( here I use sduino because it has enough pins to control 2 motor servos) – an infrared sensor – jumper wires (any color doesn’t matter) – 2 motor servo as kinetic actuator (front leg and rear leg)

all

First, plug jumper wires to infrared sensor, here we use sharp infrared sensor. Actually jumper wires color doesn’t matter, but to make it easy, we’ll plug red for 5v, black for ground and yellow for analog input :

ir1

Here we plug red jumper wires to 5v pin on sduino, black jumper wires to ground pin (ground is minus), plug yellow jumper to A5 (analog input pin 5). Plug 2 Servos Next we’ll be plugin 2 motor servos directly to our board using jumper wires, Plug the first motor servo for front leg :

ir2

for analog input we’ll be using pin number 9, for voltage we use 3,3v pin (actually to control a motor servo we can also use 3,3 v pin beside using 5v pin), next we plug the last jumper wire for ground. After plug the first motor, we plug the second motor (rear leg) :

ir3

for analog input, we plug jumper wire to pin 0, for voltage we plug red jumper wire to 5v pin, and the last jumper wire, plug it to ground pin. Actually colors of jumper wire doesn’t matter as long as the arrangement of cable that comes from motor servo plugged correctly with the pins on arduino. Programming The final step is uploading a program to use ir sensor, here’s our code for arduino ide :

/*
simple kinetic actuator using infrared
made by : Antonius (sw0rdm4n)
twitter :  @sw0rdm4n
http://www.ringlayer.net - https://sw0rdm4n.wordpress.com - http://sw0rdm4n.blogspot.com - http://www.indonesianbacktrack.or.id
*/
#include <Servo.h>
int sensorval;
int pos_front_leg = 0;
int pos_rear_leg = 0;
Servo front_leg, rear_leg;
void setup()
{
              front_leg.attach(9);
              rear_leg.attach(0);
}
void loop()
{
               sensorval = analogRead(5);
               if ((sensorval > 200) && (sensorval <300)) {
                           if (pos_rear_leg == 0) {
                                 rear_leg.write(180);
                                 pos_rear_leg = 180;
                           }
                           else {
                                 rear_leg.write(0);
                                  pos_rear_leg = 0;
                           }
              }
              else if (sensorval > 300) {
                          if (pos_front_leg == 0) {
                                front_leg.write(180);
                                pos_front_leg = 180;
                          }
                          else {
                                front_leg.write(0);
                                pos_front_leg = 0;
                          }
              }
              delay(500);
}

Upload that code to arduino board. To test we’ll be using 6 x 1,5 v battery :

ir4

On successfull, if we put any object near the infrared at sensor val range 201-299 the rear leg servo will be moving, if we put any object at sensor val range above 300 the front leg servo will be moving.

Kontrol Motor Servo Dengan Arduino

Fritzing

servo

Kebutuhan Hardware : 1 pc / notebook, 3 kabel jumper (merah, hitam, kuning), kabel usb penghubung pc ke arduino, motor servo

servo1

Di sini saya menggunakan SG90 9G micro servo motor, Hubungkan kabel jumper ke motor servo :

servo3

Kabel servo merah adalah untuk daya (5v), kabel kuning untuk sinyal / pulse dan kabel hitam digunakan untuk GND (ground). Setelah itu hubungkan kabel jumper ke pin2 arduino

servo2 Untuk kabel kuning (sinyal / pulse) yang digunakan untuk mengatur posisi pada motor servo bisa dihubungkan dengan pin apa saja pada arduino yang digunakan untuk analog output. Di sini dari pin nomor 0 sampai nomor 13 bisa kita pakai untuk mengatur motor servo.

servo4

Pada contoh kali ini pin nomor 3 digunakan untuk mengontrol motor servo dengan menghubungkanya dengan kabel kuning, pin GND di atas pin 13 disambungkan dengan kabel jumper hitam, untuk tegangan, tancapkan pin merah ke pin 5V. Setelah itu hubungkan arduino dengan kabel usb ke pc / laptop dan upload program contoh di bawah ini :

/* simple motor servo bipedal race made by Antonius (sw0rdm4n) */ 
#include <Servo.h> 
Servo bipedal; 

void setup() { 
	bipedal.attach(3); 
} 
void loop() { 
	bipedal.write(180); 
	bipedal.write(0); 
}

Upload kode di atas dengan arduino ide. Jika berhasil maka motor servo berhasil kita gerakkan

servo5 Video :