Parallel MOSFET's with Different PWM Pins? (Teensy 4.1)

NewLinuxFan

Well-known member
Are the PWM outputs in sync? Even with different timers?

I know somebody will say just use the same pin or add a larger MOSFET with a MOSFET driver, but the boards are already made, and I might have to drive more current than they were originally designed for.
 
Thanks! I'm guessing A and B have to be looked up in the chip datasheet. Some timers have 3 PWM outputs shown on the PJRC web site.

The MOSFET outputs are grouped by sets of labelled red, green, blue for specific LED strips. However, if I have to get creative and only use the same timer for parallel outputs, it would work but just look a bit weird and confusing. :)
 
I'm guessing A and B have to be looked up in the chip datasheet. Some timers have 3 PWM outputs shown on the PJRC web site.

I have used file FreqMeasureMultiIMXRT.CPP as a reference. You will find it in library FreqMeasureMulti, which is included with TeensyDuino. Each of the 4 modules within each FlexPWM has 3 outputs (A,B,X). I think of A and B as the most easily synchronized, but X may be equally so. I could be wrong about this, but I don't think TeensyDuino supports synchronization directly. I think you have to get into the FlexPWM chapter of the IMXRT reference manual for that.

If you do some searching of the forum, you'll find examples of programs with synchronized PWM output, and here is a link to @KurtE's excellent supplemental docs.

https://github.com/KurtE/TeensyDocuments
 
Thanks again. I don't have experience with low-level commands or how to type them into Teensyduino based on reading a microchip manual, but I'll see what I can figure out. Maybe it will be obvious in some examples.
 
If you tell us what you’re trying to do, what signals you want to produce on which pins, and what exactly you mean by synchronized, you’ll probably get some help.
 
Okay, here's how the boards are wired, with MOSFET drains (to LED strips) corresponding to MOSFET gates (with series resistor and bleed resistor):

Red1, Green1, Blue1: PWM pins 3, 4, 5

Red2, Green2, Blue2: PWM pins 6, 9, 10

Red3, Green3, Blue3: PWM pins 11, 28, 29

Red4, Green4, Blue4: PWM pins 33, 36, 37

Red5, Green5, Blue5: PWM pins 14, 15, 18

Red6, Green6, Blue6: PWM pins 19, 22, 23


I would like to run 3 pairs of MOSFET's with connected drains for higher current (not connected gates) at about 2,000 Hz or the highest that will still do 16 bits. It might be 2288 Hz. It looked like 2289 Hz can only do 15 bits because it seemed less smooth. Any help would be very much appreciated.

I can't separate the LED runs because at low light levels there are significant color differences due to manufacturing tolerances of the MOSFET's (gate capacitances). Trying to color correct is a tedious process with a light meter and is more complicated than it might seem.
 
I would like to run 3 pairs of MOSFET's with connected drains for higher current (not connected gates) at about 2,000 Hz or the highest that will still do 16 bits. It might be 2288 Hz. It looked like 2289 Hz can only do 15 bits because it seemed less smooth. Any help would be very much appreciated
.

I'm still trying to understand what you want to "synchronize", and exactly what you mean by that. Do you mean that within each set of Red/Green/Blue, you need the start of each PWM period to be synchronized? Do you mean that all 18 (6 x 3) PWM periods need to be synchronized?
 
Only each pair needs synchronized signals. So if 2 MOSFET's have drains tried together and control the red LED's of 1 strip, the gate voltages need to go up and down at the same time, even though they are driven with different Teensy pins (ignoring differences in gate capacitances). Same with the 2 MOSFET's driving green, same with 2 MOSFET's driving blue.
 
Without looking carefully at the pins, it seems unlikely they will match up on the same PWM module. You should be able to get the same clock frequency, regardless of PWM source, and the same period, so they should not drift relative to each other, but getting them to start on the same clock cycle may be difficult. Can you just use one pin and tie them together at the MOSFETs?
 
Without looking carefully at the pins, it seems unlikely they will match up on the same PWM module. You should be able to get the same clock frequency, regardless of PWM source, and the same period, so they should not drift relative to each other, but getting them to start on the same clock cycle may be difficult. Can you just use one pin and tie them together at the MOSFETs?

Yeah, I've done that with a board that has through-hole components, and the extra current burst on the Teensy pin is not too much for just a pair of MOSFET's though it can be harder to estimate lifetime. I could still do that with surface-mount components and get creative with some technical soldering, but I was hoping for a coding solution. I have about 80 PCB's left to use at work, and it will take some effort to design a new PCB with MOSFET drivers. When I've used MOSFET drivers in the past on a protoboard, the ground bounce is a major issue and hopefully is overcome by a ground plane, but that's hard to test without having a ground plane 1st. :)
 
Sounds like you're going to have to dig into the details of the T4.1 PWM signals. The lines below are from cores\teensy4\pwm.c, so you can see that in your first 2 sets of signals, most are from FlexPWM, and one from QuadTimer. If you look at the code, you'll see that when you use the Arduino API, there will eventually be functions called that are specific to whatever hardware module controls a given pin. I've experimented a little with writing additional logic that uses features of FlexPWM that aren't supported by the Arduino API. The manual is actually quite good, but it takes a few times through to digest it and find the features that will give you what you want. Pins 6/9 happen to be A/B of the same FlexPWM module, so you might start with those.

Code:
        {1, M(4, 2), 2, 1},  // FlexPWM4_2_B   3  // EMC_05
	{1, M(2, 0), 1, 1},  // FlexPWM2_0_A   4  // EMC_06
	{1, M(2, 1), 1, 1},  // FlexPWM2_1_A   5  // EMC_08

	{1, M(2, 2), 1, 2},  // FlexPWM2_2_A   6  // B0_10
	{1, M(2, 2), 2, 2},  // FlexPWM2_2_B   9  // B0_11
	{2, M(1, 0), 0, 1},  // QuadTimer1_0  10  // B0_00
 
That is awesome! Thank you so much. I'll dig through that when I have some time. Have to finish a different project at the moment.
 
After reading about this for hours and doing some testing, it appears that MOSFET's can run parallel as long as duty cycle is the same and the same type of timer channel is used:
all Flex A in parallel,
all Flex B in parallel,
all Flex X in parallel, or
all Quad in parallel

Does that sound right? This is with the default settings in pwm.c file and my very basic understanding of page 3,035 of the microcontroller manual. It seems that using the synchronization methods of page 3,043 would have minimal effect on appearance of LED's unless it's a POV-type project with a fast-moving object, and the heat-buildup of the first MOSFET to change duty cycle would be very brief.

And can modifications to functions in pwm.c be done inside a sketch? I'm wondering if that overrides the functions in the file.
 
It's unclear yet whether the main module number has to match up, but it sure looks like the submodule does not need to. I don't have an oscilloscope, but I can measure the temperatures of the MOSFET's and watch the LED strips.
 
Back
Top