LIN and RS232

I have an embedded target I am trying to program (MC9S08DZ60 microcontroller) that has the SCI pins connected to a TJA1020T LIN transceiver with single-wire output.

My question is, can I connect this single-wire LIN directly to a pin (or pins) of the RS232 port on the back of an old DOS PC, and if so, how? Can anyone provide link(s) to FAQs or tutorials to help me get started?

Or, are the electrical characteristics different and I need some sort of hardware adapter between the LIN wire and the RS232 pin (pins)?

I am somewhat familiar with RS232, having written a few comm programs in C and assembly on a DOS machine years ago.

Thanks.

Reply to
Jones
Loading thread data ...

LIN: single wire, bidirectional --> half-duplex

RS232: two wires, one per direction --> double simplex, effectively equivalent to full duplex

Looks like a pretty solid "no" being the answer to that question to me. You'll need a LIN transceiver between the bus and the PC for pretty much the same reasons that led you to put that TJA1020 between the bus and your embedded controller.

Reply to
Hans-Bernhard Bröker

Thanks Hans. I did a little more digging into it and I think the answer is indeed "No", but it has more to do with electrical characteristics than half/full duplex. LIN signal levels are +12V and ground. RS232 are +5V and -5V wrt ground. That's why you can't just wire the LIN and the RS232 to each other.

If the RS232 signal voltages were the same as LIN, I could just tie the RS232 TX and RX together and tie that to the LIN bus, and connect the grounds. Then write half-duplex software for both sides. After all, that's what a LIN transceiver is essentially; a receiver and a transmitter sitting on the same wire (I think?).

I don't necessarily need the two devices to speak to each other in LIN-ese. I just need to be able to electrically connect them so I can write very simple software for both sides to get a little dialog going.

I'm assuming if I look around enough I'll find a fairly inexpensive LIN-to-RS232 in-line converter for not much money. If anybody has any experience with this and could provide a link to a product they have used successfully, it would be appreciated.

Reply to
Jones

I think you are mis-stating the RS232 spec. Specifically, what you need to look at are the outputs of each spec relative to the spec for the detected and allowable inputs for the other. My guess is that there's a fair chance that part may work, at least in practice if not in theory.

The more challenging part is figuring out how to tri-state the PC's RS232 transmit line so that it can listen. You could probably do it with some active device (analog FET switch?) controlled by one of the status lines. This shouldn't be hard to squeeze into the connector shell, but wouldn't be all passives.

Well, I take that back. There is one more ugly game you could play. Don't use the RS232 transmit line. Instead, bit bang low baud rate serial transmissions through the two control outputs, opposing diodes on each so that one drives the highs and the other the lows. To tristate, drive the signals to reverse bias both diodes.

Reply to
cs_posting

Jones wrote: snip:

Can't grasp your idea;-) how you will actually do that? Anyway if different voltage level is the only hurdule then why don't you add some thing on LIN side for down conversion? (12v -> 5v)

ali

Reply to
Ali

The common (but non-standard) way to allow multiple RS-232 transmitters on the same line is to connect a diode between the Tx pin and the common bus (with anode at the Tx pin). The line is actively driven only to the "0" (space) space, while the internal receiver resistors pulls the line to Mark ("1") state. With long lines, it might be a good idea to run a resistor from the common point to -12 V (e.g. DTR driven inactive) to maintain a stable Mark state.

However, I have no idea, what the LIN character structure is, is it even asynchronous (start/stop bit) and are the speeds compatible with what you might find on PCs.

Paul

Reply to
Paul Keinanen

Thanks Hans. I did a little more digging into it and I think the answer is indeed "No", but it has more to do with electrical characteristics than half/full duplex. LIN signal levels are +12V and ground. RS232 are +5V and -5V wrt ground. That's why you can't just wire the LIN and the RS232 to each other.

Reply to
Steve at fivetrees

The RS232 input is expecting to see the voltage go above (+5) and below (-5) ground. The LIN signals are +12V and 0V wrt ground. RS232 will not recognize 0V as a valid "0" or "1". I can't just connect the LIN bus directly to the RS232 input.

I don't think so. RS232 will not recognize 0V as a valid logic level.

