Hi everyone,
I'm currently studying in engineering school and I try to make my own gimbal as the Gimbal Brushless Controller by Martinez. It's just a challenge for me to design my own gimbal, mechanical, PCB and software.
I got some questions that no one can answer around me, so I hope that there are matinez's users who can help me here...
Firstly I made my PCB as martinez I use driver L6234 to drive my motors ans use a MPU6050 to get the angle, the différence is that I use a PSoC instead of ATMEGA... :
To control my motor I made a array of 256 PWM's values (from 0 to 255 =>8bits). I send to each motors's phase a value, dephase of 83values (120°). If I test, my motors turns well...
I get the value of the MPU from I2C and make a "kalman filter light" It takes around 1ms to get my final value x,y and z
Now I would like to make my control, but my tests doesn't work very well.
The PWM frequency is around 31250HZ while I reload the pwm value each 500Hz in interrupt.
In another interrupt, I load my MPU value and make my filter, each 100Hz
I would like to make my PID in my main, but It doesn't work very well, my motor is not smooth or it unstable.
And I'm not sure about my PID, cause my array are INT type, and when I dot my PID I do
I know that I'm not far away from a good result.
So what do you think of my approach and my algorythm?
Should I make my PID in an interrupt, should I make everything at 500Hz?
Thank you for your help
I'm currently studying in engineering school and I try to make my own gimbal as the Gimbal Brushless Controller by Martinez. It's just a challenge for me to design my own gimbal, mechanical, PCB and software.
I got some questions that no one can answer around me, so I hope that there are matinez's users who can help me here...
Firstly I made my PCB as martinez I use driver L6234 to drive my motors ans use a MPU6050 to get the angle, the différence is that I use a PSoC instead of ATMEGA... :
To control my motor I made a array of 256 PWM's values (from 0 to 255 =>8bits). I send to each motors's phase a value, dephase of 83values (120°). If I test, my motors turns well...
I get the value of the MPU from I2C and make a "kalman filter light" It takes around 1ms to get my final value x,y and z
Now I would like to make my control, but my tests doesn't work very well.
The PWM frequency is around 31250HZ while I reload the pwm value each 500Hz in interrupt.
In another interrupt, I load my MPU value and make my filter, each 100Hz
I would like to make my PID in my main, but It doesn't work very well, my motor is not smooth or it unstable.
And I'm not sure about my PID, cause my array are INT type, and when I dot my PID I do
Code:
err=consigne-pitch; //or roll dep
errDif = err - lastError;
lastError = err;
if (err>debIntergr) {
integr=0;
} else {
integr += err;
}
increment=err*Kp + integr * Ki+ errDif * Kd ;
if (increment> maxIncr)
{increment=maxIncr;
}
if (increment< -maxIncr)
{increment=-maxIncr;}
currentStepA = currentStepA - increment; // THE PWM VALUE FOR PHASE 1 MOTOR
if(currentStepA > 255) currentStepA = 0;
if(currentStepA<0) currentStepA =255;
currentStepB = currentStepB - increment; // THE PWM VALUE FOR PHASE 1 MOTOR
if(currentStepB > 255) currentStepB = 0;
if(currentStepB<0) currentStepB =255;
currentStepC = currentStepC - increment;
if(currentStepC > 255) currentStepC = 0;
if(currentStepC<0) currentStepC =255;
So what do you think of my approach and my algorythm?
Should I make my PID in an interrupt, should I make everything at 500Hz?
Thank you for your help