Create a string from a group input (48 bytes)
fross
✭
How to create a string from a group input?
The string represents the content of 2D barcode glued on a container. The 2D barcode contains 48 bytes of information. The barcode value is transmitted to a IRB140 robot using an Allen-Bradley PLC.
48 bytes can be handled by 12 UDINT in RAPID. Should 12 group inputs be created and merged using PackRawBytes, then interpreted as a string using UnpackRawBytes? It works in theory, but I'd like to know if there is a better way to do this.
I do not have access to a robot at the moment. Thanks!
The string represents the content of 2D barcode glued on a container. The 2D barcode contains 48 bytes of information. The barcode value is transmitted to a IRB140 robot using an Allen-Bradley PLC.
48 bytes can be handled by 12 UDINT in RAPID. Should 12 group inputs be created and merged using PackRawBytes, then interpreted as a string using UnpackRawBytes? It works in theory, but I'd like to know if there is a better way to do this.
I do not have access to a robot at the moment. Thanks!
1
Best Answer
-
Hi fross,
i´m using this Function for reading a Barcode out of the PLC. I didnt know any other way to convert a groupinput to string. But the string is limited to 80 signs, so maybe you have to split it.
Maybe this is helpfully for youFUNC string fReadString() VAR string Out; VAR rawbytes raw_data_IO; ClearRawBytes raw_data_IO; PackRawBytes GInputDnum(giGlasID1),raw_data_IO ,1\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID2),raw_data_IO ,5\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID3),raw_data_IO ,9\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID4),raw_data_IO ,13\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID5),raw_data_IO ,17\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID6),raw_data_IO ,21\IntX:=UDINT; PackRawBytes GInputDnum(giGlasID7),raw_data_IO ,25\IntX:=UDINT; UnpackRawBytes raw_data_IO,1,Out\ASCII:=25; RETURN Out; ENDFUNC
0
Answers
-
I just had an idea, why not send over the ascii code numbers and then convert those codes to string? Bulli is right about string size is limited. Maybe you might write the data into an array.Lee Justice0
-
I ended up using PackRawBytes and UnpackRawBytes as Bulli pointed out.
Note that RawBytesLen can be used for the parameter StartIndex of PackRawBytes in order to remove some hardcoded values.
ie.PackRawBytes GInputDnum(giGlasID1), raw_data_IO, (RawBytesLen(raw_bytes) + 1)\IntX:=UDINT;
0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings