Author Topic: Special time-shifted (phase-shifted) multi-channel PWM generator  (Read 4479 times)

0 Members and 2 Guests are viewing this topic.

Offline msimunicTopic starter

  • Contributor
  • Posts: 26
  • Country: hr
Special time-shifted (phase-shifted) multi-channel PWM generator
« on: February 12, 2018, 11:10:49 pm »
I'm need to generate N channel (N>1) PWM output in a such a way that one channel is main 'governor' lets say ch0. Every other channel repeats the same duty, but with time shift of exactly pulse width. Ch1 need to set pulse (ch0_duty) time duration after ch0 set the pulse. Ch2 need to repeat after ch1 set the pulse (or 2*ch0_duty after ch0 set pulse). Constraints are: duty_max <= 50%*2/N; N*Ton=T. Duty need to be regulated from 0 to duty_max. Iv'e attached drawing to be more clarifying.
Those PWM signals should drive N FETs.

PWM frequency would be in range 25 - 100 kHz.
Probably, I can achieve very good solution on any MCU equiped with enough PWM/counter/timer modules by using PWM, up and down counting, and some ISR software.

Is there any microcontroller which can generate such kind of signals using only PWM/timer/counter module, without ISR?
Or maybe ASIC or some kind of other integrated circuit which can generate such PWM signals?
Maybe for N=2 I could use just 2 outputs from 4CH PWM configured for driving MOSFETs in a full-bridge (H-bridge) configuration?
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2693
  • Country: us
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #1 on: February 12, 2018, 11:27:34 pm »
That looks like a job for a shift register or decade counter.  If you only need three channels and don't want to use an external chip,  There's almost certainly an MCU out there that can do this with a chainable timer or three.  Or maybe use an MCU with a timer system designed for three phase motors.  You could certainly do it with a PSoC.  If you need more channels it depends how many.  You might be able to do something like use one timer more than once, using an ISR to change IO MUXes so that timer drives a different pin at different points in the sequence.  But based on your stated requirements, a shift register driven by a single timer seems like the way to go.
 

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #2 on: February 12, 2018, 11:30:09 pm »
A FPGA can do this easily.

