thiemar / vectorcontrol

Vector control (FOC) firmware for the S2740VC and PX4ESC 1.6.
MIT License
55 stars 33 forks source link

Motor starts and stops with Pixhawk 1.6 ESC with constant setpoint #12

Open CarlOlsson opened 8 years ago

CarlOlsson commented 8 years ago

The ESC communicates with the GUI but when the setpoint is set to something higher than approx. 30 the motor starts and stops. @bendyer From the plots, could you indicate what is wrong?

11

12

13

We built the fw using gcc 4.8.3, the git hash is 544c8 and the binaries are in the ESC_bringup Drive.

bendyer commented 8 years ago

Are you still using the 0.021 Ω motor? If so, the current sense measurements at the very start of spin-up look about right; it's getting around 5 A from an applied voltage lower than 0.2 V, so it's definitely well under the 0.1 Ω it estimated during startup.

Current offsets are also minimal, so overall the charts are looking pretty good, but the motor is stopping because the estimator loses track of the rotor position (you can see it starting to slip when you get the noise in the current chart).

For reference, on the "Current draw" chart, red is the current setpoint (i.e. the target torque value), blue is the D current, and black is the Q current. The inner control loop tries to keep the D current at zero, and the Q current at the setpoint; when you see oscillation around those points, either you have a lot of current sense noise, or the estimator is losing sync.

The output of the inner control loop is shown on the "Voltage" chart; the D and Q voltages are blue and black respectively.

CarlOlsson commented 8 years ago

Yes we are still using the 0.021 Ω motor. Thanks for the explanation of the labels etc.

Looking at the getting started guide we will try again with adjusting the gain, or do you have any other input on how to proceed? What kind of logs would be most interesting for figuring out if it is an HW, SW or configuration issue?

bendyer commented 8 years ago

This is a measurement problem, so I don't think any parameter changes will be useful. I expect it's related to current shunt sample timing during the resistance and inductance measurement, since that was the hardest part to get right during the porting process; it's entirely possible it's not as robust as it needs to be for the Pixhawk ESC 1.6 hardware.

bendyer commented 8 years ago

In 68e34de I have introduced per-board motor parameter measurement configuration, and adjusted the PX4ESC's configuration to improve its measurement performance. I did not see the specific issue you had with the motors I'm using, but did see similar issues which arose from poor measurement accuracy.

The new parameters increase measurement currents quite significantly in order to overcome current shunt measurement noise, so you should see better results.

One other point is you may need to reduce the gain to 0.5–0.75 and the braking to 0.2–0.5 to improve stability during significant step changes in throttle.

CarlOlsson commented 8 years ago

Hi Ben, thanks for the update! Unfortunately we still have the same problem, see plots below:

The following plots are for constant setpoint (i.e. we do not start and stop intentionally) and different parameter configurations: constant1

constant2

constant3

If we set the setpoint to 10 the motor does not stop. Here is a plot from such a case: working_setpoint_10

And here is a plot of rpm estimation with motor not spinning

motor_still_rpm_estimated_strange

bendyer commented 8 years ago

Thanks @CarlOlsson, those charts provide the information I need to continue investigating.

CarlOlsson commented 8 years ago

No problem! Just ping us if you want any other logs etc!

bendyer commented 8 years ago

I have been testing using a Scorpion S3026-II 790 Kv, which has reasonably similar specs to the Hacker A40-14S V2 you've been using.

I was able to reproduce the measurement issues you've seen, as well as the starting/stopping behaviour, which is due to a loss of sync during the sudden change in target voltage when it comes out of the initial speed ramp.

Here are some changes which significantly improve performance in my tests: https://github.com/thiemar/vectorcontrol/tree/pixhawk_esc_bringup

Please try them out and let me know how you go. My suggested parameters are:

Current limit: 12 A Voltage limit: 12 V (for now) Acceleration limit: 0.25 V Bandwidth: 50 Hz Gain: 1.0 Braking: 0.2

CarlOlsson commented 8 years ago

Preparation:

Results when running the motor with different setpoints:

Some plots: Setpoint 10: setpoint_10

Setpoint 20: setpoint_20

Setpoint 30: setpoint_30

Setpoint 50: setpoint_50

Setpoint 70: setpoint_70

Setpoint 100: setpoint_100

Setpoint 300: selection_300

We tried increasing the maximum current and voltage but with the same qualitative behaviour

mhkabir commented 8 years ago

@bendyer @CarlOlsson I'm trying to bring up a Pixhawk ESC 1.6 with some Turnigy motors. (http://www.hobbyking.com/mobile/viewproduct.asp?idproduct=38456)

I'm facing the exact same issues. I'm on the pixhawk_esc_bringup branch.