Instructions

339 C-Control Pro IDE
© 2013 Conrad Electronic
A 16-bit Timer is needed for the servo steering routines. Is the timer turned off, or is used for other pur-
poses the servo routines will not work.
Parameter
servo_cnt number of possible servos (maximum 20)
servo_interval periodic length (0=10ms, 1=20ms)
ramaddr address of memory block
timer 16-Bit Timer used for servo steering
Mega32: 0 = Timer 1
Mega128 & Mega128 CAN: 0=Timer 1, 1=Timer 3
AVR32: all Timer (0 - 5)
5.22.2 Servo_Set
Servo Functions Example
Syntax
void Servo_Set(byte portbit, word pos);
Sub Serial_Init(portbit As Byte, pos As Word)
Description
Sets the pulse length to steer the actuator arm. The output port is set with the portbit parameter
(See Pin Assignment of M32 and M128).
The sum of all user set pulse lengths should not exceed the period length (see servo_interval para-
meter), otherwise an erratic behaviour could happen. E.g. with 20ms period length, a total of 8 servos can
each be set to a pulse length of 2500µs. To have some safety margin, the sum of the pulse lengths should
be less than the period length for a small amount.
Parameter
portbit bit number of port (see Port Table)
pos pulse length for servo in µsec (500 - 2500)
5.22.3 Servo Example
byte servo_var[30]; // Servo internal variables
// Activation of 3 Servos and stop after 10 seconds
void main(void)
{
// Max. 10 Servos, 20ms interval, Timer 3
Servo_Init(10, 1, servo_var, 1);
Servo_Set(7, 2000); // Servo Portbit 7 2000µs
Servo_Set(6, 1800); // Servo Portbit 6 1800µs
Servo_Set(5, 1600); // Servo Portbit 5 1600µs