Your PC as a Nmea0183 Talker or Listener

This forum is for discussing hardware (electronics) and software design aspects of multiplexers in general.
Post Reply
Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Fri Nov 15, 2019 6:08 pm

Hello,

Nmea0183 devices, from the electrical point of view, follow the RS-422 protocol and, in many cases, just follow the RS-232 protocol. I briefly describe here the basic characteristics of the 2 protocols. First of all it is important to notice that there are talkers (that output data) and listeners (that receive data) and that connections can be "one to many" but, in no case, "many to one". In other words one talker can be connected to, say, two listeners, but two talkers can not be connected to the same listener.

In the case of RS-232, talkers have a TX (transmitting) line and listeners have a RX (receiving) line. In addition they share a common GND (ground). When a talker is not talking (not sending data out) the TX line is said to be in its idle state with a negative voltage to GND between -3V to -15V (or zero in the "simplified RS-232"). When the talker transmits, its TX line pulsates, going positive to send a "0" bit or returning to the negative or zero voltage to send a "1" bit. The positive voltage of the TX line (for bit "0") can vary between +3 to +15 volts. Following is a diagram of RS-232 serial communication. In the top is the case of the RS-232 standard. In the middle is the case of the "simplified RS-232". And in the bottom is the case of the what is called "Serial TTL".

serial-com.jpg

Looking to the 2nd and 3rd waveforms, we note how similar they are with regard to the voltage values but, at the same time, how different they are with regard to their logic values. Actually one is the logical inverse of the other. We can use an inverter IC or a simple transistor to perform the inversion. Another point to note which we explore later in this post is that each of these waveforms can be obtained by subtraction from 5V. We have:
  • (+5V) - (Simple RS_232) = (Serial TTL) and also
  • (+5V) - (Serial TTL) = (Simple RS-232)
I could discuss RS-422 but I will only refer that in this case the communication uses 2 lines. The talker has a TX+ and a TX- and the listener has a RX+ and RX-. This is called differential communication and noise robustness is the main advantage. More details about connecting Nmea 0183 devices using differential lines can be found here.

Now I turn my attention to the title of this post. Today computers have USB ports and we can find adapters from USB to RS-232 or USB to Serial TTL. We can buy these adapters from China for a little more than 1 euro. With the USB to RS-232 adapter we can "transform" a USB port on a Nmea 0183 talker and listener. In the case of the USB to Serial TTL adapter we need an inverter or use a trick explained below.

usb-ttl-cable.jpg

I have in my lab some USB to Serial TTL adapters. The reason I chose these adapters is that they have the cable terminals ready to use. All the electronics is inside the box on the USB end. On the contrary, the adapters on the right side of the picture have the electronics on the box on the RS-232 end and it is not possible to cut the cable just before the DB9 socket. Here is the meaning of the colors:
  • black color = GND
  • red color = +5V
  • green color = TX
  • white color = RX
That would be the end of this post but then we have the "Windows 10 problem". The fact is that the majority of the referred to adapters use "fake" versions of the popular Prolific PL-2303HXA or PL-2303X integrated circuits. They work fine in Windows 7 but, starting with Windows 8, the drivers that come with Windows will not work with those chips. If you find the old drivers and install them on Windows 10 they work until Windows Update will install the new drivers. It is not advisable to disable Windows update for various and obvious reasons. Fortunately it is possible to instruct Windows Update not to install new drivers. The old W7 drivers that work in my case are version 3.3.2.105 from October 2008. You can download the zip file Profilic_Win8_x64_x86.zip that contains the old W7 drivers directly from the Vela-Navega website. You should unzip the contents of the zip file to an empty folder. In the following are 3 steps to get a proper installation of the old drivers:

1 - when you insert the adapter in a USB socket, W10 will try to find the best drivers and installs them. The yellow "!" that appears in the Device Manager goes away and you get this:

coms1-2-3-4.gif

It looks fine but the serial port does not work. So you go to the next step.

2 - In the Device Manager right click the Prolific driver and choose "Update Driver". You can have a message saying that the best drivers are already installed but you need to install the old W7 drivers. If you find the option to tell Windows the location of the drivers that you want to install just point to the temp folder where you unzipped the old W7 drivers. If Windows insists that you already have better drivers you can follow another route. When right clicking the Prolific driver you choose "Uninstall Device". In the dialogue form that opens check the box that says "Delete the driver Software for this Device" and then press Uninstall. Unplug the device and plug again. Windows may install another driver that still resides in the computer. Repeat the "Uninstall Device" as before. You reach a point where Windows does not have more drivers. In that occasion it will ask you to point to a location or a disk where to get the drivers. Pointing to the the above referred to folder you get the old W7 drivers and they work great. The Device Manager will show you this:

prolific-good.jpg

3 - Now the problem is Windows Update. The only solution that I found was to disable the automatic update of drivers. To do that you open the "Control Panel" and then you press "System". Press "Advanced system settings" on the left menu. In the "Systems Properties" form that opens, press the tab that says "Hardware". Press the "Device Installation Settings". Choose the option "No" and ignore the Windows recommendation. Save the changes and that is all!

To end this post I refer to the trick to use the USB to Serial TTL with the Nmea2Wifi or Nmea4Wifi multiplexers. When the adapter is used as a talker you need to invert TX (to get a RS-232 type waveform) and connect NOT_TX to the RX pin of the listener. With our multiplexers as listeners you do not need the inverter. Considering the input P2, for example, you can connect +5V (red cable) to A2 and TX (green cable) to B2. In this way the optocoupler receives a waveform (or a voltage between A2 and B2) which is equal to (5V - TX). The following picture shows all the waveforms that we are referring to.

waveforms.jpg

We see that there is a problem with the TX waveform. The waveform is 0V in the idle state as it should be but the positive going pulses will just go to 3.3V. Therefore the difference 5V - TX will not be 0 in the idle state but 1.7V. Since the optocoupler diode conducts when the voltage is 1.2V it will not stop conducting in the idle state. A trick is to connect a small diode in series with the +5V. That diode will have a voltage drop of 0.7V so that the voltage that you apply to A2 is 4.3V instead of +5V. In this way the (4.3 - TX) waveform will be about 1V in the idle state. The optocoupler will not conduct and that is OK.

When the adapter is used as a listener you use B3 or B5 (Nmea2Wifi or Nmea4Wifi) to connect to RX (white cable) and GND to GND (black cable). You simply use the fact that A3 and B3 (or A5 and B5) are the inverse of each other! All of these connections are shown in the following picture. You can see the diode in series with the red cable. This is a solution to get USB connectivity in the case of the Nmea2Wifi multiplexer.

ttl-diode.jpg

Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Sun Nov 17, 2019 10:15 pm

Hello,

This is a follow up of my previous post. One day after posting it, I found new information and instead of editing the first post I will be adding posts with more information. I will do it in a succession of posts, each one focusing a particular point.

We saw that the "Serial TTL" TX waveform varied between 0 and 3.3V. This is required by "modern" 3.3V TTL logic circuits which are powered by 3.3V. A long time ago almost every TTL logic circuit used 5V power supplies. The red cable in the USB adapter has a voltage of 5V not because of TTL but because USB cables do carry that voltage in one of their bus lines. In order to allow a direct connection to the multiplexers without using an inverter, I proposed (and tested) to add a diode in series with the red cable as a way to reduce its voltage from 5V to 4.3V which was fine to the optocoupler characteristics. However, today, I opened the plastic box at the USB end to see what was inside and saw a free soldering pad labelled 3.3V. The red cable was soldered to a pad with the label +5V.

solder-red.jpg

