CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC16f877 -finding offset of ADC i/p with sine reference.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kanthi



Joined: 25 Nov 2003
Posts: 4

View user's profile Send private message

PIC16f877 -finding offset of ADC i/p with sine reference.
PostPosted: Tue Nov 25, 2003 10:25 pm     Reply with quote

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.
Guest








Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 12:27 am     Reply with quote

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
Kanthi



Joined: 25 Nov 2003
Posts: 4

View user's profile Send private message

Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 12:20 pm     Reply with quote

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
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 12:32 pm     Reply with quote

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?
Kanthi



Joined: 25 Nov 2003
Posts: 4

View user's profile Send private message

Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 12:37 pm     Reply with quote

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?
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 1:38 pm     Reply with quote

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.
Kanthi



Joined: 25 Nov 2003
Posts: 4

View user's profile Send private message

Re: PIC16f877 -finding offset of ADC i/p with sine reference
PostPosted: Wed Nov 26, 2003 1:47 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group