Hi,
I thought it best to start a new topic so I don't clutter the other one up.
I have been having a lot of issues with Modbus RS485, I am getting closer but now think there is an issue with the direction control.
I now have the send message as it should be but I get no response from the slave. Instead of the device I hooked up a USB/RS485 converter and Modbus slave software. This showed it was only getting part of the message, the logic analyser showed it was sending it all but it looks like the data direction is being changed early. I put the link for the direction to VCC so it was high permanently and the slave receives the whole message which leads me to believe there is an issue with the direction software.
Here is the slave showing part message.
Here is the logic analyser showing the whole message being sent but the direction changes after the function byte.
Here is the slave showing the whole message received and a simulated response.
The project is here if you need it, 2nd to last post. viewtopic.php?f=3&t=1348
Regards,
Bob
Modbus direction control
-
- Posts: 283
- http://meble-kuchenne.info.pl
- Joined: Sat Mar 19, 2022 4:53 pm
- Has thanked: 25 times
- Been thanked: 32 times
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Modbus direction control
Hi Bob,
I beleive I've seen this before on PIC16/32 hardware and has to do with UART Tx bytes not being transmitted immediatley or being queued up to be sent. The ESP certainly does this. So I've now added a check in the Modbus Master component to wait until the transmit buffer is empty before switching the RS485 DDR state.
Update is now available via the library updates.
Hopefully this helps.
I beleive I've seen this before on PIC16/32 hardware and has to do with UART Tx bytes not being transmitted immediatley or being queued up to be sent. The ESP certainly does this. So I've now added a check in the Modbus Master component to wait until the transmit buffer is empty before switching the RS485 DDR state.
Update is now available via the library updates.
Hopefully this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Modbus direction control
Hi Ben,
Update, in my test with the software slave it appears to work but something strange is happening now.
The message is sent as expected but there is an extra byte on the end (circled), then there is also another request that I have no idea where that is coming from. This is happening on evert message where it did not before? I am not sure when I will be able to try with the actual slave device, probably the weekend but this should not be any different as this is sent data.
Bob
Update, in my test with the software slave it appears to work but something strange is happening now.
The message is sent as expected but there is an extra byte on the end (circled), then there is also another request that I have no idea where that is coming from. This is happening on evert message where it did not before? I am not sure when I will be able to try with the actual slave device, probably the weekend but this should not be any different as this is sent data.
Bob
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: Modbus direction control
Hi Bob,
I can't spot anything in your program that you showed that would account for the second message, not sure where that one is coming from?
Glad it's working better for you now though.
I can't spot anything in your program that you showed that would account for the second message, not sure where that one is coming from?
Glad it's working better for you now though.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: Modbus direction control
Hi Ben,
I did try it with the actual hardware and it did not work, I will need to hook the logic analyser up to see what is happening there.
I have also just collected some transcievers that do not need a direction control so will update later.
Bob
I did try it with the actual hardware and it did not work, I will need to hook the logic analyser up to see what is happening there.
I have also just collected some transcievers that do not need a direction control so will update later.
Bob
Re: Modbus direction control
Hi Ben,
The issue is partly resolved, I changed the MAX485 module to one that does not require a direction input. This worked straight away so it appears there is still an issue with the updated change. When I had the logic analyser on it I think the extra transmitted byte was the issue.
When I have played around with the webserver and getting the data from the module into it I will see if I can put the other MAX485 transceiver back and get screen grabs so we can see what each looks like.
Regards,
Bob
The issue is partly resolved, I changed the MAX485 module to one that does not require a direction input. This worked straight away so it appears there is still an issue with the updated change. When I had the logic analyser on it I think the extra transmitted byte was the issue.
When I have played around with the webserver and getting the data from the module into it I will see if I can put the other MAX485 transceiver back and get screen grabs so we can see what each looks like.
Regards,
Bob