So I desoldered the red cable from the 5V pad and soldered it to the 3.3V pad. Then I closed again the box (very easy to open and close again, by the way). So the problem was solved. No need for the diode solution that I proposed yesterday! Here are the previous waveforms where we see that the idle state of the (3.3V - TX) comes exactly to zero.

3v3waveforms.jpg

This is my first addition to the initial post. More to come, Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Sun Nov 17, 2019 10:26 pm

Hello again,

I lost some time trying to explain how to solve the "Windows 10 problem" of the Prolific PL-2303HXA IC. I found a website that describes what they say is a complete fix for that problem. I leave here the link for that website which describes much better than me this problem. However I did not tried the solution because I have fixed the problem on my PC and because I found similar cables that apparently work fine in Windows 10. I like those that have a plastic box on the USB end as the one I analysed in the first post. If you search in AliExpress or Banggood using the keyword "FTDI FT232RL" which is a different IC to make the conversion you get thousands of possibilities. I have 2 at my lab which I use to programme the Arduino but they do not have the plastic box to cover the PCB that holds the conversion electronics. I order a pair of cables costing less that 2 euros using the PL-2303TA chip by Prolific which apparently work OK in Windows 10. They have a blue box and I hope to be able to open it to change the red cable from 5V to 3.3V. I will update this topic when I receive them.

pl2303ta.jpg

Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Sun Nov 17, 2019 11:24 pm

Hello,

There are some important points to note if you think in using these cables with our multiplexers on a boat. Here are some notes that come to my mind:
  • In order to get USB communcation between the the Nmea2Wifi multiplexer and a PC or a laptop you need to use one of these cables as the USB micro-B receptacle that exists on the ESP8266 module is only used for flashing the module.
  • In the case of the Nmea4Wifi multiplexer you can use the USB micro-B receptacle that exists on the ESP32 module and connect a USB cable between the multiplexer and the PC. That USB port is also used to programme the module.
  • In the case of the Nmea4Wifi multiplexer you should note that the receptacle is soldered on the PCB of the module and it should be used with care. I never had a problem with those connectors (that I use to programme the module for the first time; then you can programme it using OTA or no cables) but I had one or two users who returned to me the modules so that I could fix broken receptacles. So these cables could be a solution even in the Nmea4Wifi case.
  • If you want to use one cable to send and receive data as, for example, it is shown in the last picture of the initial post, the baud rate of the input port P2 and the baud rate of the output port P3 should be the same. This is so because on the PC end you have a unique COM port that send and receives data at the same rate. So, in addition, the baud rate of the PC COM port should also be equal to that of P2 and P3
  • Finally you should note that I only referred to PC and laptops. May be you want to use a tablet as a chart plotter. (I do not see a need to use a USB connection in the case of a smartphone). When you connect a multiplexer to a PC or to a laptop using a USB cable, the PC is the host and the multiplexer is a device. May be I will post here in the future a brief description of the USB protocol. Old smartphones and tablets are also USB devices. They can be connected to the same host (PC or laptop) as the multiplexer but, in a USB system, devices can not talk to each other. They can only talk to the host when the host asks them to do so. Modern smartphones and tablets, however, comply with the OTG USB standard. OTG means On The Go and the main difference to normal USB is that they can operate as devices or as hosts. So, if you want to make a USB connection between the multiplexer and a tablet, you must check if the USB port on the tablet complies with OTG.
Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Mon Nov 18, 2019 1:46 am

Hello,

Here is a video using the adapter cable. Sorry for the synthetic voice that appears near the end of the video. I am learning how to make and edit videos!


Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Tue Nov 19, 2019 10:35 am

Hello,

This topic is increasing! I just remembered that I had an USB to RS-485 adapter somewhere in my lab. I found it and tried to use it with success. That is the reason of this post. Before I describe the adapter I return to the RS-422 protocol that I have briefly referred to in the initial post. I made this drawing that explains how the RS-422 works in terms of connections.