For a micro, you could set up a PWM to have length Tp and have an output that is high for Tp/2 (it doesn't matter as long as it is less then Tp).

Every time the PWM gets to 0, it generates an interrupt that is used to set one of N outputs high in a sequence. These are presets for a latch. Then with a simple 74HC latch (N of latches in total) use the PWM output as the latch clock and the preset outputs as the latch input.

This would give exactly the same Tp width on all outputs and a Td of zero.

This can work as long as Tp does not have to go too close to zero. If Tp does not have to go below, say, 1us, this could work.

To get the T, during the interrups, a counter has  to total the Tp and when the N pulses are complete, the PWM is set to run for T-(N x Tp) with all the latch preset outputs at zero. Again, you cannot go all the way to T = N x Tp. Micro-based PWM solutions usually have issues at one or both of the extreme PWM values. A FPGA solution can produce a perfect output from Tp=0 to Tp = T/N and it can control the pulse width with about 10 times more resolution then a micro.
 
« Last Edit: February 12, 2018, 11:46:29 pm by amspire »
 

Offline filssavi

  • Frequent Contributor
  • **
  • Posts: 433
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #3 on: February 12, 2018, 11:35:10 pm »
It all depends on how big N is

If N is small, up to maybe 6/8 you can quite easily do it with a motor control specific MCU ( every manufacturer has a line of mcu’s with lots of advanced timers and pwm outs like for example NXP kinetis V series ) by employing one or two timers with synchronisation

if n gets larger but not to much you could try taking  a look to mcu’s like ti Hercules or NXP MCP5x series (the safety oriented ones) they are usually as High end an industrial (no multimedia/Hi speed comm protocols) MCU can get , they have very complex but very versatile timers and lots of them (since these devices are usually used in ECU’s they must be able in principle to drive at least 8/12 injectors  minimum)
 But these parts are very difficult to use (orders of magnitude more than an Arduino)

If N is big the only solution is writing your own own generator in a CPLD/FPGA this can scale to multiple hundred channels on the larger devices, also I suspect that using an FPGA will be easier than using a high end safety MCU
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13871
  • Country: gb
    • Mike's Electric Stuff
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #4 on: February 13, 2018, 12:05:29 am »
The answer depends a lot on the value of N and the required resolution.

Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22122
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #5 on: February 13, 2018, 12:15:16 am »
I did this for a job some years ago.  In discrete logic:
- Master CLK oscillator at Fout * N
- Counter (mod N) + decoder
- For each phase:
* Ramp generator (CCS + cap + switch)
* Decoder drive switch, discharging cap in desired phase
* Compare threshold voltage to cap voltage --> PWM
* PWM --> gate driver --> switch --> inductor, current sense resistor + current sense amp
* Current error amp compares current sense to input current setpoint value (common to all channels)
- Master voltage error amp sets current setpoint to regulate output voltage.

Assuming a typical e.g. buck converter application.  This implements average current mode control, which is quite nice.

As you can see, it's rather tedious to do it by hand.  Phase generator chips help (e.g. LTC6909), but you really should figure out if your application can use an off the shelf integrated controller instead.

This can all be integrated into an FPGA or MCU.  Some MCUs have vernier PWM generators with complex timing options, allowing an implementation of this fairly directly; an FPGA of course you only need to add external timing capacitors (if the FPGA has LVDS inputs, those will make fine comparators) for a continuous-time solution, or all integrated (using a much higher master clock frequency and longer dividers) if discrete-time is acceptable.  Current sense can be implemented with a fast ADC (say >1MSa/s), and the error amps with PID functions.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #6 on: February 13, 2018, 02:40:48 am »
Do it in PSOC, either using Verilog capability on its fabric, or using
schematic capture.


http://www.cypress.com/file/42161/download


http://www.cypress.com/documentation/application-notes/an82250-psoc-3-psoc-4-and-psoc-5lp-implementing-programmable-logic


http://www.cypress.com/file/42156





Lots of videos on Cypress website, or Youtube.


https://www.youtube.com/results?search_query=psoc+verilog


Start with PSOC 5LP, high end part, then look into doing it in PSOC 42xx low end to save cost
depending on rest of design requirements.



Regards, Dana.
« Last Edit: February 13, 2018, 02:42:31 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #7 on: February 13, 2018, 02:44:51 am »
The wall of text on PSOC -

For me what stands out is -

1) Routability
2) Fast 12 bit SAR A/D and slow 20 bit DelSig
3) DFB (Digital Filter Block) that is dual channel, handle FIR or IIR filters, or DFB
can be used as a GP fast processor block, similar to RISC block
4) MSI logic elements GUI based and/or the UDB Verilog capability. Eg. the FPGA
like capability
5) Onboard Vref
6) IDAC, VDAC, OpAmps (up to 4), comparator, mixer, switch cap, analog mux....
7) LCD,  COM, UART, I2C, I2S, One Wire, SPI, Parallel, LIN, CAN, BLE, USB
9) Custom components capability, create with schematic capture or Verilog
10) DMA to offload processes like filters, COM, Display
11) ARM M0 (PSOC 4) or M3 (PSOC  5LP) or 8051 core(PSOC 3) or M0+/M4 dual core PSOC 6
12) Extensive clock generation capabilities
13) All components supported by extensive prewritten APIs

https://www.element14.com/community/thread/23736/l/100-projects-in-100-days?displayFullThread=true

http://www.cypress.com/documentation/code-examples/psoc-345-code-examples

Great video library

Attached component list.  A component is an on chip HW resource.

Free GUI design tool with schematic capture, "Creator". Components have rich API library attached
to each component. Compilers free as well.

PSOC 4 is low end of family, consider 5LP parts as well. PSOC 4 also has arduino footprint boards (pioneer) as well. PSOC 6 dual core M0+/M4.

https://www.elektormagazine.com/labs/robot-build-with-cypress-psoc

http://www.cypress.com/products/32-bit-arm-cortex-m-psoc


https://brightcove.hs.llnwd.net/e1/uds/pd/1362235890001/1362235890001_5241352463001_2606504288001.mp4?pubId=1362235890001&videoId=2606504288001



Regards, Dana.
« Last Edit: February 13, 2018, 02:51:44 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 
The following users thanked this post: botvink

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Online jbb

  • Super Contributor
  • ***
  • Posts: 1193
  • Country: nz
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #9 on: February 13, 2018, 05:54:28 am »
Is there any microcontroller which can generate such kind of signals using only PWM/timer/counter module, without ISR?

