• AVR Freaks

Helpful ReplyHot!PIC32MX : Modbus

Page: 12 > Showing page 1 of 2
Author
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
2017/05/03 10:10:39 (permalink)
0

PIC32MX : Modbus

Hi All,
 
I have worked on  1-1 UART Serial Communication with RS-232 and RS-485
where One is Master and other  is slave.
 
Now I have to work on One transmitter and 5 Receiver. My Data is very important so It should not be lost.
I have checked on Net and Forums .Modbus is best suitable for me for Proper Communication in Industrial Noisy Environment (Also Include 16-bit CRC).
At very basic, Some I got the knowledge from Link below:
 
http://www.simplymodbus.ca/faq.htm
 
I need to send 19200 Byte  in 10ms with 5 Meters and some doubts :
 
1)  From Where do I should start ?
2)  Should I use Modbus ASCII vs Modbus RTU . I need to Send on Hex data ?
3) Can Modbus be Implement on RS-485 or CAN or Both?
4)  How Modbus Related for TCP-IP ?
5)  Is other any link/book which helps me understand the concept for writing code?
6)  Any Link for Demo code PIC32MX795
7)  Does MHCP provide any library support for that ?
8)  How Can I use Hardware CRC for  CRC Calcution?
9) Can I use Harmony 2.xx ?
 
Any Other Suggestions......................
 
Thanks I advance
--
TS9
 
 
 Edit : I am using MAX487  for RS-485 and  MCP2561 For CAN Protocol as PHY Layer
 
post edited by TS9 - 2017/05/03 10:16:46
#1
bosco
Super Member
  • Total Posts : 2119
  • Reward points : 0
  • Joined: 2004/07/24 10:17:53
  • Location: Idaho
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 11:19:52 (permalink) ☄ Helpfulby TS9 2017/05/03 19:27:57
4.5 (2)
1 start here
http://www.modbus.org/tech.php
http://www.opensourcepic.com/modbus.php
 
2 I would use RTU for binary.
3 underlying transport is not that important, it just has to be asynchronous.
4 modbus-tcp transport is Ethernet.
5 mostly online
6 see second link above
7 probably not
8 yes, if you pick the right polynomial and starting value
9 would not touch it with a 10 foot pole.
#2
cgiordan
Super Member
  • Total Posts : 1364
  • Reward points : 0
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 11:33:19 (permalink)
3 (1)
bosco, like your #9 response Smile: Smile
#3
NKurzman
A Guy on the Net
  • Total Posts : 17817
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: PIC32MX : Modbus 2017/05/03 17:30:07 (permalink) ☄ Helpfulby TS9 2017/05/03 19:27:52
3 (1)
You can Use ModBus, But it in not required.  Your Data must fit its format.
Modbus does not add much for a single Master/Singe Slave System.

2)  Should I use Modbus ASCII vs Modbus RTU . I need to Send on Hex data ?
If you are sending binary data you can't use ASCII unless you convetr it to text
3) Can Modbus be Implement on RS-485 or CAN or Both?
Definite RS-485
CAN I do not think so.
4)  How Modbus Related for TCP-IP ?
You can Do Modbus over TCP/IP
5)  Is other any link/book which helps me understand the concept for writing code?
For ModBus or in General?
6)  Any Link for Demo code PIC32MX795
Look at the Microchip Appnotes
7)  Does MHCP provide any library support for that ?
For CAN(Yes)? Serial(Yes)? or Modbus(Not Sure)
8)  How Can I use Hardware CRC for  CRC Calcution?
AppNotes, Data Sheet, Data Sheet FRM Sections
9) Can I use Harmony 2.xx ?
Yes You Can, But It may not speed up the Project, and might slow it down.
I had an eleven foot pole, such is life.
 
#4
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 19:22:23 (permalink)
0
Hi
 
Thanks bosco , cgiodan , NKurzman ..Actually I have One Transmitter and 5 Recevier ?
 
1) Do I Perfer CAN or RS-485 ?
 @bosco
2)  I have recevied following error the link you have provided.
      Error demo.c:23:16: fatal error: mb.h: No such file or directory compilation terminated.
--
TS9
post edited by TS9 - 2017/05/03 19:27:36
#5
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 19:32:43 (permalink) ☄ Helpfulby TS9 2017/05/03 19:39:58
0
Must be some include path problem.
That file is in the archive, at:
\freemodbus-v1.4.0\demo\PIC32\modbus\include\mb.h
 
#6
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 19:39:11 (permalink)
3 (1)
@NKurzman
 
I found Modbus TCP for the Microchip TCP/IP Stack Application Note for  MHCP Website.
http://www.microchip.com/....aspx?appnote=en566544
 
But At Server Side Only.. Do you need to Configure  Server(s) at Transmitter and  Recevier(s)?
 
Thanks..
--
TS9
 
 
 
 
post edited by TS9 - 2017/05/03 19:44:53
#7
NKurzman
A Guy on the Net
  • Total Posts : 17817
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: PIC32MX : Modbus 2017/05/03 21:13:19 (permalink)
3 (1)
The server is what you connect to.
A client will connect to the server.
You can look at a Berkeley sockets client sample for details on how to connect to a server.
You plan to connect with all three methods?
#8
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 21:43:22 (permalink)
0
Hello 
 
