Teensy 4.1 Timer Pins

skylarl

New member
Hello,

I am a member of the University of Michigan Supermileage project team where we aim to create a hyper-efficient electric vehicle. We're currently trying to use Teensy 4.1 to control our motor. We're using a 3 phase BLDC motor to power our vehicle. So, we're looking to use 6 PWM pins (two for each phase) on the Teensy 4.1.

We're using open source code from the simple FOC website: https://docs.simplefoc.com/code

In order to implement the algorithm on simple FOC, we require 6 PWM pins where pairs of two pins are each on the same timer. (3 timers total, each with two pins for the high and low sides of the phase). As a group of undergraduate students, we're having trouble sifting through the data sheet of the microprocessor on the Teensy 4.1 to see if there are pins which meet this requirement. Thank you for your help!
 
There have been some other PWM on T_4.x notes recently. Did a Forum search "PWM Phase" that can be repeated.

These three showed some links to info or details/examples that might help?

pjrc.com/threads/70839-T4-0-FlexPWM-Documentation

pjrc.com/threads/42158-PWM-phase-shift-help

pjrc.com/threads/71220-PWM-shift-phase-on-teensy-4-1

That search was deeper and there may be more better threads ...

They may point to manual sections that may not have been found?

Also, there are posted pin summary sheets by @KurtE and @MichaelMeissner that may point out details on pin associations.
 
Hi skylarl,

Please send me a direct message - hopefully I can help. Not to many years ago I finished Electrical Engineering at UofM.
 
The built in forum search is terrible. Do a google search like this site: forum.pjrc.com your search terms

Generally quite true - though it can work at times with usable words that cover the topic ...
Bing used here would look like:
bing.com/search?q=site:pjrc.com%20pwm+phase

Here top results show some of the above ...
Code:
PWM phase shift - help - PJRC
https://forum.pjrc.com/threads/42158-PWM-phase-shift-help
Oct 06, 2022 · PWM phase shift - help; Forum Rule: Always post complete source code & details to reproduce any issue! If this is your first visit, be sure to check out the FAQ by clicking the link …

phase correct PWM
https://forum.pjrc.com/threads/24992-phase-correct-PWM
Oct 05, 2019 · I was recently 'asked' to supervise some power electronics labs on behalf of an absent colleague. The students are required to build a class D audio amplifier using a dsPIC & …

Phase Shift PWM? - forum.pjrc.com
https://forum.pjrc.com/threads/63318-Phase-Shift-PWM
Sep 25, 2020 · Hello! I using 4 PWM channels for 4 Motors. I want to lower the current that goes through the somewhat long cable to the whole PCB.. and my idea is that the 4 PWM channels …

Understanding PWM phase shift code - PJRC
https://forum.pjrc.com/printthread.php?t=68697&pp=25&page=1
We have to set the 75% low period but not the 50% low period because we want it to be adjustable thats why we need to use 2ch for the second pwm? FTM3_MOD = 119; Is that the subdivision …
 
The 6 pins used for the SD card are probably your best option.

This sort of board might help you get easier access to them.

https://www.sparkfun.com/products/9419

Maybe other people will know of better SD breakout boards?

To actually use them, you'll probably need to dive into the FlexPWM chapter of the reference manual, which starts on page 3091. The good news is the FlexPWM timers have a lot of advanced features to control motors in almost any way.

The bad news is the FlexPWM timers have a lot of advanced features which can be a pretty overwhelming learning curve. You can probably get a start with the pwm.c code, but it configures each pin as an independent single phase output. You'll see each pair run from the same counter and you can just write to the 6 registers to configure each to be high while the other is low, or add a little dead time in the middle as you like. One feature important which you'll see in pwm.c is the CLDOK and LDOK bits needed to commit changes written to the 6 waveform timing registers to the output pins. In pwm.c it's done with a bitmask for 1 submodule. This LDOK part is the really nice feature for 3 or 4 phase output, because you can write all the registers for all the waveforms, then a single write to LDOK causes them to all take effect at the same moment.

If you get stuck trying to figure out FlexPWM, we can try to help here. Just remember we can do much more to help when you post a complete program any of us can copy into Arduino and run on a Teensy 4.1 to reproduce the problem.
 
Back
Top