On Mon, 21 Aug 2000, Andrew Kunz wrote: > Scott, > > According to that last posting about the sine wave generation (not about > determinism ), it appears to me that you are expecting to see a sine wave as > an input. I'm not so lucky - I just get a 60uS pulse during the zero crossing, > as determined by some off-chip electronics. > > Do I want to implement a FIR filter and try to track either 50 or 60 Hz (yes, > it's supposed to lock to either one) with a PID loop? Guess I got a little > confused - that was basically my thought. > > As for amplitude, I only have to generate a 0-5V sine wave at the right > frequency (determined by the incoming line); the power electronics convert that > to 480V for me. Oh. You're correct. I was assuming that you had continuous access to the sine wave. I guess it's safe to assume then that the `off-chip electronics' do some kind of conditioning to guard against the noise problems I alluded to before. I haven't thought about the problem in this context, but it'd probably make sense to create a filter that takes the time between pulses as it's input. This filter could be as simple as averaging the last n-samples. The output of the filter would be the period of the sinewave. Divide this by `N' and you'll have the sine wave sample time (and could be fed right into the phase accumulator sine wave algorithm - btw, I think you'll want to use this algorithm [or at least a variation], otherwise there will be jitter if N doesn't exactly divide into period of the sine wave). What does the synthesized sine wave need to lock to? Is it sufficient to generate the right frequency? Scott -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu