Need help in several things!!

Hello there,

Recently, A friend of mine asked me to help him develop a really weird system. He has a Data acquisition system working at his place. This is system is presently based on use of PLC using MODBUS RTU protocol and connects through RJ45 jack.

Now he wishes to have a wlan system for this replacing the PLC hardware. In a way, DTU (Data terminal Unit) connects to PC instead of PLC through RJ45 jack and receives query in MODBUS RTU format, it then Places this query on WLAN and sends this to RTU(Remote Terminal Unit), the RTU receives it and gives response back to DTU in MODBUS RTU format after executing what it has to be done in the query. So he asked me to help me in this matter.

The way I analyzed this situation is like - for DTU I need something that will accept data from PC through RJ45 jack (ethernet jack) for this I chose ENC28J60 module that will communicate with my arduino over SPI arduino will receive it. Then I need something to put the whole stuff I received onto WLAN for this I decided to use ESP12 communicating with my arduino through serial.

I know its not the correct way to use MODBUS RTU over WLAN but that is the key thing that has to be implemented in this project. So my question is whatever I have thought of will it work accordingly? like using ENC28J60 can I receive the MODBUS RTU over RJ45? If so how do I suppose to read it through my arduino. will it be in MODBUS RTU format still when I read it?

The approach I am planning to implement is to receive the query from RJ45 in MODBUS RTU break it into my arduino and put some custom built character/code on the WLAN. This way I don't need to put the MODBUS RTU over WLAN. At the receiving end there will be a local look up table for these custom built codes and thr RTU will act accordingly and reply in similar fashion rather than replying in MODBUS RTU. at the DTU end on receiving the response from RTU the whole thing will be reconstructed in MODBUS RTU and sent to computer for the display. So is it the right way? is it possible in a way I am planning to do so?

for RTU - I need something to receive the queries over WLAN so I chose ESP 32, which will have WLAN as well as process the queries that it receives.

Any help/suggestions? thanks in advance

I think you need to come up with a much clearer specification both of what already exists and what you want to change it to.

Just because an RJ45 connector is being used that does not mean it is an Ethernet connection.
Modbus RTU normally refers to a serial protocol using RS232 or RS485 for the physical connection.
If Ethernet is being used then normally that is called Modbus TCP/IP.
So the first question would be are you sure the physical connection is Ethernet.

What is the real objective here is it just to use Wireless LAN?
If it is then does the PLC equipment supplier not have wireless bridge options?
What PLCs are being used?

I am pretty much sure that it just ss rJ45 for connection and the protocol used is mOdBus RTU and not the MODBUS TCP/IP

Yeah, it can be said that the main objective is to go on WLAN. I don't knowmuch about the previous system that existed i only know that PLc was used. And now they wish to replace it with system which i discussed above.

Count:
I am pretty much sure that it just ss rJ45 for connection and the protocol used is mOdBus RTU and not the MODBUS TCP/IP

Yeah, it can be said that the main objective is to go on WLAN. I don't knowmuch about the previous system that existed i only know that PLc was used. And now they wish to replace it with system which i discussed above.

I am not understanding because you wrote "The way I analyzed this situation is like - for DTU I need something that will accept data from PC through RJ45 jack (ethernet jack) for this I chose ENC28J60 module". If you are not using MODBUS TCP/IP why are you using a ethernet controller?
If you are going to replace an existing system then the first thing you need to find out is exactly what the old system does in detail.

ardly:
I am not understanding because you wrote "The way I analyzed this situation is like - for DTU I need something that will accept data from PC through RJ45 jack (ethernet jack) for this I chose ENC28J60 module". If you are not using MODBUS TCP/IP why are you using a ethernet controller?
If you are going to replace an existing system then the first thing you need to find out is exactly what the old system does in detail.

what should I use instead of ethernet controller then to accept the data from RJ45 jack? and which things I should know about the existing system?

If it is Ethernet at the RJ45 jack then just plug it into a wireless router. Job done.

The way you tell if it is Ethernet is to follow the cable. If it goes to an Ethernet router or the network port on the back of a PC then it is Ethernet.

