Home > other >  Based on the stm32 of SPWM inverter
Based on the stm32 of SPWM inverter

Time:11-19

With the SPWM stm32 produce that array is how to get the specific is how to calculate and inverter into specific frequency sine wave when the interruption period how to calculate? At the same time generate PWM cycle and each time compared to interrupt the cycle have what relation?

CodePudding user response:

The SPWM inverter stm32 produce, generally we are using a data table, data is within a cycle of sine wave data, the design process is as follows:
Suppose we design the fundamental frequency of PWM is 20 KHZ, then sampling rate of 20 k/50=400, which is we need data inside the data table holds 400 sine wave,
Then again according to the PWM frequency, TIM's clock design, such as the clock is 72 MHZ, so cycle overloading data for 72 MHZ/20 KHZ=1440,
We know now, sine wave table between 0-1440, 0-1720-0144 of the corresponding sine wave of the corresponding sine wave 0 1 of the corresponding sine wave, this data is TIM's duty ratio, comparator real-time data
Specific output, in TIM cycle interrupt function, we according to interrupt count (400) look-up table, then according to the PID output data, enter less than 1 floating point data and look-up table data multiplication, can obtain the real-time output SPWM control data,

CodePudding user response:

Is not very understand but if demodulation for frequency of 50 hz sine wave for 72 m if the stm32 timer 1 output PWM timer interrupt to duty ratio 2 do it for 50 hz sine wave period of 20 ms if you take every 100 us 200 point to a duty ratio and the frequency of the timer interrupt of 2 to 200 x 50 or 50000 hz is the 20 ms into 200 shares each is 100 us timer interrupt the cycle for us so I can give timer 2 100 pre installed load values for 7199 preassigned frequency value to 0 and every point of the sample needs a PWM cycle of the timer 1 output PWM preload value can give 7199 preassigned frequency value to 0 is cycle is the same with 2 timer interrupt this understanding is right? And that is the SPWM array can calculate SPWM=Arr present 2 x (1 + sin (2 * f (t) pai) Arr is preloaded value of the timer 1 f is the frequency modulation of sine wave variable can t at 2 x pai present 200 base using c language to do cycle t=t + 2 x pai present 200
Has been added to the 2 x pai present number 200 and get 200 is that right?

CodePudding user response:

As far as possible the original poster can give reply? Urgent please!!!!!!

CodePudding user response:

First of all, if you take 200 samples, then you should is the fundamental frequency of 50 hz=200 * 10 KHZ, the fall in the audio range, of course, you can use super sampling methods, namely PWM cycle or 20 KHZ, just once every 2 interrupt modified digital comparator numerical, slightly low precision can also be that
To chip resources have enough time to do other things, for SPWM data, do not recommend using calculation method, linear frequency conversion system, unless you want to do otherwise, using look-up table is the most economic, data precision is highest at the same time,
Fixed frequency, detailed give you parse:
72 MHZ clock, TIM1, with a channel such as channel 1, MODE=PWM1, TIM1_ARR was $1440, open the complementary output, set the appropriate dead zone generally 300 ns is enough, the comparator initial value=720, open to compare interrupt,
PWM data table is a series of sine wave you through the calculated data, when each comparison output, look-up table to obtain the sine wave data, in order to output voltage stability, we must have a generally after the output rectifier integral to score a dc sampling data, after the partial pressure, to return to the ADC, as the output sine wave voltage measurement data, and then we set the target data of the PID arithmetic, get a PID result of less than 1, then the look-up table of sine wave data * PID is the SPWM data, we can send directly to send TIM1 comparative register,
Below is a sine wave form that the polarity and the zero value is we can control, so, in fact, we only need to store data can be half a cycle, the table data is acquired sin_tab []=720 * sin (PI * I/400)... (I=0-199), in order to save Labour, we can use of automatic calculation function in excel spreadsheet, direct access to the data,
Obviously, now sin_tab [I] there is a range of 0-720 data of sine wave, I=interrupt count, SPWM data between the first 200 interrupt count, for normal polarity, namely TIM1_CCR1=720 + sin_tab [I] * PID as a result, the 200 data after negative polarity, namely TIM1_CCR1=720 - sin_tab [I] * PID as a result,
Because it is Tim interrupts is equal to the event, the time to refresh the comparative data, can only change comparison results next time, and this two time interval is equal to our basic tim1 cycle, so we don't need to worry about these calculations and data refresh program takes up time, sure enough,

CodePudding user response:

SPWM is that so? This is directly from the microcontroller tube Angle measurement without filtering hardware circuit but the cycle is changing don't know why

CodePudding user response:

This does not support image upload or calculated

CodePudding user response:

Like upstairs is not profound understanding, but is not important, you have configured 32 chip, program for, according to the method, I provide the program with the correct sine data table, and then assume a constant PID correction value is 0.8, TIM1_CCR1=720 + sin_tab [I] * 0.8 and then run the program directly, you should be able to get complementary SPWM waveform, all the way with an arbitrary output PWM port, and then use the RC low-pass filter, you should be able to measure to stable perfect 50 hz sine wave, and then you modify the PID correction, 0.8 to get 50 hz sine wave amplitude control, the largest value should be limited to less than 1, such as 0.99,

CodePudding user response:

Application if not using look-up table, but SPWM value computing activities, generally USES the Taylor expansion, must be a multiple iterations of the floating-point multiplication, so want to get the appropriate precision (int) a large amount of calculation, code overhead also many, so the sine table, as in the above example, we only need 200 int storage unit, in terms of the total size of the code, also won't uneconomical, and through the synchronous change the value and the procedure of SPWM TIM1_ARR, sine tables for 1440 and the actual number of proportion, and also can realize perfect frequency conversion control, without the need to use real-time computing sine value to write programs, the disadvantage is that the carrier will change with the alternating current is proportional to the change of the frequency, the change in frequency range is when I was a child, was completely is not a problem such as design 30 KHZ - 20 KHZ frequency range as the carrier, then your frequency sine wave range will have 60-40 hz range, for the inverter should be fully covered,

CodePudding user response:

I roughly understand what you mean is the use of complementary output as long as the output half cycle after cycle is the use of complementary channel output, I am a full wave output the entire cycle of sine I just put the sinusoidal output data up to the part of the negative into a positive number and then divided by 2 the pid as to what you say I'm not doing I only did the SPWM output from the MCU tube Angle output SPWM
I can't understand from the oscilloscope to measure the wave period and frequency are changing the PWM output cycle and the frequency is not constant? Why might change my poor basis this don't understand

CodePudding user response:

And I the SPWM array is written using vc is put the data in the array is not directly in engineering calculation

CodePudding user response:

Each other and I eventually is to get a 3 120 short of sine wave

CodePudding user response:

STM32F103 do three phase hardware fully equipped, itself, tim1 can have 3 compared with complementary output output channel,
If the design is 120 degrees three-phase inverter, only need a little improvement, on the whole scheme for here because there must be 120 degree phase Angle difference, therefore, sine data table must be a multiple of 3, for example, we take 360 samples values here, then we only need to save data 180 and a half sine wave, sine wave cycle is 360, and then according to the interrupt count, respectively, for I + 120, + 240 I three sampling points, of course the data through the positive and negative polarity judgment, and more than 360 carry circulation processing, and then respectively in each Tim is register it is ok to fill in the data, thus direct access to the three complement each other driving signal,
Found on PWM you seem very not clear, PWM is a series of duty cycle square wave signals, affected by the control data for a typical half bridge, 50% duty cycle, is equal to zero, less than 50%, is negative, is higher than 50%,
And we only need the tim1 is half the input cycle data registers, you get 50% of the PWM signal, at that time, PWM cycle counter data and clock decided the PWM carrier frequency, and we according to the dynamic comparative data compare interrupt refresh, you can let us according to the design cycle, arbitrary function modulation waveform, if we refresh the sine wave data, then we can win at the demodulation end of the PWM sine wave, sine wave cycle depends on we refresh the data and the ratio of carrier,

CodePudding user response:

refer to 12 floor tianxj001 reply:
STM32F103 do three phase hardware fully equipped, itself, tim1 can have 3 compared with complementary output output channel,
If the design is 120 degrees three-phase inverter, only need a little improvement, on the whole scheme for here because there must be 120 degree phase Angle difference, therefore, sine data table must be a multiple of 3, for example, we take 360 samples values here, then we only need to save data 180 and a half sine wave, sine wave cycle is 360, and then according to the interrupt count, respectively, for I + 120, + 240 I three sampling points, of course the data through the positive and negative polarity judgment, and more than 360 carry circulation processing, and then respectively in each Tim is register it is ok to fill in the data, thus direct access to the three complement each other driving signal,
Found on PWM you seem very not clear, PWM is a series of duty cycle square wave signals, affected by the control data for a typical half bridge, 50% duty cycle, is equal to zero, less than 50%, is negative, is higher than 50%,
And we only need the tim1 is half the input cycle data registers, you get 50% of the PWM signal, at that time, PWM cycle counter data and clock decided the PWM carrier frequency, and we according to the dynamic comparative data compare interrupt refresh, you can let us according to the design cycle, arbitrary function modulation waveform, if we refresh the sine wave data, then we can win at the demodulation end of the PWM sine wave, sine wave cycle depends on the data and the ratio of carrier, we refresh



"For a typical half bridge, 50% duty cycle, is equal to zero, less than 50%, is negative, is higher than 50%,"
Here should be H bridge (bridge), Umotor=2 rho (1) Usource Umotor for motor voltage, Usource for dc power supply voltage, rho for duty ratio

CodePudding user response:

Learning, say well
  • Related