Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To improve flight dynamics, separate the gyro task from the scheduler. #10713

Open
and-sh opened this issue Feb 20, 2025 · 2 comments
Open

To improve flight dynamics, separate the gyro task from the scheduler. #10713

and-sh opened this issue Feb 20, 2025 · 2 comments

Comments

@and-sh
Copy link

and-sh commented Feb 20, 2025

Current Behavior

The gyro task goes through the common scheduler. As a result, with a set frequency of 6400 Hz, the actual frequency varies from 4000 to 6000 Hz. This disrupts the reading of new data and filtering at the gyro frequency.

Desired Behavior

Reading gyro at gyro frequency.

Suggested Solution

void FAST_CODE NOINLINE scheduler(void)
{
    // Cache currentTime
    const timeUs_t currentTimeUs = micros();

//gyro task
static timeUs_t prevGyroDiv,GyroDiv;
GyroDiv=currentTimeUs / GyroTaskmkS;
if(GyroDiv != prevGyroDiv){
 gyroUpdate(void);
prevGyroDiv=GyroDiv;
}

//other tasks

    // The task to be invoked
    cfTask_t *selectedTask = NULL;
    uint16_t selectedTaskDynamicPriority = 0;
    bool forcedRealTimeTask = false;

    // Update task dynamic priorities
    uint16_t waitingTasks = 0;
    for (cfTask_t *task = queueFirst(); task != NULL; task = queueNext()) {
        // Task has checkFunc - event driven
        if (task->checkFunc) {
....

Who does this impact? Who is this for?

Mainly for small drones 5 inch and less.

Additional context

In my case gyro task takes about 15mks and it rather will not affect other tasks behavior .

@and-sh
Copy link
Author

and-sh commented Feb 20, 2025

On the oscilloscope it looks terrible. The frequency became closer to the set one, but the phase is random.
It looks like fifo will have to be done after all

@and-sh
Copy link
Author

and-sh commented Feb 26, 2025

It fly fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant