RobotStudio event

Send string via Profinet to a PLC

SimoneCosti
edited February 2023 in RAPID Programming

Goodmorning,

Actually i'm working on a project with a CRB15000, i'm programming it with Robotstudio. The Robot is mounting a camera that is going to read some serial numbers.

From the camera i receive a string similar to "SN1234|123" but it could be different.

I need to cast this string into an array of byte, so i can send it to my PLC via Profinet with SetGO.

For example:


PERS string sendString;

sendString:= "SN1234|123";


SetGO SendByte0, StrToByte(sendString{1});

SetGO SendByte1, StrToByte(sendString{2});

Ecc...


But it didn't work

I also tried with SetGO SendByte0, StrToByte(StrPart(sendString, 1, 1)) but it didn't work.


What is the correct way to do it?


Thanks everyone.

Post edited by SimoneCosti on

Comments

  • Hallo,
    you have to use \char switch when converting ASCII. See documentation.
  • Yes, you're right
    I used the format SetGO SendByte0, StrToByte(StrPart(sendString, 1, 1)\Char)
    Thank you so much