Instructions

337 C-Control Pro IDE
© 2013 Conrad Electronic
// Power on -> SD-Card
Port_WriteBit(14,1); // EN2 (PB.6) +5V
AbsDelay(50); // 50ms Pause
// SD-Card Fat init
SDC_Init (fat);
// Create a new file folders
SDC_MkDir("0:/CC-PRO");
// Does the file already exists?
// If the file is not created
res=SDC_FOpen(fil, "0:/CC-PRO/test.txt", FA_READ|FA_WRITE|FA_OPEN_EXISTING);
if(res!=0)SDC_FOpen(fil, "0:/CC-PRO/test.txt", FA_WRITE|FA_CREATE_ALWAYS);
// Writes to a text file
buf= "Hallo... 123!\r\n";
SDC_FWrite(fil, buf, Str_Len(buf), bytes_written);
SDC_FSync(fil);
// File is closed
SDC_FClose(fil);
}
5.22 Servo
RC servos are composed of a DC motor mechanically linked to a potentiometer. Pulse-width modu-
lation (PWM) signals sent to the servo are translated into position commands by electronics inside
the servo. When the servo is commanded to rotate, the DC motor is powered until the potentiometer
reaches the value corresponding to the commanded position. The servo is controlled by three wires:
ground (usually black/orange), power (red) and control (brown/other colour). The servo will move
based on the pulses sent over the control wire, which set the angle of the actuator arm. The servo
expects a pulse every 20 ms in order to gain correct information about the angle. The width of the
servo pulse dictates the range of the servo's angular motion. A servo pulse of 1.5 ms width will set
the servo to its "neutral" position, or 90°. For example a servo pulse of 1.25 ms could set the servo
to 0° and a pulse of 1.75 ms could set the servo to 180°. The physical limits and timings of the servo
hardware varies between brands and models, but a general servo's angular motion will travel some-
where in the range of 18 - 21 and the neutral position is almost always at 1.5 ms.
Connection to C-Control Pro