Sign in to follow this  
Followers 0
rajsiyer

RSView Reports

2 posts in this topic

Hello friends, For the past couple of months I've been busy with a project the purpose of which is to generate reports from about 21 energy meters, whose data are being read by ML-1100 plcs logged in RS-View's database. So far, I've managed to display the data on excel sheets using a VB front end, which enables the user to select a period for the report to be generated. Thus I am able to get reports for any day, shift or week. for such data as Average-current, average Power, average voltage etc, This is because the query from VB, connects to the data base and asks for the "average" values from the data as a built in function.(I'm using MSQuery with output to excel) But when it comes to finding such quantities such as Hours_Run, Hours_run_at_50%, Hours_idled etc, I need to find the difference between the values of the respective tags,when read at the beginning and end of the report period. In the PLC logic, I've created variables that continuously increment the minutes while the required conditions are true. For example. consider a tag called RUNNING_HRS_CHILLER_05A. If this chiller 05A is running, a counter associated with it keeps incrementing every minute of running. To determine how much it has run during the week, I plan to read the available value for the tag at the end of the week, and subtract the value of what it was at the beginning. My difficulty is that I do not know how to create a query that reads the value of a tag at 2 instants of time from the database and take its difference. All the same, the boys who help me know how to add up the values and take its average. I am sure, many at mrplc, have confronted this kind of problem I'd like them to share their knowledge and guide me accordingly. A million thanks for any guidance in advance. Have a nice day. Raj S. Iyer

Share this post


Link to post
Share on other sites
I normally would use a stored procedure to do this sort of query, What Database are you using, I think most allow stored procedures?? More details of your Database where this information is stored would be helpful. You may be able to do something like this assuming your counter is always incremeting during your chosen timeframe, this allows you to query for the Minimum counter value and the Maximum counter value in a given timeframe and subtract the two values to find the difference.. "CounterValue being your Runtime Counter" Select MAX(CounterValue), MIN(CounterValue), MAX(CounterValue) - MIN(CounterValue) as Minutes Run FROM Tablename WHERE Date BETWEEN YourStrtDate AND YourEndDate Edited by TechJunki

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