Target velocity offset

Hello,
I just started testing SimpleFOC shield 2.03 with Arduino Due.
It works :slight_smile: in velocity close loop mode but I have some issues:

  • There is an offset between target velocity and the actual RPM
  • I have hard time adjusting the PID
    — It does control - keeping up ± 2 Hz on the hall sensors. I was expecting more stable RPM.
    — I can not get the max RPM of the motor -

My setup:
SimpleFOC shield 2.03
Arduino due
Motor: 4 pole pairs, 3 Hall sensors, 3.2ohm phase to phase, 12V power
Load: no load except a comparatively light encoder wheel
Code: I started it with the Velocity motion control sample and i modified it to enable the current sensing and to be able to change the target and PID parameters from the serial interface.

PID config for the best stability:
float new_pid_P = 0.02; // default pid
float new_pid_I = 0.03; // default pid
float new_pid_D = 0.0; // default pid
float new_pid_V_RAMP = 2000; // default pid
float new_LPF_V_TC = 0.00005; // velocity low pass filter time constant

Results with hall sensor input:
Target rad/sec Stabilized @ Stability
100 (15.91Hz x 4 = 63.66Hz) 66.5 ±0.5 Hz
200 (127.32Hz) 131.2 ±0.5
300 (190.98Hz) 194.8 ±1 Hz

Results with independent 10 ppr optical encoder
Target rad/sec Stabilized @ Hz Stability
100 (15.91Hz x 10 = 159.1Hz) 165.5 ±0.5 Hz
200 (318.31 Hz) 327.1 ±0.5
300 (477.46 Hz) 487.3 ±1 Hz

RPM stability was tested with varying the supply voltage 11 to 13 volts.

Can not adjust the RPM higher than ~340 rad/sec. After 360 there is no RPM change

The goal of my project is to achieve the most stable RPM adjustable between 500 and 3600.

I will appreciate any suggestion :).

Hey @orlin!

Nice! I’m interested to hear your thoughts!
But still I’d suggest you to make sure your velocity and angle control works well before using the current control. :slight_smile:

Your low pass filter seems a bit too low in my opinion. I’d expect it to be in a range of 0.005-0.02s.

I’m having rouble understanding the difference in between different numbers in your post. :slight_smile:
What are hertz? Is it rotation per second or interrupt per second?
Did you use your encoder for foc or just as an additional mesurement?

340 rad/sec is around 340rad/s*60/6.28= ~3300rpm.

Could you detail a bit more the data so we can dig into the problem better!

P.s. thanks for the example typo errors I’ll update the code for the next release :smiley:

Thanks for the rapid support !!

I followed the suggested steps - test the sensors, poles…, open loop and then velocity control.
I don’t understand yet how to use current control. Looking at the examples i added to the velocity control example:

InlineCurrentSense current_sense = InlineCurrentSense(0.01, 50.0, A1, A2);

in setup():
current_sense.init(); // initialise the current sensing
current_sense.gain_b *= -1; // for SimpleFOCShield v2.01/v2.0.2
motor.linkCurrentSense(&current_sense); // link the current sense to the motor

But i don’t understand how to use the following for velocity control:
motor.torque_controller = TorqueControlType::foc_current;
and the current PID settings.

The 2 test results were both with hall sensors as foc sensor.
The first group is using one of the hall sensor pins to check the frequency on the scope.
The second group is using an independent (on the motor shaft) 10 slots wheel optical sensor.
The Hz are the readings on the scope at different target velocities.

looks like i miscalculated the conversion. I must have been at max RPM of the motor. This explains why i could not ho higher - thanks!