Commit 55f755ed authored by Pavel Semerad's avatar Pavel Semerad
Browse files

repair servo speed to not be dependent on ppm frame length

parent f09f9c90
*0.6.1 ()
repaired ABS to use cycle length same as before PPM frame length changes
added extra brake channel for throttle brake side
repaired steering/throttle/channel speed to not beeing dependent
on ppm frame length
*0.6.0 (28 Apr 2012)
increased model memories by using FLASH also
......
......@@ -186,7 +186,7 @@ static s16 steering_speed(s16 val, u8 channel) {
// calculate max delta
if (stspd == 100) max_delta = PPM(1000);
else max_delta = PPM(1000) / 2 / (100 - stspd);
else max_delta = PPM(1000) / 2 / 20 * ppm_frame_length / (100 - stspd);
// compare delta with max_delta
if (delta < 0) {
......@@ -207,7 +207,7 @@ static s16 steering_speed(s16 val, u8 channel) {
// check if it is moving from return to turn
if (delta2) {
if (cm.stspd_turn == 100) max_delta = PPM(1000);
else max_delta = PPM(1000) / 2 / (100 - cm.stspd_turn);
else max_delta = PPM(1000) / 2 / 20 * ppm_frame_length / (100 - cm.stspd_turn);
if (delta2 < 0) {
if (max_delta < -delta2) val = -max_delta;
......@@ -245,7 +245,7 @@ static s16 channel_speed(s16 val, u8 channel) {
}
}
max_delta = PPM(1000) / 2 / (100 - speed);
max_delta = PPM(1000) / 2 / 20 * ppm_frame_length / (100 - speed);
if (delta < 0) {
if (max_delta < -delta) val = last - max_delta;
}
......
......@@ -57,6 +57,7 @@ u8 ppm_timer; // timer incremented every 1ms
u8 ppm_start; // when to start servo pulses
u8 ppm_end; // when must last PPM frame end (to not start again before)
u8 ppm_calc_awake; // when to awake CALC task
u8 ppm_frame_length; // last length of ppm frame
......@@ -172,19 +173,19 @@ void ppm_calc_sync(void) {
ppm_calc_len -= ppm_calc_awake;
ppm_calc_len++;
// calculate new ppm_end
ppm_end = (u8)((ppm_microsecs01 + 9999) / 10000);
// calculate frame length and new ppm_end
ppm_frame_length = (u8)((ppm_microsecs01 + 9999) / 10000);
if (cg.ppm_sync_frame) {
// constant frame length
u8 fl = (u8)(cg.ppm_length + 9);
ppm_end += PPM_SYNC_LENGTH_MIN; // minimal frame with SYNC signal
if (ppm_end < fl) ppm_end = fl;
ppm_frame_length += PPM_SYNC_LENGTH_MIN; // minimal frame with SYNC signal
if (ppm_frame_length < fl) ppm_frame_length = fl;
}
else {
// constant sync length
ppm_end += (u8)(cg.ppm_length + 3);
ppm_frame_length += (u8)(cg.ppm_length + 3);
}
ppm_end += ppm_start;
ppm_end = (u8)(ppm_start + ppm_frame_length);
ppm_microsecs01 = 0;
// set new ppm_calc_awake
......
......@@ -48,6 +48,7 @@ extern u8 ppm_values[]; // as bytes for ppm_interrupt and timer_interrupt
extern u8 ppm_timer; // timer incremented every 1ms
extern u8 ppm_start; // when to start servo pulses
extern u8 ppm_calc_awake; // when to awake CALC task
extern u8 ppm_frame_length; // last length of ppm frame
// set actual number of channels
extern void ppm_set_channels(u8 n);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment