cancel
Showing results for 
Search instead for 
Did you mean: 

Salutations! I need guidance to choose a micro controller that can communicate with STM32F103VCT6 at the same speed through UART and has 36 PWN pins. Thank You J.

JJ..1
Associate II

23 REPLIES 23

Let's say you have 4 outputs for starters, PB0 needs 80% duty cycle, PB1 50%, PB2 10%, and PB3 100% (always on). So you have to output the following sequence of bits repeated on each pin (of course you can shift the phase too by shifting the bits around)

PB0  1111111100
PB1  1111100000
PB2  1000000000
PB3  1111111111

turn the above table 90 degrees clockwise, you get a list of binary numbers

uint16_t pb_pattern = {
  0b1111,
  0b1011,
  0b1011,
  0b1011,
  0b1011,
  0b1001,
  0b1001,
  0b1001,
  0b1000,
  0b1000
};

This is just a simplified example, you can use full 16 bit values to output on PB0-PB15 simultaneously.

Now you can set up a timer to 10 times the PWM frequency, and a DMA channel that transfers 10 halfwords in circular mode from the buffer above to GPIOB->ODR, on each timer period. If more than 10% precision is needed, use a longer table and adjust the timer period.

It can then be extended to more GPIO banks, using more timer and DMA channels, for 32, 48, etc PWM signals.

It might even be possible to do it on the controlling MCU if there are enough pins and RAM available, maybe replacing it with a 144-pin STM32F103 variant with some more RAM.

If the two MCUs have to be separate, calculate the memory requirements based on the required PWM precision, and chose the cheapest MCU that has enough pins and RAM.

Yes I mean PWM.

Beredi, will work on it. thanks.

JJ..1
Associate II

Hello,

1) Can STM32G474 with 43 PWN pins to control 36 solenoid PWM outputs independently? all of them work without affecting the operation of the rest outputs.All outputs receive different PWN signals and different period of time.

2)Another issue is that, under volting the solenoid coil through PWN signals is causing a high pitch noise(low volume) at 33.33% PWM of 12V i.e equivalent to 4V is supplied to solenoids. The mechanical components are removed then also the noise persists. The noise doesn't come if i give a linear power supply of 4V to the solenoid.

Kindly advice.

Thank you

1) No. PWM frequencies are not all independent. Regular timer units support a single frequency with 4 independent duty cycles, HRTIM supports 6 independent frequencies. There is no MCU in the STM32 series with 36 completely independent PWM outputs.

2) Try increasing the PWM frequency and/or adjust the low pass filters on the outputs (or add one to each when there isn't any).

3) Check total current ratings in the datasheet.

JJ..1
Associate II

There are 2 cases :

CASE 1:

These are the list of 6 PWN signals of 12 V that are in use.

1) 100% i.e 12V equivalent

2) 75% i.e 9V equivalent

3) 50% i.e 6V equivalent

4) 41.66% i.e 5V equivalent

5) 33.3% i.e 4V equivalent

6) 25V% i.e 3V equivalent

There are 36 Outputs.

1) 1 output would only receive 3V to 5V equivalent PWN signa, which ever is called for

2) 1 Output would only receive 6V to 12V equivalent PWN signal, which ever is called for

3) 34 Outputs receive 100% or 33.3% PWM independently. First 100% for 100ms to turn on then 33.3% to remain ON.

CASE 2:

I can even work with 2 PWM signals

1) 100%

2) 33.3%

This will be used for 34 outputs. Outputs receive 100% or 33.3% PWM independently. First 100% for 100ms to turn on then 33.3% to remain ON.

Are any of the cases possible?

berendi
Principal

Previously you've written that each period is different. Now you are implying that the period doesn't really matter (maybe the faster the better), you just want to control the output voltage by means of the duty cycle in 12 steps.

Using the same timer period on all pwm channels would of course work with any combination of timers, and it would simplify the DMA controlled GPIO solution above, which works on any STM32 MCU (requiring only 3*4*12=144 bytes of memory for the DMA buffers).

Apologies for not being able to explain well. I would like to elaborate on the last statement you wrote, just so that i make myself clear and I understand well.

if code says turn ON output 1 : then 100% is given to 1 for 100 ms then it drops to 33% PWM. This will be continuously ON.

while it is on a code could ask output 2 to be ON: then 100% is given to output 2 for 100ms(while other output 1 at 33% isn't affected) after that only 33% is send to output 2.

likewise there are 34 outputs.

(optinal if possible) other 2 outputs can receive any of the below mentioned PWM

1) 100% i.e 12V equivalent

2) 75% i.e 9V equivalent

3) 50% i.e 6V equivalent

4) 41.66% i.e 5V equivalent

5) 33.3% i.e 4V equivalent

6) 25V% i.e 3V equivalent.

So can this work?

Piranha
Chief II

Maybe it's easier to introduce two supply voltage levels for solenoids and add some simple delay circuit consisting from resistor, capacitor, transistor and probably diode to each solenoid control logic in a way that at turning on it turns on the higher voltage for some time and then drops to a lower "hold" voltage. Just an idea to think of... 🙂

Yes, but that would require double the number of MOSFETs so that would increase the board size and costs . That is the final last option. Thus trying for PWN the the recommended MCU first