Search an array and output repetitive counts

sxj1988

Member
Join Date
Apr 2014
Location
Rochester, NY
Posts
38
Hi guys,
I have a small project that I am working on, I have this station that a unit enters, an RFID reads the unit's serial ID then it starts its operation.

The objective of this project is that if that same unit (serial ID) has arrived to this station 5 times then I want to latch an output bit.

Currently I have setup an FIFO array to store the unit's serial ID and used the FSC instruction to search within the FIFO array in which it works fine, however, it only checks for 1 match. I want something that can check that unit serial ID within the array and if the counter is equal to 5 (for that same serial ID) then latch an output bit.

I was wondering if its possible to do it with ladder or do I need to use structured text?
 
I think people will need a lot more info, what PLC are you using, how many stations are there, is this just 5 of the same ID's in a row or will it contain multiple ID's, how big an array does each station need. It sounds if you might need a lot of processing but without more info it is impossible to give you any ideas, there are a number of scenario's that come to mind.
 
All you should need to do is unlatch the FSC Control.IN (inhibit) bit. This will allow the instruction to continue searching through the entire array. Also use the ADD instruction not a CTU.

The logic would be simply: if FSC Found Bit and NOT FSC Done Bit then Add and Unlatch FSC Inhibit Bit.
 
@parky

The PLC I am using is a 1769-L36ERMS, running v.28.12, it is only 1 station, and the station needs to detect 5 serial ID's total in a FIFO array[100]

@cwal61

I have tested this on the emulator and it seems to give me the same results (unless I did not set it up correctly).

This is how I have it set up:

I have an FIFO_Array[50] (In this array currently everything is 0, there are a few positions where I purposely wrote a 1 just to check if the FSC will add the total amount found in this array)

FSC Instruction:
Control: FSC_Control
Length: 50
Position: 0
Mode: ALL
Expression: Code = FIFO_Array[FSC_Control.POS]

On one rung I have the FSC_Control.FD (XIC) and FSC_Control.IN (OTU)
On the second rung I have the FSC Instruction with the ADD instruction
 
I just tested this, but with a slightly different run order.

I have the FSC on a rung of it own with just a start bit so I can control it.
the rung after I have:

XIC FSC_Control.FD Add (Count 1 Count) OTU FSC_Control.IN

I am doing the same 0 and 1 thing you are and I pick up however many 1's i have in the array.

Keith
 
Yeah, did you get your to work to count the total amount of 1's in your array? Mine just counted just 1 even though I had five 1's in that array.
 
Yes, mine will count as many 1's as I put in the array.
One interesting thing I find is that if the FSC is oneshotted it will only execute until the first instance is found. Does your position value increment all the way to 49 if your length is set to 50?

Keith
 
So it would seem it has something to do with the way you are counting. Are you sure you aren't resetting your count somewhere every scan?

The counting rung I show should work correctly. You really should include an XIO FSC_Control.DN in the rung in case element 49 evaluates as true. That would cause the addition to keep incrementing. But other than that, it works for me.

Keith
 
In your add instruction your Source B and Dest tags need to be the same tag. that will create a sum that increments once every time the FD bit is high.

You will just need to come up with a way to reset the sum before you run your next scan through the array.

Keith
 

Similar Topics

Hi I new to ST programming and I am trying to figure out how I can search an array for an value (3). I want TEST to go high if eg trayArray[6] =...
Replies
10
Views
2,416
Hi I am stuck in trying to get my code search an array and retur an index number. So, I have an array from 0 to 254 created from an UDT where I...
Replies
7
Views
2,424
A customer is asking if I can do a check on his batch numbers and reject a batch from starting if the check fails. The setup is as follows: I have...
Replies
5
Views
1,566
when you have an array of 100 DINT's... And you enter in a wincc flex I/O field a DINT value to search for. How can you do that and know the...
Replies
3
Views
2,340
Searching edit zones within all routines and other criteria still says no results found, yet I still have the "edits present" indicator at the...
Replies
6
Views
241
Back
Top Bottom