I am new to programming micros, but I am using the EVK1100 (Atmel UC3A0512 32-bit processor) and I want to sample two sinusoidal voltage signals (using A/D) and detect when their rising edges occur. The time between rising edge detections between the two signals needs to be recorded, so that we can estimate power factor (of a grid demo unit we are creating).
My approach is to: start a timer, start detecting rising edges in signal 1 and signal 2. When a rising edge is found, an interrupt records the time of detection and raises a flag. The algorithm runs until the rising edge in the other signal is found, at which point its time of detection is recorded. The difference in time of detections is calculated, and an estimate of the power factor is returned.
If anyone has any suggestions on where to start it would be greatly appreciated. I have been looking at the A/D examples in the AVR32 software framework. Also, I am using AVR32 studio with GNU toolchain.
My approach is to: start a timer, start detecting rising edges in signal 1 and signal 2. When a rising edge is found, an interrupt records the time of detection and raises a flag. The algorithm runs until the rising edge in the other signal is found, at which point its time of detection is recorded. The difference in time of detections is calculated, and an estimate of the power factor is returned.
If anyone has any suggestions on where to start it would be greatly appreciated. I have been looking at the A/D examples in the AVR32 software framework. Also, I am using AVR32 studio with GNU toolchain.