You are here

FOC wizard confusion

5 posts / 0 new
Last post
Stupidspencer's picture
Last seen: 3 years 2 months ago
Joined: 2019-06-20 00:06
Posts: 32
FOC wizard confusion


First of all, let me say hello to everybody as this is my first post to this forum although I have been following the VESC project for around 2 years. I have only been using VESC tool for Android along with the new bluetooth 4.0 module. All references I make to VESC tool are for the Android phone version. My hardware consists of 2 original VESC 6.6's from Trampa connected through CAN, and the BLE module. 

I have already run the FOC wizard and got my motor working, but I want to make sure I have given the wizard the correct parameters for optimal operation and a correct speed reading. My motors are not typical; each motor is actually 2 Ninebot scooter in-wheel motors side by side. The stators are keyed to the same orientation on shafts I machined from 4340 steel to accommodate both stators. The rotors are coupled together with an aluminum spacer that orients the magnet poles in line. The mechanical alignment allows me to run 2 motors (with the phase wires connected in parallel) using the hall sensors from only one, and with only 1 VESC. This theoretically doubles the torque output from each wheel with the added benefit of the wheels looking like the double tires on the batmobile! It also takes better advantage of the power capabilities of the VESC6 hardware, which was my original motivation for doubling-up.

I don't know the KV of these motors, but I believe the scooters they came from are rated at 300 watts. However, I also think that number comes from the limits of the original controller because the (double)motor I already set up can draw up to 59 amps according to VESC tool. At 41.7 volts (battery voltage during testing) this works out to 1230 watts per motor. That is not a continuously sustainable current draw, but rather the max surge amp draw that can occur. My battery is custom built with Panasonic NCR18650 cells in a 10S9P configuration giving 27Ah capacity.

When I ran detection on the first motor, I used the following setup parameters:

- Type: Large outrunner​

- Power loss changed to 150W from the default 200 (I was scared of frying motor)

