Fast Current control with reverse

General topics and discussions about the VESC and its development.
blezalex
Posts: 10
Joined: 05 Apr 2017, 04:51
Location: US

Fast Current control with reverse

Postby blezalex » 05 Apr 2017, 05:58

I'm working on my self balancing one wheeled board. It works well now, but I had to create my own firmware for VESC as i could not get VESC stock firmware to do theses things:
- Bi-Directional current control with break. Say I set 5amp current for 20 seconds, then -5 amp for 50 seconds. I expect controller to apply breaking force equivalent of 5amp, then accelerate in reverse direction with 5amp power.
- Very fast reaction to current control input. My balancing controller runs at 100hz, ESC needs to be fast enough to control current with that speed
- Control current on all 3 phases. Board needs to maintain balance when motor is halted.


Is there a way to configure VESC to support those? Will VESC 6 support it?

Here is a short video of me riding my board

benjamin
Site Admin
Posts: 280
Joined: 15 Dec 2015, 08:38
Location: Sweden
Contact:

Re: Fast Current control with reverse

Postby benjamin » 05 Apr 2017, 10:08

FOC should support this without problems. The firmware that I'm working on will do a bit better job than the one on github now, but even the current one should work.

Do you have a sensored motor? Are you using FOC? It is essential to use sensors if you want to alternate between full torque in both directions at 0 speed.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Fast Current control with reverse

Postby lizardmech » 06 Apr 2017, 04:56

Can you put your custom firmware fork on github? I have been working on custom hardware for VESC based balancing vehicles but I haven't been able to find anyone familiar with balancing vehicles to work on the software so far. Many other people on another forum have been trying to create controllers for balancing vehicles we were able to collect quite a lot of info regarding how existing designs operate so we might be able to help you.

blezalex
Posts: 10
Joined: 05 Apr 2017, 04:51
Location: US

Re: Fast Current control with reverse

Postby blezalex » 06 Apr 2017, 05:58

I just tried FOC - i'm very impressed by how smooth and quiet motor gets - huge difference from my version of controller.

I have sensored motor with HAL sensors. Here is the link to motor https://www.aliexpress.com/store/produc ... 43206.html.

Looks like the controller is almost solving my problem, but not quite yet.. (possibly some tuning needed)

BLDC mode: I get very strong kick in each direction, almost impossible to balance it no matter how low my PID controller goes. It seems like VESC is attempting to get motor to spin up from halt and so applies more PWM than my balancer is asking for.

FOC mode: works almost perfectly, but seems to loose sync when I'm slowing down on my board. It does not happen always but very often. I feel rapid clicks and pushes. Sometimes it re-syncs quickly enough to maintain the balance but quite often it completely loses torque (or maybe applies it in a wrong direction).
It first i though it may be due to missing 3rd shunt, but seems like same thing happens in PWM mode too, not just in current mode.


BTW: what does current controller do when motor halted and low side with no shunt is active?
BTW2: I did not notice motor advance configuration, how do it set it? in FOC mode in particular..
Last edited by blezalex on 06 Apr 2017, 06:13, edited 1 time in total.

blezalex
Posts: 10
Joined: 05 Apr 2017, 04:51
Location: US

Re: Fast Current control with reverse

Postby blezalex » 06 Apr 2017, 06:11

lizardmech wrote:Can you put your custom firmware fork on github? I have been working on custom hardware for VESC based balancing vehicles but I haven't been able to find anyone familiar with balancing vehicles to work on the software so far. Many other people on another forum have been trying to create controllers for balancing vehicles we were able to collect quite a lot of info regarding how existing designs operate so we might be able to help you.


I have two controllers in my setup - one is VESC, the other is balancing controller. Technically I could use custom app on VESC, but VESC does not have enough I/O pins available for my setup. On top of that, additional controller is very cheap and it is easier to develop these two things in separate.

I'm going to opensource the firmware for balancing controller responsible some time soon. I need to clean it up a bit before I publish it.

Ideally I would love to configure or improve VESC so its firmware works as ESC firmware in my application. It is far more advanced than what I have as ESC firmware.

