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

methods to calculate harmonics from voltage and current

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



Joined: 29 Nov 2007
Posts: 15

View user's profile Send private message

methods to calculate harmonics from voltage and current
PostPosted: Mon Jan 31, 2011 10:15 am     Reply with quote

hi all,
I am working on a project where I need to show total harmonics distortion of voltage and current signal.
Currently I am taking 32 adc samples of voltage and current in a cycle(20 ms) of 50Hz system and calculate rms values of V & I with almost 2% accuracy. Now I need to calculate V-THD & I-THD from this signals.
I have two choices. 1] - using hardware ie by making LPF of opamp (50 Hz)and calculate rms value of this fundamental wave. At same time another adc will read and calculate unfiltered signal and this is with harmonics.
So (unfiltered - filtered) will give me harmonics content. Is this correct?
and another way 2] Digital filtering - this can also be useful but I have very small knowledge about it. If anybody will help me on this topic,will surely go for it as it requires more software and math and less hardware change. And also can calculate individual harmonic using this.
So Friends, need your help and opinion on this topic.
regards
PAD
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 11:08 am     Reply with quote

How will this relate to CCS and the PIC? What PIC are you planning to use?
_________________
Google and Forum Search are some of your best tools!!!!
pad



Joined: 29 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 11:34 am     Reply with quote

Quote:
How will this relate to CCS and the PIC? What PIC are you planning to use?


Friend, is PIC & CCS is must? I think I have asked generic question on digital/analog filter which required straight forward answer, irrespective of controller and compiler.
But for your KA, I am using PIC18F6722 and CCS4.020.
I do not require any code. I am going to write that for myself. I just require help on digital/analog filter and how it will useful in my project.
If have any experience on digital/analog filter or THD, please share.
dyeatman



Joined: 06 Sep 2003
Posts: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 11:43 am     Reply with quote

This is a CCS C forum and CCS C and PIC are required by the forum
otherwise the moderator will likely lock the thread as being off topic.

Version 4.020 is a very old and buggy version and will likely give you lots of
problems if you try to use to use it. In addition, it will take quite a bit of
horsepower to perform the kind of analysis you are describing so I would
expect you would need a PIC24 or PIC 30 minimum.
_________________
Google and Forum Search are some of your best tools!!!!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 2:19 pm     Reply with quote

It sounds like you need to do a FFT of your data. That will give you the amplitude and phase of each harmonic. If you can live with an update rate of 1 reading/second or so I think any reasonable PIC should handle it. You do want to update your compiler though.
_________________
The search for better is endless. Instead simply find very good and get the job done.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 2:34 pm     Reply with quote

I agree, that a 16-Bit PIC would be fine. But nothing has been said about real-time capability, so even complex signal processing, e.g. by FFT would be basically possible with a PIC18. Classically, THD is measured with band stop filters rather than by subtracting power of RMS and fundamental. But an FFT power spectrum (magnitude only) is an interesting option. Taking only 32 samples per period may be a bit low to measure the total harmonic content.
pad



Joined: 29 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Wed Feb 02, 2011 8:49 am     Reply with quote

thanks for reply dear FvM & Sherpadog.
I am thinking that once I can find THD of V or I,though slow updated at start( once in a sec.)but will be my first step towards the goal.After that I ca definitely speed up it by higher end controller.
I am trying FFT so that I can remove 50Hz signal samples from input and will compare funda.V & I values with PQ meter.If accuracy is <=5% ,it will absolutely OK for me.
I am searching forums and google for same and have some useful data. mostly code is in assembly for fast calculations.I am new to ASM for PIC but studying it.
So friends,looking forward for your valuable suggestions and help on FFT.

PAD
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Feb 02, 2011 9:47 am     Reply with quote

Have a look at:
<http://www.ee.washington.edu/class/472/peckol/code/FFT/brent_fft/>

Not much except changing types to suits CCS, needed.

Best Wishes
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