luca_l
Guest
|
|
« on: December 13, 2007, 08:51:28 20:51 » |
|
I’m looking for a communication protocol between 2 or more pic, expect can bus, What protocol do you use? And why?
|
|
|
Logged
|
|
|
|
|
LuoPan19770708
Junior Member
Offline
Posts: 82
Thank You
-Given: 20
-Receive: 11
|
|
« Reply #2 on: December 15, 2007, 12:15:16 00:15 » |
|
Mr. Trump, Can you upload some examples?
|
|
|
Logged
|
|
|
|
Trump
Guest
|
|
« Reply #3 on: December 17, 2007, 10:41:10 22:41 » |
|
Mr. Trump, Can you upload some examples?
Hm... The link above have all the info... The data frames are very simple and the CRC is in the end of the paper, in C... With the CCS driver (use the project Wizard) the work is only asign the variables and pins for the Input Registers, coils, Holding Registers and Input status... I have the master anda the slave software for protocol tests and Monday I upload both... Posted on: December 15, 2007, 08:39:33 20:39 - Automerged
Hm... Here is the link: http://rapidshare.com/files/77291978/Modbus.rar.htmlThe Modscan and Modsim software (master and slave). with the paper and this 2 softwares you have all the tools for start the work... Run the softwares in a PC with 2 serial ports, plug a serial cable and see all the packages in the Modscan...
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #4 on: December 19, 2007, 02:02:32 14:02 » |
|
many thanks for the link, I have done the question but I'm not able to see answer because in place of the suggestion; as Inactive I read: 'You are not allowed to view links' can you help me? regards luca_l
|
|
« Last Edit: December 23, 2007, 02:03:09 14:03 by luca_l »
|
Logged
|
|
|
|
phu_thanh
Guest
|
|
« Reply #5 on: December 20, 2007, 12:37:41 12:37 » |
|
If you want to communicate among Pic or other microcontroller. Then I should suggest you to use CAN bus protocols. which is multi-nodes commucation and require only 3 wires (Line+,Line- and Common). This protocol is very flexible in which it can transfer data at a very fast rate and immune to noisy environment. The errors checking is done in the hardware itself so there is not need to write codes for it.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #6 on: December 20, 2007, 03:37:40 15:37 » |
|
about CAN bus protocols is interesting, I am studying it, but reading on: http://en.wikipedia.org/wiki/Controller_Area_Network 'Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g. 125 kbit/s at 500 m).' it would serve me an easy protocol that transmits on greater lengthes. thanks Luca
|
|
|
Logged
|
|
|
|
kcid
Guest
|
|
« Reply #7 on: December 20, 2007, 09:42:57 21:42 » |
|
I recommend you use Can with CCS compiler its very easy to work in any project.
|
|
|
Logged
|
|
|
|
vmax
Newbie
Offline
Posts: 11
Thank You
-Given: 7
-Receive: 0
|
|
« Reply #8 on: December 21, 2007, 01:29:14 01:29 » |
|
Luca_l
The first thing that you need to have in mind, before you choose the communication protocol that you will use is define what are you intending to do.
Sometimes, the USART fits all your needs
Keep in mind that CAN, as well as LIN, were developed to automotive use, in a poluted (in terms of noise) environment.
Anyway, you have 1-wire protocol, I2C, USART, SPI, PSP among others.
Again, the better wolution will depend on what are your needs.
Success!
|
|
|
Logged
|
|
|
|
Trump
Guest
|
|
« Reply #9 on: December 21, 2007, 02:40:27 02:40 » |
|
about CAN bus protocols is interesting, I am studying it, but reading on: it would serve me an easy protocol that transmits on greater lengthes. thanks Luca For greater lenghts use the RS485 (1.5 Km on twisted pair 120 Ohm balanced). I use RS485 with up to 30 Freescale microcontollers (9S12) whith high noise environment at 57.6K with Modbus protocol. For the RS485 I use the MAX3483 (250Kbps max.), but in the MAX3486 the baud rate is 2.5Mbps.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #10 on: December 21, 2007, 07:52:14 19:52 » |
|
First of all many Thanks to all, for the answers! Anyway, you have 1-wire protocol, I2C, USART, SPI, PSP among others. I will go to read the documentation with ccs for these protocols. But currently the more interesting thing is: Modbus protocolmanaging 255 devices it is enough for me The hardware using the MAX3486 is easy, but understanding some example code on ccsinfo.com is different matter. thanks sincerely
|
|
|
Logged
|
|
|
|
Connection
Guest
|
|
« Reply #11 on: December 22, 2007, 05:33:13 05:33 » |
|
I am using SPI and I2C protocol.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #12 on: December 22, 2007, 12:21:59 12:21 » |
|
I recommend you use Can with CCS compiler its very easy to work in any project.
Which PIC do you Use? 18F458 or the better 18F4580, or what do you suggest?
|
|
|
Logged
|
|
|
|
ucanturk
Newbie
Offline
Posts: 15
Thank You
-Given: 17
-Receive: 6
|
|
« Reply #13 on: December 22, 2007, 01:24:38 13:24 » |
|
I suggest Modbus protocol because this is an open source protocol, for more information about protocol details please visit www.modicon.com/techpubs/toc7.html
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #14 on: December 22, 2007, 05:47:15 17:47 » |
|
if I understood I can use the MODBUS driver on USART of my Pic but there is a specific library in css for that?
|
|
« Last Edit: December 23, 2007, 02:06:44 14:06 by luca_l »
|
Logged
|
|
|
|
Trump
Guest
|
|
« Reply #15 on: December 22, 2007, 10:35:26 22:35 » |
|
if I have understanded correct I can use the MODBUS driver on USART of my Pic but there is a specific library in css for that? Yes... The CCS Compiler have a full driver for ModBus. You have only to use the Project Wizard in CCS. Select "Use Modbus Protocol" and define the pins of the serial, Buffer size, Master or slave, Address, etc... And CCS build all the code.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #16 on: December 23, 2007, 02:33:06 14:33 » |
|
Perhaps ... close to 2008 is the time to change my actual ccs version ( 3.2) thanks and MERRY CHRISTMAS
|
|
|
Logged
|
|
|
|
siwat2
Guest
|
|
« Reply #17 on: December 25, 2007, 03:10:34 15:10 » |
|
I used SPI to communication with 8 dsPIC30f2010. It's work great(If u don't set baud rate too much).
|
|
|
Logged
|
|
|
|
micropar
Active Member
Offline
Posts: 173
Thank You
-Given: 44
-Receive: 13
|
|
« Reply #18 on: December 27, 2007, 07:12:26 19:12 » |
|
Hi all,
If you want to use CAN bus, I suppose it would be better if you use CANopen library of higher application layer than lower CAN plain messages type.
Does any one know good library routines of CANopen on PICmicro? or CANopen development on PC side which we can latter on port it to PIC?
If not, where can we get good CANopen documents so that we may develop it ourselves?
Thanks in advance,
Regards, --micropar--
|
|
|
Logged
|
|
|
|
narc60
Newbie
Offline
Posts: 17
Thank You
-Given: 12
-Receive: 1
|
|
« Reply #19 on: December 28, 2007, 06:50:30 06:50 » |
|
luca_l,
Any luck on the Modbus protocol using CCS? I was reading something in the CCS forum and I think it requires a Modbus.c file that can only be downloaded by sending a formal request to CCS.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #20 on: December 28, 2007, 03:26:08 15:26 » |
|
Any luck on the Modbus protocol using CCS but Modbus.c is not integrated with a CCS recent version ? I am only at the beginning with ccs but if you use the Project Wizard it writes: #define MODBUS_BUS SERIAL #define MODBUS_TYPE MASTER #include "modbus.c" in the circumstances I hope my ccs compile correctly!! regards Luca P.S. if you like, I send you the modbus.c code from my CCS version.
|
|
« Last Edit: December 28, 2007, 03:49:37 15:49 by luca_l »
|
Logged
|
|
|
|
graywolf
Newbie
Offline
Posts: 13
Thank You
-Given: 0
-Receive: 19
|
|
« Reply #21 on: December 29, 2007, 03:15:52 03:15 » |
|
I prefer rs485, you can create your own packet protocal but you can use twiested wire nad go very far distance and it is very cheap. We used it on 100 pics at once. It all depends on your header to access 255 or 64K pics and useht first 2 as address.
|
|
|
Logged
|
|
|
|
luca_l
Guest
|
|
« Reply #22 on: December 29, 2007, 03:58:35 15:58 » |
|
dear Graywolf creating a personal protocol is one of the first things comes in my mind! the doubt is correct to invent the wheel again? for this reason I began this Topic...can you explain the reason of your choice?cheers Luca
|
|
« Last Edit: December 30, 2007, 07:58:57 19:58 by luca_l »
|
Logged
|
|
|
|
arvind
Guest
|
|
« Reply #23 on: December 30, 2007, 04:02:15 16:02 » |
|
CAN bus is wat we found to be easy...particularly because of very good documentation...
|
|
|
Logged
|
|
|
|
graywolf
Newbie
Offline
Posts: 13
Thank You
-Given: 0
-Receive: 19
|
|
« Reply #24 on: December 30, 2007, 08:02:53 20:02 » |
|
Hi luca_l
When you are looking at cost factor, pics have onboard uarts so you dont need a can controller, all you need is the rs485 voltage converter. Then you datapacket is what you design and keep it simple. As you know with rs485 you have 9 bits of data and not 8 with uart. So I designed my packet header very simple. I am using less than 255 devices so the first byte is the chip id. Here is my packet design
1. address 3. command 4. flags 5+6. data size 7. header crc 8..... data to follow ?..... data crc
So the first byte is address to talk to the device, then the next byte is the command for exmaple read AD etc.. The 3rd byte is any flags you want to send to the device. The next 3 bytes holds the size of data to receive or send. Then have a crc for the header only. The data bytes are sent and a crc for the data.
Graywolf/
|
|
|
Logged
|
|
|
|
|