Hi,
Indeed .. a schematic should be useful to validate if it is possible at all and what errors one has to expect.
Yes, I can do it in my older method but those are time consuming for this product
This sentence is useless, because we neither know your "older method" nor your expectation of timing.
You don't give details at all. Thus it is hard to help.
In my eyes the problem is not related to dsPIC, it rather is related to
* signal timing
* used analog filters
* ADC sampling rate
* ADC resolution
And on the expected output
* update rate
* resolution
* precision
* continous processing (real time sampling and prcessing) or discontinous processing (first sample a lot of data, then process the sampled data)
Also you should be more exact about "averaging".
* often "averaging" is made with a low pass filter (like RC)
* but it can also be "true averaging" over a specified time
* but it can also be "true averaging" over a specified number of peaks
You should be aware of all this before you start coding. I usually take a piece of paper and a pencil and draw some pictures of the signals and the code flow chart.
******
My recommendations:
* use an analog filter to get rid of noise = to focus on the "true" signal
* use a sampling rate at least 25 times the signal frequency. In detail it depends on expected precision and waveform
* use constant and known samling frequeny
* use a (running) average signal, or a low pass filterd signal ... over all samples ... as helping signal to validate the input signal.
* use this signal to detect whehet the input signal is valid (in amplitude as well as in frequency), and to detect in which halfwave you currently are
* define a positive halfwave when n input_samples > average signal
* define a negative halfwave when n input_samples < average signal
* every time when you detect a positive halfwave: save the negative_peak and then set it to the average value
* every time when you detect a negative halfwave: save the positive_peak and then set it to the average value
* ... here you need to specify output rate
* now calculate the average of the saved positive peaks
* now calculate the average of the saved negative peaks
To define whether the input signal is symmetric (top right picture) I'd compare (pos_avg_peak - average value) with (average_value - neg_avg_peak).
If both are about the same value (you first need to define your tolerance), then you may consider the input signal as symmetric.
--> top right picture with x and y values
If not: --> other picture with just x values
Klaus