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 CCS Technical Support

A basic question regarding RS 485 collisions

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



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

A basic question regarding RS 485 collisions
PostPosted: Sun Mar 04, 2007 12:04 pm     Reply with quote

Hi,

How can I detect collisions on a RS 485 bus. I am unable to follow the logic used in the RS485.c example in the PICC folder.

thanks
arunb
Sherpa Doug
Guest







PostPosted: Sun Mar 04, 2007 12:37 pm     Reply with quote

There is no inherent collision detection in RS485. Therefore you either

1) Use a strict Master-Slave protocol where a slave never speaks unless spoken to, to prevent collisions.
2) Use a Token Ring system to prevent collisions
3) Use packet checksums to detect collisions.
or
4) Tollerate some collisions and data loss.

SherpaDoug
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sun Mar 04, 2007 8:47 pm     Reply with quote

Hi,

I have implemented some of the points you have mentioned

Kindly explain why the RS485.c checks the state of the RS pin before sending data ??

thanks
arunb
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Mar 04, 2007 9:24 pm     Reply with quote

The routine Wait for Bus comment says:
"Wait for wait time for the RS485 bus to become idle"
(it is intended to mean "wait for RS485 bus to become idle")

This is collision avoidance, not collision detection, since the transmission has not started.

If you examine the code it says multi-master, meaning more than one node can control the bus, so the driver checks to see if another master has the bus before starting transmisson.

However, as was stated earlier, it will not detect a collision that occurs during a transmission.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sun Mar 04, 2007 11:48 pm     Reply with quote

Hi,

Thank you for the reply.

Please advise if there is any problem in this setup...I have develped a RS485 state machine for this purpose, the system works Ok, but I need to know if there are any potential bugs in the system concept..

My system consists of 5 nodes, The system has two masters, all the nodes have unique addresses (16 Bit long)

One of the masters is the PC (with a serial to RS 485 converter), the PC is used whenver the nodes have to be configured, this is done by sending the node address (destination) and then node address of the source in this case the PC. The data is sent in another 12 bytes, the entire frame is 16 bytes long.

The other master is the controller device, the controller device becomes the master when the PC is disconnected from the network (more specifically when the power to the converter is removed).

The slaves do not initiate communication, they only respond to packets from the master(s).

thanks
arunb
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Mon Mar 05, 2007 2:50 pm     Reply with quote

In theory it should work. Essentially the content of the packets can be
any format (protocol) that fits your needs. I have a custom single master
RS485 network in my house with 37 nodes. In my case I "invented" a
protocol that contained fields for all the data I needed for every node so
they could take what they needed and ignore the rest. I round-robin
poll my nodes on a 1.5 second interval.

What is your plan to handle two masters on the network?
The main problem I see is whether the PC has collision avoidance
(multi-master mode).... Are you somehow going to tell the PIC master
node when he is the master via some type of command? The best thing to
do might be to simply take the PIC master offline when the PC is online.
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Tue Mar 06, 2007 8:45 pm     Reply with quote

Hi,

In the multi-master mode, the PC will disable the second master by a command. After the PC has finished accessing the system, the second master will have to be restarted and the PC disabled.

thanks
arunb
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Mar 07, 2007 5:13 am     Reply with quote

Quote:

In the multi-master mode, the PC will disable the second master by a command.

This assumption is true until they collide while the PC take control of the bus trying
to send the disable command to the second Master while it is transmitting.
What about if the PIC Master send an enquire to the PC in an regular interval
asking if it want to access the bus.
If the PC needs to access the bus, the enquire is granted and the PIC Master keep
listening for a command comming from the PC (who already is in charge of the bus)
telling that the transaction is over, wich means that the bus was released again but
now by the PC.
After this, the PIC Master will have full control of the bus without any risk of collitions.
I don�t know the data priority schemes of your architecture, you know that this
procedure is highly dependable of how fast the data need to be refreshed in each
node or in the PC side, you should decide who ask to who.
I have several RS485 architectures working in this fashion since many years (24H x 365)
using my own Master-Slave protocol, with CRC16 data integrity control and never
got collitions nor other types of communications errors (at least, never detected).


Humberto
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