The Texas Instruments C2000 series processors can do it. There is quite a range (32b fixed point single core @ 60MHz up to 32b floating point dual core @ 200MHz) - you can sort them by number of PWM channels.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3495
  • Country: it
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #10 on: February 13, 2018, 07:14:11 am »
In order from 8 bit to 32 bit:
PIC16F1789 >:D (it has the Programmable Switch Mode Controller)
Product Page: http://www.microchip.com/wwwproducts/en/PIC16F1789
Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/40001675C.pdf
Errata: http://ww1.microchip.com/downloads/en/DeviceDoc/80000575B.pdf

dsPICs with the *complete* high speed PWM module. Each HSPWM channel has 2 PWMs which can be independent or complementary outputs, with dead time, fault inputs, overcurrent inputs and yada yada yada.

For example the MU series (e.g: the dsPIC33EP512MU814) has up to 7 channels (total 14 PWMs, 5 fixed position 2 remappable).
the GS series (such as dsPIC33EP64GS504) has 5. GS Series is designed with digital SMPS in mind so even if no DMA controller, ADC,comparators,timers,PWM,Current source have additional interconnections.

MU Page: http://www.microchip.com/wwwproducts/en/dsPIC33EP512MU814
MU Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/70616g.pdf
MU Errata: http://ww1.microchip.com/downloads/en/DeviceDoc/80000526g.pdf

GS Page: http://www.microchip.com/wwwproducts/en/dsPIC33EP64GS504
GS Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/70005127d.pdf
GS Errata: http://ww1.microchip.com/downloads/en/DeviceDoc/80000656G.pdf

Relevant Reference Manual, but be sure to double check with the datasheet for gotchas: http://ww1.microchip.com/downloads/en/DeviceDoc/70000323h.pdf

There should be other dsPICs families with the high speed PWM module that can do what you want but i haven't used them myself.

The PIC32MK Series (such as PIC32MK0512GPD100) should be able to do what you want but i haven't used it much yet
Page: http://www.microchip.com/wwwproducts/en/PIC32MK0512GPD100
Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/60001402D.pdf
Errata: http://ww1.microchip.com/downloads/en/DeviceDoc/80000737C.pdf



In my experience the dspics are the most pleasant to deal with, i use them daily.

Currently i am developing a big project around the MU814 (which come in a handy 20x20mm TQFP  :-DD about 1/5th of the testing PCB area) and i suggest you read the datasheet carefully because there ARE some gotchas:
- For example ADC2 is 10 bits only, it's written on a side note in the ADC chapter :palm: nothing wrong on writing it on the front page, come on. But that wasn't a problem.
- only IC1 through 4 can trigger a DMA transfer. I thought about it and decided that wasn't a problem either because i can use the buffer and trigger the interrupt ever 2-3-4 events instead.
- ICx can't reset themselves reliably because there isn't an option to reset the internal timer on interrupt event (yes, each IC and OC module has its own independent timer, and period registers) while other dspic families can. so if you want absolute time, you have to reset the timer manually at each capture.

On the good side, there isn't something as idiotic as "you can use either CAN or USB" a-la stm32f1 so that's good  :-+ and the canbus is the kvaser-based ECAN MODULE.
« Last Edit: February 13, 2018, 07:17:58 am by JPortici »
 

Offline msimunicTopic starter

  • Contributor
  • Posts: 26
  • Country: hr
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #11 on: February 13, 2018, 10:54:37 am »
So many useful informations! Thank you all.
The N isn't supposed to be big, up to 4 or 5. But, hey, you never know what you will need.
I'm aware of FPGA solution and I thought that this would be expensive solution.
Now, those PSOC4 and PSOC5 are looking very handy. For other projects, also.

Although there are great PIC devices, I'm far more aligned to ARM solution then to Microchip. Reason for this are Microchip tools.
I'm a student and I can't afford 200+ USD for proper debugger/emulator (RealICE) which by the way comes with sheaty telephone cable (it breaks frequently). They offer JTAG extension cable for something like 50 USD, which IMO should be in package with RealICE and cost something like 5 USD. MPLAB IDE is good IDE, but toolchain is locked to MPLAB. Also, I'm not sure what are the licensing options for compilers and software packages I would need.

I will need some time to check everything.
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3495
  • Country: it
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #12 on: February 13, 2018, 11:22:05 am »
well i use ICD3 but it's the same price area. (who use the real ICE, which is not an ICE for anything else than the basic chips anyway??) i don't care for the connector because i do my own cables.
Keep in mind that original Microchip tools are buy once - have them forever and ever. If the programmer breaks you just have to open a ticket and they send you a new one. we got a bunch of them replaced for free. Yes, also if you are a private and not a business.

