Skip to content
Karim Mansour edited this page Mar 7, 2019 · 2 revisions

Servos

Quick update on how they work

First of all i would strongly suggest that you watch this video first it will explain how the servo works and basically will describe the problems i faced.

the TowerPro Analogue SG90

The servos i am using currently are super cheap analogue micro servos with plastic gears from a company called Tower Pro. You can more information about those servos here.

The Current Setup

I have an Arduino Due feeding the power to both servos and controlling them as the same time. I have some suspicion that this is not the most optimal way as this might cause power fluctuation in the Due. It never happened so far but it is a risk.

Problems faced

I faced several problems with these servos:

  1. The first one was that the Servo library from Arduino assumes the same pulse width to angle for each servo which is completely wrong as you've seen in the video.
  2. The way i am driving the servos is by advancing the horizontal servo by 1 degree then when it reaches 180 i move it back to 0 and increment the vertical one. This might be causing problems as 1 degree could be "still didn't validate this" below what is called the dead band of the servo. Dead band is basically the smallest difference between the PW that the servo decides is enough to move.

Solutions

Independent Servos Driver

I will move to a new setup where the arduino due controlling a PCA9685 which will generate the PWM independently from the due and will also power the servos. The advantage that this chip gives is that it has a constant frequency since nothing interrupts it, has a bigger resolution to set the width of each pulse and can drive multiple servos "16" at the same time. This will give us the precision we need to set each servo to the exact angle we want.

Calibration tables for servos

I will calibrate each servo by creating a table of Pulse Width / Angle and use that table to drive each servo. This will give us the Maximum accuracy we can get out of those servos.

New Scanning Algorithm

To avoid falling in the dead band when we are scaning instead of moving the servos by 1 deg each step i propose that we move it by a bigger number say 10 deg.

As an example imagine the movement of the horizontal servo to scan from 0 to 180. The old way was to iterate from 0 to 180 (0,1,2,3,4,5,6 .... 180). The new way would be to start from 0 and move 10 degrees at a time then come back to 1 and so on so having something like (0,10,20,30 ... 180,1,11,21.. 171,2,12 etc..) this will make sure that we are always moving far away outside the dead band every single time.

New Digital Metal Gear Servos

In case none of the above actually made a difference i can move to more high end servos like the Dynamixel AX-12A. Those servos are used in robot arms and the are supposed to be very accurate. It will also mean that we will have to design a new mount but that i will cover in another page.