Help with RS232 to TTL conversion for NMEA0183

supplementary question - will an opto-isolator do the same job. It inverts the signal (which I need to do) and i can (within limits) use whatever voltage I want to on the output side, so i can go from (say) a signal that varies between +3V (logic 0) and 0v (logic 1) to one that varies between +5v (logic 1) and 0v (logic0) etc?

You don't use opto-isolators on output lines, you use them on inputs. You need a suitable line driver like a MAX232 (or its 3V equivalent if you only have a 3V power source).
 
Yes I did do the TTL/232 conversion with a small board using a 3232 chip, (basically the converter board is the Max3232 with all the extra caps and resitors etc built in) its just a lot of extra wiring, soldering and something else to go wrong if its not needed when - it seems to me - the opto-i does the same job.

Not sure what you mean by not using them on output - probably my poor use of terminology, - but obviously the output of device A is the input of device B so an o/i between A and B is reasonable, no?

I guess the answer is try it and se eif it works; if it doesn't then build in the TTL/232 converter chips instead!

edited to add:
I understand that the purpose of an o/i is to electrically isolate one circuit fro another. But if as a "by product" of that the logic is inverted and the voltage on one side of the circuit can be set as desired (within limits) surely it does the job - effectively - of a TTL/232 dedicate converter?

You can get an Arduino to read NMEA0183 by using Software.Serial to invert the signal - there is no change in voltage required in this case, without 'properly' converting from RS232 to TTL

All my N0183 kit is single wire spec.
 
Last edited:
you mean a standalone opto-isolator chip right?
Cause the ones I bought (admittedly small boards with pinouts) had some leds on them to invert again to what it was pumped into them...

Sorry cannot really answer the main Q although I doubt it will work, didn't you succeed in NMEA0183 testing already, or you never bought the TTL-232 converter?

cheers

V.

V - just to answer you specifically, as we've been corresponding elsewhere on similar issues:

Yes I have my circuit all working using the small TTL/232 converter boards, and am now starting to think about tweaks and assembling something into a box for practical use. As part of that I wanted to add opto/isolation, not least because Due works on 3.3v maximum and there are other bits of the boat working on 5v and 12v+ !

Only when i started experimenting with the (stand alone) o/i did it dawn on me that it should - in theory - do a good enough job of inverting the digital signal logic and changing the voltage range, that maybe the TTL/232 board can be dispensed with?
 
Yes I did do the TTL/232 conversion with a small board using a 3232 chip, (basically the converter board is the Max3232 with all the extra caps and resitors etc built in) its just a lot of extra wiring, soldering and something else to go wrong if its not needed when - it seems to me - the opto-i does the same job.

Not sure what you mean by not using them on output - probably my poor use of terminology, - but obviously the output of device A is the input of device B so an o/i between A and B is reasonable, no?

I guess the answer is try it and se eif it works; if it doesn't then build in the TTL/232 converter chips instead!

edited to add:
I understand that the purpose of an o/i is to electrically isolate one circuit fro another. But if as a "by product" of that the logic is inverted and the voltage on one side of the circuit can be set as desired (within limits) surely it does the job - effectively - of a TTL/232 dedicate converter?

You can get an Arduino to read NMEA0183 by using Software.Serial to invert the signal - there is no change in voltage required in this case, without 'properly' converting from RS232 to TTL

All my N0183 kit is single wire spec.

An opto-isolator doesn't do the same job because its output won't meet the electrical specification required by the NMEA0183 standard for line voltage and current. A line driver and an isolator are 2 different devices for 2 different jobs.

Your device is the transmitter (talker in NMEA0183 speak), so use a line driver - either a TIA232 or TIA422 spec one will do, because all versions of the NMEA0183 spec require a TIA232 signal to be accepted. The device that is receiving your signal (the listener in NMEA0183 speak) will have the opto-isolator. You do not need an opto-isolator at your end if you are only doing the talking.

You are correct in stating that an opto-isolator is a good idea between A and B, as you describe it, but incorrect in proposing putting it at A. It should be (or will already be) at B. This is all described in the NMEA0183 standard and they give sample circuits for doing this.
 
Last edited:
Angus

I appreciate you are trying to help, but I think a lot of (lazy?) people - like me - want answers to simple "sub-sets" of a topic without wanting to learn the whole thing. So to simply refer me to the NMEA standards is a little like me asking "I'm looking for a French word for 'great' , I've been told it is 'magnifique', but I'm wondering if 'fantastique' would work instead, and then being told to go and learn fluent French from a dictionary"!

Since i posted originally I have done some more Googling on Rs232 (which has previously been stated to work fine with single line N183) vs TTL. I think I can see the problem. The RS232 signal varies between -12v and +12v and the range -3v to +3V is undefined. So an RS232 device will not be able to interpret 0v as either a 1 nor as a 0 logic signal.

TTL works between 0v and 5v.

So if you invert the logic of an RS232 signal and "truncate' anything below 0v (i.e. anything less than 0v is seen as 0v) you have a signal that can be read by a TTL device. Hence an Arduino, using Software.serial can happily read the N0183 input from my GPS.

The reverse will not work, however - (I assume) as the RS232 cannot interpret 0v.

Hence - whether good practice, or not, or working outside the N183 specs, my guess is that an optoislator will work just fine to enable a TTL device (Arduino) to read a RS232 input. I can see that i will need to use a MAX3232 to do the reverse though!

The reason this is an issue is that if i use a TTL/232 converter it will invert the signal (as wanted). if I then add an o/isolator to the circuit it inverts it back again. So now i have to find a way to invert it a third time! Probably a doodle for this ego whom electronics are as intuitive as using a knife and fork, but for this elf us struggling on the margins.... !

