View previous topic :: View next topic |
Author |
Message |
Kanthi
Joined: 25 Nov 2003 Posts: 4
|
PIC16f877 -finding offset of ADC i/p with sine reference. |
Posted: Tue Nov 25, 2003 10:25 pm |
|
|
Hi,
Im using a PIC16f877 and the adc input is the voltage from ac supply.
the input is abt .4 v and I want to find the offset from a sinusoidal reference. I couldnt get the samples /cycle part right to frame the sinusodial reference. I came across this equation
Vref = Vp * sin (2*pi*k)/N
where N is samples per cycle.
I gave the ADC clock to be internal.
I have been really trying to figure out what N, and Vp are.
Thanks in advance.
kanthi. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 12:27 am |
|
|
Kanthi wrote: | Hi,
Im using a PIC16f877 and the adc input is the voltage from ac supply.
the input is abt .4 v and I want to find the offset from a sinusoidal reference. I couldnt get the samples /cycle part right to frame the sinusodial reference. I came across this equation
Vref = Vp * sin (2*pi*k)/N
where N is samples per cycle.
I gave the ADC clock to be internal.
I have been really trying to figure out what N, and Vp are.
Thanks in advance.
kanthi. |
Hi Kanthi,
I am not quite sure what you need to sample. However you may want to consider building an interface from the AC supply to generate a zero crossing trigger signal producing a 120Hz external interrupt signal into RB0. This way you could synchronize the ADC process precisely to the line frequency so it stays in phase with the line frequency.
By utilizing a programmable delay (TIMER1/2) you could trigger the ADC using the ADCON register bit GO/DONE bit to start a conversion and let the ADC run in the background without any significant program intervention. The ADC conversion complete intererupt can be used to allow to run the ADC completely in the background at precise intervalls. By adjusting the programmable delay you can sample when and how often you want to sample. Since the conversion time is only some 10th of us you will be able to sample the waveform frequently.
Hope this helps,
Gerhard |
|
![](templates/subSilver/images/spacer.gif) |
Kanthi
Joined: 25 Nov 2003 Posts: 4
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 12:20 pm |
|
|
Hi ,
gerhard- Thanks for your reply. I guess I didnt explain my problem properly. Im actually using a current sensor to get the current from 120 V ac supply and I give it to the one of the ADC pins. Now I actually want to find the difference between the input signal and a sinusoidal reference. That sinusoidal reference is about 0.1 * amplitude of the input signal. So I get the error or the offset of the input from the reference. Now that the input signal is digital, my reference should also be digital , so I want to know how to frame the reference sine signal.
ADC clock is set to be internal.
Thanks in advance.
thanks again-gerhard.
Anonymous wrote: | Kanthi wrote: | Hi,
Im using a PIC16f877 and the adc input is the voltage from ac supply.
the input is abt .4 v and I want to find the offset from a sinusoidal reference. I couldnt get the samples /cycle part right to frame the sinusodial reference. I came across this equation
Vref = Vp * sin (2*pi*k)/N
where N is samples per cycle.
I gave the ADC clock to be internal.
I have been really trying to figure out what N, and Vp are.
Thanks in advance.
kanthi. |
Hi Kanthi,
I am not quite sure what you need to sample. However you may want to consider building an interface from the AC supply to generate a zero crossing trigger signal producing a 120Hz external interrupt signal into RB0. This way you could synchronize the ADC process precisely to the line frequency so it stays in phase with the line frequency.
By utilizing a programmable delay (TIMER1/2) you could trigger the ADC using the ADCON register bit GO/DONE bit to start a conversion and let the ADC run in the background without any significant program intervention. The ADC conversion complete intererupt can be used to allow to run the ADC completely in the background at precise intervalls. By adjusting the programmable delay you can sample when and how often you want to sample. Since the conversion time is only some 10th of us you will be able to sample the waveform frequently.
Hope this helps,
Gerhard |
|
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 12:32 pm |
|
|
Kanthi wrote: | Now I actually want to find the difference between the input signal and a sinusoidal reference. |
What kind of difference are you looking for?
Voltage, Current ,Phase shift, or Frequency? |
|
![](templates/subSilver/images/spacer.gif) |
Kanthi
Joined: 25 Nov 2003 Posts: 4
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 12:37 pm |
|
|
Hi,
Thanks for ur reply, I want to find the difference between the input current and a sinusoidal current reference.
kanthi.
Neutone wrote: | Kanthi wrote: | Now I actually want to find the difference between the input signal and a sinusoidal reference. |
What kind of difference are you looking for?
Voltage, Current ,Phase shift, or Frequency? |
|
|
![](templates/subSilver/images/spacer.gif) |
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 1:38 pm |
|
|
Kanthi wrote: | Hi,
Thanks for ur reply, I want to find the difference between the input current and a sinusoidal current reference.
kanthi.
Neutone wrote: | Kanthi wrote: | Now I actually want to find the difference between the input signal and a sinusoidal reference. |
What kind of difference are you looking for?
Voltage, Current ,Phase shift, or Frequency? |
|
RMS or Instantaneous current diference. |
|
![](templates/subSilver/images/spacer.gif) |
Kanthi
Joined: 25 Nov 2003 Posts: 4
|
Re: PIC16f877 -finding offset of ADC i/p with sine reference |
Posted: Wed Nov 26, 2003 1:47 pm |
|
|
Input current-> RMS calculator-->Difference between RMS current and
reference signal --> PID-->PWM
This is what im abt to do, i want to know how to frame the reference signal. The reference signal will be a instantaneous signal(not RMS).
thanks for ur immediate reply Neutone.
Neutone wrote: | Kanthi wrote: | Hi,
Thanks for ur reply, I want to find the difference between the input current and a sinusoidal current reference.
kanthi.
Neutone wrote: | Kanthi wrote: | Now I actually want to find the difference between the input signal and a sinusoidal reference. |
What kind of difference are you looking for?
Voltage, Current ,Phase shift, or Frequency? |
|
RMS or Instantaneous current diference. |
|
|
![](templates/subSilver/images/spacer.gif) |
|