- Motor poles: 15    (this is one setting I'm a little confused about. I will explain below)

- Sensorless ERPM left at default of 4000

- Openloop ERPM left at default of 1000

I am unsure if I should run the detection with "power loss" set to 600. My reason for doing so would be that these motors are designed to run at 300W continuous, and I have 2 coupled together. But after seeing that the E-bike hub motor (a similar motor type) is set to only 75W, the warning message has me scared I will fry the motors if I change the setting that high. I don't know the final effect this setting has on the available power output, but I assume that if the detection can't run the motor at its max safe current, the final power output will also be limited. Am I correct in that assumption? Is this setting asking for the power rating of the motors?

The other thing I'm confused about is the number of poles. The reason I'm confused is that elsewhere in VESC tool (I think it was somewhere in the motor settings page), the number of poles that can be selected can only be changed by factors of 2. But in the detection settings, the number of poles can be changed by factors of 1. My motors have 30 magnets... 15 pole pairs.   Should I set it to 30, or 15? If it should be set to 30, then VESC tool should be changed to only allow this number to be even, like it is elsewhere in VESC tool.

And what is the effect of changing the "openloop ERPM" and "sensorless ERPM" values on the final motor parameters? Does a higher value change the max ERPM output when detection is complete, or does it just make sure the motor can start spinning synchronously during the detection without sensor feedback?

These settings are probably easily recognized and set by a person who has taken an electric motor design course, but I have not. I'm not a dummy, but I'm also not an electronics engineer. I'm somewhere in the middle of the competence scale with electronics. Its a hobby, and I have no formal training. But I do have 35 years or so of experience with repairing and using electronics and automation control systems.

I look forward to sharing pictures of this crazy build when it is complete. It will have independent 8cm swing-arm suspension, hopefully reach 68kph and be mostly silent due to the in-wheel direct drive motors. I want it to exceed a stock Bajaboard G4 in speed and power performance although it is being designed for mostly pavement riding (with the suspension for handling jumps off stairs and curbs and stuff).

Last seen: 1 month 1 week ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

Interesting build. Driving two motors in parallel should work well if they are aligned properly. Would be nice to see some pictures!

Regarding the motor pole setting in the wizard, I had a quick look and it is a bug - it should only allow multiples of two and thus is the number of poles and not pole pairs. That will be fixed in the next version. Thanks for noticing.

Regarding the motor size and settings, the picture you click on will set the values of max power loss, openloop erpm and sensorless erpm as you have seen. They work as follows:

Max Power Loss: This value is used to set the current limit. The detection slowly ramps up a static current vector in the motor to figure out the motor resistance, and then sets the current limit such that the resistive power losses in the motor are at this value under full current. The reason that it is based on the motor size is that the mass of the motor is a good indicator of how much power it can take. Setting the power losses to determine the current limit is easier to get right, as the current that causes a given amount of heating depends on the motor resistance, which can vary greatly based on how the motor is wound; it can have few turns with thick wire (high kv) or many turns with thin wire (low kv).

Openloop ERPM: The ERPM value below which the motor runs on open loop during sensorless operation. Having this value too low can make it difficult to start the motor if the resistance and flux linkage is a bit off (which happens when the motor is warm), and having it too high makes it difficult to start with high inertia or high low speed load. I have determined the default for this value based on trial and error with most motors in my box, and by the fact that most small motors tend to be used on drones and RC cars, which usually don't have so much inertia and or high load when starting; larger motors usually drive some kind of vehicle that has high load when starting. Experimenting with this value on your setup does not hurt. Keep in mind that this value is not used and thus irrelevant when using sensors, unless you set the sensorless ERPM value lower than it which you probably shouldn't do.

Sensorless ERPM:  The ERPM above which sensorless operation is used when using sensors (not used when the motor is sensorless). The observer usually tracks the motor better at high speed than sensors do, and thus give smoother and more efficient operation. It is desirable to switch to sensorless as early as possible in general. The lower the speed is the less the motor is observable, and at some point the observer cannot track it smoothly any more. How low the speed can be depends on how accurate the motor parameters are, and how warm the motor is, as temperature changes the resistance which is very important for tracking at low speed. As with the other value, I have set this one based on trial and error with my motors. Experimenting with it does not hurt. Both Openloop ERPM and Sensorless ERPM can be changed in the FOC settings after the wizard is done.


Regarding the power losses, the rating of the motor can be a bit arbitrary. Usually it can take the power as long as it does not overheat, which is why I'm always using temperature sensors on my motors so that the maximum current is ramped down when the motor starts to overheat. That being said, pushing too much power even for a short time will saturate the motor, and the observer won't be able to track it any more. It will also not increase the torque proportional to the current when it goes into saturation, which makes it kind of pointless pushing way too much current.

Stupidspencer's picture
Last seen: 3 years 2 months ago
Joined: 2019-06-20 00:06
Posts: 32

I have finished the build. I ended up not putting suspension on it because the design complexity was gonna be way to much for a single build. Its harder than you might think to get a setup with full independent suspension to turn when you lean, but not when you go over a bump!

So I ended up modifying the upper part of some old Exkate torsion trucks, and making the bottom part that holds the axles out of some aluminum billets. I also machined the electronics enclosure from a scrap block of aluminum.

But all the details of the build are not what this forum is for. If you want to see pictures, here is the link to my public google drive folder.

The double motors have amazing torque! Too amazing actually. I don't have the means to measure the torque output, but I can say that the board can take me (I weigh 86kg) up ANY hill at top speed if I put the controllers on PID mode. BTW, PID mode is definitely not for an electric skateboard. It works for testing torque availability, but on this board it is a most freightening control method. I reckon this board could take me straight up vertically at full speed if it had enough traction.

Now on to tuning. I have been having some problems with the VESC tuning. One issue is that I am limited to 35km/h. I don't know if this is due to not running a high enough voltage (my battery is 10S9P Panasonic NCR18650 cells), or some parameter in the VESC.  As stated, the motors have ridiculous torque, but I would think the 2 VESC 6+s should be able to spin them faster. Part of the problem is that I don't know what the KV rating of these motors is. Is there a way to calculate it based on physical attributes (winding wire gauge, # of turns, etc) of the motors that I can measure?  I would sacrifice some torque for more speed if there is a VESC parameter that could be tweaked to do so. The motors have 15 pole pairs, so I am only running 14311 ERPM currently in FOC.

The other issue I'm having (the more important one) is in regards to braking. When I increasingly apply the brakes, I hit some threshold where, all of a sudden, the braking force increases drastically. When I hit this threshold, the braking action becomes very choppy and un-smooth. It sounds and feels like the braking action is randomly skipping some motor poles. Also, if I brake even harder, sometimes one of the VESCs faults out and I lose brakes completely on that side for a second, despite having the VESC fault reset time set to 0ms. I have tried messing with regen current, power and scale settings, but nothing helps. The only way to not hit that threshold is to limit the negative throttle endpoint in my transmitter to 15% of full braking. That doesn't give much braking power, and means full speed (35km/hr) to stop on level ground takes well over a hundred feet, so its not a solution. BTW, this occurs regardless of the charge state of the battery. If this was a regen issue, I would think the problem would go away with a more drained battery, but it does not.

I've been wondering, where does the energy go when braking on a full battery with the VESC6? Does the energy just go into the FETs and get dissipated as heat?

I will post the motor parameters detected during setup later today, but I gotta go to work now.

If anybody can help me work through these problems, I would appreciate it greatly.


Stupidspencer's picture
Last seen: 3 years 2 months ago
Joined: 2019-06-20 00:06
Posts: 32

Ok, here are the detected parameters for my dual double motor setup:

VESC ID         97

Motor current  92.82A

Motor R           34.82mΩ

Motor L            65.96uH

Motor flux linkage   16.71mWb

Temp comp     False

Sensors          Hall sensors

VESCs on CAN-bus:

VESC ID         67

Motor current  91.14A

Motor R           36.12mΩ

Motor L            65.50uH

Motor flux linkage  16.90mWb

Temp comp     False

Sensors          Hall sensors

Last seen: 3 weeks 5 days ago
Joined: 2021-10-05 18:56
Posts: 33

Always here ?

fabulous board !

I have the same problem at braking with 2 hoverboards 250W hubs . noisy at hard brake ..

it happend on vesc when I ask more than 20A braking .

on generic chinese ESC , no noise but poor braking .Vesc tent to reach max I braking , and the R and L of these hub motors seem not compatible with that . not found solution yet . but it brake Oui

I think Ichar (mWb/mH) is not enouth high ....