Sign in to follow this  
Followers 0
zach_zachary1@yahoo.com

Convert analog KW to KWH daily total.

5 posts in this topic

I have a Control Logic AB processer and RS Logix 20.04 program that uses function block programming.  I have a 4-20mA analog signal for Kilowatts.  How can I take this analog signal and convert it into a daily total?  

Share this post


Link to post
Share on other sites

You can use the SCL block to scale your 4-20 into KW and the TOT to totalize your daily value.  

Share this post


Link to post
Share on other sites

kW x hours = kWh

If power consumption is constant then it's easy. Run time in hours x kW usage = kWh.

If it's not constant (more likely) then it becomes more interesting. Not difficult, just more interesting.

Personally, I would make it an AOI so I could use it for individual users (motors, etc) or total power, variable load, etc. I would use a periodic task. I like structured text for things like this.

Kind of like so:

GSV(task, THIS, Taskrate);  // Get the rate of the periodic task. Units are microseconds

t := Taskrate / 1000000; // Convert task rate in microseconds to seconds 

kWh := kW x t; // calculate kw(t) where t is the number of seconds of the period. If t is 1s then the units are kWs. If t = 60s then kWm (kilowatt-minutes), etc. So you can vary the period of the periodic task to get the resolution that you want.

You can use a totalizer outside of the AOI or incorporate it in the AOI. If you put it in the AO! you might want to add 

GSV(WALLCLOCKTIME, ,DateTime, Clock.Year); Date, Time, etc This would be used to trigger the time that the totalizer resets (time of day)

I created a user defined datatype called DateTime and used it inside of the UDT for the Clock tag. Ie a tag named Clock of the type DateTime. If this interests you at all I can cut and paste the UDT structure here tomorrow. It's late here and I'm not typing this on my programming computer or I would add it now.

Of course you could forgo all of this and just do what the post above mine says. Just remember that this is a value per unit time calculation and time is an important part of the calc / totalization.

This all sounds complicated but it's really not. If you sample every second you'll get kWs in the totalizer. If you sample every hour you'll get kWh in the totalizer. If you sample every minute then you get kWm... etc. Sample time depends on how much resolution you want.

 

 

Share this post


Link to post
Share on other sites

Thank you guys for responding to my post.  

I was thinking  of using the first example.  I'm pretty new at programming and it seems a little simpler.  I was thinking of sampling ever second for 24 hours then taking that number and dividing it by 3600.  This would give me KWH over a 24 hour period.  

Is there a way to reset the Totalizer after a 24 hour period and move the final reading to another tag that could hold that reading for 24 hours until the cycle starts over again. 

I am trying to end up with a yesterday's total that I can export from my SCADA system to a Hach Wims report.

Share this post


Link to post
Share on other sites

Posted (edited)

On 08/01/2016 at 10:52 AM, Michael Lloyd said:

kW x hours = kWh

If power consumption is constant then it's easy. Run time in hours x kW usage = kWh.

If it's not constant (more likely) then it becomes more interesting. Not difficult, just more interesting.

Personally, I would make it an AOI so I could use it for individual users (motors, etc) or total power, variable load, etc. I would use a periodic task. I like structured text for things like this.

Kind of like so:

GSV(task, THIS, Taskrate);  // Get the rate of the periodic task. Units are microseconds

t := Taskrate / 1000000; // Convert task rate in microseconds to seconds 

kWh := kW x t; // calculate kw(t) where t is the number of seconds of the period. If t is 1s then the units are kWs. If t = 60s then kWm (kilowatt-minutes), etc. So you can vary the period of the periodic task to get the resolution that you want.

You can use a totalizer outside of the AOI or incorporate it in the AOI. If you put it in the AO! you might want to add 

GSV(WALLCLOCKTIME, ,DateTime, Clock.Year); Date, Time, etc This would be used to trigger the time that the totalizer resets (time of day)

I created a user defined datatype called DateTime and used it inside of the UDT for the Clock tag. Ie a tag named Clock of the type DateTime. If this interests you at all I can cut and paste the UDT structure here tomorrow. It's late here and I'm not typing this on my programming computer or I would add it now.

Of course you could forgo all of this and just do what the post above mine says. Just remember that this is a value per unit time calculation and time is an important part of the calc / totalization.

This all sounds complicated but it's really not. If you sample every second you'll get kWs in the totalizer. If you sample every hour you'll get kWh in the totalizer. If you sample every minute then you get kWm... etc. Sample time depends on how much resolution you want.

 

 

Plz Share with us yours UDT, and screenshots of ur Ladder Logic

Edited by MD SULTAN ALAM

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
Sign in to follow this  
Followers 0