NMEA 0183 mux

cpedw

Senior Member
I would like to build a multiplexer to combine 2 NMEA 0183 streams (I understand that NMEA is essentially RS422). One of the streams runs at 4800 baud (standard for NMEA) and the other is high speed, 38400. The multiplexed output is to be at 38400.

I have sketched the attached concept schematic. I've been told the 2 inputs require opto isolation for NMEA work. Each input is serial character by character input (NMEA sentences all start either $ or ! and end CR,LF) then when a sentence has been received, the Busy bus input is checked and if low then Busy Out goes high (to stop the other line from activating) and the received sentence is put out at 38400, regardless of the speed it was received at. Then Busy is set low. If Busy is High then wait for it to go low and then transmit. Repeat.

This system could easily lose some data but, provided it's not a lot, that's OK. The high speed is a single sentence every 0.1s (fast heading $APHDM). The low speed is less predictable but should be at a similar rate (AIS data !AIVDM and !AIVDO). That's my current requirement but if the concept is sound, I think it could easily be extended to several inputs.

I have several questions for the assembled experts:
Is this feasible and as simple to program as I hope? It seems 2 08M2s could handle it easily.
Any recommendations for the opto isolator? I've seen 6N139M and HCPL2731. Would either be good?
Would diode ORing be OK for the combiner or does it need buffering/amplifying to achieve RS422 standard?

For testing, I plan to make 2 NMEA transmitter simulators and an LCD NMEA display but if I can sort out the multiplexer, they should be easy enough. I'm a bit concerned that these would be Picaxe to Picaxe communication, which may not exactly simulate NMEA to Picaxe to NMEA.

Your observations are welcomed.

Derek
 

Attachments

hippy

Technical Support
Staff member
Sounds feasible. I would go for an analogue 'busy' signal, all resistors the same value ...
Code:
-------.    __                 __    .-------
  Want |-->|__|---.---.---.---|__|<--| Want
       |          |  .|.  |          |
   Got |<---------'  |_|  `--------->| Got
-------'             _|_             `-------
Each starts with their 'want' digital line as an input, when one has something to send on, waits for the 'got' ADC to be near zero, then sets its 'want' line high. If it's about half continue, if near two-thirds, there's a clash, make 'want' an input and try again. It is possible to make that robust, and more so than a purely digital system.
Code:
Do
  Input WANT_PIN
  Gosub ReadNmeaData
  Do
    Input WANT_PIN
    Do
      ReadAdc GOT_PIN, got
    Loop Until got < $20
    High WANT_PIN
    ReadAdc GOT_PIN, got
  Loop Until got > $60 and got < $A0
  HSerOut ...
Loop
For receiving 38400 baud with potential back-to-back data; I'm not sure an M2 would be up to the task. I would either prototype it first to check, or make it a 20M2 so you can swap to 20X2 and use background receive if it isn't.

Your combining function can be done with diode mixing. You don't need the diodes at all, only a pull-up/pull-down resistor, but it's safer to include them -

Code:
-------.
    Tx |-->|>|---.---.---> Out
-------'         |  .|.
-------.         |  |_|
    Tx |-->|>|---'  _|_
-------'
 
Last edited:

cpedw

Senior Member
Thanks Hippy. I'm sure you are right that the hybrid system is more robust but is it possible to explain, in simple terms, why it's more robust? Another less important question: if I wanted to expand to more channels would the hybrid scheme adapt easily?

I don't understand how the outputs can function without the diodes. Won't the inactive output load and suppress the active output without?

Derek
 

hippy

Technical Support
Staff member
Thanks Hippy. I'm sure you are right that the hybrid system is more robust but is it possible to explain, in simple terms, why it's more robust?
If two or more PICAXE check the busy line at roughly the same time, both see it as low, then both seize the line, they can both end up thinking they have gained the right to transmit. Checking the busy line will simply indicate 'someone has access' but not who or whether it's just one or more.

Another less important question: if I wanted to expand to more channels would the hybrid scheme adapt easily?
It should. A single PICAXE gaining access will make the ADC about half voltage, more than one pushes it closer to full voltage.

I don't understand how the outputs can function without the diodes. Won't the inactive output load and suppress the active output without?
Each PICAXE can keep its transmit output as an input until it knows it has access to the shared transmit line, return to input before relinquishing access.
 
Top