forked from rajeshfarswan/BOOST-MPPT-CONTROL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
63 lines (37 loc) · 1.38 KB
/
main.h
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
//Processor variable definitions //
#include "p30f6010A.h"
#define RL1_ON PORTGbits.RG0
#define RL2_ON PORTGbits.RG1
#define RL3_ON PORTGbits.RG2
#define RL4_ON PORTGbits.RG3
#define RL5_ON PORTGbits.RG6
#define PWM1 PDC1
#define PWM2 PDC2
#define PWM3 PDC3
#define T1us_Flag IFS0bits.T1IF //every 1.5us flag
#define PWM_PERIOD PTPER
#define Converstion_Done ADCON1bits.DONE
#define Start_Converstion ADCON1bits.SAMP
#define CH0_MULA ADCHSbits.CH0SA
#define CH0_MULB ADCHSbits.CH0SB
#define Ipeak_flag IFS2bits.PWMIF
#define Vr_ref 1000 //1count == .202volts //max output voltage ref 1023
#define Ir_ref 160 //40count == 1A //max current ref 160
#define softCount 3000 //4.5mS
#define IrTIMER_ON T2CONbits.TON //timer2 for peak current detect
#define IrCOUNT PR2
#define T2_Flag IFS0bits.T2IF //for Ir peak detect
#define PWM_Flag IFS2bits.PWMIF
#define fault_Flag IFS2bits.FLTBIF
#define PWMenable PTCONbits.PTEN
#define PWM_InterruptEnable IEC2bits.PWMIE
#define T1ON T1CONbits.TON
#define FAULT_ENABLE FLTBCON
#define ADC_ON ADCON1bits.ADON
#define SET PWMCON1
//********************************************************
//Iout = (2.5+-(0.625*Ip/6)V)*(1024/5)
//VDCout = (Vdc*15/600)V)*(1024/5)
//VACout = (2.5+-(Vac*6.8/600)V)*(1024/5)
//********************************************************
//Iref max = 384//6A