RS485 Hat with NMEA0183 Messages

Hey Team,
I have an RS485 Hat (SKU: WS-14882). I want to use it for a NMEA0183 interface on boats to an MFD (Multi Function Display). I want to transfer a generated waypoint for navigation.

I have an RPI Zero 2W with the RS485 hat connected. I can using Python code to send a correct NMEA0183 sentence to the device. Im find the data is not received even though with a CRO I can see the data is sent but not received. My underdstadning is that the receving device needs the data line to be low after transmission to correctly interpret the sentence sent. What I see with the CRO is that data line is high at +2vdc after transmission which I think is the problem. The data line should be high at the start of a transmission and low after transmission so as set to be in receive mode. The manual fo rthe RS485 HAT is a little unclear on how to acheive that. Can anyone help me here please ?
I have a CRO screenshot but not sure how to attach

Cheers
Matt

Some initial thoughts from a look over the waveshare site.

This hat looks like it can be CAN via the SPI or RS485 via the UART, so I will assume you are looking at the UART interface on the Pi.

Im a little unclear what’s talking to what. Im assuming you have a MFD that is getting gps data from the boats GPS, and now you want to inject a packet such that the MFD hears it ?

With NMEA0183 its RS485. CAN is not in the conversation.
The RPI via the HAT is talkoing to a NMEA0183 slave.

Cheers
Matt

To be clear I want to inject a Waypont location to the MFD’s on any MFD device thats accepts a WPL mesage.

Although NMEA0183 is RS422, many devices actually implement RS232, particularly where they are not intended for use on a network. Do you have the specifications of the NMEA device to confirm it is RS485?

Hi Jeff,
Is a Shipmodule - https://www.shipmodul.com/miniplex-3usb.html

I have A from Core Hat to + on Channel 2
B from Core Hat to - On Channel 2
0v from Core Hat to 0v on Shipmodul power supply

Regards
Matt

That’s a very nice unit. The documentation confirms that the ports are RS442, which is what would be expected for any NMEA0183 device designed with multiple connections. Port 2 is identified as configurable for RS485, so your connections appear correct. Note that your measurement of the data lines is not telling you what you think it is. RS485 is a differential protocol - the actual voltage level of the signal lines is not relevant (other than being within spec). The important thing is the difference between the two levels. To see the data on the CRO you need to monitor both signals and use the difference function on the CRO to calculate the logic level. But RS485 is not a data protocol, so the rule you mention about a low logic level being required in order to identify the start bit will be because of the particular data protocol implemented, and that is going to be specific to the device. Unfortunately I am not familiar enough with the hat to suggest what configuration is required to implement a matching data protocol. As a rough trick you could try swapping the connections - the worst that will happen is that the data is mangled.

1 Like

Hi Jeff,
Thanks.

ChatGPT is advising


3. DE/RE Control

Ensure your Pi is releasing the line after each transmission (i.e., DE LOW between messages).

At the moment I believe that there’s no DE LOW happening. It seems to be high ?

Regards

Matt

Since this is connected to the UART of the controller, then normal UART byte packets would apply. e.g. baud, stat/stop parity.
I have some projects that run on RS485 and I needed to send a 0xFF byte first. I just cant remember the exact reason why now.

I believe it was a way to ensure “I was the talker” i.e. hold one of the lines High for X Bits. In my code, all I did was prepend 0xFF to the actual data I wanted to send.

1 Like

Hi Matthew
Jeff just about sums it up.
It is important to realise this.

And this

There is another way to do this if your CRO does not have a differential function. If the CRO is mains operated you need to remove the mains earth connection. I do this with about 300mm of mains lead fitted with a socket and plug and the earth not connected. I leave the earth wire hanging out and visible so it is obvious to the user there is no mains earth connection.
Connect the CRO across A and B. Make sure the frame of the CRO is not contacting anything else and nothing else is plugged in. A tablet type battery operated CRO is useful here but still make sure there is nothing else connected to get a phantom ground connection.

Also, like another device on the market, that Hat has a pull up and pull down resistor to Vcc and Gnd on the A and B lines. A discussion on this has come up before and I nor anyone else could see any reason for these except to unbalance the line and interfere with any advantages the use of a balanced line offers in the first place. Like using very long cable runs. There is also a 120Ω terminating resistor which is switchable which is OK.

