Logix Brain Teaser

JankyPLC

Member
Join Date
Sep 2016
Location
WI
Posts
46
Guys(and gals) I'm stumped on this one.

Below is the text of a rung that seems to defy logic. Datatypes for Label_ID and Label_ID_Loaded are string. pallet_label_length is a dint with a value of 3.

The intent is that when a new label_ID is entered, if the length is correct, it increments the counter by 1. the NEQ at the beginning should ensure that the rung only is true for one scan.

The problem is it only functions like this if the ID length is kept the same. I.e. a 3 character ID is replaced with a 3 character ID. If a valid ID is entered it executes once, then if an invalid length ID is entered, it does not execute as you would expect, but when the correct 3 character length ID is entered again, it executes twice. Can anyone explain why this is?

Pulling my hair out just trying to understand what's going on here at this point.

NEQ(Label_ID,Label_ID_Loaded)EQU(Label_ID.LEN,pallet_label_Length)XIC(bit)CPS(Label_ID,Label_ID_Loaded,1)CTU(test_ctr3,?,?);
 
I would do a cross reference on Label_ID_Loaded and make sure this rung is the only destructive reference, as well as making sure external access is none or read-only.

Then I would carefully examine how Label_ID is being set, to make sure there are no possible ways it is being set/cleared/set, causing the output CPS to be executed on multiple scans. Or if the length is being manually set, independent of the string data.

Then there is XIC(bit), which can hold back the CPS.
 
Last edited:
I forgot to mention the bit, is in there because if you leave it on and run the logic it counts twice, but if you enter the ID with that bit off, then turn it on, it counts once, which makes even less sense. This is set up on a test PLC at my desk directly connected to my PC. The tags are not referenced anywhere else. I encourage anyone who has a compactlogix to copy the rung and try it. Very weird.
 
I agree with Mispeld. Do a cross reference on the questionable tags to make sure they aren't being used anywhere else. Also, is there any chance that they are being written to from the HMI?

I had a project once, where a bit was getting latched in the PLC (CompactLogix) and it wasn't used anywhere else in the logic. It wasn't even used on the HMI screens (RSView32 HMI). It turned out there was VBA code in the RSView32 project that was latching this bit. Took a long time to figure this out.
 
No HMI connected. It’s a PLC we have for testing that’s connected to my computer directly. This is the only rung of logic in the program.
 
How is Label_ID getting its value loaded into the string tag?

Is it coming from a hardware device, such as being continuously copied from an I/O tag into processor memory? In this case, it is important to make sure your program is synchronized with the external device in order to make sure the whole string is copied before executing the rung that copies it into Label_ID_Loaded.

For example, when going from a non-three-digit input, if the length changes to 3 first, the rung will execute, copying old characters. Then if the string characters change slightly later, the rung will execute a second time, copying the new characters.

You might be able to test this by creating a trend chart with the three string characters, each as pens, and the length as a fourth pen. Though it's possible they might change faster than can be picked up by the trend.
 
Right now I’m just typing the value in for testing. I believe what you’re saying is what’s happening because I added a Catch OTL at the end of the rung with an XIO Catch at the beginning. Allowing it to only be scanned once. What I’ve seen is that it appears it copies the correct length to the destination on the first scan and then the characters on the second. What I don’t understand is why. According to what I’ve read online the Point of a CPS is that it “pauses” the scan while it executes so it happens in one scan. Clearly that’s not the case though. My next question is does anyone have any ideas how to get around this?

I tried copying the Label ID.len to the loaded ID.len first and once they’re equal, allow the rung I shared above, run, same result. Thinking this would eliminate the the NeQ execution with the garbage data if it transfers Len first. I also at one point added a ons after the Label ID and Label ID Loaded. Still executed twice, which means it’s becoming not equal. Then equal. Then not equal again which makes no sense to me. What am I missing here?
 
I am currently running the rung you have listed in a test plc in my cube and it is working what I believe to be correctly.

Trial 1 I enter a 3-character string and it increments the counter by 1.
Trial 2 I enter a 4-character string and it does not increment the counter
Trial 3 I enter a second 3-character string and it increments the counter by 1
Trial 4 I enter a 4-character string and it does not increment the counter
Trial 5 I enter the same 3-character string as is Trial 3 and it does not increment the counter
Trial 6 I enter the 3-character string from Trial 1 and it increments the counter by 1

Looks like a winner to me.

Keith
 
Just curious, JankyPLC, what happens if you enter "1234" as the 4-digit Label_ID, and then "123" as the next 3-digit Label_ID? Does it still count twice (using the original rung)?
 
Thanks for all the replies everyone! At the suggestion of a coworker I copied the rung to another test PLC we have that’s running v30.11. Worked perfectly as it should. The PLC I was initially testing on was v20.12. I’m guessing it’s just a Rockwell bug... that cost me far too much development time.
 

Similar Topics

I have done, one time, read a barcode scanner into plc and search a UDT for selected part of ASCII string and set outputs desired. This mostly...
Replies
4
Views
4,556
I'm trying to integrate a Beckhoff IPC with a Controllogix PLC. There is some documentation, on the Beckhoff website, on how to do a PLC-PLC comms...
Replies
0
Views
61
So basically i have 2 queries : 1. I have a program file of S7-300 PLC which i want to migrate in RSLogix500.In short i want to convert my simatic...
Replies
14
Views
129
Hey all, first time poster here. I am wondering if anyone has tried using a Keyence SR-X300 barcode scanner to a Micrologix 1400. Keyence sent...
Replies
0
Views
48
Hello Everyone, I have a issue with communication between two different PLCs. So here is the facts, The Master PLC is Guard Logix 5069 with IP...
Replies
4
Views
98
Back
Top Bottom