HI,
attached is my circuit diagram, and my codes below.
i am working on a maximum powerpoint tracker for solar (PV) modules.
I want to use a MOSFET  being a voltage controlled device to control the resistance the pv module 'sees' as its load, by controlling the voltage to its gates.
I am using the FDA79N15 mosfet and i am using the ATmega16 with 10bit DAC AD7533(not labelled in diagram)
with a 5V reference.
Right now , i am not getting any resonable tracking and also the current through the circuit is very small.
Any ideas? is it the DAC? is the code ok (pretty much my first code in assembler ); is it the shunt resistor ? or the mosfet?
thanks for your advice in advance
olu
code
****************************************************
/*

Maximum Power Point Tracking

Olusola Osinowo
Ver 1.0
2007

ATmega16 Microcontroller
*/
//===========================================================================================
// Port and variable bit definitins:
;
; PortA:
; Bit 0 (ADC0): Voltage Input positive
; Bit 1 (ADC1): Current Input positive
;
; PortB:
; Bit0: Output to DAC LSB
; Bit1: Output to DAC
; Bit2: Output to DAC
; Bit3: Output to DAC
; Bit4: Output to DAC
; Bit5: Output to DAC
; Bit6: Output to DAC
; Bit7: Output to DAC
;
; PortD:
; Bit0: Output to DAC
; Bit1: Output to DAC MSB
;
;
; Move_Status:
; Bit0: Right (increasing Voltage) > low; left (decreasing voltage) > high
//===========================================================================================
// Inclued ATmega 16 definition
.include "m16def.inc"
// Variable definitions
// Outputs
// > Power Output only
// Internal Calculation
.def Mul_H = r1; > Multiplier MSB
.def Mul_L = r0; > Multiplier LSB
.def Power_Old_H = r2;
.def Power_Old_M = r3
.def Power_Old_L = r4
.def Power_New_H = r5
.def Power_New_M = r6
.def Power_New_L = r7
.def Move_Status = r17
.def Voltage_H = r19
.def Voltage_L = r20
.def Current_H = r21
.def Current_L = r22
.def Temp = r23
.def DAC_out_H = r24
.def DAC_out_L = r25
//
// Interrupt definition
// Reset
.org $000 jmp Main;
// Interupt Timer 1
.org $00C jmp MPPT;
// 
// Main function:
Main:
cli; //disabling interupts
// Clear Inputs
clr Voltage_H;
clr Voltage_L;
clr Current_H;
clr Current_L;
clr Power_New_H;
clr Power_New_M;
clr Power_New_L;
clr Power_Old_H;
clr Power_Old_M;
clr Power_Old_L;
clr Mul_H;
clr Mul_L;
clr Temp;
clr DAC_out_H;
clr DAC_out_L;
clr Move_Status;
// Initial Stack pointer
ldi Temp, LOW(RAMEND);
out SPL, Temp;
ldi Temp, HIGH(RAMEND);
out SPH, Temp;
// Initialise Timer 1
ldi Temp, 0b00010000;
out OCR1AH, Temp;
ldi Temp, 0b00000000;
out OCR1AL, Temp;
ldi Temp, 0b00000001;
out TCCR1B, Temp;
ldi Temp, 0b00010000;
out TIMSK, Temp;
// Initialise AD Converter
sbi ADCSRA, 7; set ADEN  enable AD converter
cbi ADCSRA, 2; set ADC clock prescaler
sbi ADCSRA, 1; set ADC clock prescaler
cbi ADCSRA, 0; set ADC clock prescaler
// Set inputoutput directions
ldi Temp, 0b00000000;
out DDRA, Temp; Port A Input
out PORTA, Temp;
ldi Temp, 0b11111111;
out DDRB, Temp; Port B Output
ldi Temp, 0b00000011;
out DDRD, Temp; Port D Output
// Enable Interupts
sei;
//***** First Conversion  Discard)
// Measure Voltage
ldi Temp, (1<<REFS1)(1<<REFS0)(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_K:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_K;
in Voltage_L, ADCL; Store Converted Low Bit value
in Voltage_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
//=============================================================================
// Timer 1 interrupt routinte  MPPT
MPPT:
// Reset Timer 1 clock counter
clr Temp;
out TCNT1H, Temp;
out TCNT1L, Temp;
// Measure Voltage
ldi Temp, (1<<REFS1)(1<<REFS0)(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_V:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_V;
in Voltage_L, ADCL; Store Converted Low Bit value
in Voltage_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
// Measure Current
ldi Temp, (1<<REFS1)(1<<REFS0)(1<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_C:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_C;
in Current_L, ADCL; Store Converted Low Bit value
in Current_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
// Calculate Power Performing 10bit x 10bit = 24bit multiplication
mul Voltage_H, Current_H; AH*BH
mov Power_New_H, Mul_L;
mul Voltage_L, Current_L; AL*BL
mov Power_New_M, Mul_H;
mov Power_New_L, Mul_L;
mul Voltage_H, Current_L; AH*BL
add Power_New_H, Mul_H;
add Power_New_M, Mul_L;
mul Current_H, Voltage_L; BH*AL
add Power_New_H, Mul_H;
add Power_New_M, Mul_L;
// Control Output  Perturb Algorithm
cp Power_New_H, Power_Old_H;
breq Equal_H;
brlo Lower;
rjmp Higher;
Equal_H:
cp Power_New_M, Power_Old_M;
breq Equal_M;
brlo Lower;
rjmp Higher;
Equal_M:
cp Power_New_L, Power_Old_L;
breq Equal_L;
brlo Lower;
rjmp Higher;
Lower:; move Voltage in oposite direction
sbrc Move_Status, 0;
rjmp Lower_Increase;
rjmp Lower_Decrease;
Lower_Decrease:;
sbr Move_Status, 0;
dec DAC_out_L;
cpi DAC_out_L, 255;
brne Finish;
dec DAC_out_H;
rjmp Finish;
Lower_Increase:;
cbr Move_Status, 0;
inc DAC_out_L;
brcc Finish;
inc DAC_out_H;
rjmp Finish;
Higher:; move Voltage same direction as before
sbrc Move_Status, 0
rjmp Higher_Decrease;
rjmp Higher_Increase;
Higher_Decrease:;
dec DAC_out_L;
cpi DAC_out_L, 255;
brne Finish;
dec DAC_out_H;
rjmp Finish;
Higher_Increase:;
inc DAC_out_L;
brcc Finish;
inc DAC_out_H;
rjmp Finish;
Equal_L:; equal value > do nothing
Finish:; set outputs
out PORTB, DAC_out_L;
out PORTD, DAC_out_H;
// Set New power to old power
mov Power_Old_H, Power_New_H;
mov Power_Old_M, Power_New_M;
mov Power_Old_L, Power_New_L;
// return from interrupt
reti;
attached is my circuit diagram, and my codes below.
i am working on a maximum powerpoint tracker for solar (PV) modules.
I want to use a MOSFET  being a voltage controlled device to control the resistance the pv module 'sees' as its load, by controlling the voltage to its gates.
I am using the FDA79N15 mosfet and i am using the ATmega16 with 10bit DAC AD7533(not labelled in diagram)
with a 5V reference.
Right now , i am not getting any resonable tracking and also the current through the circuit is very small.
Any ideas? is it the DAC? is the code ok (pretty much my first code in assembler ); is it the shunt resistor ? or the mosfet?
thanks for your advice in advance
olu
code
****************************************************
/*

Maximum Power Point Tracking

Olusola Osinowo
Ver 1.0
2007

ATmega16 Microcontroller
*/
//===========================================================================================
// Port and variable bit definitins:
;
; PortA:
; Bit 0 (ADC0): Voltage Input positive
; Bit 1 (ADC1): Current Input positive
;
; PortB:
; Bit0: Output to DAC LSB
; Bit1: Output to DAC
; Bit2: Output to DAC
; Bit3: Output to DAC
; Bit4: Output to DAC
; Bit5: Output to DAC
; Bit6: Output to DAC
; Bit7: Output to DAC
;
; PortD:
; Bit0: Output to DAC
; Bit1: Output to DAC MSB
;
;
; Move_Status:
; Bit0: Right (increasing Voltage) > low; left (decreasing voltage) > high
//===========================================================================================
// Inclued ATmega 16 definition
.include "m16def.inc"
// Variable definitions
// Outputs
// > Power Output only
// Internal Calculation
.def Mul_H = r1; > Multiplier MSB
.def Mul_L = r0; > Multiplier LSB
.def Power_Old_H = r2;
.def Power_Old_M = r3
.def Power_Old_L = r4
.def Power_New_H = r5
.def Power_New_M = r6
.def Power_New_L = r7
.def Move_Status = r17
.def Voltage_H = r19
.def Voltage_L = r20
.def Current_H = r21
.def Current_L = r22
.def Temp = r23
.def DAC_out_H = r24
.def DAC_out_L = r25
//
// Interrupt definition
// Reset
.org $000 jmp Main;
// Interupt Timer 1
.org $00C jmp MPPT;
// 
// Main function:
Main:
cli; //disabling interupts
// Clear Inputs
clr Voltage_H;
clr Voltage_L;
clr Current_H;
clr Current_L;
clr Power_New_H;
clr Power_New_M;
clr Power_New_L;
clr Power_Old_H;
clr Power_Old_M;
clr Power_Old_L;
clr Mul_H;
clr Mul_L;
clr Temp;
clr DAC_out_H;
clr DAC_out_L;
clr Move_Status;
// Initial Stack pointer
ldi Temp, LOW(RAMEND);
out SPL, Temp;
ldi Temp, HIGH(RAMEND);
out SPH, Temp;
// Initialise Timer 1
ldi Temp, 0b00010000;
out OCR1AH, Temp;
ldi Temp, 0b00000000;
out OCR1AL, Temp;
ldi Temp, 0b00000001;
out TCCR1B, Temp;
ldi Temp, 0b00010000;
out TIMSK, Temp;
// Initialise AD Converter
sbi ADCSRA, 7; set ADEN  enable AD converter
cbi ADCSRA, 2; set ADC clock prescaler
sbi ADCSRA, 1; set ADC clock prescaler
cbi ADCSRA, 0; set ADC clock prescaler
// Set inputoutput directions
ldi Temp, 0b00000000;
out DDRA, Temp; Port A Input
out PORTA, Temp;
ldi Temp, 0b11111111;
out DDRB, Temp; Port B Output
ldi Temp, 0b00000011;
out DDRD, Temp; Port D Output
// Enable Interupts
sei;
//***** First Conversion  Discard)
// Measure Voltage
ldi Temp, (1<<REFS1)(1<<REFS0)(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_K:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_K;
in Voltage_L, ADCL; Store Converted Low Bit value
in Voltage_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
//=============================================================================
// Timer 1 interrupt routinte  MPPT
MPPT:
// Reset Timer 1 clock counter
clr Temp;
out TCNT1H, Temp;
out TCNT1L, Temp;
// Measure Voltage
ldi Temp, (1<<REFS1)(1<<REFS0)(0<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_V:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_V;
in Voltage_L, ADCL; Store Converted Low Bit value
in Voltage_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
// Measure Current
ldi Temp, (1<<REFS1)(1<<REFS0)(1<<MUX0); set voltage meausurement channel and internal referece
out ADMUX, Temp;
sbi ADCSRA, ADSC; start AD conversion
ADC_wait_C:; wait until AD conversion finished
sbis ADCSRA, ADIF;
rjmp ADC_wait_C;
in Current_L, ADCL; Store Converted Low Bit value
in Current_H, ADCH; Store Converted High Bit value
//sbi ADCSRA, ADIF;
// Calculate Power Performing 10bit x 10bit = 24bit multiplication
mul Voltage_H, Current_H; AH*BH
mov Power_New_H, Mul_L;
mul Voltage_L, Current_L; AL*BL
mov Power_New_M, Mul_H;
mov Power_New_L, Mul_L;
mul Voltage_H, Current_L; AH*BL
add Power_New_H, Mul_H;
add Power_New_M, Mul_L;
mul Current_H, Voltage_L; BH*AL
add Power_New_H, Mul_H;
add Power_New_M, Mul_L;
// Control Output  Perturb Algorithm
cp Power_New_H, Power_Old_H;
breq Equal_H;
brlo Lower;
rjmp Higher;
Equal_H:
cp Power_New_M, Power_Old_M;
breq Equal_M;
brlo Lower;
rjmp Higher;
Equal_M:
cp Power_New_L, Power_Old_L;
breq Equal_L;
brlo Lower;
rjmp Higher;
Lower:; move Voltage in oposite direction
sbrc Move_Status, 0;
rjmp Lower_Increase;
rjmp Lower_Decrease;
Lower_Decrease:;
sbr Move_Status, 0;
dec DAC_out_L;
cpi DAC_out_L, 255;
brne Finish;
dec DAC_out_H;
rjmp Finish;
Lower_Increase:;
cbr Move_Status, 0;
inc DAC_out_L;
brcc Finish;
inc DAC_out_H;
rjmp Finish;
Higher:; move Voltage same direction as before
sbrc Move_Status, 0
rjmp Higher_Decrease;
rjmp Higher_Increase;
Higher_Decrease:;
dec DAC_out_L;
cpi DAC_out_L, 255;
brne Finish;
dec DAC_out_H;
rjmp Finish;
Higher_Increase:;
inc DAC_out_L;
brcc Finish;
inc DAC_out_H;
rjmp Finish;
Equal_L:; equal value > do nothing
Finish:; set outputs
out PORTB, DAC_out_L;
out PORTD, DAC_out_H;
// Set New power to old power
mov Power_Old_H, Power_New_H;
mov Power_Old_M, Power_New_M;
mov Power_Old_L, Power_New_L;
// return from interrupt
reti;
Attachments

90.7 KB Views: 139