I am attaching my Circuit.
Which I have to implement Modbus or CAN (By Changing CAN Physical IC)?
Please suggest which protocol will be best for commnucation in industrial Noisy Envirnoment 1 TX and 5 RX ?
 
--
TS9
#9
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/03 22:10:15 (permalink)
3 (1)
I am unable to attach Image
 
You don't have permission to access "http://www.microchip.com/forums/post.aspx?" on this server. Reference #18.16807c7c.1493874213.944d9a1
 
Concept it as below:
 
MCU_TXD   -----> OPTO-COUPLER   ------------> MAX487  ------------->  PHY WIRE
 
MCU_RXD  <----- OPTO-COUPLER   <------------ MAX487   <------------  PHY WIRE
 
MCU_DIR   -----> OPTO-COUPLER   ------------ >MAX487 ----------------  TXD OR RXD
 
GND                                                             GND_ISO
#10
NKurzman
A Guy on the Net
  • Total Posts : 17817
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: PIC32MX : Modbus 2017/05/03 23:30:15 (permalink)
4 (2)
It is RS485 it will work in a noisy area with many protocols.
19200byte in 10ms? That is over 15 million buad. That will be an issue. Worse with the opto isolator. You can buy transceivers with the isolator built in. Not that I am sure you need them.
You may want to start with the problem you are actually trying to solve.
#11
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 00:49:04 (permalink)
0
Hello Sir,
 
19200byte in 100ms . Should be fine ?
 
I  am using below Optocoupler.
High Speed Optocoupler, Single and Dual, 10 MBd.
https://www.vishay.com/docs/84732/6n137.pdf
 
Please suggest which protocol will be best for commnucation in industrial Noisy Envirnoment 1 TX and 5 RX ?
1) RS-485 (with CRC)
2) RS-485 Modbus
3) CAN Protocol
 
--
TS9
#12
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 02:03:14 (permalink)
4.67 (3)
TS9
19200byte in 100ms . Should be fine ?

That is still 1,536,000 baud. Do you understand the numbers you are throwing around?
 
 
#13
karan123
Super Member
  • Total Posts : 849
  • Reward points : 0
  • Joined: 2009/02/02 11:11:21
  • Location: 0
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 02:20:21 (permalink)
3 (1)
19200 x 8=153600?

Is it?
#14
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 02:24:11 (permalink)
4.5 (2)
My mistake, it's worse than that.
For asynch serial, every byte takes ten bits to send, as you must allow for the start bit and stop bit.
That means you need 19,200 * 10 * 10 bps to send all that data in 0.1s, so 1,920,000 baud.
 
#15
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 02:36:07 (permalink)
0
Hi,


Thanks for update me..

In Actually, I can increase Baudrate at Max
And decrease Data width.

But the issue the to chose right protocol and decrease Development time

I am at experiment stage so Mistake from my side only..


TS9
#16
bosco
Super Member
  • Total Posts : 2119
  • Reward points : 0
  • Joined: 2004/07/24 10:17:53
  • Location: Idaho
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 05:47:20 (permalink)
3 (1)
CAN is more complicated although it is relatively noise immune because it is a differential signal.
It requires external line drivers.
But there are as much as 40+ bits of overhead (more for extended frame format) for each 64 bits of payload.
it might be to much overhead for your speeds, but I have no data for max CAN payload bandwidth.  interesting question.
 
 
#17
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 05:58:18 (permalink)
3 (1)
bosco
CAN is more complicated although it is relatively noise immune because it is a differential signal.

So is RS485.
 

It requires external line drivers.

Ditto
 
 
#18
cgiordan
Super Member
  • Total Posts : 1364
  • Reward points : 0
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 06:46:42 (permalink)
4.5 (2)
CAN 2.0B can have up to 8 data bytes payload per frame.  Typical speeds in this range are (in automotive) 125k and mostly 500k (given US vehicles).  Some other OEM's like 250k...  Either way, CAN spec decides how much distance can be physically mapped between nodes - higher speed, less distance between nodes (inverse proportion I think, that's why I always go back to spec Smile: Smile).  Hence, getting 1Mbps to work should take this into account.  I don't think you can go to FD - MCHP currently doesn't have this IP in their devices as far as I know - at least not the PIC32's at this point.  This can get up to 64 data bytes and handle data portions of the frames on a baud rate switch to higher Mbit ranges (such 5Mbps for example), but the arbitration portion of the frame still is limited to the 2.0B speeds. 
 
The thing about CAN is you have to understand a lot of parts of this from the physical layer into the SW layers, or you will be plagued with error frames.  As well, you probably have to implement some sort of transport layer in SW if you plan on making messages that have content greater than max payload of a 2.0B frame (i.e. 8 bytes).  This adds to yet another layer of complexity...  Not trying to discourage, but I wouldn't start entertaining CAN unless you are experienced user given you are trying to reduce development time - not a good way to go IMHO. 
 
Overall, developing is difficult, and you have some decisions to make.  Both RS485 and CAN are good for noise immunity, but they will take time to master if you have limited information right now.  Anything worth doing takes effort.  Not to be cliche here, but it is true. 
#19
TS9
Super Member
  • Total Posts : 785
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: PIC32MX : Modbus 2017/05/04 10:23:44 (permalink)
0
Thanks, How and Where should I start?
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2019 APG vNext Commercial Version 4.5