paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Paparazzi-devel] module period accuracy ???


From: Chris
Subject: [Paparazzi-devel] module period accuracy ???
Date: Wed, 17 Oct 2012 09:15:19 +0300
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121011 Thunderbird/16.0.1

Hi.
I have made some tests using CHDK and a Canon SX230HS and it "almost" works ok but i do
have some small problems.
I want to ask anyone that might know if the module period is accurate enough or it might miss
or skip some cycles especially during intialization of the autopilot.
I have wrote the module code and the chdk script and it works flawlessly in pulse count mode where the camera camera counts the number of pulses and decides what to do but it is a slow process. In this mode module period accuracy does not matter thus it works fine. In pulse duration mode which is very fast my pulses during the autopilot initialization are all over the place but i haven't checked what happens during normal operation, maybe during intialization some things take more time which would explain the inaccuracy. Some times it works fine, other times some pulses get longer like the call to the module's
periodic function (@ 15 Hz) is delayed.
I am now searching of a way to use a spare autopilot timer otherwise there is always the I2C -> PW
converter option using a small AVR (attiny85) or a spare ppm encoder.
Here is the periodic function:

void chdk_periodic(void){

uint8_t x = 0;

if (chdk_command > 0){
// Since this variable is ment for Joystick camera control where the operator // has visual confirmation of each command execution there is no need for a buffer. // If the buffer is completely empty execute the new command else try again...
   for (x=0; x<sizeof(cmd_buffer); x++){
       if (cmd_buffer[x] != 0){
          break;

       }else{ *cmd_buffer = chdk_command; }
   }
   chdk_command = 0;
}

if (cmd_buffer[0] > 0){

   if (command_finished == TRUE){
      pulse_counter = *cmd_buffer;
      reset_counter=CHDK_RESET_CYCLES;
      command_finished = FALSE;
   }

   if (pulse_counter > 0){
      LED_OFF(12);  //LED_ON=Low. LED_OFF=High.
      pulse_counter--;

   }else{
           LED_ON(12);
           if (reset_counter <= 0){
              // Shift left the whole buffer one position
for (x=1; x<COMMAND_BUFFER_SIZE; x++){ cmd_buffer[x-1] = cmd_buffer[x]; } cmd_buffer[COMMAND_BUFFER_SIZE-1] = 0; // set last buffer slot to 0
              command_finished = TRUE;

           }else{ reset_counter--; }
        }
}

return;
}


uint8_t chdk_cmd(uint8_t cam_cmd)
{
uint8_t x = 0;

if (cam_cmd == CHDK_CLEAR_BUFFER){
   for (x=0; x<COMMAND_BUFFER_SIZE; x++){
       cmd_buffer[x]=0;
   }
   pulse_counter = 0;
   reset_counter = 0;
   command_finished = TRUE;

}else{
           // Find an empty slot in the buffer
           for (x=0; x<COMMAND_BUFFER_SIZE; x++){
               if (cmd_buffer[x]==0){ break; }
           }
if(x != COMMAND_BUFFER_SIZE){ cmd_buffer[x] = cam_cmd; } // register the command
     }


return(0);
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]