More information than you can shake a stick at here...doesn't delve too much into the 3 phase aspect though...
http://www.picbasic.co.uk/forum/show...light=inverter
More information than you can shake a stick at here...doesn't delve too much into the 3 phase aspect though...
http://www.picbasic.co.uk/forum/show...light=inverter
Hi Sylvio,
(Somehow related).
Speed Control of 3-Phase Induction Motor Using PIC18 Microcontrollers
Microchip AN843: (PDF)
http://ww1.microchip.com/downloads/e...tes/00843a.pdf
(Code and PDF).
http://www.microchip.com/stellent/id...pnote=en012011
Example of 3-phase bridge driver chip:
http://www.irf.com/product-info/data...ata/ir2136.pdf
Best regards,
Luciano
Well.. Thank you Skimask and Luciano. Excelent readings!
So, I've bought a 16F777 and it has 3 CCP modules. As suggest in the readings above, it becomes easier to create an analog output when using high PWM frequencys. Using @ 20Mhz and Mister_E's PicMultiCalc, it turn out that it can generate frequencys > 20Khz, what is enought to this application.
Timer2 is responsable to control the PWM frequencys (all the same).
Timer1 is responsable to create the interruption to supply the new duty cycle value.
Now, let'ss think about the sine table and the software. Just to remember, I'll create an interface to control sine frequency, amplitude and also the sine table, as it would be interesting to create harmonics, sags and swells.
The sine table could be in the pic's data memory or it could be sent throught USART everytime that the user changes the interface option, like frequency. Do you think that it would work in real time using USART?
Thanks again!
Sylvio,
Well, things have been working until now...
When Timer1 interrupts, a INDEX var is summed and another position in a sine table is selected.. then a new value is output throught HPWM.
The sine table is filled with 72 number.. So, to create a 60Hz sine wave, o must read it at approx. 4.32KHz.
So, When I set timer1 to 64386 (1:1 prescaler @ 20MHz), it should interrupt at ~4.32KHz and create de 60Hz sine wave... but, it is generating a 26Hz... if I set timer1 to 65000, it decreases the 26Hz to 20Hz ... I didnt get iT! It should read the table faster, shoul'nt it?
Well, thanks!!!
Sylvio,
I'm guessing here, wild stab, since I don't see any other code here...
It might be reading it faster, but it might be missing/skipping a Tmr1 interrupt due to how long it takes to accomplish your interrupt code.
Try increasing the number by small amounts, see if it actually increases up to a point, and then drops off.
So, here we go..
Didnt show var byte stuffs..
Code:define OSC 20 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1,36% DEFINE HSER_CLROERR 1 ' Clear overflow automatically ' Set CCPx pins to outputs TRISC.2 = 0 ' CCP1 output TRISC.1 = 0 ' CCP2 output (could also be assigned to RB3) TRISB.5 = 0 ' CCP3 output ' Set CCP modules to PWM mode CCP1CON = %00001100 ' Mode select = PWM CCP2CON = %00001100 ' Mode select = PWM CCP3CON = %00001100 ' Mode select = PWM INTCON = %11000000 LOAD = 64386' 4320Hz 'LOAD = 0 TMR1H = LOAD.HIGHBYTE TMR1L = LOAD.LOWBYTE T1CON = %00000001 PIE1.0 = 1 PR2 = 49 PORTD.0 = 0 ' Set TMR2 up for 1:1 prescale & turn it on T2CON = %00000100 ' TMR2 ON 1:1 prescale ASM INT_LIST macro ;IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _Timer1, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT ; Habilita interrupção do TMR1 MAIN: IF FLAG = 1 THEN flag = 0 CONTA = CONTA + 1 CONTB = CONTB + 1 CONTC = CONTC + 1 if contA = 71 then contA = 0 if contB = 71 then contB = 0 if contC = 71 then contC = 0 index = conta GOSUB tabela va = v index = contB GOSUB tabela vb = v index = contC GOSUB tabela vc = v GOSUB SAIDA endif GOTO MAIN TABELA: SELECT CASE DIST CASE 1: ' Fundamental LOOKUP INDEX, [100,109,118,126,135,143,151,158,165,171,177,183,187,191,195,197,199,200,200,199,198,196,193,189,185,180,175,168,162,154,147,139,130,122,113,104,96,87,78,70,61,53,46,38,32,25,20,15,11,7,4,2,1,0,0,1,3,5,9,13,17,23,29,35,42,49,57,65,74,82,91], V CASE 2: ' 3 com 20% LOOKUP INDEX, [100,114,127,140,152,162,170,177,182,185,187,187,187,185,184,182,181,180,180,180,181,182,184,185,187,187,187,185,182,177,170,162,152,140,127,114,100,86,73,60,48,38,30,23,18,15,13,13,13,15,16,18,19,20,20,20,19,18,16,15,13,13,13,15,18,23,30,38,48,60,73,86], v CASE 3: ' 3 com 20% + 5 com 10% LOOKUP INDEX, [100,118,135,150,161,170,175,178,178,178,177,177,178,180,182,185,188,189,190,189,188,185,182,180,178,177,177,178,178,178,175,170,161,150,135,118,100,82,65,50,39,30,25,22,22,22,23,23,22,20,18,15,12,11,10,11,12,15,18,20,22,23,23,22,22,22,25,30,39,50,65,82], V CASE 4: ' 3 com 20% + 5 com 10% + 7 com 10% LOOKUP INDEX, [100,124,144,159,168,171,170,168,168,171,175,181,187,190,190,188,184,181,180,181,184,188,190,190,187,181,175,171,168,168,170,171,168,159,144,124,100,76,56,41,32,29,30,32,32,29,25,19,13,10,10,12,16,19,20,19,16,12,10,10,13,19,25,29,32,32,30,29,32,41,56,76], V CASE 5: ' 5 com 10% + 7 com 20% lookup index, [100,122,139,149,151,147,141,136,137,145,157,172,186,194,197,194,188,183,181,183,188,194,197,194,186,172,157,145,137,136,141,147,151,149,139,122,100,78,61,51,49,53,60,64,63,55,43,28,14,6,3,6,12,17,19,17,12,6,3,6,14,28,43,55,63,64,59,53,49,51,61,78], v CASE 6: return CASE 7: return end select return SAIDA: CCP1CON.4 = VA.0 CCP1CON.5 = VA.1 CCPR1L = VA >> 2 CCP2CON.4 = VB.0 CCP2CON.5 = VB.1 CCPR2L = VB >> 2 CCP3CON.4 = VC.0 CCP3CON.5 = VC.1 CCPR3L = VC >> 2 RETURN Timer1: TMR1H = load.highbyte TMR1L = load.lowbyte FLAG = 1 @ INT_RETURN END
Sylvio,
Do(does?) DT_INT's reset TMR1IF for you?
Past that, get rid of everything else and just toggle a pin, only toggle a pin, and nothing but toggle a pin...and measure that and see what happens.
What does this do on PortD.0?
My point is that it looks like your program 'flow' is jacked up and needs to be reworked.Code:define OSC 20 DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1 DEFINE HSER_SPBRG 10 ' 115200 Baud @ 20MHz, -1,36% DEFINE HSER_CLROERR 1 ' Clear overflow automatically TRISC.2=0 : TRISC.1=0 : TRISB.5=0 : TRISD.0 = 0 : CCP1CON=12 : CCP2CON=12 CCP3CON=12 : INTCON=$c0 : LOAD=64386 : TMR1H=LOAD.HIGHBYTE TMR1L=LOAD.LOWBYTE : T1CON=1 : PIE1.0 = 1 : PR2 = 49 : PORTD.0 = 0 : T2CON = 4 ASM INT_LIST macro ;IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _Timer1, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE TMR1_INT ; Habilita interrupção do TMR1 MAIN: GOTO MAIN Timer1: TMR1H = load.highbyte : TMR1L = load.lowbyte if portd.0 = 0 then portd.0 = 1 else portd.0 = 0 endif @ INT_RETURN END
Bookmarks