1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

Flight/Servo Fix Servo driver buffer overflow, was messing up the I2C and altitude readings, now working fine. Servo index used to be 1-8 but the Servo driver was indexing a buffer out of bounds. Changed everything to use index 0-7 for servo outputs.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1061 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-07-11 01:54:43 +00:00 committed by vassilis
parent 3896baa908
commit 9f2a01a78a
3 changed files with 18 additions and 18 deletions

View File

@ -147,7 +147,7 @@ static void actuatorTask(void* parameters)
// Update servo outputs
for (int n = 0; n < ACTUATORCOMMAND_CHANNEL_NUMELEM; ++n)
{
PIOS_Servo_Set( n+1, cmd.Channel[n] );
PIOS_Servo_Set( n, cmd.Channel[n] );
}
// Update output object
@ -269,7 +269,7 @@ static void setFailsafe()
// Update servo outputs
for (int n = 0; n < ACTUATORCOMMAND_CHANNEL_NUMELEM; ++n)
{
PIOS_Servo_Set( n+1, cmd.Channel[n] );
PIOS_Servo_Set( n, cmd.Channel[n] );
}
// Update output object

View File

@ -246,6 +246,8 @@ static void TaskServos(void *pvParameters)
/* Used to test servos, cycles all servos from one side to the other */
for(;;) {
/*xDelay = 250 / portTICK_RATE_MS;
PIOS_Servo_Set(0, 2000);
vTaskDelay(xDelay);
PIOS_Servo_Set(1, 2000);
vTaskDelay(xDelay);
PIOS_Servo_Set(2, 2000);
@ -260,11 +262,7 @@ static void TaskServos(void *pvParameters)
vTaskDelay(xDelay);
PIOS_Servo_Set(7, 2000);
vTaskDelay(xDelay);
PIOS_Servo_Set(8, 2000);
vTaskDelay(xDelay);
PIOS_Servo_Set(8, 1000);
vTaskDelay(xDelay);
PIOS_Servo_Set(7, 1000);
vTaskDelay(xDelay);
PIOS_Servo_Set(6, 1000);
@ -278,10 +276,13 @@ static void TaskServos(void *pvParameters)
PIOS_Servo_Set(2, 1000);
vTaskDelay(xDelay);
PIOS_Servo_Set(1, 1000);
vTaskDelay(xDelay);
PIOS_Servo_Set(0, 1000);
vTaskDelay(xDelay);*/
xDelay = 1 / portTICK_RATE_MS;
for(int i = 1000; i < 2000; i++) {
PIOS_Servo_Set(0, i);
PIOS_Servo_Set(1, i);
PIOS_Servo_Set(2, i);
PIOS_Servo_Set(3, i);
@ -289,10 +290,10 @@ static void TaskServos(void *pvParameters)
PIOS_Servo_Set(5, i);
PIOS_Servo_Set(6, i);
PIOS_Servo_Set(7, i);
PIOS_Servo_Set(8, i);
vTaskDelay(xDelay);
}
for(int i = 2000; i > 1000; i--) {
PIOS_Servo_Set(0, i);
PIOS_Servo_Set(1, i);
PIOS_Servo_Set(2, i);
PIOS_Servo_Set(3, i);
@ -300,7 +301,6 @@ static void TaskServos(void *pvParameters)
PIOS_Servo_Set(5, i);
PIOS_Servo_Set(6, i);
PIOS_Servo_Set(7, i);
PIOS_Servo_Set(8, i);
vTaskDelay(xDelay);
}
}

View File

@ -150,42 +150,42 @@ void PIOS_Servo_SetHz(uint16_t onetofour, uint16_t fivetoeight)
/**
* Set servo position
* \param[in] Servo Servo number (1-8)
* \param[in] Servo Servo number (0-7)
* \param[in] Position Servo position in milliseconds
*/
void PIOS_Servo_Set(uint8_t Servo, uint16_t Position)
{
#ifndef PIOS_ENABLE_DEBUG_PINS
/* Make sure servo exists */
if (Servo <= PIOS_SERVO_NUM_OUTPUTS && Servo > 0)
if (Servo < PIOS_SERVO_NUM_OUTPUTS && Servo >= 0)
{
/* Update the position */
ServoPosition[Servo] = Position;
switch(Servo)
{
case 1:
case 0:
TIM_SetCompare1(TIM4, Position);
break;
case 2:
case 1:
TIM_SetCompare2(TIM4, Position);
break;
case 3:
case 2:
TIM_SetCompare3(TIM4, Position);
break;
case 4:
case 3:
TIM_SetCompare4(TIM4, Position);
break;
case 5:
case 4:
TIM_SetCompare1(TIM8, Position);
break;
case 6:
case 5:
TIM_SetCompare2(TIM8, Position);
break;
case 7:
case 6:
TIM_SetCompare3(TIM8, Position);
break;
case 8:
case 7:
TIM_SetCompare4(TIM8, Position);
break;
}