Q on PWM frequency, processor power and resolver signals

Post Reply
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Q on PWM frequency, processor power and resolver signals

Post by Pete9008 »

Hi,
I'm starting a new project converting a Smart Roadster to electric power and have spent a fair bit of time reading everything I can find but have been left with a few questions. During my reading this site has proved the most useful so hopefully this is the right place to ask them?

My current plan is to use a Prius Gen3 Inverter with the Heubner controller software driving a Mitsubishi Outlander rear diff/motor.

1. The motor has 5pole pairs and with the wheel size I'll be using needs to spin up to its max rpm of 9600. If my understanding is correct this means I'll need a commutation frequency of 800Hz ( (9600 *5)/60 ). The recommended PWM frequency for the Prius inverter is 4.4KHz giving only 5 cycles per commutation, this seems a bit low? In real life is this enough or should I be planning on using a higher PWM frequency? If higher what frequencies can the FOC software cope with?

2. I think I'm going to do a custom board so that I can integrate some extra interfaces and features and noticed that there is a branch of the libopeninv ported to the STM32F4 family. Is there any benefit in using a STM32F405 in place of the usual STM32F103 (they appear virtually pin compatible) to provide a bit more headroom for higher PWM frequencies and provide hardware floating point or is the 103 more than enough?

3. The resolver input looks pretty critical to operation of the FOC software. If I've understood correctly the rotor position is measured based on a single pair of readings from the sin and cos inputs. I assume it's done this way to give the lowest possible latency on the measurement but doesn't it make it sensitive to electrical noise? Would it be worth adding some hardware bandpass filters to the sin and cos inputs centred on the resolver drive frequency or has it been found that with careful wiring and screening it isn't a problem?

Thanks in advance,
Pete
User avatar
johu
Site Admin
Posts: 5685
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Q on PWM frequency, processor power and resolver signals

Post by johu »

1. The control loop frequency is fixed at 8.8 kHz while the PWM frequency can be 4.4 (2 control loops per period, the downcounting period can be changed), 8.8 (1 loop per period) or 17.6 kHz (1 loop every other period)
2. The F1 is loaded about 35% with the current code
3. You do have a point and I do multiple samples for everything BUT the resolver. Reason is that resolver is read with injected channels that can only fire once. Timing is very critical as the resolver signal is amplitude-modulated and must be read at carrier peak. It is not a practical problem, jitter is about 1° with screening (CAT5e Ethernet cable is sufficient)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Q on PWM frequency, processor power and resolver signals

Post by Pete9008 »

Thank you, that all makes perfect sense.

Is there any general rule of thumb for commutation speed vs PWM frequency?

I had incorrectly assumed that the control loop ran at PWM frequency and so was worried that load would increase if the PWM frequency increased. With 35% load the F1 looks like the best choice and I'll stick with it.

Two further resolver questions if you don't mind. Firstly regarding reading at carrier peak, how do you compensate for the delay through the 3pole filter that is used to convert the square wave to sin? Secondly with the encoder carrier at 4.4kHz do you read at both pos and neg peaks to feed the 8.8kHz control loop?

I'd also like to say thank you for open sourcing your work. Without it I wouldn't be considering an electric conversion.
User avatar
johu
Site Admin
Posts: 5685
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Q on PWM frequency, processor power and resolver signals

Post by johu »