Reply to
Jones

I was looking at page 123 of Jan Axelson's book "Serial Port Complete" where it states:

"At an RS232 data output, a logic 0 is defined as equal to or more positive than +5V, and a logic 1 is defined as equal to or more negative than -5V. ... Because an RS232 receiver may be at the end of a long cable, by the time the signal reaches the receiver, its voltage may have attenuated or have noise riding on it. To allow for this, the minimum required voltages at the receiver are less than at the driver. An input more positive than +3V is a logic 0. An input more negative than -3V is a logic 1. The logic level of an input -3V and +3V is undefined."

RS485 and RS422 are differential signals, and their voltage wrt ground doesn't matter at all so long as it is less than 7 volts. At an RS485 receiver, the voltage differential between the A and B inputs needs to be just 0.2V. If A is a least 0.2V more positive than B, it is a valid logic 0. If B is at least 0,2V more positive than A, it is a valid logic 1.

A LIN bus is held at +12V wrt ground by a pullup resistor. The transmitter pulls it to ground to create the opposite logic level. An RS232 input expects to see at least +3V wrt ground for one valid logic level, and -3V wrt ground for the opposite logic level. I'm sure this can be done with the proper electronics, but my original question was whether or not I could just connect the wires. I think the answer is "No".

Reply to
Jones

Thanks Paul. Do you a link to a web site that discusses this approach in a bit more detail, and maybe elaborates on some potential pitfalls to watch out for?

LIN baud rates are between 2 and 20 Kbaud. It is asynchronous. I have since found there are LIN/RS232 converters out there, that you can place between the LIN bus and your PC's RS232 connector. The simpler ones do not do any baud rate translation or any other translation. All they do is take care of the logic level voltage mismatch, and allow you to connect both the TX and RX RS232 signals.

Reply to
Jones

"undefined" is where we start getting into the difference between theory and practice.

And also the difference between what the RS232 spec requires, and what common parts actually tolerate.

For example, without using the response control input, the MC1489 has a VIL typically 0.8 V. Positive 0.8 volts that is. So does the MAX232.

Should you depend on this in a product? No. With long cables? No.

And it might not work at all, but there is a good chance that it will, most of the time, in a pinch.

(I'm pretty sure I remember making do on a project with an MC1489 receiver, which needs no extra power supplies, and simply using a nice

5v CMOS NAND gate in place of a of the MC1488 driver back in the days before the MAX232 was common)
Reply to
cs_posting

OK, I understand the point you are making, and it is a good one.

But to clarify: whatever I come up with has to work with any device that has RS232. So I have to follow the spec. I have no control over what chip the device may be using.

Reply to
Jones

Hmm. Word of history and caution if you are interfacing to old equipment RS232 has had various revisions which also affected the threshold levels and the conector pinouts for D type connectors was a PTT V24 standard. The connector pinouts I believe got incorporated in Revision D of the EIA RS232 spec.

From *memory* RS232 was originally easy to do as +/-12V signals due to drops in drivers from +/-15V rails, however the receiver thresholds over the years has dropped

Rev +/- Threshold A 9 B 5 C&D 3

Quite a lot of PCs have the ability to do +5V/0V level detection but this should NOT be relied on.

It is sometimes possible to create a driver for SHORT cable runs that drives +5 to +12V and in some cases can use the input weak pulldowns to -12V to get other level. This is NOT a recommended way to do things. This is only useful for SLOW baud rates 0 to approx 2400 baud as then cable and other capacitance comes into play.

Considering the easy availability of 232 single chip converters and LIN converters, I would choose the appropriate parts for the job to work under all circumstances (including short circuit and often ESD protection).

--
Paul Carpenter          | paul@pcserviceselectronics.co.uk
    PC Services
              GNU H8 & mailing list info
             For those web sites you hate
Reply to
Paul Carpenter

in

o,

me.

Thanks Paul. I found the following low-cost converter. It looks like it will do the job:

formatting link

Reply to
Ether Jones

That would be +12 and -12VDC

Reply to
Neil

What does the pronoun "that" refer to in your short reply above?

Reply to
Ether Jones

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.