praty

How to calculate KWH from instantaneous KW

7 posts in this topic

Hi everyone

Can anyone help me in calculating KWH from instantaneous KW.

For 24 hrs basis.

Program example will be helpful.

Thank you.

Edited by praty

Share this post


Link to post
Share on other sites

KWH is KW x hours. Since instantaneous KW changes over time, then what you want is some sort of totalizer. So, for example, on a periodic basis add the KWH to an accumulation register, and then convert that to KWH. I would probably use the 1s clock pulse, so you're adding to the accumulator once per second, which gives you KWs. Then divide by 3600 to get KWH. You can use the real time clock to reset the totalizer at midnight, or any other time really. If you want to capture the daily KWH, move the value into a FIFO array before resetting it.

You didn't indicate which PLC you are using. Different models have different instruction sets, system bits, RTC registers, etc. But the process is basically the same.

Share this post


Link to post
Share on other sites

Perhaps it's easier if you consider that a Watt = Joules per second, the rate of energy transfer. So a kWh = 3600000 Joules.

1kW = 1000 J/s

1 kWh = 3600000 J

Now imagine you wanted to know how close you got to a city 3600000 meters away travelling at a speed of 1000m/s. You would integrate the speed over time to get distance. If you travelled for 10 minutes you would do (10*60)seconds * 1000 m/s = 600000m. 600000/3600000 = 0.166 so you are 16.6% of the way to the city.

In the same way, if you integrate the instantaneous kW over 24 hours you will find how close you got to a kWh. Or how many multiples of kWhs you did.

You can do this in the PLC by adding the kW PV to the on the rising edge of a one second timer.

|--(NOT t0)-------------------------------------[t0 10]--|

|--(t0)--↑---[+ kW_SUM kW_PV kW_SUM]--|

|---------------------[/ kW_SUM 3600 kWh_PV]--|

The kWh_PV will tell you how many kWh you have done in the integrating period and you could log this value and reset to zero every 24 hours.

Sampling the kW PV every second may not be fast enough depending on how fast it fluctuates. So you could sample it every 100ms but you would have to devide by 10 before adding it to the sum.

Share this post


Link to post
Share on other sites

One quibble... For best accuracy you will want to use the 1s (or 100ms) clock pulse, not a self resetting timer. The timer has an error because of the PLC scan time, so it loses a few ms each time. This will accumulate over the course of an entire day. The clock pulse, on the other hand, isn't handled inside the scan, so as long as the scan time is shorter than the clock pulse, you'll get exactly one addition per clock cycle.

Code is also simpler this way. No timer.

Edited by JRoss
Typo

Share this post


Link to post
Share on other sites

Thank you  JRoss and Luke.S

I am using Mitsubishi Fx3u-32M plc.

I am pretty new in plc programming can you please give me an example.

 

Thank you..

Share this post


Link to post
Share on other sites

The manuals have code snippets that you can use. Register on the website to be able to search for and download manuals. Here's something to get you started:

   M8013
----| |---------------------------[ DADDP D100 D0 D100 ]----

   M8000
----| |-------------------------[ DDIV D100 K3600 D110 ]----


----[ D= D8015 K0 ]------,----[ WSFLP D110 D200 K2 K62 ]----
                         |
                         '-------------[ DMOVP K0 D100 ]----

M8013 is the 1s clock pulse. M8012 is the 100ms clock pulse, if you prefer.

ADD is the addition instruction. I modified it with a D at the beginning for 32-bit operation and a P at the end for operation only on the rising edge. Will only operate once per clock pulse.

D100 is a data register that I'm using for the totalizer, and D0 is the instantaneous KW. Change to whatever register you need. Since the addition is 32-bit, the instruction will actually use two registers (D100-101 for total, D0-1 for KW).

M8000 is a system bit that is always on.

DIV is the division instruction. I modified it with a D for 32-bit operation. I did NOT use a P modifier in this case. I want it to operate all the time.

K3600 is a constant value of 3600 to convert KW*sec to KWH. Make this K36000 if you switch to the 100ms clock pulse.

D110 is the data register I'm using for KWH. Again, the value is 32-bit. Also, the division instruction returns both the quotient and the remainder. Quotient is in D110-111 and remainder in D112-D113.

D= is a 32-bit comparison instruction that is comparing D8015 with K0. D8015 is the real time clock (RTC) register that stores the current hour. K0 is a constant of 0. So the condition is true when the hour is 0, which is equivalent to midnight. You can set the time on the PLC with the programming software, by using the TWR instruction, or by moving values directly to the RTC registers D8013-8019.

WSFL is the word shift left instruction. It's modified with a P for rising edge operation. There is no 32-bit version. I'm using D200 and following as the array storage for the historical data. K2 is the constant that indicates the number of registers to shift. It's 2 because the data is 32-bit and takes 2 registers. K62 is the size of the storage array to store a month's worth of data (31 days * 2 registers). The instruction will take the source data (D110-111 which is KWH) and shift it into the array (D200-261), with all the older data being shifted up, and the oldest data being deleted.

MOV is the move instruction. I modified it with D for 32-bit and P for rising edge operation. This will reset the KW totalizer.

So at midnight the last rung will store the day's data in the array and reset the totalizer.

 

Share this post


Link to post
Share on other sites

Thank you very much..JRoss.

Your program is really very helpful.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now