What do you use as hardware platform for you balancing vehicle? My board with the motor posted above goes up to 13mph, I'm looking for a new, faster motor :)

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Fast Current control with reverse

Postby lizardmech » 06 Apr 2017, 07:12

I'm making my own hardware, it's basically a larger VESC with an IMU and components with 80V maximum voltage as many of the electric unicycles run 60V or 67V. It got delayed a little, it makes more sense to have it set up for VESC 6 firmware, it has 3x in-phase current sense but it isn't taking advantage with them on the old firmware.

I did actually pay someone to write IMU drivers and a kalman filter for VESC 4 but I couldn't find anyone to help write the code to take the filtered IMU data and send it to one of the VESC apps. The person who did the drivers didn't have any motor control or balancing vehicle experience.

You can have a look here https://github.com/votuananhs/bldc/tree ... lectronics the code is self contained in the application folder. I had him release as GPL code so it's all open. I have had it built and running, but I don't understand how to integrate it or write the PID loop for balancing. In theory you should be able to connect a mpu 6050 IMU breakout board via I2C and get it working on a normal VESC 4.1x if you know how to finish the code.

benjamin
Site Admin
Posts: 280
Joined: 15 Dec 2015, 08:38
Location: Sweden
Contact:

Re: Fast Current control with reverse

Postby benjamin » 06 Apr 2017, 09:04

blezalex wrote:FOC mode: works almost perfectly, but seems to loose sync when I'm slowing down on my board. It does not happen always but very often. I feel rapid clicks and pushes. Sometimes it re-syncs quickly enough to maintain the balance but quite often it completely loses torque (or maybe applies it in a wrong direction).
It first i though it may be due to missing 3rd shunt, but seems like same thing happens in PWM mode too, not just in current mode.


Are you using the hall sensors? You could try to increase the sensorless ERPM a bit to run on hall sensors longer before switching to sensorless. Another thing you can try is to experiment with the observer gain as it is not calculated properly for all motors. Try halving or doubling it and see if it makes some difference. Parameter detection and gain calculation is something that I'm about to solve perfectly with the new firmware, so hopefully this won't be as much of a problem in the future.

blezalex wrote:BTW: what does current controller do when motor halted and low side with no shunt is active?


I'm not sure what you mean, but you never end up in a situation where current only flows in one of the low-side shunts, especially not when the motor is halted as this would imply full modulation on that vector giving thousands of amps current until something burns. When running the modulation is never higher than 95%, so there is always a bit of time in the SVM zero vector to sample currents. However, as you have noticed, there are situations when there is little time for the measurement to settle with two shunts only, especially on high modulation, and this is where the VESC6 helps a lot.

blezalex wrote:BTW2: I did not notice motor advance configuration, how do it set it? in FOC mode in particular..


In FOC mode there is no need for a timing advance setting. The reason for having advance from the beginning is that the motor current vector will lag behind the voltage vector because of inductance, and timing advance compensates for that in a very naive way, which simply is to put the voltage vector a bit ahead of the rotor position. In FOC mode, the currents are measured, transformed into a reference frame that rotates with the motor (and thus turn into dc values decoupled from the motor speed) and a PI controller is run on them to align the current vector 90 degrees ahead of the rotor position. You can say that FOC has automatic optimal timing that works across all operating points of the motor.


lizardmech wrote:I'm making my own hardware, it's basically a larger VESC with an IMU and components with 80V maximum voltage as many of the electric unicycles run 60V or 67V. It got delayed a little, it makes more sense to have it set up for VESC 6 firmware, it has 3x in-phase current sense but it isn't taking advantage with them on the old firmware.

I did actually pay someone to write IMU drivers and a kalman filter for VESC 4 but I couldn't find anyone to help write the code to take the filtered IMU data and send it to one of the VESC apps. The person who did the drivers didn't have any motor control or balancing vehicle experience.

You can have a look here https://github.com/votuananhs/bldc/tree ... lectronics the code is self contained in the application folder. I had him release as GPL code so it's all open. I have had it built and running, but I don't understand how to integrate it or write the PID loop for balancing. In theory you should be able to connect a mpu 6050 IMU breakout board via I2C and get it working on a normal VESC 4.1x if you know how to finish the code.


