View Full Version : more than 1 counter
April 25th, 2002, 08:49 PM
In a simple paintball target shooting situation,we have a fx2n programmer sending targets up at different times.When 1 gets shot down it sends another one up etc.Now we want to send up 3 at a time,when we did this if 2 targets go down together it only counted it as 1 hit.
Can someone please help
April 25th, 2002, 09:32 PM
This is classic in any PLC. If you only have one input line to a counter and two inputs drive the same line, the possibility exists for both inputs to be on at the same time. When this happens, the count input only sees a single transistion from off to on.
You need a separate counter for both inputs and then some math to add the counter values together and place them in a seperate register. If you have three inputs you need three counters, and so forth.... utoh
Ya'll Mits programmers need to help him out with the right statements for Mits, but the concept remains the same from PLC to PLC. nodi
April 26th, 2002, 09:05 AM
Thank you very much for your quick reply.(Next Problem)
We are not driving led's from the plc.
we are just sending a single to a stand alone unit (4 way led display unit)which will only exept 1 single to take the total up,and another seperate one to take it down again.
We had thought we could send 3 different singles and add them up,but we did not know how to display the answer.
Is there some way of doing this using the 4 way display we have.
April 26th, 2002, 09:44 AM
We had a similar situation where ther were multiple (possibly simultaneous) detections of 4 items but only one external total counter display (kind of a hybrid machine). I kept an internal register which was incremented (math instruction in 4 places) with each item seen. In another part of the code, if the internal register was non-zero, I issued timed pulses out to the external counter and decremented the internal register with each pulse sent. While the external counter may at times lag the real count, it was only by a fraction of a second, not enough to worry about.
April 26th, 2002, 09:52 AM
I love Bernie's answer. Way cool! Bernie, you may have to help him out. Have you got any sample code? nodi
April 26th, 2002, 11:56 AM
I'll have to do this as pseudocode since my original has a lot of other stuff intertwined. I think I extracted the gist of it OK though.
Inputs: Item1. Item2, Item3, Item4 (sensors from items)
Output: External Counter (Increment line to external counter)
Internals: Counter1, 'Do Pulse', Timer1, 'Timer1 is done', Timer2, 'Timer2 is done'
If Item1 (one shot) THEN increment Counter1
If Item2 (one shot) THEN increment Counter1
If Item3 (one shot) THEN increment Counter1
If Item4 (one shot) THEN increment Counter1
If Counter1 > 0 then turn on 'Do Pulse'
If 'Do Pulse' AND NOT 'Timer2 is done' THEN Timer1 (on time for output pulse)
If 'Do Pulse' AND NOT 'Timer1 is done' THEN turn on External Counter
If 'Do Pulse' AND 'Timer1 is done' THEN Timer2 (off time for output pulse)
If 'Do Pulse' AND 'Timer2 is done' THEN decrement Counter1
April 26th, 2002, 12:27 PM
What do you say we make pseudocode part of IEC 61131? ;)
April 26th, 2002, 10:41 PM
To Jay and Bernie
Many thanks for your answer on our counter problem,we had to read your note about 5 times before we started to understand it.Please believe me,we are not programmers.
We now think we understand and will be trying it tonight,we will drop you a line on our progress.
P.S. Great site or what.
April 26th, 2002, 11:25 PM
Great! I'll be here tomorrow online (in about 10 hours.) Give us some idea of your actual code when you get it figured out.
BTW, here's some tips on how to post ladder.