You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old June 19th, 2019, 01:02 AM   #1
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
Search an array and output repetitive counts

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?
  Reply With Quote
Old June 19th, 2019, 02:31 AM   #2
parky
Member
United Kingdom

parky is offline
 
Join Date: Oct 2004
Location: Midlands
Posts: 1,112
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.
  Reply With Quote
Old June 19th, 2019, 05:00 AM   #3
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 1,058
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.
  Reply With Quote
Old June 19th, 2019, 03:20 PM   #4
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
@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
  Reply With Quote
Old June 19th, 2019, 03:52 PM   #5
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
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
  Reply With Quote
Old June 19th, 2019, 04:01 PM   #6
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
Also, are you leaving the rung with the FSC true or are you triggering the FSC with a oneshot?

Keith
  Reply With Quote
Old June 19th, 2019, 04:03 PM   #7
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
@kamenges

On my test I was leaving it true (with a test bit)
  Reply With Quote
Old June 19th, 2019, 04:05 PM   #8
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
Very good. That is how i ran it also. It didn't work quite right when i oneshotted the FSC.

Keith
  Reply With Quote
Old June 19th, 2019, 04:07 PM   #9
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
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.
  Reply With Quote
Old June 19th, 2019, 04:10 PM   #10
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
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
  Reply With Quote
Old June 19th, 2019, 04:16 PM   #11
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
Oh okay, yeah it goes all the way up to 49 if its set to 50.
  Reply With Quote
Old June 19th, 2019, 04:21 PM   #12
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
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
  Reply With Quote
Old June 19th, 2019, 04:35 PM   #13
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
Yeah, I am not resetting the count.

Here is a screenshot of what I have: https://ibb.co/HT8Lg0C
  Reply With Quote
Old June 19th, 2019, 04:38 PM   #14
kamenges
Member
United States

kamenges is offline
 
kamenges's Avatar
 
Join Date: Nov 2002
Location: Brillion, WI
Posts: 3,831
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
  Reply With Quote
Old June 19th, 2019, 04:41 PM   #15
sxj1988
Member
United States

sxj1988 is offline
 
Join Date: Apr 2014
Location: Rochester, NY
Posts: 38
Okay, that did it and will have something to reset the counter for the next scan.
Thanks alot!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Array of struct dahnuguy LIVE PLC Questions And Answers 9 November 21st, 2012 09:27 PM
Logix 5000 2D array - all confused - please help the brain wave work Vertical LIVE PLC Questions And Answers 4 August 10th, 2012 03:35 PM
Addon Instruction - output array of unknown size. RsLogix 5000 clementcbc LIVE PLC Questions And Answers 5 September 3rd, 2010 11:26 AM
TP177B + S7-300 on Profibus: No output happyhippo LIVE PLC Questions And Answers 23 May 15th, 2008 06:31 AM
Creating a register array to sequence rsdoran LIVE PLC Questions And Answers 15 October 17th, 2003 11:22 PM


All times are GMT -5. The time now is 06:15 AM.


.