Pada kesempatan yang berbahagia kali ini akan dijelaskan cara membuat inverter 3 fasa sendiri menggunakan mikrokontroller dsPIC30F4012, perlu diketahui bahwa inverter ini terdapat tegangan spike / tegangan over, sehingga spesifikasi MOSFET dan IC driver mosfet harus di perhatikan, karena jika tidak memenuhi standart yang diinginkan, alat bisa rusak atau jebol, untuk membuat alat ini beberapa komponen yang harus dibuat yaitu, mikrokontroller dsPIC30F4012, driver MOSFET IC IR2110 dan MOSFET IRFP460. berikut penjelasan mengenai skema dan programnya.
*ket: pada gambar minimum sistem diatas sengaja menggunakan ATMega8, namun susunan pin disesuaikan dengan pin dsPIC30F4012.
2. Driver MOSFET
*ket: pada gambar diatas hanya 1 skematik driver MOSFET saja, jika digunakan untuk 3 fasa maka memerlukan rangkaian MOSFET driver sebanyak 3 buah.
komponen = IR2110, MOSFET IRFP460
3. PROGRAM MPLAB IDE
* Requires MPLAB C30 v3.25 or above
#include <p30fxxxx.h>
//#include <pwm.h>
#define XTFREQ 16000000 // External crystal frequency [Hz]
#define PLLMODE 4 // Internal PLL multiplication factor
#define FCY (XTFREQ * PLLMODE / 4) // Internal operating frequency
#define FPWM 20000 // PWM frequency [Hz]
#define _DES_FREQ 60 // desired sine wave frequency [Hz]
#define _DELTA_PHASE (unsigned int)(_DES_FREQ * 65536 / FPWM)
#define _120_DEGREES 0x5555
#define _240_DEGREES 0xAAAA
// Configuration bits:
_FOSC(CSW_FSCM_OFF & XT_PLL4); // Turn off clock switching and
// fail-safe clock monitoring and
// use the XT osc and 4x PLL as
// system clock
_FWDT(WDT_OFF); // Turn off Watchdog Timer
_FBORPOR(PBOR_OFF & MCLR_EN);
// Set Brown-out Reset voltage and set Power-up Timer to 16 ms
_FGS(CODE_PROT_OFF); // Set Code Protection Off
// Constants
const int SineTable [64] = {
0,3212,6393,9512,12539,15446,18204,20787,23170,25329,
27245,28898,30273,31356,32137,32609,32767,32609,32137,31356,30273,28898,
27245,25329,23170,20787,18204,15446,12539,9512,6393,3212,0,-3212,-6393,
-9512,-12539,-15446,-18204,-20787,-23170,-25329,-27245,-28898,-30273,
-31356,-32137,-32609,-32767,-32609,-32137,-31356,-30273,-28898,-27245,
-25329,-23170,-20787,-18204,-15446,-12539,-9512,-6393,-3212
};
// Variables
int Multiplier, Result;
unsigned int Phase = 0, Delta_Phase,Phase_Offset;
// Function prototypes
void __attribute__((__interrupt__, auto_psv))_PWMInterrupt(void);
void SysInit(void);
// PWM Module Interrupt
void __attribute__((__interrupt__)) _PWMInterrupt(void){
PWMCON2bits.UDIS = 1;
// Update PDC1 register
Phase += _DELTA_PHASE;// Accumulate Delta_Phase in Phase variable
Multiplier = SineTable[Phase >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC1 = Result + PTPER;// Remove negative values of the duty cycle
// Update PDC2 register
Multiplier = SineTable[(Phase + _120_DEGREES) >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC2 = Result + PTPER;// Remove negative values of the duty cycle
// Update PDC3 register
Multiplier = SineTable[(Phase + _240_DEGREES) >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC3 = Result + PTPER;// Remove negative values of the duty cycle
PWMCON2bits.UDIS = 0;
IFS2bits.PWMIF = 0;
}
// System initialization
void SysInit(void) {
// Initialize the I/O Ports
TRISB = 0X0000;
TRISE = 0x0100;
// Initialize the PWM Module
PTPER = ((FCY/FPWM) - 1 ) >> 1;
OVDCON = 0x3F00;
DTCON1 = 0x00C4;
PWMCON1 = 0x00FF; //Enable PWM Pins and enable complementary mode
PWMCON2 = 0x0011;
PDC1 = PTPER; // initial value = 0 Volts
PDC2 = PTPER; // initial value = 0 Volts
PDC3 = PTPER;
IFS2bits.PWMIF = 0; // Clear PWM interrupt flag
IEC2bits.PWMIE = 1; // Enable PWM interrupt
PTCONbits.PTEN = 1;
PTCONbits.PTMOD= 2 ;
}
// Main
int main (void){
SysInit();
while (1){
// Endless loop
}
return 0;
}
//#include <pwm.h>
#define XTFREQ 16000000 // External crystal frequency [Hz]
#define PLLMODE 4 // Internal PLL multiplication factor
#define FCY (XTFREQ * PLLMODE / 4) // Internal operating frequency
#define FPWM 20000 // PWM frequency [Hz]
#define _DES_FREQ 60 // desired sine wave frequency [Hz]
#define _DELTA_PHASE (unsigned int)(_DES_FREQ * 65536 / FPWM)
#define _120_DEGREES 0x5555
#define _240_DEGREES 0xAAAA
// Configuration bits:
_FOSC(CSW_FSCM_OFF & XT_PLL4); // Turn off clock switching and
// fail-safe clock monitoring and
// use the XT osc and 4x PLL as
// system clock
_FWDT(WDT_OFF); // Turn off Watchdog Timer
_FBORPOR(PBOR_OFF & MCLR_EN);
// Set Brown-out Reset voltage and set Power-up Timer to 16 ms
_FGS(CODE_PROT_OFF); // Set Code Protection Off
// Constants
const int SineTable [64] = {
0,3212,6393,9512,12539,15446,18204,20787,23170,25329,
27245,28898,30273,31356,32137,32609,32767,32609,32137,31356,30273,28898,
27245,25329,23170,20787,18204,15446,12539,9512,6393,3212,0,-3212,-6393,
-9512,-12539,-15446,-18204,-20787,-23170,-25329,-27245,-28898,-30273,
-31356,-32137,-32609,-32767,-32609,-32137,-31356,-30273,-28898,-27245,
-25329,-23170,-20787,-18204,-15446,-12539,-9512,-6393,-3212
};
// Variables
int Multiplier, Result;
unsigned int Phase = 0, Delta_Phase,Phase_Offset;
// Function prototypes
void __attribute__((__interrupt__, auto_psv))_PWMInterrupt(void);
void SysInit(void);
// PWM Module Interrupt
void __attribute__((__interrupt__)) _PWMInterrupt(void){
PWMCON2bits.UDIS = 1;
// Update PDC1 register
Phase += _DELTA_PHASE;// Accumulate Delta_Phase in Phase variable
Multiplier = SineTable[Phase >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC1 = Result + PTPER;// Remove negative values of the duty cycle
// Update PDC2 register
Multiplier = SineTable[(Phase + _120_DEGREES) >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC2 = Result + PTPER;// Remove negative values of the duty cycle
// Update PDC3 register
Multiplier = SineTable[(Phase + _240_DEGREES) >> 10];// Take sine info
asm("MOV _Multiplier, W4"); // Load first multiplier
asm("MOV _PTPER, W5");// Load second multiplier
asm("MOV #_Result, W0");// Load W0 with the address of Result
asm("MPY W4*W5, A");// Perform Fractional multiplication
asm("SAC A, [W0]");// Store multiplication result in var Result
PDC3 = Result + PTPER;// Remove negative values of the duty cycle
PWMCON2bits.UDIS = 0;
IFS2bits.PWMIF = 0;
}
// System initialization
void SysInit(void) {
// Initialize the I/O Ports
TRISB = 0X0000;
TRISE = 0x0100;
// Initialize the PWM Module
PTPER = ((FCY/FPWM) - 1 ) >> 1;
OVDCON = 0x3F00;
DTCON1 = 0x00C4;
PWMCON1 = 0x00FF; //Enable PWM Pins and enable complementary mode
PWMCON2 = 0x0011;
PDC1 = PTPER; // initial value = 0 Volts
PDC2 = PTPER; // initial value = 0 Volts
PDC3 = PTPER;
IFS2bits.PWMIF = 0; // Clear PWM interrupt flag
IEC2bits.PWMIE = 1; // Enable PWM interrupt
PTCONbits.PTEN = 1;
PTCONbits.PTMOD= 2 ;
}
// Main
int main (void){
SysInit();
while (1){
// Endless loop
}
return 0;
}
4. VIDEO HASILNYA
No comments:
Post a Comment