If it goes into some other kind of adapter then look at what is written there. It may be RS485.

MorganS:
If it is Ethernet at the RJ45 jack then just plug it into a wireless router. Job done.

The way you tell if it is Ethernet is to follow the cable. If it goes to an Ethernet router or the network port on the back of a PC then it is Ethernet.

If it goes into some other kind of adapter then look at what is written there. It may be RS485.

the DTU should connect to PC through RJ45 and accept the queries in MODBUS RTU only. That's what I have been asked to develop

Count:
what should I use instead of ethernet controller then to accept the data from RJ45 jack? and which things I should know about the existing system?

The RJ45 is just a connector. You need to find out if the protocol is being sent using ethernet or RS232 or RS485.
You need to find out everything about the existing system. What PLCs are being used, what are they being used for, where are they located, why do they need replaced, why is a wirless LAN required.

Research the exisitng system. What is the DTU is it a PLC card if so what make and model. Likewise what is the RTU is it a PLC card if so what is the make and model. If you then lookup these cards you will find out whether they are using ethernet or RS232/RS485

Count:
the DTU should connect to PC through RJ45 and accept the queries in MODBUS RTU only. That's what I have been asked to develop

What you have been asked to develop is unclear and does not really make sense.

Modbus RTU is normally a serial protocol let's say it is using RS232, why on earth would somebody specify that it has to connect to a PC using an RJ45 connector? You would connect to the PC using a USB to RS232 converter. These typically have a male 9 way 'D' type connector, so you would connect with a cable fitted with a female 9 way 'D' type connector.

The existing system does not have a PC does it. So what software are you going to be running on the PC, is it a package you are going to buy or something you are going to write yourself, what does it do?

You seem to be planning on translating characters from one format to another and back again. That sounds like a completely needless and complicated step.

What does the Arduino do, why is it there?

Nobody can help you without a clear understanding of the existing system, what you want to replace it with and why.

Thanks for the reply, I’ll look for all the details you have said and get back with a complete idea

ardly:
The RJ45 is just a connector. You need to find out if the protocol is being sent using ethernet or RS232 or RS485.
You need to find out everything about the existing system. What PLCs are being used, what are they being used for, where are they located, why do they need replaced, why is a wirless LAN required.

Research the exisitng system. What is the DTU is it a PLC card if so what make and model. Likewise what is the RTU is it a PLC card if so what is the make and model. If you then lookup these cards you will find out whether they are using ethernet or RS232/RS485
What you have been asked to develop is unclear and does not really make sense.

Modbus RTU is normally a serial protocol let's say it is using RS232, why on earth would somebody specify that it has to connect to a PC using an RJ45 connector? You would connect to the PC using a USB to RS232 converter. These typically have a male 9 way 'D' type connector, so you would connect with a cable fitted with a female 9 way 'D' type connector.

The existing system does not have a PC does it. So what software are you going to be running on the PC, is it a package you are going to buy or something you are going to write yourself, what does it do?

You seem to be planning on translating characters from one format to another and back again. That sounds like a completely needless and complicated step.

What does the Arduino do, why is it there?

Nobody can help you without a clear understanding of the existing system, what you want to replace it with and why.

ardly:
The RJ45 is just a connector. You need to find out if the protocol is being sent using ethernet or RS232 or RS485.
You need to find out everything about the existing system. What PLCs are being used, what are they being used for, where are they located, why do they need replaced, why is a wirless LAN required.

Research the exisitng system. What is the DTU is it a PLC card if so what make and model. Likewise what is the RTU is it a PLC card if so what is the make and model. If you then lookup these cards you will find out whether they are using ethernet or RS232/RS485
What you have been asked to develop is unclear and does not really make sense.

Modbus RTU is normally a serial protocol let's say it is using RS232, why on earth would somebody specify that it has to connect to a PC using an RJ45 connector? You would connect to the PC using a USB to RS232 converter. These typically have a male 9 way 'D' type connector, so you would connect with a cable fitted with a female 9 way 'D' type connector.

The existing system does not have a PC does it. So what software are you going to be running on the PC, is it a package you are going to buy or something you are going to write yourself, what does it do?

You seem to be planning on translating characters from one format to another and back again. That sounds like a completely needless and complicated step.

What does the Arduino do, why is it there?

Nobody can help you without a clear understanding of the existing system, what you want to replace it with and why.

I got back with some detail. The system uses RS485 communication over RJ45 connector. So what should be done now? Should I go for using MAX485 with my arduino?

Yes, that will work.

MorganS:
Yes, that will work.

can you suggest which Library should I use? Will it be RS485 library or MODBUS RTU library? and how do I put it on WiFi?

I surfed the net and found MODBUS RTU library

Interesting to see the progression of thought here. Root Cause Analysis comes to mind. We ask the question, state the facts, analyze and revise the question.

Everyone should observe that the OP presented some information and asked a question. When asked for clarification, he revised his question and provided additional information. Eventually, the OP provided the solution to his own question.

However, this process wasn't a waste of time, but rather an exercise we all go through. Unfortunately, many of these posts look just like this one.

I have a problem.
I have formulated a question (might not be the right question).
I state some facts.
I analyze the facts.
I rephrase the question (still might not be the right question).
I restate the relevant (revised) facts.
I rephrase the question (might be the right question now).
repeat until the solution is arrived at.

The OP came to his own rescue by analyzing answering the support questions. What is the protocol on the RJ45 jack?

Root Cause Analysis is easy on it's face, but hard when you are close to the problem. The support network on this forum is great and I'm happy you guys are here.

Thanks!

Count:
I got back with some detail. The system uses RS485 communication over RJ45 connector. So what should be done now? Should I go for using MAX485 with my arduino?

Stop. Take a step back from this and think.
In your original post you said you wanted a PC to communicate with a Data Terminal Unit.
So we now know that the DTU communicates using the Modbus RTU protocol using RS485 and an RJ45 connector.
Where and why does an Arduino come into this at all?
You can get a USB-RS485 converter that plugs into a PC.
RS485 can be carried over wireless using and RS485 wirless bridge.
If it was me I would start by plugging the PC directly into the DTU and making sure they could talk using the Modbus RTU protocol. I would use an free Modbus package for the PC to test this.
Once that is working I would introduce an RS485 wirless bridge.
If a direct connection worked the wirless connection (if used within spec) should also work.
However you still have not answered some very basic questions e.g. where is the PC going to be in relation to the DTU. If wirless does not carry between the two locations because of say distance or the materials in between there is no point in looking at wireless.
Also if the existing system actually works and the only new requirment is to have a wirless connection why not look at what wireless bridging options the PLC provider supples. Most PLC manufacturers have such options, but you still have not said what equipment is being used.

Count:
can you suggest which Library should I use? Will it be RS485 library or MODBUS RTU library? and how do I put it on WiFi?

I surfed the net and found MODBUS RTU library

GitHub - jecrespo/simple-modbus: Automatically exported from code.google.com/p/simple-modbus</titl

Yes that looks like a good library.

Next you have to determine which wires on the RJ45 are in use and the function of each one. It is likely to only use one pair of wires for both transmit and receive but it might use two pairs for full duplex. Choose a RS485 adaptor which comes with wiring diagrams for both options.

ardly:
Stop. Take a step back from this and think.
In your original post you said you wanted a PC to communicate with a Data Terminal Unit.
So we now know that the DTU communicates using the Modbus RTU protocol using RS485 and an RJ45 connector.
Where and why does an Arduino come into this at all?
You can get a USB-RS485 converter that plugs into a PC.
RS485 can be carried over wireless using and RS485 wirless bridge.
If it was me I would start by plugging the PC directly into the DTU and making sure they could talk using the Modbus RTU protocol. I would use an free Modbus package for the PC to test this.
Once that is working I would introduce an RS485 wirless bridge.
If a direct connection worked the wirless connection (if used within spec) should also work.
However you still have not answered some very basic questions e.g. where is the PC going to be in relation to the DTU. If wirless does not carry between the two locations because of say distance or the materials in between there is no point in looking at wireless.
Also if the existing system actually works and the only new requirment is to have a wirless connection why not look at what wireless bridging options the PLC provider supples. Most PLC manufacturers have such options, but you still have not said what equipment is being used.

PC -> MODBUS RTU on RJ45 -> DTU

DTU ->WLAN -> RTU

RTU -> WLAN -> DTU

DTU -> MODBUS RTU on RJ45 -> PC

this what is expected. The reason I couldn't answer some very basic questionnaire is because the answers were unavailable from the source. Thats all they were able to tell me about the system. They themselves don't know anything beyond.

MorganS:
Yes that looks like a good library.

Next you have to determine which wires on the RJ45 are in use and the function of each one. It is likely to only use one pair of wires for both transmit and receive but it might use two pairs for full duplex. Choose a RS485 adaptor which comes with wiring diagrams for both options.

thanks for the suggestion MorganS I'll go through it. But i am still confused about how do I put the whole stuff on WLAN because it is the most important part of the project that this whole thing goes wlan

And for RS485 I'll be using this module from sunrom. is it ok?RS485-TTL Module [4519] : Sunrom Electronics

.....But i am still confused about how do I put the whole stuff on WLAN because it is the most important part of the project that this whole thing goes wlan

And for RS485 I'll be using this module from sunrom. is it ok?RS485-TTL Module [4519] : Sunrom Electronics

You are not the only one that is confused. At the moment you have zero chance of getting this to work. You were asked where an Arduino fitted into the solution and you have not said. You have slected a module that would allow RS485 to be connected to an Arduino but what good would that do you?

Look at post #15 which you say is what is expected.
To me that looks like this;

RS485 Wireless RS485
PC------------DTU-----------RTU----------PC
The protocol used is MODBUS RTU throughout.

To connect the PCs to the DTU and RTU you should probably be looking at something like this
http://www.usconverters.com/usb-rs485-converter-xs885?zenid=3ae146e650a2acb158ab58c8e23044ca
I am sure that you can get similar much cheaper. You would just cut off the existing RJ45 connectors and wire the cables into the screw terminals.

For the wirless connection between the DTU and the RTU ASSUMING the connection between the two is presently RS485 then you would use an RS485 wireless bridge something like this;
https://datawavewireless.com/index.php/products/rs485-wireless-bridge.html

HOWEVER I would strongly suggest that if the existing system actually works somebody took the time to take a look at it, to record what the DTU and RTU actually are and then check whether or not the PLC manufacturer already has a suitable wirless bridge product that can be used.

So far nowhere do I see a need for an Arduino and your earlier posts about sending and translating between custom characters seem like a crazy way to go.

Looking at post #15 again maybe what you have is;
RS485 Wireless
PC------------DTU-----------RTU

The answer is still the same though.

Replying to post #17 and post #18.

Ardly, I am exteremely sorry for creating this whole confusion. At present there dows not exist DTU-RTU system. The existing system comprises of PLC and wired networks. They wish to take this whole thing on WLAN. That’s when they came up DTU and RTU concept.

They asked me to make these two systems DTU and RTU which are supposed to communicate over WLAN with each other. DTU (Data Terminal Unit) will connect to PC (through RJ45 connector), from PC queries will be generated in MODBUS RTU protocol. DTU is supposed to fetch them from PC and put it (or may convert it to some other form and then put it) to WLAN. Which then will be received by RTU (remote terminal Unit) and take neccessary actions asked in the query, after execution of those activities RTU replies back to DTU over WLAN. DTU then send the reply received from RTU back to PC in MODBUS RTU protocol only.

To note here is DTU and RTU does not exist in the current system. I have been asked to design them. So I figured out that DTU should have something to process the queries for this I am using arduino and put it on WLAN I’ll be using ESp12E for it. On RTU side to receive the query on WLAN I’ll be using ESP32

Now further, after our discussion I came to know I need something to accept those queries so I got RS485 to TTL converter.

Now I know that I need something more like USB to RS485 Converter. would this one do?
http://www.dnatechindia.com/index.php?route=product/search&search=USB%20to%20RS485

Is it possible to use DB9 connection of PC to communicate with this RS485 to TTL converter? Sorry if my question is too immature, but I am pretty new to MODBUS and RS485