Hai this is surendra,
I have doubt regarding MODBUS communication to communicate the micro controller to Schneider drives using MODBUS RTU communication.
My objective is i want to monitor the 3 Schneider drives from my micro control with help of MODBUS RTU communication.
Here i was follow the RTU frame mechanism like first i have to send
1) slave address 2) function code 3) register address 4) CRC.
Then my doubt is how can i get the slave response i.e (drive response) to my controller. please help me i am new with MODBUS RTU communication.
A Modbus-enabled slave, the drive your case, will reply to a properly addressed query/request from a Modbus master. So your microcontroller has to be prepared to receive the reply and deal with the data as soon as the request is finished.
Apparently, your micro controller does not support Modbus protocol, so you have to write the code for Modbus communications?
If so, you need to download two Modbus serial RTU standards
- MODBUS Protocol Specification
- Modbus Serial Line Protocol and Implementation Guide V1.02
from this link (agreement)
Your RTU frame order, 1) slave address 2) function code 3) register address 4) CRC is not correct.
The 03/04 query/request function code frame order is
1) slave address [1 byte] 2) function code [ 1 byte] 3) starting register [2 bytes] 4) number of registers [2 bytes] 5) CRC [2 bytes]
The slave's response message frame is described in the Protocol spec. The master (microcontroller) has to be ready to receive the reply shortly after the query/request message is sent to the slave.
It will be a project.
> It will be a project.
Control Terminal has simple and Free Pascal code and can make it easy to first talk to the slave device with a PC.
Thanks for valuable reply.
Could you please tell me is there any terminal (like uart) to check the slave(device) response in the PC.
I already tested with modscan software i didn't get any response back from slave.
please suggest me.
> Could you please tell me is there any terminal (like uart) to check the slave(device) response in the PC.
> I already tested with modscan software i didn't get any response back from slave.
The custom Control Terminal source code for Modbus is here:
Did you get any response back from the slave with the Control Terminal program? If so you should see a line with "R" like this:
Maybe you can click the "Save" button (which creates two files) and copy in a reply what is being transmitted (line with "T")?
Modscan is a widely used 'test' master used to establish communication with a Modbus slave.
My advice is that you really need to use Modscan or the other test master to establish communication with the drive from the PC so that you can see and understand what 'makes' a connection and even look at the traffic to see a query and a response.
If you can't get a commercial product like Modscan to connect and provide a reading, you've missed the basics of Modbus. Writing code for a custom Modbus master is a really tough way to learn the basics of making a Modbus connection and getting a reply from a slave.
i tested with modscan software when i check the traffic mode the data is continuously transmitting like.Here i am using the socomec energy meter as slave it has the address starts at 50512.
05 03 c5 53 00 0a 89 94
//05--slave id//03 slave id //c553 hex value for register 50516 //
//000a 10 registers //8994 is CRC.
but i didn't get any data back...
when i check in the "show data" mode it shows the "modbus time out" message.
where i am doing fault please suggest me.Thank u.
If you receive no response you have a problem with wiring and/or communication settings. Check your cabling, baud rate settings, ...
If you send a request to a slave the slave will always respond. If the command or register is not allowed by the slave, the slave will respond with the Most Significant Bit of the command high followed by the error code. (Request command &H03 --> Response command &H83)
Also when trying to setup a communication try with only one register somewhere in the middle of the allowed registers. Some modbus devices user zero based addresses while others start from one. If you use only one register it is easier to troubleshoot your communication.
Thanks for u r reply i tested modbus communication in modscan software that's fine.
Now my objective is my master(micro controller) wants to get the data from the slave device for this i transmit the data like
now i got the same data reply back, where i did mistake?
please reply me.........thank u
Your telegram seems to be OK so this should work.
Since you are receiving the same telegram I assume you have Full Duplex communication enabled on your microcontroller. The slave will never respond with exactly the same telegram.
I don't know what the ; means. Is that one byte at a time, each byte sent separately with some indeterminate pause in between?
The message has to be one continuous stream of bits.
Assuming the change in start address, the change in number of bytes, and change in CRC (from your earlier request) are all correct, then the master's message has to be the binary equivalent of
05 03 C5 52 00 02 58 92
with no spaces; spaces are just for humans to read and make sense of the hex characters.
If the slave sent your request back you must be getting close, to send it back it must be receiving it first.
I find starting with the slowest possible baud rate sometimes helps, I think the slow rate allows for more overlap if you have an error.
It sounds as though the Modscan software is a great tool, I used to use HyperTerminal as mentioned in this topic
"MODBUS Comunication with RS485 on ST-200"
now i am facing a new problem in my program i have sending the slave id, address, registers and CRC continuously. Here the problem is before converting the RS485 (i.e at the DB9(Rs232), i am getting the continuously) but after converting the RS485 it will take some time (approx 5sec) to getting the data at the rs485 end. what is the problem?