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

what is rs-485

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



Joined: 28 Jun 2008
Posts: 24

View user's profile Send private message

what is rs-485
PostPosted: Fri Sep 12, 2008 1:08 am     Reply with quote

Hello every one
What is RS-485 ? , how their different from RS-232
Do you have an example code for me ?

ex. PIC1 Control led1 interfaced with PIC2 to on/off it or
PIC1 Control led1 interfaced with PIC3 to on/off it

i would like to use RS-485 interface by PIC


PIC1----->PIC2
PIC1----->PIC3

PIC1 is master , otherwise is slave

thank you
Ttelmah
Guest







PostPosted: Fri Sep 12, 2008 2:50 am     Reply with quote

RS232, and RS485, are _signalling_ standards. They actually describe the voltages used across the wire connections, to send a '1', or a '0'.
RS485, differs from RS232, is using a pair of wires, and differential signalling, making it much more immune to induced noise on the lines, despite using a lower signalling voltage than RS232. The drivers can also handle significantly greater bus capacitance, giving much longer signalling distances.

The PIC itself, does not actually generate 'RS232'. It generates TTL logic asynchronous serial. This can be connected to another device using RS232 signalling (by adding a MAX232 or similar), or by using RS485 (by adding something like a MAX485). There is no difference at all in terms of the PIC code!. You can send and receive using '485', in exactly the same way as you do with '232'.

However 485, has an 'extra' ability. 232, only supports a single 'point to point' connection. One device talking directly to another. 485, allows multiple devices to be listening at once on one connection. You can then add an extra 'layer' to the protocol you send over the connection, by allowing multiple devices to sit and listen on these wires, and have a 'master' device, which switches to transmit mode, and sends a packet with a target address, and have the slave devices recognise their own address and decode the data. You can also go a stage further, and allow multiple devices to switch to becoming 'masters' at different times. The protocol here, has nothing to do with RS485 as such. So (for example), you have standards like 'profibus', and 'modbus', which can use RS485 signalling for their connections. Implementing such a protocol, becomes a major programming exercise...

Included with the compiler, is a simple example protocol (ex_rs485.c, and ex_rs232_485.c), allowing normal serial data to be 'packeted', and sent across an RS485 bus, to a specific target ID. Also implementations of a simple modbus slave, and master, using RS485 signalling.

Best Wishes
atomy_kwang



Joined: 28 Jun 2008
Posts: 24

View user's profile Send private message

atomy_kwang
PostPosted: Fri Sep 12, 2008 3:06 am     Reply with quote

Do you have an example circuit about RS 485 with pic and
code for control it

thank you
Ttelmah
Guest







PostPosted: Fri Sep 12, 2008 4:03 am     Reply with quote

Circuit wise, you would just connect each PIC's TXD line to the 485 transceiver's 'DI' pin, the PIC's RXD line to the transceiver's 'RO' pin. Connect the DE, and /RE pins together, and connect these to a single output pin on the PIC. Then connect the 'A' pins on each 485 transceiver _linearly_ to those on the other chips. Use twisted pair cabling between the chips. So the bus runs chip-chip-chip. Then at each end of the pair of wires, have a 120R resistor between the 'A', and the 'B' lines, and a 1200R resistor, from the 'A' line to 5v, and another from the 'B' line to 0v. This gives the bus nominally 100R 'termination' (prevents ringing or the lines), and provides a small 'bias', so that an idle bus returns an idle level to the PIC.
The #use RS232 lines in the code, will need to have 'ENABLE=xxx' added, where 'xxx' is the pin connected to the direction control pins on the MAX485.
Then code is going to depend on what _you_ want to do. The examples show an approach with proper device addressing, or (for instance), since you only show a 'one way connection, you could simply have the master send lines of data, with just a single leading digit, to select which device should accept it.

Best Wishes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

Re: atomy_kwang
PostPosted: Fri Sep 12, 2008 7:19 am     Reply with quote

atomy_kwang wrote:
Do you have an example circuit about RS 485 with pic and
code for control it

thank you


For a good description of the hardware look at the MAX485 family datasheet http://datasheets.maxim-ic.com/en/ds/MAX1487-MAX491.pdf especially figure #21.
_________________
The search for better is endless. Instead simply find very good and get the job done.
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Fri Sep 12, 2008 8:13 am     Reply with quote

Here is a link to some information that might be useful.
http://bb-elec.com/technical_library.asp
I don't work for B&B but I have used their products and application notes.
_________________
David
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

PostPosted: Mon Sep 15, 2008 10:08 am     Reply with quote

for some ideas, see
http://www.ccsinfo.com/forum/viewtopic.php?t=25980

and refer specifically to the PDF file i linked to near the bottom of the first page...
http://losdos.dyndns.org:8080/public/pic-uC/cbus-protocol-spec-draft-rev1.pdf

jds-pic
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