S5 maths question

Johnny T

Member
Join Date
Jul 2003
Location
Fife, Scotland
Posts
642
Hi,

I've been asked to add a "Products per minute" value to a text display. The machine is running an S5 115U and, at first, I thought it would be quite a simple task.. however, the more I think about it the less simple it appears.

I have lots of other signals from the machine such as 'Course clock pulse' (one pulse per product), 'Fine clock pulse' (ten pulses per product) etc

My first reaction was to set up a 1s pulse through a counter. Then set up the 'Course clock' through another counter. After 1s compare the course clock counter value with the previous value and then multiply by 60. I don't think the resolution of this would be good enough though.. If the machine was doing products every 1.1 seconds it would only show up as running 60 a minute which would be wrong.

So.. I then thought about 'counting' over a minute and working it out that way but this would mean that if the operator changed speed it would take a full minute for the screen to update which isn't acceptable.

Has anyone any ideas on this? I've seen "products per min" counts on lots of machines and can't help thinking that I'm missing something simple here..

Many thanks for any light you can shed on this..

Cheers

JT ;-)
 
It simply can be done by using a timer. You would measure the time between parts and then divide minute by that time counted. For example a part goes by every 1.1 seconds then the product/minute would be 60/1.1 = 54.55.
 
MrDave

Superb.. I knew I must be missing something.

Do you know how I can read a value of a timer in S5 and then use that value in some maths to divide it into 60?

Can the value be put into a FW like it can in S7?
 
Johnny T said:
Can the value be put into a FW like it can in S7?

Johnny

The BI and DE pins on the timer 'output' the current timer value, the BI in binary and the DE in BCD. You can probably make use of these.

Paul
 
Very often it is better to do a running sum, if you count number of products over a 10 second period then shift this into a word while shifting the previous ones down then add up the six words this will give you a 10 second update for packs a minute.
this has to be done as a function block
\\first have a ten second clock
an f0.0
l kt 100
sd t 1
a t 1
= f0.0
\\count the products
an f 0.0
a i 0.0
cu c1
a f0.0 \\when ten secs up jump
jc stor
beu \\block end unconditional
stor:
\\Simple word shift
l fw208 \\load the 5th
t fw210 \\overrite the 6th
l fw206 \\load 4 & transfer to 5th
t fw208 \\& so on....
l fw204
t fw206
l fw202
t fw204
l fw200
t fw202
l c 1
t fw200
l fw200 \\Add them all up
l fw202
+f
l fw204
+f
l fw206
+f
l fw208
+f
l fw210
+f
T fw212 \\store the value
fw 212 now holds the 10 second counts for 6 10 second slots
you are best to use a DB as the fw 200 to 255 are often used as scratch words by siemens own blocks.
you now have a running sum of 1 min counts that updates every 10 seconds (better than waiting 1 minute).
fw200 fw202 fw204 fw206 fw208 fw210
22....0000..0000..0000..0000..0000 = 22 in first 10 secs
45....22....0000..0000..0000..0000 = 67 in 20 secs
15....45....22....0000..0000..0000 = 82 in 30 secs
and so on after a minute it gives you your count per minute this also works if product count slows down or stops as if no counts are added, every 10 seconds the rate falls.
do not take the code as gospel as I'm a bit rusty on S5 & if I were to do it I'd build a function for the shift & do it in a loop.
 
Thanks for that Parky. I'll give it a go over the weekend and see how I get on. It might be that 10 seconds isn't enough but I'll sound the operators out and see what they want..


Thanks again..

JT ;-)
 
Johnny
Seems to me to be easiest to divide the total counted by the total time.
For instance
550 parts in 55 minute = 10 ppm (parts per minute)

This simplistic approach overlooks realities such as
how accurate do they want this number
do they want minute by minute update
do the parts get made on a regular cycle or can they vary production rate.
When how and who resets the algorithm back to zero
How do you get the number to the guy who wants it??
What are they going to do with this number (or is this more management "it would be neat if,,,,,," and then they do not have an idea of what the number means much less what to do with it.

Almost forgot
division by zero
and never ending values ie 10 divided by three.
 
Last edited:
This has been covered many times before

Do you have access to a free running clock with millisecond or microsecond resolution?

DO NOT USE TIMERS!!!!! If you must then they better roll over nicely so you can always calcuate the difference in time between products WITHOUT reseting the timer. I know I have said this many times before.

You should be able to count the milliseconds or microseconds between the products to calculate a rate. Then use a low pass filter to smooth the rates.
 

Similar Topics

I have a dataword ,each bit is actually an alarm, No i have to program a condition that shut down the installation when more than two bits are set...
Replies
42
Views
8,768
I'm sure someone must have done something like this before (i'm sure i have too at some point but cant remember), anyways. I'm working on a...
Replies
3
Views
2,462
Hi Folks I hope this is not a dumb question,I am a newbie . I want to perform simple math functions like multiplication, addition etc in TIA...
Replies
6
Views
2,803
Hi all, I am trying to copy paste a routine from rs logix500 into rs logix5000, I get an error on rung where they are searching for scada values...
Replies
1
Views
1,850
Hi I am fairly new to PLC programming and I am self learning. I have written a simple program to detect and store the RPM and ultimately the...
Replies
0
Views
1,412
Back
Top Bottom