473,595 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

measuring RMS Current, RMS Volatge, Power factor - any sample prog in C?

365 Contributor
Need to write small prog to measure RMS Current, RMS Voltage and power factor for 50HZ 8 plug power strip, any sample prog?.
Oct 14 '09 #1
37 13894
Banfa
9,065 Recognized Expert Moderator Expert
To my knowledge most power strips don't usually have a data interface.

How are you planning on physically taking the measurements? Should surely be the first question to ask before you ask the question of how you write the code to obtain and process that data.
Oct 14 '09 #2
tvnaidu
365 Contributor
Thanks for question. I have designed small hardware with small microcontroller to do these measurements.
Oct 14 '09 #3
Banfa
9,065 Recognized Expert Moderator Expert
OK what data interface exists on the micro control, RS232 for example?
What protocol are you using to transfer data across this interface?
Oct 14 '09 #4
tvnaidu
365 Contributor
This is 24 plug power strip (8 plugs are one group - 3 power boards in strip), with 3 input power cards for strip, each power card controls one power board on that 24 port strip, only one microcontroller to read all 24.

Basically I am using GPIO to select plugs on 24 plug power strip, to read Current and voltage form each plug, I have ADC on microcontroller , I select one plug at a time (840 samples per second, I have to read 24 currents form 24 plugs and 3 voltages from each group (8 plugs are one group)), select one and read ADC input, which gives value of that either I[1].....I[24] or V[1], V[2], V[3].


I am using Five GPIOs as input to a mux to fanout 32 separate input sources like below (since all other GPIO used for something else),

Current 1 00000
Current 2 00001
Current 3 00010
Current 4 00011
Current 5 00100
Current 6 00101
Current 7 00110
Current 8 00111
Current 9 01000
Current 10 01001
Current 11 01010
Current 12 01011
Current 13 01100
Current 14 01101
Current 15 01110
Current 16 01111
Current 17 10000
Current 18 10001
Current 19 10010
Current 20 10011
Current 21 10100
Current 22 10101
Current 23 10110
Current 24 10111
Current 25 11000
Current 26 11001
Current 27 11010
Current 28 11011
Current 29 11100
Current 30 11101
Current 31 11110
Current 32 11111
Oct 14 '09 #5
donbock
2,426 Recognized Expert Top Contributor
There must be some interface circuit between the plugs and the ADC. What sort of signal is presented to the ADC: instantaneous voltage, peak voltage, RMS voltage? Same question for current.

That is, are you obtaining RMS via hardware or via software?

By the way ... be careful. You're working with potentially lethal currents.
(That's lethal to you, I'm much less worried the microcontroller .)
Oct 14 '09 #6
tvnaidu
365 Contributor
Thanks for your valuable mail.

There is an interface circuit, all AC outlets are controlled through relays, relay can turn ON/OFF each plug, that is separate logic, but there is a mux between microcontroller (ADC) and relay, that is an analog MUX which gets feed current and voltage back to ADC for measurement, which gives Instaneous current and Instaneous voltage. I have to read 24 currents and 3 voltages 840 times per second (840 samples per second). I have to store those 27 readings in separate buffers, then I have to calculate average and then RMS of each 24 current and voltage.

for (count=0; count < 840; count++)
{
for(inst_curr_c nt=0; inst_curr_cnt < 24; inst_curr_cnt++ )
{
set GPIO of one out of 32 and read ADC value and store
I_buff_loc[inst_curr_cnt] = ADC
}

for(inst_volt_c nt=0; inst_curr_cnt < 3; inst_curr_cnt++ )
{
set GPIO of one out of 32 only Three times and read ADC value and store
V_buff_loc[inst_curr_cnt] = ADC
}

square those accumulation of each instaneous curent and voltage, then calculate rms for all 24 currents and voltages
rms_curr = accumulation of each current / 420
}


I need some logic how to calculate power factor for reach based on instaneous current and voltag, thanks in advance.
Oct 14 '09 #7
donbock
2,426 Recognized Expert Top Contributor
@tvnaidu
The only way I can think of to do this involves measuring the phase angle between the voltage and the current.
Oct 14 '09 #8
tvnaidu
365 Contributor
Hardware provides an input to ADC to measure instaneous current and voltage only, by measuring those two 840 samples per second and then store those values, accumulate, then average and get RMS of each and calculate real power, then apparent power, using those Two calculate power factor.

