Jump to content

PLC not calculating totals properly


Recommended Posts

HI everyone. I have a Unitronics PLC with HMI USP-104-B10

I have a Flow meter connected to one of the Analog input cards and it sends out a flow rate, I want to calculate the total flow in cubic meters and display it on the HMI, I also want another display with Weekly Flow ( so it uses the same logic and calculations of the total flow but should reset every time the operator pushes a reset button after he takes his readings).


Both The Calculations are the Exact same logic the difference is they are assigned to different tags. But the readings are completely different and random.



Link to comment
Share on other sites

  • MVP 2023

And note the edit after this original lot which I've changed to italics!!   And as well as Joe's comment, and perhaps related to your issue, your descriptions describe the flow meter 1 output as M/Hr.  If it is indeed giving you an instant reading of cubic metres per hour, then why is there a 3600 involved in your calculations?  If the reading is M³/Hr, then even though you are doing it once a second you don't want to be multiplying it by 3600 to turn it into an hourly rate.  It already is.   And it might result in the different readings.

Edit additions:  You know how some mornings all your brain cells are firing off fantastically and that horrible problem programming issue gets resolved in a flash?  Well...this morning wasn't one of them (  ⚠️  ) and I wrote some odd things!  However, this question tumbled around in my head on and off all day, and I realised that I was partly on the right track....I probably hadn't had enough coffee.  And it was a Saturday morning.  And it was hot.  And anything else I can use as an excuse.

It needs to be broken down into the sequence.  The sequence you have is, to my eye, incorrect.

The M³/hr is read every second, that reading needs to be divided by 3600, the result of this division is added to both the full accumulated total and your weekly total, and nothing further needs to be done to it.  At your weekly button push, the weekly total is simply reset to 0 and that count starts again.   You will also have to ensure that the system's operands in use can cope with the different number ranges needed.

Me writing this now will (hopefully) let my brain sleep properly tonight!




Link to comment
Share on other sites

Thank you so much for the responses  and sorry for my late reply, for some reason I got no notification of replies to my thread.

I have attached my entire program. 

From what I understand that the sequences may be incorrect but they are the exact same logic with the exact same sequence for total and weekly, why are the readings different for both of them?

Thank you guys once again for taking the time.


Link to comment
Share on other sites

  • NoamM changed the title to PLC not calculating totals properly

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...