??? 11/25/04 14:11 Read: times |
#81936 - Assymetry Responding to: ???'s previous message |
Most simple zero cross detectors don't give you a symmetrical zero cross point on the positive and negative cycles. also, because you should have a bit of analog filtering this causes a phase difference. Your zero cross signal is not at real zero cross! Therefore I use only one edge of the zero cross detector and re-create the missing zero cross pulse in the code. We then get back to my earlier post talking about frequency and phase locking to the mains. How do we do this with the PCA? Firstly setup a compare channel and load with 10mS of time, have it interrupt and toggle the port pin (so we can observe operation with a scope). Setup a capture channel to capture on one edge only - no interrupts. When we get a compare interrupt, check for any input captures. If we have one, subtract the current capture value from the previous one. Test the range (it should be around 20mS), ignore it if it is too high or too low. The difference of the current capture and the previous one is the current mains period, we also know if it is within an acceptable range from the test we did. Divide this value by two to get the half phase time. We also do a little filtering using this value to obtain the compare reload value. This gives us the frequency locking. To get phase locking we use the current capture value and compare this with the compare value (the compare value is where the software thinks the zero crossing is, the capture has the actual time of where it is). If it is a large difference, we scale that value down (say 1/10th) and add this to our next compare value. If it is a small difference, we decide if it is small enough not to worry about or we scale the value less. The idea here is that if there is a difference, we will gently correct until we get a lock. Doing this we filter out short term variations in the zero crossing input as well as tracking long term mains variations. Add some more code and you get your phase control and pulse output. That's my suggestion. But this doesn't necessarily address the problem at hand. I'm still not clear as to what the flickering is - is it a small variation or a large variation? This flicker should be visible on the scope. Prahlad - measure the amount of flicker and where is occurs on the mains phase. This may allow us to pinpoint the root cause rather than run around blindly trying a myriad of software 'fixes'. |