1
\$\begingroup\$

I am programming a FOC 3 phase motor controller on a Teensy4. The motor will be driven by 6 MOSFETs and a gate driver IC for the MOSFETs.

I have looked though the data sheets for many different gate drivers and they don't have any images of the signals required for their inputs from the microcontroller. Some have 3 inputs, which I assume is just a basic sinusoidal PWM signal going from 0-100% duty cycle as the sine goes from -1 to +1.

However most have 6 inputs. Are these 6 inputs standardised? My guess is that 3 are for the high side MOSFETs and 3 are for the low side. The PWM signal for the high side going from 0-100% duty cycle as the sine wave goes from 0 to +1, and the low side PWM going from 100-0% as the sine wave goes from 0 to -1.

enter image description here
enter image description here

\$\endgroup\$
  • \$\begingroup\$ FOC is far more than just 3 phase PWM. Q1 What FOC resources have you looked at? \$\endgroup\$ – Russell McMahon May 8 at 13:09
  • \$\begingroup\$ I am writing the FOC from scratch. I am going to start by just driving a motor in open loop with the 3 phase signal. I am interested in making something like the diagram on this page trinamic.com/technology/std-technologies/field-oriented-control because is has position control. I will use a sine cosine analog hall encoder for position feedback. \$\endgroup\$ – John Spence May 8 at 22:23
  • 2
    \$\begingroup\$ The idea of a Teensy doing FOC gave me collywobbles :-). I'm pleased to see that a "Teensy-4](pjrc.com/teensy-4-0) is a vastly more capable beast. FOC from scratch sounds interesting. I'd be interested to see how it goes. And to know what you wish to do it from scratch. If you have not met it, Benjamin Vetters "VESC" code is open source and may be of great value if you don't know of it. Older versions are still extant and may be more applicable. While I've not (yet) used it it seems that VESC does about everything you'd want in the area. \$\endgroup\$ – Russell McMahon May 9 at 3:21
  • \$\begingroup\$ I am assuming from this diagram trinamic.com/technology/std-technologies/field-oriented-control that's it's not too complicated. Maybe that's naive. I will use a position encoder and not do position sensing using the back EMF, that should make things easier. I will look at the VESC, remember seeing it a while ago in relation the electric skateboards. \$\endgroup\$ – John Spence May 9 at 10:08
2
\$\begingroup\$

Take a look to DRV8353RS datasheet from Texas Instrument , it's great gate driver that i used for my bldc application. I used both FOC and trapezoidal commutation and worked perfectly. You can take look at "Instaspic FOC" documents from TI

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Looks good. Do the input signals for high side and low side, it requires look like the ones I have shown above? \$\endgroup\$ – John Spence May 8 at 22:53
  • \$\begingroup\$ I have one of the TI boards for FOC motor control, but I couldn't get started with it because too much of a steep learning curve. The Teensy is really easy for someone who has not done embedded programming before. \$\endgroup\$ – John Spence May 8 at 23:01
1
\$\begingroup\$

For your chip you would be using a "FlexPWM" block per H Bridge, The datasheet for this chip is cut down to a point where PWM channels are a single statement, So I'm afraid I will have to be light on specifics for your specific use case

Normally a single timer can drive multiple PWM channels, each of those channels will usually have both a normal output and an inverted output that you can use, this means your high side and low side can have an output,

Depending on the exact device some have allowances for fixed dead-time delays between switching state on 1 then the other. when you not using a H-Bridge driver with that functionality built in

The 3 inputs are where the driver is only high side or low side, common in 180 degree commutation control, the 6 inputs are where they are broken out separately and usually just have some safeties in the chip to prevent both high and low on at the same time (Shoot through protection), for 120 degree commutation (180 is usually a bit better)

As for how to generate your cycle, you can think of that triangle wave like the timer in your micro, counting up and down at a frequency you set up. at each timer min / max you update the values the PWM should switch at, to make this easier, you would usually set up the timer to be a division of the frequency you wish to use, in your diagram you can see it only needs to update 8/9 times per phase per cycle, normally motor controllers would have a higher PWM frequency, but it conveys the point.

Depending on how much else your juggling, and the architecture, the next step in the PWM update may be a DMA that keeps cycling around the pattern length, or may fire an interrupt to make sure it happens in a reasonable time.

enter image description here

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ FOC is far more than just PWM/. It's not obvious that he understands this. \$\endgroup\$ – Russell McMahon May 8 at 13:10
  • \$\begingroup\$ @Reroute for now I am using the 'analog out' on the teensy4 board which is a PWM output. I can get 12 bit resolution at 30kHz, which seems pretty good for motor control. I don't know how the timing will work between channels though. I might have to write my own PWM code and use the digital outputs to have more control over the timing. I was more trying to find out in detail, what signals gate driver ICs expect to see because it is not clear on the data sheets. The flex IC looks complicated, I was looking at non programable ones like the IRS2330. \$\endgroup\$ – John Spence May 8 at 22:49
  • 1
    \$\begingroup\$ The flex PWM stuff is built in to the teensy4, the gate drivers will tell you there input logic high and logic low thresholds in the datasheet, but usually they are based around either 5V or 3.3V, so a threshold near 2V as logic high. with high usually being switched on for many 6 input ones, for the 3 input ones, best to check the datasheet \$\endgroup\$ – Reroute May 8 at 22:58
  • \$\begingroup\$ I see, but I don't know how much control there is over it using the Arduino environment that is used for the Teensy4. The data sheet for the IMXRT1060 mentions peripherals for PWM and motor control. I have only seen how you can change the PWM frequency and resolution on the Teesny4. I don't know if it's possible to program the Teensy4 without using the Arduino environment. I am not ready to do real embedded programming at this stage. \$\endgroup\$ – John Spence May 9 at 9:54
  • 1
    \$\begingroup\$ I presume at a minimum you can analog write to the pwm peripheral, and read the timer count? you could do that with the older atmel based arduino flavors, as for setting up the inverted outputs, that must be covered somewhere if you need it. otherwise just analog write them aswell, \$\endgroup\$ – Reroute May 9 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.