As for cheap programmers/debuggers.. I actually found the PICKIT 3 to be more reliable than STLINK or the equivalent for NXP and ATMEL when it came to debugging. They would hang much more frequently. I have no experience with higher quality programmers but they still are in the ICD3 price range.. and UP!

Re: Licences, XC16 and XC32 are GCC. there are a number of topics in the Microcontroller section regarding the sofware license to unlock optimizations greater than -O1 (but -O1 is good enough as the debugger don't get crazy because of optimized code) and how to disable the license check, because it's GCC and in theory you CAN do that. but again, -O1 is good enough IMHO, generated code is harder to debug with higher optimizations

Keep in mind that something like PSOC ties you to them a lot more, because you must use their PSOC Creator, which is windows only if you use a different OS :) and even if the ARM compiler is GCC the FPGA part is not, the binary blob is generated by PSOC creator only (or that is my understanding)
« Last Edit: February 13, 2018, 11:29:20 am by JPortici »
 
The following users thanked this post: msimunic

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #13 on: February 13, 2018, 12:04:50 pm »
Although there are great PIC devices, I'm far more aligned to ARM solution then to Microchip. Reason for this are Microchip tools.
As I described before, you can do this with a single microcontroller PWM + a latch chip like a 74HC374 or 74HC574 (better pinout) octal buffer chip.

You probably will need to do some ARM assembler for the PWM interrupt handling to optimize minimum and maximum Tp widths. If you need Tp to go down to zero, you probably should look at a FPGA or Cyprus solution. The minimum Tp with a micro may be in the 0.5 to 1us range.

If you do attempt to do this with a micro, you cannot let other interrupts interfere with the PWM interrupts so it may be you need a second microcontroller to do other tasks like communication.

FPGA doesn't mean expensive. You can get small demo boards that you can build into a project at a cost of $10 to $30. I have only used the free Altera Quartus IDE, but it is very good. For programming, I used the cheap Chinese USB Blaster which costs about $4.

https://www.aliexpress.com/item/New-Mini-System-Development-Board-ALTERA-FPGA-CycloneII-EP2C5T144-Learning-Board-Drop-Shipping/32835916598.html
https://www.aliexpress.com/item/EP4CE6-altera-fpga-development-board-USB-Blaster-fpga-kit-altera-kit-fpga-board-altera-board/32812957811.html
https://www.aliexpress.com/item/altera-Mini-Usb-Blaster-Cable-For-CPLD-FPGA-NIOS-JTAG-Altera-Programmer/2038559613.html

Anyway, you have a lot of options even if you are on a tight budget.
 
The following users thanked this post: msimunic

Offline msimunicTopic starter

  • Contributor
  • Posts: 26
  • Country: hr
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #14 on: February 13, 2018, 12:15:06 pm »
Whoooaaaawww!  :-DD
Thnx
 

Offline ahbushnell

  • Frequent Contributor
  • **
  • Posts: 745
  • Country: us
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #15 on: February 13, 2018, 12:16:26 pm »
Is there any microcontroller which can generate such kind of signals using only PWM/timer/counter module, without ISR?

The Texas Instruments C2000 series processors can do it. There is quite a range (32b fixed point single core @ 60MHz up to 32b floating point dual core @ 200MHz) - you can sort them by number of PWM channels.
I agree on the C2000.  The Piccolo has 8 channels of PWM and runs at 60 MHz with an internal clock.  There are more advanced versions that operate up to 200 MHz.   
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #16 on: February 13, 2018, 12:17:27 pm »
If you are looking for dead band PSOC Creator/PWM component implements
this. See attached and -

http://www.cypress.com/file/131736/download


And phase shift -


http://www.cypress.com/documentation/application-notes/an76439-psoc-3-and-psoc-5lp-phase-shift-full-bridge-modulation-and


Regards, Dana.


« Last Edit: February 13, 2018, 12:29:06 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3495
  • Country: it
Re: Special time-shifted (phase-shifted) multi-channel PWM generator
« Reply #17 on: February 13, 2018, 12:44:30 pm »
Another option may be infineon? C166 (16bit) and XMC4000 series (Cortex M4)
I was looking at their 16 bit parts for my current task but in the end i went for the dsPIC as i have a ton of code already written and tested
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf