CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Ac Dimmer

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
reptile404



Joined: 01 Apr 2011
Posts: 17

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

Ac Dimmer
PostPosted: Fri May 06, 2011 4:35 am     Reply with quote

hello guys!
I'm working on ac dimmer which i use zero crossing detector.
I don't know why this code does not work well.
(detect H.edge and L.edge)
Code:

int a=0;

#int_EXT
void  EXT_isr(void)
{
 if (a)
{
output_high(pin_b1);
a=0;
}
else {
output_low(pin_b1);
a=1;
}

what you advice me to do ?
_________________
REPTILE404

55AA55AA55
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri May 06, 2011 5:34 am     Reply with quote

You look at the example code that CCS freely supplies in the folders file......
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri May 06, 2011 6:55 am     Reply with quote

Maybe you are having problems with power line noise. You may get more than 2 crossings per cycle if the AC is noisy. It is best to only enable the interrupt shortly before you expect the next crossing to occur. For 60Hz (8.33ms/half cycle) wait 8ms with a timer, then enable the edge interrupt for the last bit of time.
_________________
The search for better is endless. Instead simply find very good and get the job done.
reptile404



Joined: 01 Apr 2011
Posts: 17

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

PostPosted: Sun Dec 25, 2011 8:53 am     Reply with quote

I don't think that problem is in noise because I'm just working on simulation (Proteus). Is my code correct (detects H.edge and L.edge , or just H.edge )? Can anyone give me another solution ?
_________________
REPTILE404

55AA55AA55
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 25, 2011 9:09 am     Reply with quote

Best (and ONLY real) solution is to get rid of Proteus. It is NOT the real World and does NOT simulate PIC code. Proteus is FULL of bugs ,errors, faulty DRCs and will never work correctly.
Quit wasting your time with it, get some real PICs and a breadboard and cut code.....

By the time you get this reply I could have cut code and had a real project working.
reptile404



Joined: 01 Apr 2011
Posts: 17

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

PostPosted: Sun Dec 25, 2011 9:16 am     Reply with quote

Well, for your records it doesn't work in reality as well. I mean I've tried it on breadboard and development boards but no achievement, doesn't work.
If you didn't find where is problem, why blaming me ?
_________________
REPTILE404

55AA55AA55
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Dec 25, 2011 10:38 am     Reply with quote

1a) what you show us is NOT a complete program.We need to know 1) type of PIC, 2) compiler version 3) most important a small but complete program( has to compile) that shows the problem.

1b) we'd need a schematic of the hardware too !

2) No one here will try to 'debug' a Proteus project. Just can't be done as the software is full of problems that's why it is necessary to use real hardware and complete code that we can test( until the turkey is ready !)
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

to all the dimmer obssessed members
PostPosted: Thu Dec 29, 2011 3:07 pm     Reply with quote

Here is a fresh off the press zero crossing circuit that I ran across today.....

http://www.edn.com/article/520185-Mains_driven_zero_crossing_detector_uses_only_a_few_high_voltage_parts.php


I believe that with this isolated output used to interrupt a port B INT ...
and then load one of the timers, say timer0 - then the overflow from the timer could easily become the trigger for the TRIAC modulator.

Just add a bit of math - and there you go.

Cool Very Happy
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Dec 29, 2011 9:54 pm     Reply with quote

After I detected a zero crossing I would mask any further detections till shortly before I expected the next crossing. That will help a lot with real world noise.

The code fragment you show looks OK, but there is not much we can tell you from such a small fragment. Follow temtronic's direction.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group