1
$\begingroup$

I have a Turnigy ESC and I am controlling it from AVR. Now I need to calibrate it to set the range of the input. With a servo tester I managed to calibrate it without any problems, more or less by following the user guide, but when I try to do the same procedure from code, the ESC starts beeping in some confused pattern and then enters programming mode.

My code looks like this:

void calibrate_turningy_esc()
{
    servo_set16(SERVO_RANGE_TICKS);
    for (uint16_t i = 0; i < 10000; ++i)
        _delay_ms(1);
    servo_set16(-SERVO_RANGE_TICKS);
    for (uint16_t i = 0; i < 10000; ++i)
        _delay_ms(1);
    servo_set16(0);
    for (uint16_t i = 0; i < 10000; ++i)
        _delay_ms(1);
}

where +SERVO_RANGE_TICKS is 2.2ms pulse length, -SERVO_RANGE_TICKS is 0.8ms pulse length and 0 is 1.5ms. The timeouts of 10s were measured during the manual calibration with a stopwatch.

I have checked with an oscilloscope that the output servo signal looks the way I would expect it -- 10 seconds of 2.2ms pulses, 10 seconds of 0.8ms pulses and then 1.5ms pulses. Edit: I made a mistake here, see my answer.

Do you have any idea what to change to calibrate the ESC?

$\endgroup$
1
$\begingroup$

So, the calibration code was essentially correct. The problem was in my Makefile dependency code.

For previous tests i used a range from 0.5 to 2.5ms and that was clearly too much for this ESC. I tried to decrease the range to 0.8ms - 2.2ms, but my makefile didn't notice the change and kept uploading the old version ... After a clean rebuild the ESC is calibrated without any problems.

As for the oscilloscope check... I mixed them up :-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.