Dynamic switching regime (DSR)

Dear all

This is just a conceptual idea i would like to swing by all the hardcore BLDC controller´s out there.

There comes a moment. Where one should ask one self; is it possible to do dynamic switching. Where the FOC algorithm is presented with a min and max switching frequency and thereby has to decide, based on various variables, if going toward the higher range or perhaps the lower range is advisable.

I came to think about this, when looking into the INA241A current sense amplifier (1Mhz bandwidth) thinking why would we need extremely fast/tight current measurement. Looking at the Teensy 4.0 having a 600Mhz processor, there is surely lots of cycles between a eg. 24khz switching freq and a 600Mhz processor.

This approach will demand a top shelf processor and will perhaps be for future development. Just a idea up in the air. Can it be done?

Hmm…

Teensy 4.0 provides support for dynamic clock scaling. Unlike traditional microcontrollers, where changing the clock speed causes wrong baud rates and other issues, Teensy 4.0 hardware and Teensyduino’s software support for Arduino timing functions are designed to allow dynamically speed changes.

PJRC Store

There was a company called RoverTec which had BLDC driver boards based on this concept. Unfortunately I don’t think they’re around any more.

There are also stepper drivers which dynamically adjust the frequency per PWM cycle to extend/reduce the PWM period cycle to cycle. In this way they can dynamically adjust to keep the current constant, I guess.

Depending on the MCU architecture you actually don’t have to scale the whole MCU clock system, it can be enough to configure the timer clocks, or even easier, just adjust the TOP register of the timer…

I do beleave it is possible to sample a 1Mhz current sense amplifier if using a external ADC. I’m looking at this one AD7387

To have the highest possible throughput, one would need to implement a two-MISO-wire SPI interface. Not sure this is thoroughly tested and in the public domain for T4 though, but have red it requires using two SPI ports, one master, the other slave.

Doing that, would provide a 14bit resolution (16bit by on chip oversampling). It has a rolling average function which does not loose sampling rate.

Having such a high res. and sample rate could provide possibilities for future advancement in eg. Dynamic Switching Routines.

Edit: I see others are proposing something similar: Dynamic switching frequency (FOC) · Issue #172 · vedderb/bldc · GitHub

Example: 54.7.5.14.1 Variable Frequency PWM Mode

i.MX RT1060 Processor Reference Manual (pjrc.com)

For inline sensing the use of an external ADC seems quite possible. Reading values via SPI will be slower than using an on-board ADC, but the external ADC could be more accurate/faster/better.
For low-side sensing, I think the PWM-synchronisation will be a big hindrance in using an external ADC - syncing ADC reading with SPI-latencies to the PWM will be a real pain in the ***.

All in all, since the MCU’s ADCs are more than adequate for the job, and for motor-control oriented MCUs they can be easily synced to the PWM, I would generally recommend using the on-board ADCs over adding an external one, which will add complexity to hardware, software and a costly component to the design…

SSI is generally no problem, it depends a bit on the timings, but it can usually be implemented using the SPI peripheral without the MOSI line being used. 2x SSI in the way the ADC you linked uses would be a major pain to implement, it would certainly not be supported via Arduino’s SPI library, and I would not recommend going for this.

Yeb, it does cost a bit, but the resolution is so sweet. I have done some thoughts on the anti-aliasing thing. If the external uses oversampling (not the moving average, but the one where it takes 8 readings and takes a average) the sample rate would still allow the use of a 1Mhz current sense amplifier, but the throughput would be lower and still avoid aliasing right?

16 bit resolution is 65535 values. This will allow a decent resolution even if the use case is maybe 1/10 of the shunt max-out.

Regarding the price. Usually the battery is the most expensive part on a ebike/eMTB. All round its not cheep converting a bike to a ebike. Deciding for a more expensive controller depends on the cost benefit/ price performance considerations. I cant say how much more efficient it will be, that depends on real life experimentation and comparison. I do believe it will be much more smooth and bionic which is the ultimate goal. If there is no difference in user experience, then it´s a waste of time.

There might already be a possible solution. FlexIO_t4/examples at master · KurtE/FlexIO_t4 · GitHub

This library experiments with the flexIOSPI of the T4. It is highly configurable and it uses DMA.

Since the two “MISO” lines of the AD7387 is synced, essentially the second line is a clone, which need to be triggered using the same trigger, but on a different DMA channel. This doubles the throughput and is effectively simultaneous sampling on two ADC´s. (Two shunt´s).

Two shunts is all we need right? Calculating the third value. Is there any drawback of using just two shunts? Besides from the time it takes to compute…

Edit: there might be a drawback regarding BEMF sensorless commutation using just two shunt’s

By the way, you gotta see this:

Yes, the FlexIO peripheral runs happily with the 480 MHz clock source, but as far as FlexIO is concerned this translates to 480 million timer edges per second so the fastest data rate is 240 MHz since the data is shifted on either rising or falling timer edges.

Source: https://forum.pjrc.com/threads/66201…t-using-FlexIO