- sin(16*90o/16)*100%
- sin(15*90o/16)*100%
- sin(14*90o/16)*100%
- sin(13*90o/16)*100%
- sin(12*90o/16)*100%
- sin(11*90o/16)*100%
- sin(10*90o/16)*100%
- sin(9*90o/16)*100%
- sin(8*90o/16)*100%
- sin(7*90o/16)*100%
- sin(6*90o/16)*100%
- sin(5*90o/16)*100%
- sin(4*90o/16)*100%
- sin(3*90o/16)*100%
- sin(2*90o/16)*100%
- sin(1*90o/16)*100%
- sin(0*90o/16)*100%
what do you suggest for a better resolution?
i mean when Q4 is on Q3 should be switched off and when Q4 on it should be switched off. Is it a good idea to do so and if it is how would i do it?
i am concerned about the situation when Q1 is on and Q4 is off. Q1 will be floating. Well this cause any problems?
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 unsigned char sin_table[64]={0, 6, 12, 18, 24, 30, 36, 42, 48, 53, 59, 64, 69, 74, 79, 84, 88, 93, 97, 100, 104, 107, 110, 113, 115, 118, 120, 121, 123, 124, 124, 125, 125, 125, 124, 124, 123, 121, 120, 118, 115, 113, 110, 107, 104, 100, 97, 93, 88, 84, 79, 74, 69, 64, 59, 53, 48, 42, 36, 30, 24, 18, 12, 6}; unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ; unsigned int TBL_temp; unsigned char DUTY_CYCLE; void interrupt(){ if (TMR2IF_bit == 1){ TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ; if (TBL_POINTER_NEW < TBL_POINTER_OLD){ CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge } TBL_POINTER_SHIFT = TBL_POINTER_NEW >> 10; DUTY_CYCLE = TBL_POINTER_SHIFT; CCPR1L = sin_table[DUTY_CYCLE]; TBL_POINTER_OLD = TBL_POINTER_NEW; TMR2IF_bit = 0; } } void main() { SET_FREQ = 1024; TBL_POINTER_SHIFT = 0; TBL_POINTER_NEW = 0; TBL_POINTER_OLD = 0; DUTY_CYCLE = 0; ANSEL = 0; //Disable ADC CM1CON0 = 0; //Disable Comparator CM2CON0 = 0; TRISC.F2 = 0; TRISD.F5 = 0; TRISD.F6 = 0; TRISD.F7 = 0; TRISC.F0 = 1; TRISC.F1 = 1; PORTC.F2 = 0; PORTD.F5 = 0; PORTD.F6 = 0; PORTD.F7 = 0; PR2 = 0b01111100; CCP1CON = 0b01001100; // duty lowest bits + PWM mode TMR2IF_bit = 0; T2CON = 4; //TMR2 on, prescaler and postscaler 1:1 while (TMR2IF_bit == 0); TMR2IF_bit = 0; TRISC = 0; TMR2IE_bit = 1; GIE_bit = 1; PEIE_bit = 1; while(1); }
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 void LoadPWM ( void ) { if ( direction== UP) PWM_counter++ ; else PWM_counter-- ; switch ( PWM_counter ) { case 0 : LevelMin() ; set_pwm1_duty ( 0 ) ; break ; case 1 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 2 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 3 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 4 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 5 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 6 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 7 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 8 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 9 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 10 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 11 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 12 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 13 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 14 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 15 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 16 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 17 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 18 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 19 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 20 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 21 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 22 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 23 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 24 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 25 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 26 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 27 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 28 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 29 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 30 : set_pwm1_duty ( Duty[PWM_counter] ) ; break ; case 31 : LevelMax(); set_pwm1_duty ( Duty[PWM_counter] ) ; break ; }
when Q1 is high and Q4 is switching, is it possible to send to Q3 the inverse signal of Q4. Q4on==Q3 off and Q4 0ff == Q3 on.
Same thing for the negative half of the cycle when Q3 is high and Q2 is switching, make Q1 do the inverse of Q2 so Q2 on ==Q1 off and Q2 off == Q1 on.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?