PDA

View Full Version : HSEROUT/HSERIN with RS422/485 Driver



Andy Wood
- 22nd October 2013, 07:01
Hello,

I am trying to work out how to use HSEROUT/HSERIN on 16F88 combined with a 75176 diff. bus tcvr chip. I want to create bi-directional, half duplex communication over a single pair.

I am stuck on how to drive the 75176 RE/DE pins to enable transmit and receive. I can join the RE and DE pins together and then connect them to an available I/O pin. Sending this pin high will put the 75176 into TX and sending it low for RX. Is there a flag I can poll to set/clear this pin based on the status of HSEROUT (i.e. high only while it is actually transmitting data). I have tried setting the pin before the HSEROUT statement and clearing it after but this doesn't work. Obviously the hardware serial is doing it's thing in the background whilst the next commands are being processed.

At this point I have confused myself and need to ask for assistance!

Regards,

Andy

Darrel Taylor
- 22nd October 2013, 07:43
The TRMT bit (TXSTA.1) reads 0 (TSR full) while the USART is still shifting out data.
Wait for it to go to 1 (TSR empty) before switching back to receive mode.


TRMT VAR TXSTA.1

HIGH RE_DE
HSEROUT ["Hello World!"]
WHILE NOT TRMT : WEND
LOW RE_DE

Be sure to have "Fail-Safe" resistors that bias the network to "True Idle" levels.

Andy Wood
- 22nd October 2013, 07:59
Hi Darrel,

Yet again another simple solution to a problem I have spent way too long on......... Thank you.

I do have the bias resistors on the bus. I read one of your previous posts containing a link to a (Maxim?) datasheet, showing how schottky diodes can be used - very interesting. Now that I have a solution to my initial problem I will work on reducing the current consumption to an acceptable level.

Regards,

Andy

Darrel Taylor
- 22nd October 2013, 17:27
Right, I love that diode arrangement.

It reduces the current dramatically since you don't need that 100Ω resistor.
The "Fail-Safe resistors can be much higher values too, I used 2K on mine.

And it allows a "Star" network where you can connect devices anywhere on the buss, instead of a long multi-drop network with a terminating resistor at the end.
And the more devices you connect, the better the signal gets.

Can't imagine why anyone would terminate RS485 any other way.

Andy Wood
- 23rd October 2013, 00:21
Hi Darrel,

I must admit I have only quickly glanced over the article. One thing that puzzles me a bit is how the diode arrangement actually works to dampen the reflections on the buss.

I have a bit of a background in RF and I always assumed the terminating resistor was selected to be approx the same impedance as the line. This is transmission line theory and, in this instance, the termination resistance equals the characteristic impedance of the transmission line, and therefore the line operates with low reflections or SWR (Standing Wave Ratio). I would like to understand more on how the diodes produce the same effect without the terminating resistor. However it works it sure seems to be better arrangement.

Andy

Darrel Taylor
- 23rd October 2013, 03:34
Well, here's a quote from the previously mentioned appnote... http://www.maxim-ic.com/appnotes.cfm/an_pk/1090


Schottky-Diode Termination
Schottky diodes offer an alternative termination when power dissipation is a concern. Unlike other
termination types, Schottky diodes do not attempt to match the line impedance. Instead, they simply
clamp the over- and undershoots caused by reflections.

This image is an example of unclamped overshoots ...
Ignore the yellow line.
http://support.melabs.com/DT/OverShoot.png

Andy Wood
- 23rd October 2013, 06:03
Ok - got it now. Just a different method of achieving a similar result.

One has to wonder then why the terminating resistor is by far more popular? The diode arrangement seems more versatile and consumes less current......

Andy