View previous topic :: View next topic |
Author |
Message |
reptile404
Joined: 01 Apr 2011 Posts: 17
|
Ac Dimmer |
Posted: Fri May 06, 2011 4:35 am |
|
|
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: 9229 Location: Greensville,Ontario
|
|
Posted: Fri May 06, 2011 5:34 am |
|
|
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
|
|
Posted: Fri May 06, 2011 6:55 am |
|
|
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
|
|
Posted: Sun Dec 25, 2011 8:53 am |
|
|
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: 9229 Location: Greensville,Ontario
|
|
Posted: Sun Dec 25, 2011 9:09 am |
|
|
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
|
|
Posted: Sun Dec 25, 2011 9:16 am |
|
|
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: 9229 Location: Greensville,Ontario
|
|
Posted: Sun Dec 25, 2011 10:38 am |
|
|
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
|
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Dec 29, 2011 9:54 pm |
|
|
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. |
|
|
|