Wednesday, June 20, 2012

Continuous rotation servo with user defined block

Antonio Lomba, from Galicia, has sent this article, which explains how to use continuous rotation servos with Minibloq and user defined blocks (this is the original post from his blog (Galician): http://www.tecnoloxia.com/index.php/control/224-motor-servo-de-rotacion-continua-con-minibloq.html):

Continuous rotation servos work with small electric pulses. According to the duration of the pulses, the servo rotates clockwise, counterclockwise, or remain stoped. To drive this kind of servomotors is necessary to know it's working characteristics.

For example, for a S35/STD de GWS servo, the manufacturer recommends 0.9 ms pulses to rotate clockwise, 1.5 ms pulses to brake the motor, and de 2.1 ms pulses rotate it counterclockwise. It's also important to control the signal period, which is the total sign time taking into account both the high and the low pulse. The recommended period to obtain the optimal rotation speed is between 16 and 23 ms.


To connect the motor to an Arduino Uno board, we will need to take a look to the colours in the conexion cable, connecting as showed in the following image (brown cable = GND, red cable = 5V and yellow cable for the control pin):
 
The basic programs to control the continuous rotation of the servo both clockwise and counterclockwise (using the digital I/O pin D3) are shown below. The delay times are expressed in microseconds. To do this it was necessary to make a new block (called  delayMicroseconds) and add it to Minibloq. This is because the delay block that comes with Minibloq manages only milliseconds, so it was not possible to program 1.5 millisecond pulses with it:
The delayMicroseconds is a user defined block, which was created using the delay block as the base. In the new Minibloq's Developers Guide we explain, among other tips, how to create this kind of blocks.