The VESC6 has a footprint for an MPU6050 or 9150, and I'm thinking of adding a driver to the code tree and a quaternion-based filter to get the attitude from the raw values. I have been working on that quite a bit when making my multirotor controller for my phd, so I can probably get it running well without too much effort and make the filtered attitude angles available to apps. If you have all the hardware ready and time to work on it soon I can try to put it in the firmware and give it to you so you can work on it in parallel with me finished the VESC6 release.

lizardmech
Posts: 171
Joined: 19 Jan 2016, 10:54
Location: Australia

Re: Fast Current control with reverse

Postby lizardmech » 06 Apr 2017, 09:40

benjamin wrote:The VESC6 has a footprint for an MPU6050 or 9150, and I'm thinking of adding a driver to the code tree and a quaternion-based filter to get the attitude from the raw values. I have been working on that quite a bit when making my multirotor controller for my phd, so I can probably get it running well without too much effort and make the filtered attitude angles available to apps. If you have all the hardware ready and time to work on it soon I can try to put it in the firmware and give it to you so you can work on it in parallel with me finished the VESC6 release.

I'm just doing PCB layout for a new board with the MCU and IMU now. Hopefully I can get it in the next week or two.

Quick question, since I'm less constrained by PCB size I have 4A gate drivers with an asymmetrical on/off circuit is it likely to be worth the effort over just having a single 4.7R? The same thing with low pass RC filters for analogue signals, are they worthwhile if I can fit them?
Attachments
mosfet.png
mosfet.png (9.58 KiB) Viewed 1118 times

benjamin
Site Admin
Posts: 280
Joined: 15 Dec 2015, 08:38
Location: Sweden
Contact:

Re: Fast Current control with reverse

Postby benjamin » 06 Apr 2017, 09:48

lizardmech wrote:I'm just doing PCB layout for a new board with the MCU and IMU now. Hopefully I can get it in the next week or two.

Quick question, since I'm less constrained by PCB size I have 4A gate drivers with an asymmetrical on/off circuit is it likely to be worth the effort over just having a single 4.7R? The same thing with low pass RC filters for analogue signals, are they worthwhile if I can fit them?


I don't know if you will notice much difference, but if you want to make a slight improvement just having the schottky diodes in parallel with the resistor to conduct when switching off should be enough. I have experienced that most ringing occurs when switching on the FET, so switching it off can be done faster. Another reason for having the diodes is that when going to higher voltage the miller effect will become more significant, which can lead to cross conduction with switching the high-side FET in if the gate isn't pulled low hard enough. I once made a motor driver for rectified mains and had this problem, so I had to add schottky diodes in parallel with the gate resistors for making it work at all.

I don't think adding anything additional to the analog channels helps. Filters also delay signals, and delays can cause more problems than noise in many situations.

blezalex
Posts: 10
Joined: 05 Apr 2017, 04:51
Location: US

Re: Fast Current control with reverse

Postby blezalex » 07 Apr 2017, 04:00

benjamin wrote:Are you using the hall sensors? You could try to increase the sensorless ERPM a bit to run on hall sensors longer before switching to sensorless. Another thing you can try is to experiment with the observer gain as it is not calculated properly for all motors. Try halving or doubling it and see if it makes some difference. Parameter detection and gain calculation is something that I'm about to solve perfectly with the new firmware, so hopefully this won't be as much of a problem in the future.


Than you for suggestions. My motor has max ERPM = 4000. Sensorless ERPM is set to 1000. I also had to set RPM in detection part to 150, otherwise detection fails.

I tried halving and doubling observer gain - i tired up to 4x and 0.25x of detected value - I did not notice any significant improvements. It seems to get only worse.

These "Sync" issues occur at very low speed too.. Please check the video below. Anytime I push load to motor it makes odd noises.


Image


I'm glad new VESC will have pads for 9150. I needed 2 I2C lines, 1 line for buzzer and 1 line for ADC, to interface force sensors on foot pads. Having one more UART is also useful for logging and bluetooth configuration..


Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests