Skip to main content

Application Note: 5069-SERIAL Communication through Generic ASCII and RS-485

You can read this post on LinkedIn as well.

Introduction:

The Allen-Bradley module 5069-SERIAL, released in 2018, offers enhanced communication capabilities for various protocols, including DH-485 and DF1, through a firmware update V2.012 in 2020. While the user manual lacks practical examples for sensor communication, this comprehensive application note aims to fill that gap. Specifically, we will focus on integrating the module with the Panasonic HL-G112 Laser Displacement Sensor. By following the outlined setup process, you can avoid pitfalls and accelerate your prototype development.

No alt text provided for this image
Fig. 1

Section 1: Understanding Sensor Specifications:

In this Application Note, I pick Panasonic HL-G112 Laser Displacement Sensor for development. I'll walk you through the entire setup process so that you can stay away from traps and have your prototype hit the ground running earlier!

No alt text provided for this image
Fig. 2

Let's start with the sensor specification sheet. (Download Link) I use RS-485 in this Application Note because I'll have more than 10 receivers in my system. You can choose RS-422 if a full-duplex serves you better. Pay attention to the Transmission code, Baud rate, Data Length, Stop bit length, Parity check, BCC, and Termination code. (Basically everything in the table below.)

No alt text provided for this image
Fig. 3

The figure below explains how to wire these sensor modules to your PLC controller in the RS-485 protocol. If you choose RS-422, you will have different wiring. Remember, RTFDS. (A quote from James Bryant. It means "Read the friendly data sheet.")

No alt text provided for this image
Fig. 4

Section 2: Examining Request and Response Strings

After knowing the communication specification and wiring, let's take a look at the string they use for transmitting requests and receiving data. (HL-G1 Series User Manual)

Oh, by the way, you have to press three buttons on the sensor and configure some parameters based on your application. I'm not going to put too much attention here. If you have questions regarding this specific sensor, you can comment below or contact the manufacturer.

No alt text provided for this image
Fig. 5

In Fig. 5, you can see a specific Read Command for this sensor. I underlined Start delimiter and Termination delimiter myself since they're key to later implementation but not explained in either manual.

No alt text provided for this image
Fig. 6

Section 3: Setting up the 5069-SERIAL Module

In Fig. 6, you see a normal response string from this sensor. Start delimiter and Termination delimiter are highlighted as well. Now, let's see how to set up the 5069-SERIAL module. (I skipped how to create a project and configure a controller because that's a common tutorial topic.)

No alt text provided for this image
Fig. 7

In the General tab, check your firmware revision. V2.012 is the latest version when I write this Application Note. Besides, configure the communication method based on your need. I pick Generic ASCII because that's the only type supported by this sensor.

No alt text provided for this image
Fig. 8

Remember Fig. 3 Communication Specification above? Filled in those parameters to the blanks in Fig. 8 and you're good to go.

Section 4: Configuring Start and Termination Delimiters

Here comes the critical/tricky part! In the drop-down lists in Fig. 9 and Fig. 10, you have Ignore Start Delimiter, Exclude, and Include. Their definitions are in Fig. 11. (Source: Compact 5000 I/O Serial Module)

No alt text provided for this image
Fig. 9
No alt text provided for this image
Fig. 10
No alt text provided for this image
Fug. 11

Look at the Receive Function first. If you keep the default setting "Ignore Start Delimiter" for the Start Mode, you only know it's not based on Start Delimiter. (Termination Mode is a bit clearer on this though.) Then what is it based on? I don't know. Maybe count backward the bytes you specified once it sees a Termination Delimiter?

To stay away from ambiguity, I choose to Include a Start Delimiter and a Termination Delimiter so that I can see them in my input tag.

No alt text provided for this image
Fig. 12

For the transmit function, the controller by default transmits and receives packets based on bytes. But here I choose the Include Mode for the same reason. Keep it clear.

After figuring out what Start Mode and Termination Mode we need, let's deal with the delimiters. For the Start delimiter, we know it's %. And the Termination delimiter is CR (Carriage Return). We then look up the ASCII table (Source: https://www.rapidtables.com/code/text/ascii-table.html) and find out their corresponding HEX representations.

No alt text provided for this image
Fig. 13

Now you know why I place $25 and $0D in the blanks in Fig. 9 and Fig. 10, right? (If you're not using the second Termination delimiter, please place $FF in the box.) Then let's move forward to the PLC program itself.

Section 5: Implementing the PLC Program

No alt text provided for this image
Fig. 14

I use S:FS to initialize the system. You can use something else if that fits your applications. Then take a closer look at the string on the lower right corner. (Review Fig. 5 if you don't remember the data request string.) Once you get this part right, you're 99% done.

Section 6: Calculating the Block Check Character (BCC)

"But how do you get the BCC (Block Check Character) result?" you may ask. No worries, I've got you covered. Simply click this link (https://bcc.beyerleinf.de/) and type in your string and voila! You have your unique BCC calculated.

No alt text provided for this image
Fig. 15
No alt text provided for this image
Fig. 16

Section 7: Finalizing the Configuration and Handling Alarms

In Fig. 16, I think everything is self-explained. (If not, feel free to drop down your question in the comment below.) In a normal operating condition, the controller will get updates from the sensor every second. Then it converts a string into a double integer; then a double integer to a real number.

No alt text provided for this image
Fig. 17

If the communication is sabotaged somehow or the sensor is dead, the value displayed on HMI will be set to zero. In the meantime, you can trigger an alarm and have people take care of it.

Conclusion:

Till this point, you should have your prototype up and running. I hope this Application Note can save you time when developing your own program. If you want to download my sample code, please visit my GitHub page.

Acknowledgment:

I'd like to take this opportunity to thank Rob Reeder. He who inspires me to start technical writing proves to be a great mentor and an incredible friend. Without him, these articles wouldn't have been written and shared on my profile.

In addition, I'd like to acknowledge my director Steven Lin's support in writing this Application Note. He trusted me when I couldn't secure a full-time position in 2020. Without him, I couldn't have been researching and developing prototypes to advance the manufacturing process in the United States.

Lastly, thank you all for supporting me in the process. I'll keep striving for the better and sharing my experience throughout my career.

Comments

Popular posts from this blog

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(一)找合作的律師事務所

Image by  David Peterson  from  Pixabay

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(零)名詞解釋 Petitioner vs Applicant

Image by  David Peterson  from  Pixabay

[申辦綠卡] EB-2 NIW 國家利益豁免綠卡申請教學(七)組裝 NIW I-140 申請文件包

Image by  David Peterson  from  Pixabay