Pete9008 wrote: Sun Apr 03, 2022 8:47 pm Is there any general rule of thumb for commutation speed vs PWM frequency?
I really don't know. Nissan run their inverters at 5 kHz and up to roughly 800 Hz. So thats also just about 6 PWM periods per sine period.
Pete9008 wrote: Sun Apr 03, 2022 8:47 pm I had incorrectly assumed that the control loop ran at PWM frequency and so was worried that load would increase if the PWM frequency increased. With 35% load the F1 looks like the best choice and I'll stick with it.
Indeed used to be like that until I thought it would be good to have it fixed.
Pete9008 wrote: Sun Apr 03, 2022 8:47 pm Two further resolver questions if you don't mind. Firstly regarding reading at carrier peak, how do you compensate for the delay through the 3pole filter that is used to convert the square wave to sin? Secondly with the encoder carrier at 4.4kHz do you read at both pos and neg peaks to feed the 8.8kHz control loop?
I measured the delay from pin toggle to peak on return line. Then I program a timer to trigger the ADC conversion after that measured (and constant!) delay. I read on both negative and positive peaks.
Pete9008 wrote: Sun Apr 03, 2022 8:47 pm I'd also like to say thank you for open sourcing your work. Without it I wouldn't be considering an electric conversion.
Thanks very much, it is good to hear that!
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Q on PWM frequency, processor power and resolver signals

Post by Pete9008 »

The Nissan ratio is a pretty good indicator that the ratio is fine. Looks like I'm worrying too much.

I'm probably also worrying too much about the resolver but a single sample is still making me uneasy. A noise problem coupling onto this input could be a nightmare to find (it might work fine on the bench or at low load but intermittently cause problems at higher loads but only when a switching event happens to coincide with the sample point). I was wondering whether it might be worth adding some kind of window function on the measured resolver position based on previous measurements? Based on some fairly rough calculations it appears that the delta in the angle between each resolver sample should be pretty predictable - even with relatively fast accelerations (0-9600rpm in 0.5sec) the rate of change of the deltas is fractions of a degree. If a new sample falls out of the predicted window then it could be flagged as a potential problem.

I've also just been looking at the Toyota logic board and they use a pair of AU6802 Resolver to Digital converters. These look like quite nice devices and should offer good noise immunity. They are completely configured via hardware pins, so no software setup, and provide both serial and parallel outputs of the current position. As I have them I'm probably going to include them on the board just in case.
User avatar
johu
Site Admin
Posts: 5685
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 154 times
Been thanked: 960 times
Contact:

Re: Q on PWM frequency, processor power and resolver signals

Post by johu »

I can sort of relate to that but then a lot of people are actually driving with this configuration, including myself (for over 30000 km). It works amazingly well and there is also some hardware filtering in place to keep spikes away.

Bespoke chips are probably "more better" in some way, but eat money, board space and manufacturing ease (e.g. JLCPCB does not have the AU6802). That's why I avoided them.

Still you'll find some code that re-purposes the resolver pins as software SPI to talk to such chips (AD2S in that case)
https://github.com/jsphuebner/stm32-sin ... r.cpp#L503
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Pete9008
Posts: 1801
Joined: Sun Apr 03, 2022 1:57 pm
Has thanked: 102 times
Been thanked: 347 times

Re: Q on PWM frequency, processor power and resolver signals

Post by Pete9008 »

johu wrote: Mon Apr 04, 2022 5:01 pm I can sort of relate to that but then a lot of people are actually driving with this configuration, including myself (for over 30000 km). It works amazingly well and there is also some hardware filtering in place to keep spikes away.
Sorry to be a pain but electrical noise has often been the bane of my life and I've learnt to try and limit it wherever possible (admittedly this was all low noise precision stuff and I have a lot to learn about what works with high power electronics).
johu wrote: Mon Apr 04, 2022 5:01 pm Bespoke chips are probably "more better" in some way, but eat money, board space and manufacturing ease (e.g. JLCPCB does not have the AU6802). That's why I avoided them.
Not sure anyone stocks it any more, looks like it may be obsolete, but having a couple of them on my desk counts for a lot at the moment!
johu wrote: Mon Apr 04, 2022 5:01 pm Still you'll find some code that re-purposes the resolver pins as software SPI to talk to such chips (AD2S in that case)
https://github.com/jsphuebner/stm32-sin ... r.cpp#L503
Perfect, thank you :D

BTW - I just noticed a post you made last year on using the DACs and DMA to generate the sin wave - I like that idea a lot.

I'll shut up about resolvers now!
Post Reply