RS-422.jpg

Remember that the Nmea 0183 specification "follows" the RS-422 specification. On the right side I used the Nmea2Wifi multiplexer. If I had used the Nmea4Wifi unit I would just place A5 and B5 where you see A3 and B3. I took the opportunity to feed the 2 input ports of the multiplexer to emphasize that one talker can connect to several listeners. You see that for full duplex communication (simultaneously transmission and reception) we need 4 wires. It could be the case that you would need a 5th wire connecting GND of both sides if the listener computer port is not optical isolated. In both directions it is the voltage difference between two lines that represents the data. This is the reason why you can get long distances and robustness to noise. On the left the computer uses one COM port where we connect the adapter. One disadvantage of this case is that the baud rate that you set on the PC (COM port) side is common both for transmission and reception. On the multiplexer side you are obliged to set P1 P2 and P3 with the same baud rate settings. Here is an example of a cheap USB to RS-422 adapter that I found in Ali-Express. It cost about 3 euros. Actually only the "green" adapter is RS-422 and you can see the labels for the 4 needed wires.

rs-422-485-adapter.jpg

The "red" adapter is not RS-422. It is RS-485. RS-485 is "similar" to RS-422 but there is only one pair of lines that share transmission and reception. When you connect a device to a RS-485 bus, the device can transmit or receive using just 2 lines. As this is completely different from Nmea 0183 I will write nothing more about RS-485 except that we can use these adapters separately in a Nmea 0183 system - one for transmission and one for reception.

The adapter that I found in my lab is shown in the following picture. I has just 2 lines as it a RS-485 adapter. The lines have labels A/D+ and B/D-. This adapter is available from Ali-Express costing less than 1 euro including shipping to Portugal.

usb-485.jpg

The adapter is based on the CH340 chip and I found no problem with drivers on Windows 10. In relation to the "USB to Serial TTL" devices they are much more robust against noise over long distances if you use a twisted pair of wires. If we need to transmit and receive Nmea 0183 data on a PC we need 2 devices. This looks like a disadvantage but, using 2 adapters, you can set different baud rates for transmission and reception. The previous implementation with a single "USB to RS-422" adapter looks like this when using 2 "USB to RS-485" adapters

2-RS-485.jpg

In the picture I assumed for the sake of this explanation that the talker adapter was given COM7 port and the listener adapter was given COM3 port. You should not instruct your PC (the Nmea0183Tester tool for example) to transmit data on port COM3 as that would correspond to 2 talkers to be connected against each other (not good, could even destroy them). You should also not set COM7 to receive as data as it will put 3 listeners connected to each other (dummy case not so grave as the previous one).

Regards, Luis

Luis Sa
Site Admin
Posts: 847
Joined: Thu May 04, 2017 4:12 am

Re: Your PC as a Nmea0183 Talker or Listener

Post by Luis Sa » Thu Oct 29, 2020 1:23 am

Hello,

The motivation for this post was an user of the NMEA4WIFI multiplexer that reported to me bad readings by ports P3 and P4. I used one of the Serial TTL to USB adapters described in this topic and the tool Nmea0183Tester (v2.3). I created a TXT file with a dozen of Nmea0183 sentences that the user had sent to me and I pointed the tool to that file. The adapter appeared in my PC as COM7. I set the tool to transmit the TXT file continuously on COM7 port at a baud rate of 9600. I also set the tool to receive from data from COM7 at 9600 baud.

The red (5V) and green (TX) wires from the adapter were connected to A3 and B3 respectively. A5 and B5 were connected to the black and white wires of the adapter. I tried output on UDP (not shown on the video below). The webpage setup was like this:

IMG_20201028_231543.jpg

Then I pressed "Resume" both on the Transmitting and Receiving Tabs of the Nmea0183Tester and took my phone to make the following video.


I will now write an email to the user using this video as a reference.

Regards, Luis

Post Reply