I developed a program into a ATmega32. It determines the actual phase angle of the three-phase utility.
I use the internal ADC to read the voltage values and after the calculation a PWM signal is generated, which is filtered by a low-pass filter (simple R-C). The output signal is a sawtooth signal between 0-5V (0 means 0degree and 5V means 360 degree).
Today I made measurements and I saved the measured values with a Oscilloscope to compare it with the simulation results in matlab. The shape of the output signal is the same as the simulation result, but there is a 1.3ms delay between the two signals, which is relative high comparing it with the 20ms time period of the output signal.
When I tested the program in the AVR Studio I find that the code works properly.
My question is that has anybody any idea why this delay occur? It is comes from the filtering?
I use a filter with 5kHz cut off frequency, and I use 9bit fast PWM with the 15Mhz clock signal.
Thanks any advice