CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

modbus tcp/ip implementation

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
aroonkriss



Joined: 03 Dec 2012
Posts: 19
Location: kerala

View user's profile Send private message

modbus tcp/ip implementation
PostPosted: Sun Nov 24, 2013 10:10 pm     Reply with quote

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
aroonkriss



Joined: 03 Dec 2012
Posts: 19
Location: kerala

View user's profile Send private message

modbus tcp/ip implementation
PostPosted: Tue Nov 26, 2013 11:50 pm     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Nov 27, 2013 12:13 pm     Reply with quote

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
aroonkriss



Joined: 03 Dec 2012
Posts: 19
Location: kerala

View user's profile Send private message

modbus tcp/ip implementation
PostPosted: Thu Nov 28, 2013 2:36 am     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Thu Nov 28, 2013 6:11 am     Reply with quote

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
aroonkriss



Joined: 03 Dec 2012
Posts: 19
Location: kerala

View user's profile Send private message

modbus tcp/ip implementation
PostPosted: Thu Nov 28, 2013 9:54 pm     Reply with quote

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
aroonkriss



Joined: 03 Dec 2012
Posts: 19
Location: kerala

View user's profile Send private message

modbus tcp/ip implementation
PostPosted: Sat Nov 30, 2013 12:13 am     Reply with quote

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
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Sat Nov 30, 2013 6:21 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group