Using Ignition 7.8.2.
I have a Allen Bradley PLC (unsure the exact make/model) connected to 3 Cognex Dataman Scanners (unsure exact make and model). Each built off of a Scanner UDT where the logic is the PLC feeds the barcode read by the scanner to Ignition, Ignition writes it back to the PLC to complete a handshake. It works well most of the time but for the second time now in two months the handshake has got stuck. The current solution is to clear our Scanner’s buffer and discard the the problematic barcode but I am wondering if there’s a better way to do this.
Here is what it looked like today before fixing it -
This time we looked inside the PLC before clearing the buffer and saw that the string in the data is
0000$00$00$00$00$00$00$00$00$00$00$00$00$00$00$00$000852C - I know the $00 is probably the problem. I thought maybe as well perhaps we were doing manual casting on the barcode string but it does not appear that way - here is the handshake logic that is eventually called on the Scanner2/Data tag change (after confirming good Quality etc).
def read(scannerIndex): import project.engine as engine scannerPath = "Scanner%i" %(scannerIndex) DataTag = system.tag.read("%s/Data" %(scannerPath)) Data = DataTag.value print "%i >> (Step 3) Read Data. Data From PLC = [%s], Quality=%s" %(scannerIndex, Data, DataTag.quality) # Write to the Ack Bit (the PLC will turn off the TIP bit) if Data != "": ackRes = system.tag.write("%s/HMI_Ack_Data_Rcvd" %(scannerPath), 1) ackResStr = system.tag.write("%s/HMI_Ack_Data_Rcvd_Echo" %(scannerPath), Data)
So it appears we just write back the value exactly, no parsing in jython. Seems to boil down to
# Get barcode DataTag = system.tag.read("%s/Data" %(scannerPath)) Data = DataTag.value # Write it back to PLC to confirm ackResStr = system.tag.write("%s/HMI_Ack_Data_Rcvd_Echo" %(scannerPath), Data)
Any idea what could be going wrong and if there’s a better way to handle the handshake implementation that would prevent this sort of issue from coming up again?