How to Configure Compactlogix PLC to Receive TCP Socket Data in HEX Format

Question:

I am currently working on establishing a TCP connection between a Compactlogix 5069-L306ER PLC and a TDI checkweigher to obtain real-time weight data for filled jugs. The Compactlogix controller will act as the TCP server in this setup. I have successfully set up the connection and can receive data from the checkweigher using sample code provided by Rockwell Automation. However, the issue I am facing is that the data received in the PLC is in ASCII format instead of HEX. I require the data to be in HEX so that I can utilize the OEM's hex map to extract the specific weight variable I need. I have included a screenshot showing the data received in Net Assistant software, which I used for testing the connection prior to setting up the PLC. In the receive options of Net Assistant, there is a checkbox where I can choose between ASCII or HEX formats for receiving the data. Can anyone provide guidance on how to configure the Compactlogix controller to receive the data in HEX format? Thank you in advance for your assistance!

Top Replies

The term "HEX data" is referring to hexadecimal data representation, which is commonly used to display binary data in a more readable format. HEX characters, such as '0', '1', '2', and 'E', are actually ASCII characters that represent individual nibbles or half of an 8-bit byte. When working with data received by the CompactLogix through the ReadSocket Service, the relevant data can be found in the .Buf[] array element. This data is of type SINT (8-bit signed integer) and is passed to the ReadSocket Service as the Destination Element. SINT data values range from 0 to 127 decimal (0x00 to 0x7F hexadecimal) for positive values, and -128 to -1 (0x80 to 0xFF) for negative values. If you need to compare the data in the .Buf[] array with hexadecimal values, you can use a comparison operation like: EQU RCVD.Buf[108] 47H, where 47H represents the hexadecimal value 0x47 in a literal form.

When establishing a TCP connection, the data received is exactly what the sender sends, making real-time conversion impossible. If ASCII data is received, your PLC program must convert it as needed. Data reception methods vary based on the protocol design. For example, Modbus often sends pure hexadecimal values, while other protocols may transmit decimal values in ASCII characters or hexadecimal values in ASCII format. There are likely additional data reception methods as well.

At the core of digital information lies bits, waiting to be interpreted in ways that shape their significance. The way we perceive and decode these bits is what ultimately assigns meaning to them.

mjp123gp inquired about setting up a TCP connection between a Compactlogix 5069-L306ER and a TDI checkweigher to access real-time weight data for filled jugs. The objective is to have the Compactlogix controller act as the TCP server. Although successful in establishing the connection and receiving data from the checkweigher using Rockwell's provided code, the issue lies in the received data being in ASCII format instead of HEX. Converting the data to HEX is crucial for utilizing the OEM's hex map to extract the necessary weight variable. The Net Assistant software used for testing the connection offers the option to receive data in ASCII or HEX format. Seeking assistance in configuring the Compactlogix controller to receive data in HEX format for proper extraction of the weight variable. Precise byte order knowledge of the checkweigher equipment can facilitate identifying the weight's position in the payload, allowing for easy extraction into a REAL variable.

Knowing the precise protocol specifications and understanding the meaning of each received byte is crucial. Typically, a header is the first component to be read, signaling any errors or indicating the number of bytes in the transmission. Once the header is processed without error, the data can be accessed. It is important to accurately track the number of bytes read and the bytes that are yet to be read, especially in TCP connections where data may arrive in separate blocks from how they were originally sent. This level of detail ensures a seamless and accurate data transmission process.

Sure, I can help with that. First, remember that ASCII data is just a representation of hex. One approach would be to create a simple function block in your PLC logic to convert ASCII into hexabyte. If you want a more sophisticated solution, you might have to modify the socket layer settings on the Rockwell PLC. For that, you'll need to use an application like RSLogix 5000 to modify the PLC logic to interpret received data as HEX, not ASCII. It's a little complex but let me know if you need further clarification.

I see your dilemma. One feasible solution could be to use the ASCII to INT instruction in RSLogix 5000. This allows you to convert the ASCII data into an integer array. From there, you can use the COP instruction to copy this data over to a DINT array. DINT arrays are easier to manipulate and you can extract HEX values from them. Finally, remember to check the OEM documentation for the correct decimal to HEX conversion for your specific weight variable. Hope this helps!

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. How can I configure a Compactlogix PLC to receive TCP socket data in HEX format?

Answer: - To configure a Compactlogix PLC to receive TCP socket data in HEX format, you may need to adjust the settings in the communication protocol or program logic to interpret the incoming data as HEX instead of ASCII.

FAQ: 2. What is the significance of receiving data in HEX format for a Compactlogix PLC communicating with a TDI checkweigher?

Answer: - Receiving data in HEX format is important when working with specific data structures or protocols that require hexadecimal representation for accurate interpretation and processing of information, such as extracting weight values from an OEM's hex map.

FAQ: 3. Can the communication software used for testing the connection, like Net Assistant, impact the format in which data is received by the Compactlogix PLC?

Answer: - Yes, communication software like Net Assistant may have options to receive data in different formats such as ASCII or HEX. Ensuring that the software is set to receive data in HEX format can influence how the data is interpreted by the PLC.

FAQ: 4. Are there any sample codes or resources available from Rockwell Automation to assist in configuring a Compactlogix PLC for receiving data in HEX format?

Answer: - Rockwell Automation may provide sample codes or documentation that can help in configuring a Compactlogix PLC to receive data in HEX format. It is recommended to consult their resources or support for assistance in this matter.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’