How to Properly Implement a Lookup Table for a Unipolar Sine Wave Inverter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-28 5:25 AM
I'm designing a unipolar sine wave inverter using a lookup table to generate PWM signals, but I'm encountering some issues and have a few questions:
- Should the values in the lookup table start from zero, or from the peak value of the sine wave?
- Is it sufficient to create the lookup table for only half of the sine wave cycle (0 to 180 degrees)? After generating the first half-cycle, can I simply change the polarity to complete the full cycle, or is there another method I should follow?
- How should I handle the transition between the first and second half-cycles? Should I invert the polarity of the PWM signal, or do I need to modify the lookup table values?
- Could someone provide a small example of a lookup table for a unipolar sine wave inverter, and explain how to use it across a full cycle?
- I'm able to generate a sine wave without using complementary channels, but when I try to use complementary outputs on two channels, it doesn't work correctly. What could be causing this issue, and how can I fix it?
I'm struggling with these concepts, and any guidance or examples would be greatly appreciated. Thank you!
- Labels:
-
Power
-
STM32F0 Series
-
STM32F4 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-28 6:26 AM
1/ The values in the lookup table should represent the amplitude of the sine wave at different points in the cycle. Typically, these values start from zero and go up to the peak value of the sine wave.
2/ yes, you can generate the first half-cycle and then change the polarity to complete the full cycle.
3/ after generating the first half-cycle (0 to 180 degrees), you can use the same lookup table values but invert the output to generate the second half-cycle (180 to 360 degrees).
5/ ensure that the two channels are properly synchronized and there is an appropriate dead time between the complementary signals.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-30 12:10 AM - edited ‎2024-08-30 12:26 AM
But I tried Likewise , but whenever the polarity changes its makes high spikes plese look the image
As am a beginer am dont know the exact problem
I used one Half cycle , CH1 output polarity is normal , and CH2 's polarty is inverted , whenever thehalf array value is transfered by the DMA the PWM_PulseFinishedCallback funtion trigger aand it inverter the polarty of the channels . aand working as expected see the above logic signals .
void PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{ if (htim->hdma[TIM_DMA_ID_CC1] != NULL && htim->hdma[TIM_DMA_ID_CC1] == &hdma_tim1_ch1)
{
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)
{ i++;
//if(i==2)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
htim1.Instance->CCER ^= (TIM_CCER_CC1P | TIM_CCER_CC1NP);
// Toggle the polarity bits for CH2 and CH2N
htim1.Instance->CCER ^= (TIM_CCER_CC2P | TIM_CCER_CC2NP);
if (i==2) i=0;
}
}
}
PWM freq = 20khz DMA array is for one half cycle is 200
so 50us *200 = 10ms
htim1.PWM_PulseFinishedCallback = PWM_PulseFinishedCallback;
HAL_TIM_Base_Start(&htim1);
// generate_center_aligned_sine_tables();
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table,200);//low
HAL_TIMEx_PWMN_Start_IT(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_2, (uint32_t *)sin_table, 200); //high
HAL_TIMEx_PWMN_Start_IT(&htim1, TIM_CHANNEL_2);
this is the main function call
How do i get a smooth sinewave ??
uint32_t sin_table[200]={0, 4, 8, 12, 16, 20, 24, 27, 31, 35, 39, 43, 47, 51, 55, 58, 62, 66, 70,
74, 77, 81, 85, 88, 92, 96, 99, 103, 106, 110, 113, 117, 120, 124, 127, 131, 134, 137, 141,
144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 180, 182, 185, 188, 190, 193,
195, 198, 200, 202, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 226, 228, 229,
231, 232, 234, 235, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 246, 247, 248, 248,
248, 249, 249, 250, 250, 250, 250, 250, 250, 250, 250, 250, 249, 249, 248, 248, 248, 247,
246, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 235, 234, 232, 231, 229, 228, 226,
225, 223, 221, 219, 217, 215, 213, 211, 209, 207, 205, 202, 200, 198, 195, 193, 190, 188,
185, 182, 180, 177, 174, 171, 168, 165, 162, 159, 156, 153, 150, 147, 144, 141, 137, 134,
131, 127, 124, 120, 117, 113, 110, 106, 103, 99, 96, 92, 88, 85, 81, 77, 74, 70, 66, 62,
58, 55, 51, 47, 43, 39, 35, 31, 27, 24, 20, 16, 12, 8, 4};
This is the half wave array am using
sorry for the mentioning , i am trying it to correct from 3,4 days
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-08-30 1:53 AM
Your trouble is based on schematics and MCU PWM cant create negative signal on simply invert ...
NORMAL one sine require shifted DC data... complementary based on schematics...