The Hardware doesnot provide anything besides inst. Currewnt and volatge?
Oct 14 '09 #9
Banfa
9,065 Recognized Expert Moderator Expert
You can not use instantaneous voltage and current to calculate the power factor and you need the power factor to calculate real power.

You can calculate instantaneous apparent power from instantaneous voltage and instantaneous current.

You can calculate root mean squared (RMS) values relatively easily. As the name suggests this is the square root of the mean of the squares of the value (voltage or current or power) taken of 1 period of the wave.

However for a sinusoidal wave centred on y=0 (true for instantaneous voltage and current but not power) this simplifies to the peek value divided by the square root of 2.

Expand|Select|Wrap|Line Numbers
  1.         peek value
  2.         ----------
  3.          sqrt(2)
  4.  

You will have to examine the captured data to determine the peek value numerically.

You will need to calculate the power factor because

real power = apparent power * power factor

where apparent power = Vrms * Irms

You should be able to calculate the phase different between the voltage and current by looking for the peaks in those values and determining the time difference between those 2 peaks compared to the total period for the wave.

Time the time difference in the range -wave period/2 to +wave period/2 this corresponds linearly to a phase difference of -180 degrees to +180 degrees.

Once you have the phase difference the power factor is

power factor = cos(phase difference)

Look up these pages, the explain a lot of it and have some useful graphs and equations

power factor
root mean square
Oct 14 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2285
by: Fabian | last post by:
I notice on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndude/html/dude100499.asp that the writer has measured the time taken to run the script down to the millisecond. Does anyone know what tools he used to calculate these load times? -- --
18
2862
by: Peter Mount | last post by:
Hello I've started using CSS more in the last couple of weeks and in the last week I've started using em units. Are there any rulers I download that can show measurements in em units or is there another way of showing a graphical representation of em units in a simple manner. I know that an em unit is based on the size of the default font in the body of the web page and I've been placing temporary coloured borders in containers to get...
1
1703
by: WinstonSmith | last post by:
Hello everyone, I need to know how much time (cpu time like in Task Manager) is consumed by a thread. I tried to use Process.GetCurrentProcess.Threads and choose the current thread by AppDomain.GetCurrentThreadID. But results were wrong. Has anyone an idea to solve thsi matter? Thanks in advance Matthias
1
8206
by: Prakash Wadhwani | last post by:
I'd like to highlight the Current Row in a continuous form using Conditional Formatting VBA Code similar to as under in the CURRENT Event of the Form: My Field Names are as follows: Name, Age, Addr1, Addr2 Sample Code picked off this NG: Private Sub Form_Current()
29
1961
by: John Devereux | last post by:
Hi, What is the best way to ensure an integer is a multiple of a given power of 2? How about int size; ...
41
3402
by: Mountain Bikn' Guy | last post by:
What is the current preferred way to save user preferences in dotnet? Is the registry the right place to do this? Can anyone recommend a good article (or book) for this topic? Thanks.
74
7697
by: Dominik Wallner | last post by:
Hi! I'm currently implementing a program which measures voltages through an external USB-AD-converter. It should output those values as time/voltage pairs. My problem is to measure the time to output (time elapsed since program start would do just fine) - it should be as precise as possible, as there may be only differences in milliseconds between two measurements.
9
1788
by: mathon | last post by:
hi, i already posted an entry because of this problem, unfortunately i havent solved it so far..:( I have created a recursion for the calculation of the power like this: double power(double x, int n) {
9
3299
by: Ross | last post by:
I'm a newbie at this, and have searched a lot but can't find something that seems appropriate for measuring a recurring elapsed time. Creating an object with: var mydate = new Date(); seems clear, as is creating a second: nowTime = new Date(); and getting a difference between the two. My quesiton is what if you have many, maybe thousands of intervals you wish to measure? Should I do: nowTime = new Date(); with every pass of a...
0
7955
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8019
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5839
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3911
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1490
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1223
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.