If you look at the Maxim485 data sheet there is useful information and connection diagrams but no mention of these pull up/down resistor requirement. There is a possibility this arrangement might interfere with what you require.

If anyone has found a reason for these resistors I would be interested to find out. RS485 will theoretically handle 32 “drops” but if you had 32 of these resistors effectively in parallel it could prove a bit embarrassing.
Cheers Bob

2 Likes

Thank you.

Ok tried to use differential mode as requested. I’m not a scope guru though.
I hope these two screen shots make sense.
Regards
Matt

1 Like

That first one doesn’t look like a differential waveform to me. It looks more like RS232/UART impressed on both A and B. Compare it with the example here.

Hi Jeff,
Both are the same trace snapshot. I just moved the trace for two photos from the end of transmission to the beginning.
I may have the wrong invert or math setting on the CRO but Its CH1 + CH2 - traces with a common ground.

I can’t help but come back to this


3. DE/RE Control

Ensure your Pi is releasing the line after each transmission (i.e., DE LOW between messages).

Regards

Matt

If the data protocol is RS485 then ‘LOW’ can only refer to the logic level, not the line level. That is, A+ < 0V, B- > 0V.

I’m sorry mate could please explain that in layman’s terms ?
I dont know the difference between logic and line.

Regards
Matt

Hi Jefff

Yes it does doesn’t it. If the setting was Ch 1 + Ch 2 the result should be zero.
I can’t help but think the pull up and down resistors are biasing the result.
The circuit from the product Wiki.


The resistors I refer to are R9 and R10.
I will try to find out what they are for. Maxim makes no mention of this sort of thing an their application notes.
Cheers Bob

1 Like

Hi Matthew
Jeff is right here. That does not look like a differential signal.
CH1 + Ch2 should result in zero.
Can you do it again but leave the maths out. Connect one input to “A” and the other to “B” lines with a common ground. adjust the grounds to be at the same point on the trace so we can see any biasing by the resistors I mention above. Also spread it out a bit so the timing is clearer, that is increase the scan speed. Don’t do any maths, remove the CH1 + Ch2. I assume the CRO inputs are DC coupled.

This is the relevant circuit from the Max485 data sheet.


Note NO pull up/down resistors.
Cheers Bob

1 Like

I have read that some people use the pull up/down to ensure no floating state if bothing is transmitting.

While i cant say i have used the pullup at the same time my master unit was alwas in tx mode to would have held the line states.

Im not sure how valid it is, just something that may explain it.

1 Like

Check the example waveform I posted earlier:
AST-CAN485 Hookup Guide - SparkFun Learn

Line is the voltage level on the wire(s). Logic is the result of how the device interprets the line level(s).

1 Like

Hi Michael

With this Hat that can’t happen. This could only occur if both the TX and RX driver were both disabled and go into a high impedance state. I think if that were allowed to happen it would be a pretty poor design on the “user” side of the 485 chip. In this case the TX and RX enable pins are connected and driven with a transistor with a pull up resistor so MUST default to the RX or “listening” state with no enable inputs.

These resistors would bias both lines to about half Vcc with a slight difference caused by the 120Ω terminating resistor IF FITTED. If the resistor is NOT in circuit the A and B lines would be close to Vcc and Ground. This resistor is apparently switch selectable in this unit. In other devices it is not which is a bit off as only the cable run ENDS should be terminated.

Now this is not the only device available using such resistors so imagine a large installation with 30 of these connected. You would have the A and B lines connected to Vcc and Ground via something a bit more than 100Ω. Not sure what that would do but it would not be good I don’t think.

I think you are correct with the assumption that these resistors force the line into some sort of “known ??” state with no input but as I said the “user” side should be designed so a “floating” situation can’t happen. This Hat seems to have that covered so I don’t really know why they are there unless it is to cope with down stream unknowns.
Cheers Bob
Add on: The 120Ω terminations only have to be at both ends in Half Duplex mode. For simplex operation (one way) only the receiver end needs to be terminated.

1 Like