simplefoc / Arduino-FOC

Arduino FOC for BLDC and Stepper motors - Arduino Based Field Oriented Control Algorithm Library
https://docs.simplefoc.com
MIT License
2.05k stars 526 forks source link

Discuss: feed forward controller implementation #81

Open runger1101001 opened 3 years ago

runger1101001 commented 3 years ago

Discussion in forum here: https://community.simplefoc.com/t/b-g431b-esc1-hoverboard-motor-not-working-with-closed-loop-modes/898/18?u=runger

Do we want to add a feed-forward controller? discuss and schedule implementation if people agree it's worth it.

askuric commented 3 years ago

It is an interesting question! But I think there are two questions here;

  1. do we include feedforward in our control loops
  2. do we add a new way to control the motor where user can set a sequence of target_angle target_velocity target_torque or target_velocity target_torque

do we include feedforward in our control loops

For the first one, I honestly think we should not do it. It is too complicated for now and it would involve a lot of apriori knowledge of the trajectory the user wants to execute. We can discuss this more in detail when we meet the next time. But feedforward term only makes sense if we know the trajectory (angle or velocity trajectory) in advance and we wish to force certain profile of velocity and torque for it. This is a great feature but for now out of scope of the simplefoc.

Now, what we could maybe integrate is a way for users to design their own controllers and link them to the simplefoc.

Controller my_new_controller();

 my_new_controller::do(target, measurement){
 // do some fancy stuff
 // return voltage/current command  
}

void setup(){

  motor.linkController(&my_new_controller());
}

And so that the guys can create their own smarter and more suitable PIDs and control loops.

do we add a new way to control the motor where user can set a sequence angle+velocity+torque

This one I'd say absolutely.

At the moment I see it as an extension of the commander interface. Where the user can set the in adition to the target value, multiple target values.

So instead of setting:

M10.5              # 10.5 rad

the user could do:

M10.5 100 3    # 10.5 rad, 100 rad/s, 3Volts

So then the simplefoc would automatically update the voltage_limit ,current_limit and velocity_limit.

In the velocity mode the use can set:

Angle mode:

Torque mode

What do you think about that?

askuric commented 2 years ago

In the dev branch at the moment the commander was extended wit the new target setting interface. It enables setting the target and limiting variables at once. User can set target angle, velocity and torque at the same time. The values are sent separated by a space.

Example. P2.34 70 2 P is the user defined command, 2.34 is the target angle 70 is the target velocity and 2 is the desired max current/voltage(depending on the torque mode).

Depending of the motion control mode one is using, the commander will expect different number of inputs:

askuric commented 2 years ago

To think about: https://community.simplefoc.com/t/motion-planner-code/2424