Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 05, 2016, 05:23:56 05:23


Login with username, password and session length


Pages: [1]
Print
Author Topic: pic code for charger using triac  (Read 5134 times)
0 Members and 1 Guest are viewing this topic.
sudipm
Guest
« on: November 11, 2009, 08:05:15 08:05 »

Hi Guys
I am trying to make a battery charger using a triac (BTA16) and PIC16F72.
Everything is working perfectly except that sometimes a big sound is coming from the box as if somebody is hammering it. I think it is coming from the transformer. The transformer is getting magnetised and is causing the sound. Now, the transformer can get magnetised only when the triac is fired for unequal time on every half cycle. I have looked at my code for many times , but could not find any error that might cause the triac to fire. Triac is connected to RC0. I am pasting here a part of the interrupt routine.
Code:
void interrupt()

 PORTC&=0xCE; // reseting RC0 , RC4 AND RC5.
 if(INTCON.INTF)
 {
  INTCON.INTF=0;
  OPTION_REG.INTEDG=!OPTION_REG.INTEDG; // detecting zero crossing
  TMR2=0;
  TMR0=cur;  // count time before firing triac , prescaler is at 1:64
  OPTION_REG.T0CS=0; // start timer0
  INTCON.TMR0IF=0;
  scron=0; // a bit in one variable  , its set when we are firing the triac
  INTCON.INTE=0; // we are not needing the interrupt now
 }
 else if(INTCON.TMR0IF)
 {
  INTCON.TMR0IF=0;
  if(!scron)  // if triac is not already on
  {
   PORTC.B0=1;  triac on
   TMR0=250; //prescaler at 1:64 , a delay of approx. 300 msec to keep the signal at the triac gate
   scron=1;  // set the variable to show that triac is on
  }
  else // triac was on
  {
   INTCON.INTE=1; enable interrupt to detect next zero crossing 
   OPTION_REG.T0CS=1; // stop timer0
  }
 }
 asm clrwdt;
}
Can anybody please help me in pointing out the mistake that i am doing.
Thanks in advance
Sudip
Logged
MazdaMan
Guest
« Reply #1 on: December 26, 2009, 06:19:47 18:19 »

Sudip,

Do you have a schematic to take a look at. It will help finding the problem.

Cheers
Logged
sam_des
Active Member
***
Offline Offline

Posts: 221

Thank You
-Given: 47
-Receive: 111


« Reply #2 on: December 29, 2009, 07:32:03 19:32 »

Hi,
Sorry for replying so late, I must have missed your post  Undecided
BTW, it would have been easier if schematic were available.

I guess you are misfiring triac. Triac gets turned off by itself when voltage applied get below threshold. So you are right in delaying the gate firing to control the phase angle, but then why are you waiting for "300mSec" once you have fired the gate to turn it off. You must fire on both +ve as well as -ve phase of line. If you continue firing on either only +ve or -ve phase, transformer will ultimately saturate due to flux imbalance. That's what is causing the 'big sound'. It not the magnetising of transformer but rapid & untimely collapse of it.
You should fire on each zero crossing(+ve & -ve) after desired delay & remove gate pulse well before next ZCD.
Better simulate your design & code, your transformer might get damaged.

BTW, I must also add that ISR is usually not a good place to reset the watchdog timer. It may happen that your main-line code fails & now requires a reset, but ISR that continues working unknowingly will keep on resetting the watchdog will just void the very purpose of watchdog. It's better to use main-loop to reset the watchdog  Roll Eyes

Hope that helps...
regards,
sam_des
« Last Edit: December 29, 2009, 07:38:34 19:38 by sam_des » Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
andig
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 39
-Receive: 6


« Reply #3 on: January 02, 2010, 03:24:08 15:24 »

Dear All,

Don't really know how the phase angle is controlled in sudip's code. Probably by offsetting the TMR0 register itself to create a variable delay starting from zero cross in the main routine. So a Zero-Cross interrupt turns off the Triac, resets the TMR0 and a TMR0 overflow fires the TRIAC. Are you using reverse-parallel SCRs to simulate a Triac.

Probably you are using in an inverter and I doubt that the harmonics generated in the 3rd quadrant firing is possibly upsetting your zero cross signal. And this can cause DC injection into your transformer.

BTW Sudip, I am from Kolkata and we have probably met on other forums.
Logged
sohel
Senior Member
****
Offline Offline

Posts: 437

Thank You
-Given: 140
-Receive: 124



WWW
« Reply #4 on: June 23, 2010, 07:36:36 19:36 »

It heppen when battery goes to float  charge mode. like 13.5v to 14v with time delay. it will work fine when snubber is make with 223K (22nF)/1000V and 47R/ 2Watt. I am also face that problem. make sure cap is realy 223K. and also make sure moc primary  is cupling with 30pf cap. thats it. now u will sleep with sweet dream.

thanks
masud
Logged

A Thousand Miles Journey Start With a Single Step<br />http://www.youtube.com/user/masud58
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC