You are here

Switching frequency factor 2 lower

11 posts / 0 new
Last post
Elwin
Offline
Last seen: 2 months 6 days ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76
Switching frequency factor 2 lower

Hi Benjamin,

What is the reasoning behind the Switching Frequency in the VESC? I notice that what you get (and therefore also hear) is actually half of the setting you put in. So putting in 30 kHz is actually 15 kHz switching of the mosfets. Is this way of defining it a standard in the space the VESC operates in? I have used various industrial motor controllers and never saw it defined like this. My proposal would be to switch it to the industry standard, such that what you set is what you get.

Kind regards,

Elwin 

benjamin
Offline
Last seen: 14 hours 31 min ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

I defined the switching frequency as the rate at which you alter between the zero vectors as that is how often the modulated voltage can be updated and roughly the frequency that affects the ripple current. When doing HFI the rate between the zero vectors is what is used and when doing V0 and V7 samples that is used in all other calculations too. As the vectors are traversed in the reverse when going from V7 to V0 compared to V0 and V7 there is also a component at the timer frequency that can be heard.

If the "standard" is to use the timer frequency and not the rate between V0 and V7 we can change to that, but that will break old configs and cause some confusion. I slightly prefer keeping it the way it is, but if there are good reasons to change lets go for it. My largest reason to not change it now would be to avoid the confusion and breaking configs.

Elwin
Offline
Last seen: 2 months 6 days ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76

Thank you for the explanation.

Unfortunately somehow it is hard to find a simple and clear picture or statement on what the industrial standard for switching frequency actually is.

However, I do have a picture of a measurement of a single phase of a Siemens S120 drive with the switching frequency set to 8 kHz. What you get is that the IGBT turns on 1 time and off 1 time during the cycle of 1/8 kHz = 125 µs. For the control loops there are indeed 2 output moments, the rising flank and the falling flank. Therefore you can set the current loop frequency to 8 or 16 kHz with the 8 kHz switching frequency.

If you just use the scopes frequency counter on a single phase, it will also tell you it is 8 kHz. Here the picture (the spikes are caused by switching of the IGBTs of the other phases combined with long motor cables):

But I indeed can imagine that changing this now might do more harm than good. Maybe in the meantime we can add a comment in the VESC tool or something. Let me know if this would be a good idea, then I can help come up with a clear description.

"and roughly the frequency that affects the ripple current" That is actually quite interesting, thanks! I took a look at the harmonics caused by the PWM, and found it is quite complex. The harmonics are amplitude and voltage vector direction dependent. When you only have alpha voltage the is no first harmonic at all, i.e. you will not hear the frequency (half of what you set in VESC). There is a large second harmonic, so you will hear the frequency set in the VESC. However, when you have a large amplitude in the beta direction, there is actually quite a large first harmonic, which is what you can hear (for example on a set frequency of 30 kHz you can hear 15 kHz). This is actually non-linear, for small amplitudes (small mod_beta) there is very little first harmonic.

One more thing I noticed during testing, the rotor_lock_openloop angle input is off by 90 degrees if you ask me. In my opinion an angle of 0 should align the voltage with the alpha axis, but it does not because it is injecting in the Q axis with phase angle 0, which actually gives you 90 degrees.

kubark42
Offline
Last seen: 10 months 3 weeks ago
Joined: 2020-07-17 18:46
Posts: 54

I have a similar experience to Elwin. However, both industry and Benjamin's perspective are equally valid.

I feel that aligning with industry is almost inevitable, but that doesn't mean it has to be painful or happen now. The sooner the transition happens the easier it is for people, but fundamentally no math has to change. Just the name we call the math, so as to avoid confusion.

An easy way to do this is to start in the UI by explicitly calling the existing parameter the "Timer frequency". The help dialog-- BTW, shout-out to whoever did such a great job of adding all those help descriptions-- can explain that PWM switching frequency is half "Timer frequency". 

At some point in the future, the UI could be updated to have a Timer setting field and immediately adjacent a text field which shows the PWM switching frequency. This way people start getting used to both, and it's very obvious which one is meant.

At the same time, and perhaps part of some greater push, the firmware could be refactored so that the variable names are semantically clear.

benjamin
Offline
Last seen: 14 hours 31 min ago
VESC FreeVESC OriginalVESC Platinum
Joined: 2016-12-26 15:20
Posts: 490

I think it is best to write a clear explanation and put it in the help text for the switching frequency parameter for now. That is the first place to look if you have doubts. It can even link to this forum thread for people who want to dive deeper. Elwin, it would be great if you can come up with a nice description.

Elwin
Offline
Last seen: 2 months 6 days ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76

Had some time to think about it. Unfortunately the switching frequency term is just very confusing the way it is being used now. When discussion with other about what switching frequency is set, we always have to include whether it is the real switching frequency or the vesc speak switching frequency. My proposal would be to either fix the factor two, or to change the name to something else to avoid confusion (e.g. Vesc frequency?).

kubark42
Offline
Last seen: 10 months 3 weeks ago
Joined: 2020-07-17 18:46
Posts: 54

Other name suggestions:

  • Zero vector frequency
  • Core frequency
  • Trigger frequency
  • FOC frequency
Ironman223
Offline
Last seen: 1 year 9 months ago
Joined: 2018-05-30 17:30
Posts: 3

I was testing my motor on my hardware. while watching PWM pulses on my oscilloscope I found that the frequency of the
pulses are exactly half of the value that was set.

I tried to adjust it by changing the timer ARR in the foc initialization and measurement of resistance, inductance and where new values are fed into ARR of TIM1. also changed the calculation of "dt".

Now the motor doesn't run, the measured resistance and inductance value are also incorrect.

 

maybe FOC_CONTROL_LOOP_FREQ_DIVIDER can be used to correct the difference between sampling frequency and switching frequency ?

Ironman223
Offline
Last seen: 1 year 9 months ago
Joined: 2018-05-30 17:30
Posts: 3

Update.

Tried today updated foc files (doubled switching frequency, FOC_CONTROL_LOOP_FREQ_DIVIDER not modified).

Motor was not running with V0 and V7 sampling. but when i tried sampling in only V0 the motor turned fine.

There were some glitches while running above 10KHz switching frequency.

The resistance and inductance measurements were fine. ( haven't touched their code, their sampling frequency remains 10KHz and 3KHz as those were)

Elwin
Offline
Last seen: 2 months 6 days ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76
Elwin
Offline
Last seen: 2 months 6 days ago
VESC Free
Joined: 2021-09-30 16:41
Posts: 76

To avoid confusion to users and keep the code as is the everything is kept the same, except the name. Now it is called Zero Vector Frequency, which will always be twice the switching frequency of the mosfets.