View previous topic :: View next topic |
Author |
Message |
aroonkriss
Joined: 03 Dec 2012 Posts: 19 Location: kerala
|
modbus tcp/ip implementation |
Posted: Sun Nov 24, 2013 10:10 pm |
|
|
HI,
I am implementing modbus tcp/ip protocol through a serial gateway TSXETG100 (Schneider Electric) in 4 wire connection. I have added the MBAP header to the modbus query and response with reference to the modbus tcp/ip implementation guide. But when i run the code by sending the query through modscan32, i got the exception code '0B' (gateway problem: targeted device failed to respond). When i debug the code, it is found that only slave id and data are being received by the UART of dspic30f3013. From this i got the idea that the serial gateway convert the tcp/ip data to pure RTU format. I changed the code according to this, but i have a confusion regarding the format of the response. I implemented the response in two format- with MBAP header and without header. But getting the same error '0B' all the time. In every document the response format is given in MBAP format, but it is not working for me. Could anyone please tell me what must be the response format?
Thank you in advance
Aroon _________________ I dream world peace |
|
![](templates/subSilver/images/spacer.gif) |
aroonkriss
Joined: 03 Dec 2012 Posts: 19 Location: kerala
|
modbus tcp/ip implementation |
Posted: Tue Nov 26, 2013 11:50 pm |
|
|
Hi,
i have debugged the code, my code is putting "slave address,func code, byte count and data" to UART1 one by one using fputc(data,UART1);. i tried to watch u1txreg of the pic, but i shows 0x0000 always. But the modscan always shows either exception '0B' - gateway problem or exception '07' - negative confirmation. i have searched a lot for the correct format for the response but could not find anything. Anyone who knows the correct response format , please respond.
Thank you _________________ I dream world peace |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Wed Nov 27, 2013 12:13 pm |
|
|
I'd say you need to implement straight MODBUS ASCII or RTU on the PIC And let the Gateway do the TCPIP work...
I'm assuming you are doing 485 after the gateway.... thus your Modbus format needs to be as per RTU or ASCII... and that gets encapsulated in TCPIP...
If i recall correctly RTU or ASCII do not use the MBAP... thats only if you are using MODBUS TCPIP directly from the PIC.
I'm not an expert... i just got Modbus TCPIP running on a 18F97j60.... more luck than knowledge, and CCS support.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
aroonkriss
Joined: 03 Dec 2012 Posts: 19 Location: kerala
|
modbus tcp/ip implementation |
Posted: Thu Nov 28, 2013 2:36 am |
|
|
HI,
Thank you very much for your inputs. i had already tried with RTU reply format but without CRC. Still gateway gives the error code '7' -negative acknowledgement. I am not setting this error code. The serial gateway itself gives this exception. I am using max488(full duplex ) at the recieving end of the modbus card. will it cause any problem? because i have read that in most of the modbus half duplex communication is used. Still trying to solve the problem. Thank you once again
Aroon _________________ I dream world peace |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Nov 28, 2013 6:11 am |
|
|
As with all PIC projects, start small.
Get modbus RTU running WITHOUT the gateway.
You can test it with Modbus Poll or modscan.... after that works, THEN try pushing it via the tcpip gateway.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
aroonkriss
Joined: 03 Dec 2012 Posts: 19 Location: kerala
|
modbus tcp/ip implementation |
Posted: Thu Nov 28, 2013 9:54 pm |
|
|
Hi,
Thank you for your reply. i had already developed modbus rtu through serial communication(through COM port). It was successfully tested. Now the requirement from client side has been changed so i need to switch into tcp/ip. Now i have added CRC to the response and i got one valid response after that all the response are negative acknowledgement.
Aroon _________________ I dream world peace |
|
![](templates/subSilver/images/spacer.gif) |
aroonkriss
Joined: 03 Dec 2012 Posts: 19 Location: kerala
|
modbus tcp/ip implementation |
Posted: Sat Nov 30, 2013 12:13 am |
|
|
Hi,
Everything is working fine now. I am using alternate pins of uart1 of dspic30f3013 (pin no: 11 and 12). i got the correct responses but when i changed the connection back to the main uart1 pins (17 an 18), i am not getting valid response. with com port communication, both alternate pins and main pins are working. with tcp/ip configurations only alternate pins work. i have checked all the hardware connections and software settings, everything looks fine. i am wondering, why the program is not working with main uart pins? if anyone has idea, please respond
Thank you
Aroon _________________ I dream world peace |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Sat Nov 30, 2013 6:21 am |
|
|
Maybe a shared peripheral on those pins?
Wrong tris settings due to use of Fast_IO.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
|