Sonsivri

Electronics => Hardware and Tools => Topic started by: Help on November 04, 2007, 11:12:49 11:12



Title: RS485 Interface
Post by: Help on November 04, 2007, 11:12:49 11:12
Hi,

I would to use RS485 for my interfacing between PC and few other serial module.

What's the step should i start on the Hardware and Firmware(Protocol) side?
Example I had 3 node (node1=PC, node2=MCU1, node3=MCU2).
My PC only had one serial RS232 port, and the MCU also only had one serial. If i would like to use standard RS232 for all the node in interface, so i just have to put a RS485-RS232 convertor? If yes, how the node recognize the protocol?

Did anyone have a simple sample code for RS485? I just want to get some idea. I had no problem with using RS232.

Thank You.


Title: Re: RS485 Interface
Post by: Dembo on November 04, 2007, 11:53:30 11:53
Hi
If You move from poimt-to point (RS232) to network like RS485, You shouldd think about a lot of issues:
1. Who will be a master? how many masters allowed?
2. How to prevent simultaneous transmit? (collisions)
3. How You handle errors?

this is only a small part of problems in networking, even when only 3 nodes in it...

So dont try to create your own protocol, start from something ready, I recommend You ASCII mode MODBUS protocol, it's very simple and reliable. It divides the protocol to transport and application layers good enough, and there are a lot of samples about it implementation.

http://www.modbus.org/

http://en.wikipedia.org/wiki/Modbus



Title: Re: RS485 Interface
Post by: Help on November 09, 2007, 07:02:07 07:02
Hi fren,

Can you guide me how to use the rs485 modbus? Where can i get the sample code for modbus?

I did find some source in net. But very few sample code is provided.

http://www.protocessor.com/techsupport/signup.asp
I try download the Free Modbus Source Code from this link but they not send the password to my email. Do you have the passward, please can you share with me?

The attach file is the modbus sample code also. After i look through the code, the sample is for TCP. and some of the function is missing.
libmodbus-1.2.1.tar

Please help me. 

Thank You.


Title: Re: RS485 Interface
Post by: bogdantk on November 09, 2007, 07:26:48 07:26
Hello
Password (case sensitive): ProtoCessor.com
All the best
Bogdan


Title: Re: RS485 Interface
Post by: lillbear on November 09, 2007, 08:25:35 08:25
Well have looked at S.N.A.P Protocol its quite easy to implement also and there is examples for PIC, AVR and Parallax BasicStamps  :D


Title: Re: RS485 Interface
Post by: Xwing on November 09, 2007, 01:12:24 13:12
Quote
so i just have to put a RS485-RS232 convertor? If yes, how the node recognize the protocol?

For transceiver use MAX485, for software protocol modbus or snap.


Title: Re: RS485 Interface
Post by: Help on November 09, 2007, 02:19:01 14:19
Hi,

Thank you everyone. :)

I'm using at89c52 microcontroller. Do you all use "modbuspw" ( http://www.protocessor.com/techsupport/signup.asp ) for this type of controller? This modbus is for PIC application. Please anyone can guide me how to apply "modbuspw" code for my microcontroller?

This "modbuspw" code got abit difficulty for me. Hope can get help from you all..

Thank You.


Title: Re: RS485 Interface
Post by: Silent_Thunder on November 10, 2007, 09:42:03 09:42
Hi;
RS485 is not a comunication protocol, it is a network based on the 485 chips, the protocol you build yourself.
Regarding the MODbus, it is an industrial standard comunication protocol, quite good for building rubost network, but hard to impliment in small systems, and whatever you use it or make your own there is no different as long as you take care of the major point that Dembo mentioned earlier,
1- Which devices will be masters ?. and if you gonna build your protocol, it is better to make only one master and all the others will be slaves, in this case you could eleminate data collisions.
2- You sould map your network and assign an address for each device.
3- Your program should handle errors and deal with them, for example by getting confirmation from the slave you address and if you got no answer resend.
4- Determine the length of you data and minimize it as you can if you gonna use slow baud rates, and better to tell the slave how many data bytes it gonna recive and more better to send a check sum for the data sent, so the slave can confirm a succesful recive.
I think this is the major points you have to consider when building a network


Regards
 


Title: Re: RS485 Interface
Post by: microled on November 20, 2007, 09:47:39 21:47
you can also use 485 for its added distance, ie point to point just like 232 or use master/slave with polling


Title: Re: RS485 Interface
Post by: spl on January 09, 2008, 05:56:33 05:56
Try to See www.rs485.com 
 They have circuit diagram for RS485  , Repeater ,HUB
 It work! ;D


Title: Re: RS485 Interface
Post by: waicon on August 30, 2009, 04:21:37 16:21
Hi;
RS485 is not a comunication protocol, it is a network based on the 485 chips, the protocol you build yourself...

i'm a beginner on RS485, did some PC to MCU projects using RS485; have some own learning protocol to share, its only transfer 3 bytes only:-
http://rapidshare.com/files/273454707/RS485_communication_protocol.rar

i having some interferance on signal line in my project, maybe its near to 32 notes where RS485 max. points, and A-B' voltage range measure which less 200mV( max. load effact) , i think should need a RS485 repeater, 1 repeater for 20 notes. any one kindly show me the link to buy or to make DIY ? 



   


Title: Re: RS485 Interface
Post by: spacetime on September 30, 2009, 07:48:51 19:48
In general, there is no difference between RS232 and RS485 from the protocol point of view except that RS485 is not duplex and you need to switch between RX and TX mode.
You can have a multi/master configuration with some suitable algorithm.
If you know how to communicate with RS232 then you know also RS485.Just switch to TX before you start sending and back to RX when the packet is sent.