RS-485 Communication & Pic16F628

Started by Roger_4U March 14, 2007
Hi All:

I have a Pic16F628 chip which I want to be able to communicate with my
PC via a RS-485 line. I want to use the USART on the chip and a
DS75176 Transceiver in a Half Duplex setup, but my problem is with
what to control the Read Enable or Transmit Enable pin on the DS75176?
If anyone also has a simple schematic and code that they don't mind
sharing I would be grateful.

Regards
Roger
--- In p..., "Roger_4U" wrote:
>
> Hi All:
>
> I have a Pic16F628 chip which I want to be able to communicate with my
> PC via a RS-485 line. I want to use the USART on the chip and a
> DS75176 Transceiver in a Half Duplex setup, but my problem is with
> what to control the Read Enable or Transmit Enable pin on the DS75176?
> If anyone also has a simple schematic and code that they don't mind
> sharing I would be grateful.
>
> Regards
> Roger
>

RS485 usually implies some kind of network with more than just two
devices. As a result, line turn-around is an issue as is the delay
required to allow the last char to shift out of the UART (don't forget
that or you will drop the last char).

Is the protocol already established or is this a new project?

A slave device should listen all the time except when it is time to
talk. A master device is probably talking all the time except when it
is time to listen. So, how long should the master wait for a reply
before giving up?

What about peer-to-peer networking? Who owns the bus? How does a
device seize the bus? This is the kind of thing that has been decided
in the case of ethernet. Collision detection and retransmission, etc.
Token ring is another solution.

There are thousands of articles on Google including
http://www.bb-elec.com/tech_articles/rs485_basics.asp Try searching
for 'rs485 line turn-around'.

There is a very simple case where RS485 is used exactly like RS232 -
point to point - where RS485 is just being used for the distance. In
this case, a 4 wire, full duplex system works just like RS232. No
particular protocols, just send and receive.

You might also follow the links from
http://www.piclist.com/techref/microchip/rs485.htm There is some
sample code for a home automation type of project.

Richard
--- In p..., "rtstofer" wrote:
>
> --- In p..., "Roger_4U" wrote:
> >
> > Hi All:
> >
> > I have a Pic16F628 chip which I want to be able to communicate with my
> > PC via a RS-485 line. I want to use the USART on the chip and a
> > DS75176 Transceiver in a Half Duplex setup, but my problem is with
> > what to control the Read Enable or Transmit Enable pin on the DS75176?
> > If anyone also has a simple schematic and code that they don't mind
> > sharing I would be grateful.
> >
> > Regards
> > Roger
> > RS485 usually implies some kind of network with more than just two
> devices. As a result, line turn-around is an issue as is the delay
> required to allow the last char to shift out of the UART (don't forget
> that or you will drop the last char).
>
> Is the protocol already established or is this a new project?
>
> A slave device should listen all the time except when it is time to
> talk. A master device is probably talking all the time except when it
> is time to listen. So, how long should the master wait for a reply
> before giving up?
>
> What about peer-to-peer networking? Who owns the bus? How does a
> device seize the bus? This is the kind of thing that has been decided
> in the case of ethernet. Collision detection and retransmission, etc.
> Token ring is another solution.
>
> There are thousands of articles on Google including
> http://www.bb-elec.com/tech_articles/rs485_basics.asp Try searching
> for 'rs485 line turn-around'.
>
> There is a very simple case where RS485 is used exactly like RS232 -
> point to point - where RS485 is just being used for the distance. In
> this case, a 4 wire, full duplex system works just like RS232. No
> particular protocols, just send and receive.
>
> You might also follow the links from
> http://www.piclist.com/techref/microchip/rs485.htm There is some
> sample code for a home automation type of project.
>
> Richard
>

Hi Richard:

Thanks for your response. The answers to your question is: Yes it a
new project, so I may have to develop my own protocol. By the way, do
you have any experience with using the MODBUS protocol
(http://www.lammertbies.nl/comm/info/modbus.html OR www.modbus.org),
and should I explore this possibility because of the potential of
demand for my product?

Thanks
Roger
>
> Thanks for your response. The answers to your question is: Yes it a
> new project, so I may have to develop my own protocol.

i2c or some other simple standard?
> Hi Richard:
>
> Thanks for your response. The answers to your question is: Yes it a
> new project, so I may have to develop my own protocol. By the way, do
> you have any experience with using the MODBUS protocol
> (http://www.lammertbies.nl/comm/info/modbus.html OR www.modbus.org),
> and should I explore this possibility because of the potential of
> demand for my product?
>
> Thanks
> Roger
>

I haven't used MODBUS for any of my industrial projects but I am well
aware of its' existence. For obvious reasons (working at GE), I used
the GEnius Bus which is completely different.

If you plan to work in the industrial marketplace, I would highly
recommend using MODBUS for inter-operability. This assumes your uC has
enough horsepower to keep up with the bus.

Another approach is ROBIN http://www.bdmicro.com/code/robin/ This is a
multi-master RS485 bus protocol and it is very well thought out. I had
forgotten about this until a few seconds ago. I played with it a year
or so back and it worked very well. It handles line turn-around and
collision detection. Where inter-operability is not an issue, I would
look at ROBIN.

Richard