Jump to content

Help required on RS485 Setup

Recommended Posts

Hello Everyone,

I am new to this community and to Unitronics PLC. I have worked on the PLCs but I am not familiar with Unitronics PLC and its software.

I am trying to connect with sensor that responds to data over RS485 (polling). I have the sensor registers and commands that are obviously in ASCII.

I need to write and read from sensor over RS485.

Can someone please just provide me a sample program to initialize COM, Send Command, Read Response and display this on HMI?

I just a sample then I can workout for the whole program, the controller I am using is V130-33-T38.


Looking for guidance


Link to comment
Share on other sites

Thanks for the reply

I have attached pics of the protocol used by sensor.

For RS485, it supports polling EE (Controller sends 2 byte message and Sensor No. 2 responds with only speed message) and EA (Controller sends 4 byte command and sensor responds in A Format).

I just need a simple example for init com, polling EE, receiving response and display it on HMI for now.

Using this example , I will go for and EF (configuring).





Link to comment
Share on other sites

  • MVP 2023

I've said this before, but here it is again.....

Don't do anything PLC wise until you've done lots of preliminary work using your PC.  The best method to start with anything Modbus that you don't really know, is to use one of the various (free) modbus programs available to get your PC communicating correctly with the device.  You then learn all the registers you want to use and how to go about it.  Doing this via the PC is far, far easier than mucking around with the PLC trying to get an unfamiliar device to work.

With that knowledge you then transfer the relevant details to the PLC, and if done correctly it will work first go.  Remember the addressing differences of 1 that the Vision's do.

As mentioned by others there are numerous examples in the various Help files within Visilogic.  Also understand that the Help files are where many questions can be answered during your learning curve, and if you look for MODBUS using the Help Index you'll find lots of info that you need to thoroughly understand.  For actual examples, go to Help/Examples/Version 900/ Project examples/Communications/Modbus.

cheers, Aus

  • Like 1
Link to comment
Share on other sites

Hello everyone,

I have just completed this program and want some suggestions/ inputs before testing to get this done efficiently.

I'll be really grateful for any suggestions/ errors pointed out.

This is the overall program.


Initialized com port


Protocol Configuration


I need to send this request and stored EA020113 in MI-1.


Stored value (EA020113) is sent after 100ms interval.


This is the send protocol which I have used.


Following is the expected response from the sensor.


I have used STX, 2 byte variable and checksum.


This is my checksum byte setting.


The two byte response is stored in MI-10 and as per response 0-11 bits contain speed. So, I have used following masking technique (0x0FFF AND Response) to get 0-11 bits which are then stored in MI-15.


Then finally created this Numeric variable on HMI (Link: MI-15) to display speed.



Please someone go through steps and check everything is fine. Specially, checksum in receive and masking of received message.



Link to comment
Share on other sites

  • MVP 2023

You're sending the request 10 times a second in rung 2 without waiting for the sensor to reply.  I'd block the SEND block with a NC of MB 2 and reset MB 2 with a NO of MB 4.  You'll also have to reset MB 4 yourself.

8 hours ago, Shahid said:

lease someone go through steps and check everything is fine

It looks OK, but I'd follow Aus's recommendation and check it with a terminal program on your PC that is capable of displaying raw hex values such as Bray's Terminal.  You'll need a USB to RS485 adapter as well for this.

I'd go ahead and download it.  You're not going to break anything.

If you don't have a second COM port installed in your V130 you need to do that - either a serial port or an Ethernet port so you can go online with the PLC.  Otherwise you'll be blind trying to troubleshoot your program.

Joe T.

  • Like 1
Link to comment
Share on other sites

  • MVP 2023
15 hours ago, Shahid said:

some suggestions/ inputs before testing

You can use info mode for test what PLC send to sensor and what sensor send to PLC.

It is possible to find com port settings and see RX and TX buffer.

Please try to load program and check this useful option.

I use it for configure communication with not standard protocol device.

If tx buffer is the same as on PC than RX from device must be the same

  • Like 1
Link to comment
Share on other sites


By info mode, I assume that it sniffers everything has been received (RX)? Even it doesn't fulfill the scan criteria. Once, the buffer is reset it is gone?

Secondly, I used store block to store value of EA020113 in MI-1 but during online test it showed only lower 2 bytes i.e. 0113 as shown below. Then I used EE12 instead.




Link to comment
Share on other sites

I have sorted out most with help of you guys, thanks.

I think there is some issue between hex to ASCII conversion whilst sending on protocol. I was trying to send HEX as ASCII but wasn't working then I inserted relevant ASCII characters to which sensor responded. Do I need to convert stored value to ASCII first then link in Scan FB Protocol?

Also, Scan FB is working on when I insert checksum byte as control character as shown below. As a variable it is not working, is it the same issue of ASCII to HEX conversion?




Link to comment
Share on other sites

  • MVP 2023
5 hours ago, Shahid said:

Do I need to convert stored value to ASCII first then link in Scan FB Protocol?

Scan FB Protocol used for "read-in" not standard messages. Main problem is to find correct message format. 

If i can not find correct check sum method - i try to read-in message without it.  It works....  Sended by another device message do not need to be scanned

directly as it appear in manual. Only start of message must be correct (for separate message) and message length must not be longer then scanned variable - message can be written to buffer and it can be parsed by byte operation.

But in this method some Silent period must be prepeared. (without  it FB Protocol sometimes react on checksum as message start).

Check sum needed only if you must 100% correct  data scan.  For testing it is not needed.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...