I have a problem on my project. Its work but inductor is over-current. How can i fix it?
Schematic
analogue analysis
(3-4s)
//MK
const int pot_pin = A0; //pot.'s pin
const int feedback = A1; //feedback's pin
int vout = 0; //vout
int vpot = 0; //vpot
int duty = 1; //duty
int i=1; //i
void setup() {
cli(); // stop interrupts
TCCR1A = 0xA2; //registerleri belirledik
TCCR1B = 0x19; //registerleri belirledik
TIMSK1 = 0x01 ; // overflow interrupt
ICR1 = 249 ; // 31.25us cycle time, 32kHz PWM but 64kHz drive pulses (differential)
OCR1A = 125-100 ; // example U drive
OCR1B = 125 ;
GTCCR = 0x83 ; // clear and halt prescalers
TCNT1 = 0xFFFF ; // synchronize counters exactly.
GTCCR = 0x00 ; // allow prescalers to fly
sei(); // allow interrupts
pinMode(pot_pin, INPUT);
pinMode(feedback, INPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
Serial.begin(9600);
}
ISR(TIMER1_OVF_vect){
OCR1A=duty; //change duty here.
OCR1B=249-duty;
}
void loop(){
readvolts(); //read pot and output voltage
while(i==1){ //for soft start
for(i=1;i<25;i++){
duty=duty+1;
delay(4);
}
}
readvolts();
if(vout < vpot){ //istenen gerilim cikis geriliminden buyuk ise calistirir--YUKSELTME
while(vout<vpot){ //if output voltage<pot voltage increase the duty
duty=duty+1;
dutyassignation();
delay(4+duty/10);
readvolts();
}
}
else if(vout > vpot){
while(vout>vpot){ //if output voltage>pot voltage decrease the duty
duty=duty+1;
dutyassignation();
delay(4+duty/10);
readvolts();
}
}
delay(10); //delay
}
void dutyassignation(){
if(duty>225){
duty=225; //limit the duty
}
else if(duty<25){
duty=25; //limit the duty
}
}
void readvolts(){
vpot = analogRead(pot_pin); //pot. voltages
vout = analogRead(feedback ); //output voltages
if(vpot>780){ //if pot. voltages > 3.8V (so output <-38V) vpot=3.8V vout=-38V
vpot=780;
}
}