Hello, i created a example for the 485 module a while ago, it's quite similar to the RS232.
The code is not overly commentated or in that high quality but it should give you some insights on how to do it. You need the manual for the inline module here:
PROGRAMPLC_PRGVAR  inStatus  AT%IB10:WORD;  outControlAT%QB10:WORD;  inData  AT%IB10:ARRAY[0..11]OFBYTE;  outData AT%QB10:ARRAY[0..11]OFBYTE;  SendConfig:BOOL;  ReadConfig:BOOL;  SendData:BOOL;  ReadData:BOOL;  ReadStatus:BOOL;  Manual:BOOL:=FALSE;  Timer:TON;  State:INT;  Pulse:BOOL;  CommandOut:BYTE:=2;  CommandIn:BYTE:=2;  ParamOut :BYTE:=2;  ParamIn  :BYTE:=2;  TextIn:STRING(11);  i:INT;  strPtr:POINTERTOBYTE;  NumRead:BYTE;  TransmitBufffer:BUFFER_STATUS;  RecieveBuffer:BUFFER_STATUS;  TransmitError:ERROR_STATUS;  RecieveError:ERROR_STATUS;END_VAR
(*ReadtheincommandfromtheRS485statusword*)CommandIn.0:=inData[0].4;CommandIn.1:=inData[0].5;CommandIn.2:=inData[0].6;(*ReadtheinparameterfromtheRS485statusword*)ParamIn.0:=inData[0].0;ParamIn.1:=inData[0].1;ParamIn.2:=inData[0].2;ParamIn.3:=inData[0].3;(*ReadtheoutcommandfromtheRS485controllword*)CommandOut.0:=outData[0].4;CommandOut.1:=outData[0].5;CommandOut.2:=outData[0].6;(*ReadtheoutcommandfromtheRS485controllword*)ParamOut.0:=outData[0].0;ParamOut.1:=outData[0].1;ParamOut.2:=outData[0].2;ParamOut.3:=outData[0].3;(*Resetthelowerbyteofthecontrolword*)outData[0]:=0;IFSendConfigTHEN  outData[0]:=16#40;  (*Errorpattern*)  outData[1]:=16#24;  (*Outputtype0:4851:422*)  outData[2].4:=0;  (*Protocol:16#00:Transparent *)  outData[2].3:=0;  outData[2].2:=0;  outData[2].1:=0;  outData[2].0:=0;  (*Baudrate:38400Datawidth:8,1,Even*)  outData[3]:=16#92;  (*Firstdelimeter*)  outData[4]:=16#0D;(*CR*)  (*Seconddelimeter*)  outData[5]:=16#0A;  (*LF*)  RETURN;END_IF;IFReadConfigTHEN  outData[0]:=16#3D;  RETURN;END_IF;IFSendDataAND(ManualORPulse)THEN  outData[0]:=16#1B;  outData[1]:=65;  outData[2]:=66;  outData[3]:=67;  outData[4]:=68;  outData[5]:=69;  outData[6]:=70;  outData[7]:=71;  outData[8]:=72;  outData[9]:=73;  outData[10]:=74;  outData[11]:=75;END_IF;IFReadDataAND(ManualORPulse) THEN  outData[0]:=16#30;  NumRead:=ParamIn;  strPtr:=ADR(TextIn);  FORi:=1TONumReadDO    strPtr^:=inData[i];    strPtr:=strPtr+1;  END_FOR;(*  Read:=FALSE;*)END_IF;IFReadStatusTHEN  outData[0]:=16#00;  NumRead:=ParamIn;  TransmitBufffer:=BOOL_TO_BYTE(inData[0].6);  RecieveBuffer :=BOOL_TO_BYTE(inData[0].5);  TransmitError :=BOOL_TO_BYTE(inData[0].2);  RecieveError  :=BOOL_TO_BYTE(inData[0].1);END_IF;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've been tasked with implementing a RS232-Pro inline module with an L40 (MLC04) to talk with a serial device (HID card reader). I have implemented the code you previously posted and have a few questions.
1) In your "FOR" loop the line strPtr^:=inData[i] is taking the data in the array (which is the input data buffer) and moving it into the data of strPtr which is actually "TextIn". The loop just puts the value of each array position to the next character of the "TextIn" string. Are those statements correct? If that is the case I should be looking at "TextIn" for the data from my serial device.
2) I see a value of <030e593b> for strPtr in my code which i'm guessing is the memory address of "TextIn"? I currently see a value of 59 in inData[0] and a value of 36 in inData[1] to inData[11]. Then in "TextIn" I see twenty two $ (I'm not sure why twenty two but the dollar signs correspond to the decimal ascii code of 36). Looking at the datasheet for the RS-232 module the 59 for byte 0 seems correct since I'm seeing 11 bytes of input data and the command is read characters.
Is my thinking correct here? I have not implemented a RS232 interface before and I haven't used pointers all that much. I would appreciate any insight you have. Thanks!
Pat
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear All.
I am using Phoenix contact inline RS232 module "IB-IL-RS232-PRO"
Can any one of you give me some sample program how to implement in the codesys. I am using rexroth L10 PLC.
Hello, i created a example for the 485 module a while ago, it's quite similar to the RS232.
The code is not overly commentated or in that high quality but it should give you some insights on how to do it. You need the manual for the inline module here:
http://www.boschrexroth.com/borexmvz2/Detailview.jsp;jsessionid=558C3B601CA6CE02FC093C95143E79EC?language=en-GB&publication=NET&ccat_id=79915&edition_id=1111692&document_id=1111691
Hi
Thank You Mr. Andreaz
Thanks a lot for your inoformation.
I will try your logic and let you know...
Regars
Vijay
Hello Andreas,
I've been tasked with implementing a RS232-Pro inline module with an L40 (MLC04) to talk with a serial device (HID card reader). I have implemented the code you previously posted and have a few questions.
1) In your "FOR" loop the line strPtr^:=inData[i] is taking the data in the array (which is the input data buffer) and moving it into the data of strPtr which is actually "TextIn". The loop just puts the value of each array position to the next character of the "TextIn" string. Are those statements correct? If that is the case I should be looking at "TextIn" for the data from my serial device.
2) I see a value of <030e593b> for strPtr in my code which i'm guessing is the memory address of "TextIn"? I currently see a value of 59 in inData[0] and a value of 36 in inData[1] to inData[11]. Then in "TextIn" I see twenty two $ (I'm not sure why twenty two but the dollar signs correspond to the decimal ascii code of 36). Looking at the datasheet for the RS-232 module the 59 for byte 0 seems correct since I'm seeing 11 bytes of input data and the command is read characters.
Is my thinking correct here? I have not implemented a RS232 interface before and I haven't used pointers all that much. I would appreciate any insight you have. Thanks!
Pat