- HMI Model: MT8102IE
- EasyBuilder Pro Version: 06.10.01
I need to transfer a Barcode to my Leadshine PLC.
The Barcode scan works, and I can access properties like RESULT and even BARCODE[0] which returns an accurate length in bytes. I can fill an ASCII box on the HMI with the correctly scanned data.
(Also- the HMI has been reading and writing general tag data successfully for over 6 months)
I have pinpointed the primary issue using the following macro code:
bool bToggle = 0
short sChar //sTring[4] = “Yes!”
short sNum = -7
char strCharX[1] = “X”, strCharZ[1] = “Z”
macro_command main()
GetData(bToggle, “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.bNewBarcodeScanned”, 1)
if bToggle == 1 then
bToggle = 0
sNum = -57
//StringSet(strCharX[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.strBCDigit_6”, 1)
SetData(strCharX[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.uiBarcode_6”, 1)
//SetData(strCharX[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.strBCDigit_6”, 1)
//StringSet(strCharZ[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.strBCDigit_6”, 1)
//StringSet(strCharZ[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.aryBarcodeChars[0]”, 1)
DELAY (10)
else
bToggle = 1
sNum = 22
//StringSet(strCharX[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.strBCDigit_6”, 1)
SetData(strCharZ[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.uiBarcode_6”, 1)
//SetData(strCharZ[0], “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.strBCDigit_6”, 1)
end if
SetData(bToggle, “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.bNewBarcodeScanned”, 1)
SetData(sNum, “CODESYS V3 (Ethernet)”, “Application.GVL_DATA.uiBarcodeLength”, 1)
end macro_command
The above code runs every 3 seconds and properly changes an unsigned int and a boolean variable (every 3 seconds)
If I uncomment any commands that reference a string, the macro fails.
i.e. the macro stops toggling the values. (actually it just fails to set or change any tag values at the PLC.)
My Tags are set for 2 bytes per char, but I have tried both. Same result- fails on write to a PLC string, works if I comment that command out.
What’s wrong?