jean12
Advanced Member level 2
- Joined
- Aug 27, 2013
- Messages
- 529
- Helped
- 5
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 18
- Activity points
- 5,497
Hello everybody,is it possible that anyone can help me to adjust the codes on Tahmid blog https://tahmidmc.blogspot.com/2012/10/generation-of-sine-wave-using-spwm-in_10.html?showComment=1380559346024#c3919127146444511070so I can replace the PIC16F684 he used with the PIC16F1827 I have.
Another problem is that few months ago I did with PIC16F876A which I don't have now then I can't control the MOSFET H-Bridge with the simple transistors on the output of the PIC so I decided to replace those transistors with MOSFET Drive HV400IP ;can anyone suggest any other thing I can do so I can control by H_Bridge?
Here below are the codes I tried to modify but I am doubting on the configuration of PORTB for output where Tahmid was using PORTC .
Consider the codes:
Please help.
Thanks.!!
Another problem is that few months ago I did with PIC16F876A which I don't have now then I can't control the MOSFET H-Bridge with the simple transistors on the output of the PIC so I decided to replace those transistors with MOSFET Drive HV400IP ;can anyone suggest any other thing I can do so I can control by H_Bridge?
Here below are the codes I tried to modify but I am doubting on the configuration of PORTB for output where Tahmid was using PORTC .
Consider the codes:
PHP:
unsigned char sin_table[32]={0,25,49,73,96,118,137,
159,177,193,208,220,231,239,245,249,250,249,245,
239,231,220,208,193,177,159,137,118,96,73,49,25};
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 >> 11;
DUTY_CYCLE = TBL_POINTER_SHIFT;
CCPR1L = sin_table[DUTY_CYCLE];
TBL_POINTER_OLD = TBL_POINTER_NEW;
TMR2IF_bit = 0;
}
}
void main() {
SET_FREQ = 410;
TBL_POINTER_SHIFT = 0;
TBL_POINTER_NEW = 0;
TBL_POINTER_OLD = 0;
DUTY_CYCLE = 0;
//ANSEL = 0; //Disable ADC commenetd myself
// CMCON0 = 7; //Disable Comparator commenetd myself
//PR2 = 249;
PR2=187; ///for 16Khz at 12MHZ of quartz
// TRISC = 0x3F; commenetd myself
TRISB=0x3F;//defined myself for PWM output pins
CCP1CON = 0x4C;
TMR2IF_bit = 0;
T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
while (TMR2IF_bit == 0);
TMR2IF_bit = 0;
TRISB=0; //defined my self for PWM out
// TRISC = 0; commenetd myself the PIC doesn't have portc
TMR2IE_bit = 1;
GIE_bit = 1;
PEIE_bit = 1;
while(1);
}
Please help.
Thanks.!!
Last edited: