M
M
Mobilander2020-12-19 22:55:26
STM
Mobilander, 2020-12-19 22:55:26

When you try to increase the frequency of interrupts, glitches appear. Why is this happening?

I am building my own -3 phase frequency converter (I understand that you can buy a bunch of them from China, but I want my own creation) ... I wrote everything as it should. But I want a soft start. Therefore, I made a check:
while (get_current_frequency() < 65){
delay_ms(100);
autoload_period_timer2();
freq += freq_plus;
period_timer2 = get_period(freq);
}

And finally what the logical analyzer shows:
5fde586b675a4292210050.jpeg

And a little further:
5fde58b6bba2e491691671.jpeg

void calc_index_phase(uint16_t index){
indexA = index;
if (indexA == 0){
if (revers == 0){
indexB = indexA+2*PERIOD/3;
indexC = indexA+PERIOD/3;
} else{
indexC = indexA+2*PERIOD/3;
indexB = indexA+PERIOD/3;
}
} else{
indexB++;
indexC++;
if (indexB > PERIOD) indexB = 0;
if (indexC > PERIOD) indexC = 0;
}
//Phase A
if (sinPhase[indexA]-PERIOD > 0)
PhaseA(0, sinPhase[indexA]-PERIOD);
if (sinPhase[indexA]-PERIOD < 0)
PhaseA(1, sinPhase[PERIOD-indexA]-PERIOD);
if (sinPhase[indexA]-PERIOD == 0){
PhaseA(0, 0);
PhaseA(1, 0);
}
//Phase B
if (sinPhase[indexB]-PERIOD > 0)
PhaseB(0, sinPhase[indexB]-PERIOD);
if (sinPhase[indexB]-PERIOD < 0)
PhaseB(1, sinPhase[PERIOD-indexB]-PERIOD);
if (sinPhase[indexB]-PERIOD == 0){
PhaseB(0, 0);
PhaseB(1, 0);
}
//Phase C
if (sinPhase[indexC]-PERIOD > 0)
PhaseC(0, sinPhase[indexC]-PERIOD);
if (sinPhase[indexC]-PERIOD < 0)
PhaseC(1, sinPhase[PERIOD-indexC]-PERIOD);
if (sinPhase[indexC]-PERIOD == 0){
PhaseC(0, 0);
PhaseC(1, 0);
}
}

void TIM2_IRQHandler(void){
if(TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET){
TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
calc_index_phase(index_phase);
index_phase++;
if (index_phase > PERIOD) index_phase = 0;
}
}



The question is, why is this happening? Since I wanted to make a smooth start also adjustable (in the future), that is, I mean engine acceleration (frequency change step and acceleration period), the same for braking.
I chose a PWM frequency of about 3 kHz, and with timer 2 I actually move the pointer along the sine table. Accordingly, by changing the interrupt frequency of timer 2, I can change the frequency of the sinusoid (well, or pchevdo sinusoid). But it doesn't work. I've been fighting for 3 days now...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question