But I accept it may not be best practice and perhaps i am leaving myself open to failures or errors. But its all being done on a test rig anyway so we will see :-)
 
Hmmm i've asked this question the wrong way, on reflection!

Let me try again

I have a multiplexed NMEA0183 format sentence, produced by an Arduino Due that is TTL logic with a maximum 3.3v output that can be transmitted down any of its Tx serial ports.
What is the easiest way to convert this so it can be read by my NMEA0183 plotter that works on a max 5v signal voltage and RS232 logic (near-as) so that the two devices are also opto-isolated?

A Max 3232 chip will not do the job on it's own as it will invert the signal (desired) but an opto-isolator will also invert it back to TTL logic(not desired).

Having two Max3232 chips back to back and an optoisolator as well seems somewhat OTT!
 
A Max 3232 chip will not do the job on it's own as it will invert the signal (desired) but an opto-isolator will also invert it back to TTL logic(not desired).

I thought that some optoisolators incorporate diodes/leds/whatever in order NOT TO invert the signal.
Am I missing something? Maybe you bought the wrong optos?

cheers

V.

PS. you sure it's not worth dumping the DUE and going for another can shield and a MEGA 2560? I'm about to buy a couple of Megas to get over all the hassle of converting 3.3 to 5 and back again for the various sensors that all seem to be 5V :(
 
A Max 3232 chip will not do the job on it's own as it will invert the signal (desired) but an opto-isolator will also invert it back to TTL logic(not desired).

Just stick a Max3232 on it and bishbosh, job done. Stop fretting about inverting levels - the output from the processor will feed straight into the MAX3232 and the output from that will drive your NMEA0183 plotter's input. Also stop worrying about an opto-isolator - they are for a device's input, not output. The plotter you are connecting to will have one if it is NMEA0183 compliant.
 
Why do you think the output needs to be opto-isolated?

Good question! Answer; because it appears to be "good practice" - Actisense on their equipment make a really big deal about it! I also seem to recall something about galvanic isolation but i struggle to see how this is relevant.

You can indeed buy "non-inverting" opto/isolators but the only ones I have found took about a month or more to arrive from China!

I went Due because it was recommended by the guy who wrote the NMEA2000 library as it has built in canbus and better processing power. My device is doing four things - creating an NMEA sentence from analog masthead wind inputs for speed and direction, multiplexing that with GPS and DEPTH sentences read from "proper' NMEA outputting transducers, transmitting the sentences using NMEA183 to the plotter and DSC radio and also converting it all to N2000 for the a/pilot to work with. So quite a bit of welly is needed!
 
Just stick a Max3232 on it and bishbosh, job done. Stop fretting about inverting levels - the output from the processor will feed straight into the MAX3232 and the output from that will drive your NMEA0183 plotter's input.

Yes I realise that, the 3232 inverts it of course which is what is needed; so yes IF there is no optoisolator performing a second inversion that is all that is needed and i have successfully run the rig like that already - it only became a problem when i wanted to add o/i and that inverted it back.

Also stop worrying about an opto-isolator - they are for a device's input, not output. The plotter you are connecting to will have one if it is NMEA0183 compliant.

Ok, I see that for the Arduino OUTPUT. However I have what is nominally a 12v analog input on three lines that is used to determine the wind direction and a nominal 5v pulse that is used to determine the windspeed, that are being read by the Arduino. There is no signal inversion required on these but I do need to protect the Arduino from any voltage above 3.3v.
 
Ok, I see that for the Arduino OUTPUT. However I have what is nominally a 12v analog input on three lines that is used to determine the wind direction and a nominal 5v pulse that is used to determine the windspeed, that are being read by the Arduino. There is no signal inversion required on these but I do need to protect the Arduino from any voltage above 3.3v.

Use voltage dividers to bring the 5V and 12V signals down to 3.3V, and you will be as safe as you need to be, because you don't have more than 12V anywhere in your whole system, lightening strikes excepted. Your inputs are going to a device costing only a few quid anyway. In the unlikely event that you fry your Arduino board it's no great loss. Opto-isolating analog signals is more complex and costly if you want accuracy. To do this you will need to read the isolator's datasheet and understand its transistor transfer characteristics.

For the 12V analog inputs get a pair of resistors for each input's divider where the tolerance is similar to the accuracy of your analog to digital converter, i.e. if your ADC is 10 bit get 0.1% tolerance resistors. They only cost a few pence from RS or Farnell and are available in old fashioned axial-wired form. Use values like 10k and 3k. That will bring a possible maximum voltage of 14.4V when charging down to about 3v.

For the digital input you can use less accurate resistors to bring the 5V down to 3.3V.
 
Last edited:
I do it this way...after a load of messing about I came to the conclusion that using a MAX3468 was the "correct" way of driving a NMEA0183 circuit...as per the spiel:-

The MAX3468–MAX3469 are high-speed differential bus transceivers for RS-485 and RS-422 communications. They are designed to meet TIA/EIA-422-B, TIA/EIA-485-A, V.11, and X.27 standards.

Works fine for me, and it quite happy being shorted out, and generally abused...(which is always handy!) I am not an expert so am standing by to be told its a load of rubbish and should never be done this way under any circumstances.Untitled.png
 
I do it this way...<snip>...should never be done this way under any circumstances.
:)

That's fine for meeting the later variants of NMEA0183 where differential output is specified. It is a transceiver though, so NMEA0183 being single direction, only half the chip would ever be used. That won't cause any problems, it's just a bit more expensive solution that it could be.
 
Top