Modbus data frame, CR+LF HExadecimal conversion

vishalkbhatt

Member
Joined
Oct 7, 2010
Messages
12
Programming Experience
Beginner
Hi friends, I m working on an application which communicates with PLC machine using Modbus protocol. Now i m able to generate and communicate a modbus data frame with PLC the only problem that i m facing is that in all the data frames of modbus the last ascii characters should be Carriage return + Line feed which should be read by the PLC as 0D 0A that is in Hexadecimal form. But i m not able to do this. The rest entire string is properly read by the PLC but How do I make it read the CR+LF. Pls help me in this who ever knows the answer. Thanks.
 
hi mate,
I know your pain, cause I'm a controls engineer too, and I know how those data frames can get fuzzy and muddle up.

but the good news is that if you already got all the rest working it's pretty easy to add the 0D 0A at the end of it:
I'm assuming your data frame is a string that you then send to the serial port, therefore:
VB.NET:
FinalString = DataFrameStr & vbCrLf
' or, if you want to be specify other characters
FinalString = DataFrameStr & chr(13) & chr(10)
 
Back
Top