- Joined
- Jan 22, 2008
- Messages
- 52,470
- Helped
- 14,756
- Reputation
- 29,794
- Reaction score
- 14,118
- Trophy points
- 1,393
- Location
- Bochum, Germany
- Activity points
- 298,310
Not suited as inrush current limiter. And very few types specified for 230 V.I am planning to use Littlefuse PPTC Resettable fuses.
I can't and will not use bulky transformers.
Please provide the falstad data.
Code dot - [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 $ 1 1.4999999999999999E-5 4.078577355933338 36 340.0 50 d 464 368 464 256 1 0.805904783 c 464 256 320 256 0 9.999999999999999E-5 200.65586007421103 w 464 256 576 256 0 g 400 368 400 400 0 d 464 480 464 368 1 0.805904783 c 464 480 320 480 0 9.999999999999999E-5 -216.8367101555673 r 576 368 688 368 0 460.0 w 576 480 464 480 0 w 576 368 576 416 0 w 400 368 464 368 0 t 512 304 576 304 0 -1 120.22767147991942 -0.7384996724127859 100.0 w 576 256 576 288 0 w 576 320 576 368 0 t 512 432 576 432 0 1 -307.2484937908043 -0.8207627924477082 100.0 w 576 448 576 480 0 x 220 427 302 433 0 24 normal g 688 368 688 432 0 w 464 368 512 368 0 r 512 368 512 304 0 64000.0 r 512 368 512 432 0 64000.0 O 576 368 640 400 0 x 283 220 666 226 0 24 AC-in-AC-out voltage multiplier x 246 480 280 486 0 24 AC x 384 294 411 299 0 20 C1 x 383 448 410 453 0 20 C2 R 256 368 256 256 0 1 50.0 255.0 0.0 -1.5707963267948966 0.5 x 234 402 290 408 0 24 sub- x 229 454 298 460 0 24 mains l 320 256 320 368 0 0.1 -0.6746108233287229 l 320 368 320 480 0 0.1 1.8117994189956972 w 256 368 320 368 0 O 576 256 640 256 0 O 576 480 640 480 0 x 661 268 676 274 0 24 1 x 665 491 680 497 0 24 2 x 605 347 655 353 0 24 load o 25 32 0 34 320.0 1.6 0 -1 supply o 25 32 0 33 234.89251465925076 4.697850293185016 0 -1 supply o 1 32 0 35 481.63936022140547 2.4081968011070285 1 -1 C1 o 5 32 0 295 294.2755191266113 2.942755191266114 1 -1 C2 o 31 32 0 34 640.0 9.765625E-5 2 -1 out1 o 32 32 0 294 640.0 9.765625E-5 2 -1 out2 o 20 32 0 290 523.7424972633827 9.765625000000001E-155 3 -1 load o 6 32 1 35 523.7424972633827 9.765625000000001E-155 3 -1 load
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 // LCD module connections sbit LCD_RS at LATC0_bit; sbit LCD_EN at LATC3_bit; sbit LCD_D4 at LATC4_bit; sbit LCD_D5 at LATC5_bit; sbit LCD_D6 at LATC6_bit; sbit LCD_D7 at LATC7_bit; sbit LCD_RS_Direction at TRISC0_bit; sbit LCD_EN_Direction at TRISC3_bit; sbit LCD_D4_Direction at TRISC4_bit; sbit LCD_D5_Direction at TRISC5_bit; sbit LCD_D6_Direction at TRISC6_bit; sbit LCD_D7_Direction at TRISC7_bit; // End LCD module connections char msg[17]; const char msg1[] = " Inverter "; const char msg2[] = ""; const char msg3[] = ""; const char msg4[] = ""; #define DEMO_LIMIT_MAX 3 #define DEMO_LIMIT_MAX_ADDRESS 0x10 char demo_limit = 0; const unsigned char sine_table[64] = { 0,1,2,5,10,15,21,29, 37,47,57,67,79,90,103,115, 128,140,152,165,176,188,198,208, 218,226,234,240,245,250,253,254, 255,254,253,250,245,240,234,226, 218,208,198,188,176,165,152,140, 128,115,103,90,79,67,57,47, 37,29,21,15,10,5,2,1 }; /* const unsigned int sine_table[64] = { 512,562,611,660,707,753,796,836, 873,907,937,963,984,1001,1013,1021, 1023,1021,1013,1001,984,963,937,907, 873,836,796,753,707,660,611,562, 512,461,412,363,316,270,227,187, 150,116,86,60,39,22,10,2, 0,2,10,22,39,60,86,116, 150,187,227,270,316,363,412,461 }; */ unsigned int TBL_POINTER_NEW = 0, TBL_POINTER_OLD = 0, TBL_POINTER_SHIFT = 0, DUTY_CYCLE = 0, SET_FREQ = 512; //Timer2 //Prescaler 1:1; Postscaler 1:2; TMR2 Preload = 194; Actual Interrupt Time : 78 us (because 12.820 KHz PWM) //Place/Copy this part in declaration section void InitTimer2() { T2CON = 0x0C; TMR2IE_bit = 1; PR2 = 194; INTCON = 0xC0; } void interrupt() { if(TMR2IF_bit) { //Enter your code here //SET_FREQ = 65536 / (64 * 2) = 512 //Required AC Frequency = 50 Hz //PWM Freq = 12821 Hz //Tpwm = 1/12.821 KHz = 78 us (Timer2 Interrupt Period) //78 us * 64 * 2 = 9984 = 9.984 ms (for 180 degrees) //9.984 * 2 = 19.968 ms //AC freq = 1/19.968 ms = 50.08 Hz 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; //Assign PWM duty 10 bit CCPR1L = (sine_table[DUTY_CYCLE] & 0x3FC) >> 2; CCP1CON.DC1B1 = (sine_table[DUTY_CYCLE] & 0x02) >> 1; CCP1CON.DC1B0 = (sine_table[DUTY_CYCLE] & 0x01); TBL_POINTER_OLD = TBL_POINTER_NEW; TMR2IF_bit = 0; } } char *CopyConst2Ram(char *dest, const code char *src) { char *d; d = dest; for(;*dest++ = *src++;)asm clrwdt; return d; } void main() { asm clrwdt /* demo_limit = EEPROM_Read(DEMO_LIMIT_MAX_ADDRESS); Delay_ms(20); if(demo_limit <= DEMO_LIMIT_MAX) { demo_limit++; EEPROM_Write(DEMO_LIMIT_MAX_ADDRESS, demo_limit); Delay_ms(20); } */ //if(demo_limit < DEMO_LIMIT_MAX) { CM1CON0 = 0x00; CM2CON0 = 0x00; SLRCON = 0x00; ANSELA = 0x00; ANSELB = 0x00; ANSELC = 0x00; ANSELD = 0x00; ANSELE = 0x00; TRISA = 0xC7; TRISB = 0b00010110; TRISC = 0b00000110; TRISD = 0x00; TRISE = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; PORTE = 0x00; LATA = 0x00; LATB = 0x00; LATC = 0x00; LATD = 0x00; LATE = 0x00; //PWM1_Init(30000); //DC-DC Converter //PWM1_Set_Duty(250); //PWM1_Stop(); //PWM1_Start(); //PWM4_Init(12821); //PWM4_Set_Duty(127); //FAN //PWM4_Stop(); //PWM4_Start(); PWM3_Init(12821); PWM3_Set_Duty(0); CCP1CON.CCP1M3 = 1; CCP1CON.CCP1M2 = 1; CCP1CON.CCP1M1 = 0; CCP1CON.CCP1M0 = 0; CCP1CON.P1M0 = 1; CCP1CON.P1M1 = 0; InitTimer2(); TRISB = 0x00; TRISC = 0x00; Delay_ms(200); /* LCD_init(); LCD_Cmd(_LCD_CURSOR_OFF); LCD_Cmd(_LCD_CLEAR); LCD_Out(1,1,CopyConst2Ram(msg, msg1)); */ PWM3_Start(); //} while(1) { asm clrwdt if(demo_limit < DEMO_LIMIT_MAX) { } } }
Ok. I changed the resistor to 32k. Now the signal is correct. Now I can feed it to Mosfets using FET drivers.
He just can't decide what to develop - voltage inverter or audio amplifier )))May be I am confusing. Will you feed this sinewave signal to MOSFET using FET Driver?
//Timer2
//Prescaler 1:1; Postscaler 1:1; TMR2 Preload = 155; Actual Interrupt Time : 78 us
//Place/Copy this part in declaration section
void InitTimer2() {
T2CON = 0x04;
TMR2IE_bit = 1;
PR2 = 155;
INTCON = 0xC0;
}
I am planning to make a AC to DC and DC to AC that is AC-DC-AC constant voltage stabilizer for refrigirator.
I just have some doubts regarding precautions to be taken like
What happens if terminals of a 12V 200Ah battery are shorted ? Will the battery explode ?
If I use a 230V AC to 14.4V DC buck converter for battery charging then what happens if PWM duty is 100% or if mosfet shorts. Will the 325V DC appear across the battery terminal and explode the battery ?
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 // LCD module connections sbit LCD_RS at LATB4_bit; sbit LCD_EN at LATB5_bit; sbit LCD_D4 at LATB0_bit; sbit LCD_D5 at LATB1_bit; sbit LCD_D6 at LATB2_bit; sbit LCD_D7 at LATB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD module connections #define MAX_DEMO_LIMIT 20 #define MAX_DEMO_LIMIT_ADDRESS 0x20 #define FBCh 0 char demo_limit = 0; char msg[17]; unsigned int FBV = 0, FB_Step = 0, adder = 0; const char msg1[] = " Stabilizer "; const char msg2[] = " Inverter "; const char msg3[] = ""; const char msg4[] = ""; const unsigned char sine_table[960] = { 0,0,2,4,6,10,14,18, 24,30,36,43,50,58,66,74, 82,89,97,105,113,120,127,133, 139,145,149,153,157,159,161,163, 163,163,161,159,157,153,149,145, 139,133,127,120,113,105,97,89, 82,74,66,58,50,43,36,30, 24,18,14,10,6,4,2,0, 0,0,2,4,6,10,14,19, 25,31,38,45,52,60,68,76, 85,93,101,109,117,124,131,138, 144,150,155,159,163,165,167,169, 169,169,167,165,163,159,155,150, 144,138,131,124,117,109,101,93, 85,76,68,60,52,45,38,31, 25,19,14,10,6,4,2,0, 0,0,2,4,7,10,15,20, 26,32,39,46,54,62,70,79, 88,96,105,113,121,129,136,143, 149,155,160,165,168,171,173,175, 175,175,173,171,168,165,160,155, 149,143,136,129,121,113,105,96, 88,79,70,62,54,46,39,32, 26,20,15,10,7,4,2,0, 0,0,2,4,7,11,15,21, 27,33,40,48,56,64,73,82, 91,99,108,117,125,133,141,148, 154,160,166,170,174,177,179,181, 181,181,179,177,174,170,166,160, 154,148,141,133,125,117,108,99, 91,82,73,64,56,48,40,33, 27,21,15,11,7,4,2,0, 0,0,2,4,7,11,16,21, 28,34,42,50,58,67,76,85, 94,103,112,121,130,138,146,154, 160,167,172,177,181,184,186,188, 188,188,186,184,181,177,172,167, 160,154,146,138,130,121,112,103, 94,85,76,67,58,50,42,34, 28,21,16,11,7,4,2,0, 0,0,2,4,7,11,16,22, 28,35,43,51,60,69,78,87, 97,107,116,125,134,143,151,159, 166,172,178,183,187,190,192,194, 194,194,192,190,187,183,178,172, 166,159,151,143,134,125,116,107, 97,87,78,69,60,51,43,35, 28,22,16,11,7,4,2,0, 0,0,2,4,8,12,17,23, 29,37,44,53,62,71,80,90, 100,110,120,129,138,147,156,163, 171,177,183,188,192,196,198,200, 200,200,198,196,192,188,183,177, 171,163,156,147,138,129,120,110, 100,90,80,71,62,53,44,37, 29,23,17,12,8,4,2,0, 0,0,2,4,8,12,17,23, 30,38,46,54,64,73,83,93, 103,113,123,133,142,152,160,168, 176,183,189,194,198,202,204,206, 206,206,204,202,198,194,189,183, 176,168,160,152,142,133,123,113, 103,93,83,73,64,54,46,38, 30,23,17,12,8,4,2,0, 0,1,2,5,8,13,18,24, 31,39,47,56,66,76,86,96, 107,117,127,137,147,157,166,174, 182,189,195,200,205,208,211,212, 213,212,211,208,205,200,195,189, 182,174,166,157,147,137,127,117, 107,96,86,76,66,56,47,39, 31,24,18,13,8,5,2,1, 0,1,2,5,8,13,18,25, 32,40,49,58,68,78,88,99, 110,120,131,141,151,161,170,179, 187,194,201,206,211,214,217,218, 219,218,217,214,211,206,201,194, 187,179,170,161,151,141,131,120, 110,99,88,78,68,58,49,40, 32,25,18,13,8,5,2,1, 0,1,2,5,9,13,19,26, 33,41,50,59,69,80,91,101, 113,124,134,145,156,166,175,184, 192,199,206,212,216,220,223,224, 225,224,223,220,216,212,206,199, 192,184,175,166,156,145,134,124, 113,101,91,80,69,59,50,41, 33,26,19,13,9,5,2,1, 0,1,2,5,9,14,19,26, 34,42,51,61,71,82,93,104, 116,127,138,149,160,170,180,189, 197,205,212,217,222,226,229,230, 231,230,229,226,222,217,212,205, 197,189,180,170,160,149,138,127, 116,104,93,82,71,61,51,42, 34,26,19,14,9,5,2,1, 0,1,2,5,9,14,20,27, 35,44,53,63,73,84,96,107, 119,131,142,154,165,175,185,194, 203,211,218,224,229,233,236,237, 238,237,236,233,229,224,218,211, 203,194,185,175,165,154,142,131, 119,107,96,84,73,63,53,44, 35,27,20,14,9,5,2,1, 0,1,2,5,9,14,21,28, 36,45,54,64,75,87,98,110, 122,134,146,157,169,180,190,199, 208,216,223,230,235,239,242,243, 244,243,242,239,235,230,223,216, 208,199,190,180,169,157,146,134, 122,110,98,87,75,64,54,45, 36,28,21,14,9,5,2,1, 0,1,2,5,10,15,21,28, 37,46,56,66,77,89,101,113, 125,137,149,161,173,184,194,204, 213,222,229,235,240,245,248,249, 250,249,248,245,240,235,229,222, 213,204,194,184,173,161,149,137, 125,113,101,89,77,66,56,46, 37,28,21,15,10,5,2,1 }; unsigned int TBL_POINTER_NEW = 0, TBL_POINTER_OLD = 0, TBL_POINTER_SHIFT = 0, DUTY_CYCLE = 0, SET_FREQ = 512; //Timer2 //Prescaler 1:1; Postscaler 1:1; TMR2 Preload = 77; Actual Interrupt Time : 78 us @ 4 MHz Internal Oscillator //Place/Copy this part in declaration section void InitTimer2() { T2CON = 0x04; TMR2IE_bit = 1; PR2 = 77; INTCON = 0xC0; } void interrupt() { if((TMR2IE_bit) && (TMR2IF_bit)) { //Enter your code here //SET_FREQ = 65536 / (64 * 2) = 512 //Required AC Frequency = 50 Hz //PWM Freq = 12821 Hz //Tpwm = 1/12.821 KHz = 78 us (Timer2 Interrupt Period) //78 us * 64 * 2 = 9984 = 9.984 ms (for 180 degrees) //9.984 * 2 = 19.968 ms //AC freq = 1/19.968 ms = 50.08 Hz 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 + adder; //Assign PWM duty 10 bit CCPR1L = (sine_table[DUTY_CYCLE] & 0x3FC) >> 2; CCP1CON.DC1B1 = (sine_table[DUTY_CYCLE] & 0x02) >> 1; CCP1CON.DC1B0 = (sine_table[DUTY_CYCLE] & 0x01); TBL_POINTER_OLD = TBL_POINTER_NEW; TMR2IF_bit = 0; } } char *CopyConst2Ram(char *dest, const code char *src) { char *d; d = dest; for(;*dest++ = *src++;)asm clrwdt; return d; } void main() { asm clrwdt OSCCON = 0x57; OSCTUNE = 0x00; /* demo_limit = EEPROM_Read(MAX_DEMO_LIMIT_ADDRESS); Delay_ms(20); if(demo_limit <= MAX_DEMO_LIMIT) { demo_limit++; EEPROM_Write(MAX_DEMO_LIMIT_ADDRESS, demo_limit); Delay_ms(20); } */ CM1CON0 = 0x00; CM2CON0 = 0x00; SLRCON = 0x00; ADCON1 = 0x80; ADCON2 = 0b10110101; ANSELA = 0x01; ANSELB = 0x00; ANSELC = 0x00; ANSELD = 0x00; ANSELE = 0x00; TRISA = 0xC1; TRISB = 0x00; TRISC = 0x06; TRISD = 0xE0; TRISE = 0x00; PORTA = 0x00; PORTB = 0x00; PORTC = 0x00; PORTD = 0x00; PORTE = 0x00; LATA = 0x00; LATB = 0x00; LATC = 0x00; LATD = 0x00; LATE = 0x00; //PWM4_Init(12821); //PWM4_Set_Duty(127); //FAN //PWM4_Stop(); //PWM4_Start(); PWM3_Init(12821); PWM3_Set_Duty(0); CCP1CON.CCP1M3 = 1; CCP1CON.CCP1M2 = 1; CCP1CON.CCP1M1 = 0; CCP1CON.CCP1M0 = 0; CCP1CON.P1M0 = 1; CCP1CON.P1M1 = 0; Delay_ms(200); // Lcd code doesn't work if called after InitTimer2() // as ISR will be called every 78 us LCD_Init(); LCD_Cmd(_LCD_CURSOR_OFF); LCD_Cmd(_LCD_CLEAR); LCD_Out(1,1,CopyConst2Ram(msg, msg1)); InitTimer2(); TRISC = 0x00; TRISD = 0x00; PWM3_Start(); while(1) { asm clrwdt //if(demo_limit < MAX_DEMO_LIMIT) { //} FBV = ADC_Read(FBCh); if(FBV < 512) { if(++FB_Step > 14) { // eg: 14 = (0 to 14) no. of pwm duty sets in the array FB_Step = 14; // example if FB_Step = 15 then (see last line) } } else{ if(FB_Step > 0) { FB_Step--; } } adder = FB_Step << 6; // << 6 because I have 2^6 = 64 entries in each pwm duty set // 14 << 6 = 896 /* ********** code from ISR *********** 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 + adder; /* ************************************* Eg: TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ; TBL_POINTER_NEW = 0 + 512; //512 TBL_POINTER_SHIFT = 512 >> 10; // 0 DUTY_CYCLE = TBL_POINTER_SHIFT + adder; //adder = 896, FB_Step = 14 DUTY_CYCLE = 0 + 896; // In the 64 pwm duties (of each pwm duty set), each duty is called twice // to get 50 Hz TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ; // So, (SET_FREQ * 64 * 2) = 512 * 64 * 2 = 65536 //So, Eg: TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ; TBL_POINTER_NEW = (65536 - 512) + 512; //65536 TBL_POINTER_SHIFT = 65536 >> 10; // 64 DUTY_CYCLE = TBL_POINTER_SHIFT + adder; //adder = 896, FB_Step = 14 DUTY_CYCLE = 64 + 896; //960 (last entry of the array that is 1) */ } }
Also there is another problem. if feedback value is >= 512 then I am getting sinewave but if feedback value is less than 512 I am getting distorted signal and also frequency is 50 Hz
PIC is PIC18F46K22, OSCCON and OSCTUNE configurations are correct but I am getting 30 Hz Sinewave. Why ?
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?