Zero-crossing and phase detecting?


diecimila (atmega168); ide 1.6.1

i want project wherein mark zero-crossing of 2 sine wave inputs (on 2 analog pins). when each cross 0 interrupt triggered.

the first signal's interrupt starts timer. second signal's interrupt stops timer , reads value. timer value can calculate phase between 2 signals. can generate pwm output relative phase.

the challenge timing. interrupts happening every 40 microseconds. arduino's (the atmega168's?) specification regarding how can process interrupts? should in atmel datasheet know this?

this article got me thinking (it's pdf):

zero-cross detector

i'd thoughts have pitfalls, ideas, pitfalls   (c; ...

never dealt arduino's timers or interrupts.

thanks.

ps, note posts' subjects have "solved" or such added (likely in other forums, programming questions forum). op (me) when i'm successful or done moderator?

i vaguely remember overhead of 50µs before interrupt handler code entered. similar delay return interrupt. entry code saves return address , registers, exit code restore them. doubt can accomplished faster in assembly language :-(

i'd suggest add external counter, started first , stopped second crossing. depending on needs may have add higher frequency clock source, instead of 16mhz provided arduino board,


Arduino Forum > Using Arduino > Project Guidance > Zero-crossing and phase detecting?


arduino

Comments