Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Communication between microcontrollers using Rs485

Status
Not open for further replies.

Debasis Swain

Member level 2
Joined
Feb 2, 2013
Messages
52
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Activity points
1,606
I need help to creat a code(.asm) for communication between multiple microcontrollers using RS485.So,pls help me with some sampule code (Using At89s51/52)
 
Last edited:

misnomerfrenzy

Junior Member level 1
Joined
May 15, 2012
Messages
15
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,417
It is nothing different from UART code.

Just implement the UART code and switch the direction control pin of the RS485 driver IC, through a I/O pin of MCU.
This will switch the MCU in master or slave mode accordingly
 

Debasis Swain

Member level 2
Joined
Feb 2, 2013
Messages
52
Helped
10
Reputation
20
Reaction score
10
Trophy points
1,288
Activity points
1,606
can it possible a MCU using as both master or slave at a time
 

debabrta kar

Member level 5
Joined
May 20, 2013
Messages
86
Helped
7
Reputation
16
Reaction score
5
Trophy points
1,288
Location
india
Activity points
1,858
i also have the same question how to select which 1 is master and which 1 is salve
 

micro-hopless

Member level 1
Joined
Sep 12, 2007
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,551
Only 1 master per RS485 bus, hardwired and impossible to change after network setup.

Multi master RS485 are theoretically possible, but very hard to implement and is much cheaper to go for another multi master bus.

Basically RS485 works like this:
- master addresses a slave;
- slave responds;
- master addresses another slave;
...

You need to implement addressing in your protocol.


PS: this sounds like a homework, especially because you need 8051 assembly code
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,156
Helped
14,391
Reputation
29,044
Reaction score
13,143
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,305
Only 1 master per RS485 bus, hardwired and impossible to change after network setup.
In a RS485 bus, definition of master/slave role is a pure software matter.


Multi master RS485 are theoretically possible, but very hard to implement and is much cheaper to go for another multi master bus.
Not only theoretically possible but widely used in industrial communication. RS485 is only the physical layer (OSI layer 1) and not fixing master/slave role. In a multi-master RS485 bus, there must be a layer 2 protocol that dynamically assigns the master role to different nodes. PROFIBUS is e.g. using a token passing scheme to assure that only one master is trying to control the bus at a time.
 

embpic

Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Activity points
5,213
RS485 is half duplex so u can send data or recive data at a time.
and both can be posible by increase wire counts.
 

micro-hopless

Member level 1
Joined
Sep 12, 2007
Messages
41
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
1,551
RS485 is half duplex so u can send data or recive data at a time.
and both can be posible by increase wire counts.

Multi wire RS485 is not RS485 !

Is RS422 !

- - - Updated - - -

PROFIBUS is e.g. using a token passing scheme to assure that only one master is trying to control the bus at a time.

Can we have an implementation ?

I have tried to do that but it is way cheaper to go to another bus.
 

ftsolutions

Full Member level 5
Joined
Nov 19, 2009
Messages
242
Helped
71
Reputation
142
Reaction score
68
Trophy points
1,308
Location
United States
Activity points
3,709
Multi wire RS485 is not RS485 !

Is RS422 !

- - - Updated - - -



Can we have an implementation ?

I have tried to do that but it is way cheaper to go to another bus.


BOTH RS422 AND RS485 can be either 2-wire (half duplex) of 4-wire (full duplex) configured. The differences are in the characteristic impedances of the devices, termination, and node topologies defined (RS422 = 1 Master, multiple (10) slaves; RS485 = 32 unit loads, can be mixture of Masters (drivers) and slaves (receivers). Many RS485 transceiver components will work fine on RS422 systems by design, but not all RS422 components will work on RS485 systems because of the impedance/unit load issue, and differences in sensitivity.

Profibus is a standard which you will need to join an organization to have it certified that it is compliant, if you wish to advertise and connect to other Profibus devices. however, you can implement your own simple networking scheme which is very similar.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top