|
Тема |
въпросче за схемичка |
|
Автор |
bat.goiko (непознат
) |
|
Публикувано | 02.08.16 20:14 |
|
|
Я малко да разнообраазя тематиката във форума
Захванал съм се да си правя МРРТ ивертор за соларен панел - по точно един приятел ме запали, докато расъждавахме как се търси максимум на функция, ама това е друга бира
Та, с помощта на колега от друг форум събрах една схемичка за въпросния контролер - не че брата китаец не ги прави, ама гъдела си е гъдел
Това е работната версия, която тествам в момента:
Не е нищо особено. Целта и е да търси работната точка, в която панела отдава максимална мощност, като променя тока през него и мери мощността, както и да превключва моста на високото в синхрон с мрежовото.Ето това е и тестовата програмка.
//// Specifications :
//
// 1.Solar panel power = 250W
// 5. Input Voltage = Solar panel with Open circuit voltage from 32 to 39V
//
/////////////////////////////////////////////////////////////////////////////
#include <avr/io.h>
#include <avr/interrupt.h>
//////// Arduino pins Connections//////////////////////////////////////////////////////////////////////////////////
// A0 - Voltage divider (solar)
// A1 - ACS 712 Out
// A2 - Voltage divider (AC grid)
// D3, D11 - MOSFET Push-Pull
// D9, D10 - MOSFET H-bridge
// Full schematic is given at
///////// Definitions /////////////////////////////////////////////////////////////////////////////////////////////////
#define SOL_AMPS_CHAN 1 // Defining the adc channel to read solar amps
#define SOL_VOLTS_CHAN 0 // defining the adc channel to read solar volts
#define LINE_VOLTS_CHAN 2 // defining the adc channel to read line volts
#define AVG_NUM 127 // number of iterations of the adc routine to average the adc readings 1-255
#define PWM_MAX 180 // the value for pwm duty cyle 0-100%
#define PWM_MIN 5 // the value for pwm duty cyle 0-100% (below this value the current running in the system is = 0)
#define PWM_START 10 // the value for pwm duty cyle 0-100%
#define PWM_INC 3 //the value the increment to the pwm value for the ppt algorithm
//-----------------------------------------------------------------------------------------------------
// global variables
unsigned int sol_amps = 0; // solar amps
unsigned int sol_volts = 0; // solar volts
unsigned long sol_watts = 0; // solar watts
unsigned int old_sol_amps = 0;
unsigned int old_sol_volts = 0;
unsigned long old_sol_watts = 0; // solar watts from previous time through ppt routine
int delta = 0; // variable used to modify pwm duty cycle for the ppt algorithm
byte pwm = 0; // pwm duty cycle 0-100%
//------------------------------------------------------------------------------------------------------
// This routine is automatically called at powerup/reset
//------------------------------------------------------------------------------------------------------
void setup() // run once, when the sketch starts
{
pwm = PWM_START; //starting value for pwm
analogReference(DEFAULT); //use built in 1.1V reference voltage for analog reading
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
TCCR1A = 0;
TCCR1B = 0;
TCCR2A = 0;
TCCR2B = 0;
OCR1A = 0;
OCR1B = 0;
OCR2A = 0;
OCR2B = 0;
TCCR1A = _BV(COM1A1) | _BV(COM1A0) | _BV(COM1B1) | _BV(COM1B0) | _BV(WGM11) | _BV(WGM10);
TCCR1B = _BV(WGM12) | _BV(CS10);
TCCR2A = _BV(COM2A1) | _BV(COM2A0) | _BV(COM2B1) | _BV(COM2B0) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS20);
Serial.begin(115200);
}
//------------------------------------------------------------------------------------------------------
// Main loop
//------------------------------------------------------------------------------------------------------
void loop()
{
byte i = 0;
unsigned int sol_amps_read = 0;
unsigned int sol_volts_read = 0;
int delta_amps = 0;
int delta_volts = 0;
unsigned int line_volts_read = 0; // measuring line volts for sinchronization
unsigned long sol_amps_summ = 0;
unsigned long sol_volts_summ = 0;
for(i = 0; i < AVG_NUM; i++) {
sol_amps_read = analogRead(SOL_AMPS_CHAN) - 500; //input of solar amps
sol_volts_read = analogRead(SOL_VOLTS_CHAN); //input of solar volts
line_volts_read = analogRead(LINE_VOLTS_CHAN);
OCR1A = 1023 - line_volts_read;
OCR1B = 1023 - line_volts_read;
sol_amps_summ += sol_amps_read;
sol_volts_summ += sol_volts_read;
}
sol_amps = sol_amps_summ / AVG_NUM;
sol_volts = sol_volts_summ / AVG_NUM;
delta_amps = old_sol_amps - sol_amps;
delta_volts = old_sol_volts - sol_volts;
if (abs(delta_volts) < 2) {
sol_volts = old_sol_volts;
}
if (abs(delta_amps) < 2) {
sol_amps = old_sol_amps;
}
sol_watts = sol_amps * sol_volts;
if (old_sol_watts > sol_watts) { // if previous watts are greater change the value of
delta = -PWM_INC; // delta to make pwm increase or decrease to maximize watts
}
else {
delta = PWM_INC;
}
pwm += delta; // add delta to change PWM duty cycle for PPT algorythm (compound addition)
old_sol_amps = sol_amps;
old_sol_volts = sol_volts;
old_sol_watts = sol_watts; // load old_watts with current watts value for next time
if (pwm >= PWM_MAX) { // check limits of PWM duty cyle and set to PWM_MAX
pwm = PWM_MAX;
}
else if (pwm <= PWM_MIN) { // if pwm is less than PWM_MIN then set it to PWM_MIN
pwm = PWM_MIN;
delta = PWM_INC;
}
OCR2A = 255 - pwm;
OCR2B = 255 - pwm;
}
Приемат се идеи и предложения във всяка насока
Редактирано от bat.goiko на 02.08.16 20:16.
|
| |
|
|
|