I am looking for some PAC Control coding support as I cannot think of a method of achieving what my customer is requesting.
Background
I installed an EPIC PR1, serial module and DI module some years ago to provide a client with a tank farm level monitoring system. It uses PAC Control and Opto Modbus Integration Kit to get Modbus RTU data via the serial card from Tank Volume and Temperature gauges. This is displayed on the clients PC using PAC Display with Supertrends.
There are 30 tanks on site and the volume are stored in a float table after every read.
Required
The client would like a daily report listing ALL the volume movements both in and out, and the time the movement began. A movement is a change in volume of 500 litres, but of course they want to be able to change this, so it would be a variable for each tank!
As an example, they have asked:
For example if the tank level goes from 50,000 to 49,500 then it’s logged as an “out” or if the tank level goes from 50,000 to 50,500 then it’s logged as an “in” for that particular tank?
Example report:
Date / time From: 05/09/24, 00:00 Date / time to: 05/09/24, 23:59
Tank 1
Movement Date Movement Time In/Out Volume
05/09/24 06:35 Out 12,000
05/09/24 08:27 In 13,000
05/09/24 11:34 In 10,000
Total movements In 2
Total movements Out 1
Total Volume in 23,000
Total Volume out 12,000
Tank 2
Movement Date Movement Time In/Out Volume
05/09/24 07:35 In 12,000
Total movements In 1
Total movements Out 0
Total Volume in 12,000
Total Volume out 0
Having looked at the historical trends it is rare for an in or an out to have a flow rate of greater than 50 l/min. I have calculated this by simply measuring change in volume over time from the historical trends.
Using code to achieve this is where I am struggling and would appreciate some help, please.
There are no external triggers available to the system to say when a movement starts and ends, either from IO or human button pressing.
Any thoughts with example PAC Control code if possible would be greatly appreciated.
Tahnks in advance.
Similar task at the hospital I used to work at - doing the automation with Opto.
We had 100’s of zones of air-conditioning. We had to allow for a small adjustment, in your case, volume unit to track.
I took that amount and added and subtracted from the current value, so now we have a window.
If the volume moves outside that limit (Use the command ‘within limits’ of the upper and lower new set points), when it does, log it.
For the reports I would look at PAC Display logging. You could do it ‘on screen’ and have a print button, I’ve done that before. Depends on if they want an email every day or paper trail only when needed.
Either way, loops clearly are going to be in your future.
Just some inital thoughts.
I suspect others will be along to mull other options.
There are going to be a lot of little nuances to this - best to break it down into smaller problems and build up.
I would recommend starting with the logic you would use for just one tank before turning it into a loop going over all the tanks.
Figure out how you are going to determine a flow has ended and then run your logic to see if it changed enough to log. You will probably be storing the last logged level (for future logging) and the last detected level (to determine if the level is no longer changing) and use the current level for comparison.
Then you can decide how you are going to store each event - in a PAC Control table to read and report later - or through PAC Display logging to be processed by another application - or through a database and a reporting server or something else.
@Beno Thank you for your suggestions. Never thought of the ‘within limits’ command. Great starting place. @philip I agree with you on starting small with one tank. Will probably use timer to try and detect ‘no change’ in volume to use for flow ended, then do the maths for the movement.
I will use PAC Control tables for this and perhaps use the number in INS or OUTS counts as the index in the tables.
As client wants a PDF report at the end of each day, I might use Node Red to do this before clearing the daily tables ready for the next day!