RS485 Hat with NMEA0183 Messages

Hi Michael
Thanks for that. I don’t think there will be any chance of getting a circuit for that one so I will play with what I get and try to hack one to emulate what Matthew has got.

Regarding your funny result with 120Ω connected. It is quite possible your devices have yhe 120Ω fitted on board in which case you have doubled up and possibly too much of aload on output.
Easy to check. With the device unpowered or not connected to anything measure the resistance between A and B. If there is a resistor fitted it will show up. I think it could be fitted as all application drawings showing connections do not show an external resistor at this point.
Cheers Bob

Yeah, I did that test. with nothing connected to the unit (and no usb/power), it measures about 44K ohms between A and B.
Im not really concered with it, outside of interest as it does work as needed.

I think we need to more focus on the OP issue where A and B are not the inverse of each other.

1 Like

Sorry guys will reply tomorrow.
Cheers and thanks for keeping this alive.

1 Like

Hi Michael, Matthew
Michael. OK that establishes that. Even though that output has that suspicious glitch if you look close it would probably work OK as I think it fulfils all the requirements.

Regarding Matthews 2 devices. If I look at the truth table I can’t see how either of them would work. Negative logic would stand some sort of a chance but I don’t see how the Waveshare device would work at all. According to the circuit the TX data input pin is tied permanently to ground via a 0R (zero ohm) resistor. Matthew maybe you could check the accuracy of this circuit as you have the device in front of you. I did not notice any reference to using negative logic in any of the Core product splurges.

And in both cases a positive data input signal would put the NOT RE pin at ground which disables the transmitter and places the chip in RX mode.

Maybe I am missing something here. Will see what I can find out when my order arrives.
Cheers Bob

1 Like

Hi Matthew
One other thing which could simplify your project.

Do you require 2 way data (half duplex) or is it all going to be one way (simplex).
Cheers Bob

1 Like

Hi Robert,
Just one way.

Cheers
Matt

1 Like

Hi Matthew.
Thanks. That simplifies things somewhat. I should get my order from Core on Monday. Let me have a little play and I will come up with a simple solution.
Cheers Bob

1 Like

:+1:

Regards
Matt

1 Like

Ok some more testing team. I hope it helps and I really appreciate all the advice and discussion so thank you.
Matt

  1. CRO chA and chB zerod with no connection to anything.

  2. Connect chA (yellow) to pin 4 on Hat.

  3. Connect chB (blue) to pin 3 on Hat.

  4. 0V of both ch connected to pin 5 on Hat.

  5. Power up and measuring 1.1vdc on both ChA and chB.

  6. Send data (see below)…

And the code in the RPI Zero 2 W…


import RPi.GPIO as GPIO
import time
import serial

GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT)

Example: Send NMEA sentence

def send_nmea_sentence(nmea_sentence: str, port: str = “/dev/ttyAMA0”, baudrate: int = 4800):
try:
with serial.Serial(port, baudrate, timeout=1) as ser:
full_sentence = nmea_sentence.strip() + ‘\r\n’

Enable driver

GPIO.output(17, GPIO.HIGH)
time.sleep(0.02)
ser.write(full_sentence.encode(“ascii”))
time.sleep(0.02)

Disable driver (return to listen mode)

GPIO.output(17, GPIO.LOW)
print(f"Sent: {full_sentence.strip()}“)
except Exception as e:
print(f"Serial send failed: {e}”)

Send a test sentence

send_nmea_sentence(“$GPWPL,3456.78,S,12345.67,E,TEST01*3B”)

As a stupid not thought out comment, but a quick look, im not sure if setting GPIO 17 high is turning the RS485 Driver into receive or transmit mode.
We want /RE and DE to be high, which is the default state of Q1 is not allowing current to flow.
Can you re-run the test but Invert Pin 17 on the script such the low is “TX” mode ?

edit:
Look more at the hat… R7 is not connected right (as factory). So it wont make any difference.
Now I need to write this down :slight_smile:

Hi Matthew
I note the following under “Enable driver”

According to the circuit of your hat (the one with a DE9 connector) GPIO 17 is not connected. R7 is noted as “not fitted” so you are essentially operating in some sort of “automatic” mode which looking at that waveform is not too successful.

Ch A looks to be spiking from about 0.8V to about 2.6V while Ch B seems to be going from about 1.2V to about 2.9V.

I can’t quite get my head around how ths “automatic” system is supposed to work. If a data pulse is applied while DE is high output A will go high, when the Mosfet switched DE will go low and disable the output which will go high impedance. This slight delay in Mosfet switching is what I think that spike is. If that R7is fitted turning GPIO 17 high would disable the transmission by taking DE low. Cant work.

If you are only transmitting one way the task is simplified. Removing the Mosfet completely from the board will allow transmission full time.

That terminating resistor R3 needs to be on the other end of the cable. I note this is compliant with RS422 which will be OK with RS485 signals. Disconnectthe wires from NEMA IN and measure the resistance between A and B. If terminated internally you should get 100 or 120Ω or thereabouts. If a high resistance a 120Ω resistor will have to be fitted at that point. Having it at the transmitting end will be no good. It HAS TO BE at the receiver end.
Cheers Bob

Hi Machael
As I just replied according to the circuit of that hat GPIO is not connected (by not fitting R7) and you are correct. switching the Mosfet ON will disable TX mode.

Our replies crossed over.
Cheers Bob

1 Like

Yeah, just looking at that…
I was more thinking to leave the mosfet in play and rather allow GPIO to drive it via R7. But for that to work, you need to remove R6

As is in auto mode, when TX is low, it will be in Driver Mode, and when TX goes high it will be in receiver mode.

Hi Michael

I think that is how it works. But when Din is low line A will be low and when it goes high and Mosfet switches and disables TX line A will go high impedance. I think the whole system depends on this high Z output to go somewhere near half rail voltage which would probably allow the RS422 receiver to work in a fashion as I think the difference between A and B only has to be 200mV. A pretty cheeky way to do this if I am correct. I have not been able to find much of an explanation of how such a system is supposed to work.
Cheers Bob

I dont have the Shipmodul connected at all for these last two tests.
The 120ohm resistor is installed in the hat.

Cheers
Matt

That kinda looks more correct to me (?)
that looks like one of my images where it would go High then drop down.
Can you remove the white lines and “zoom” in a little?

Maybe I need R7 installed to have proper manual control ?
Just a newbie thought.

Cheers
Matt

Hi matthew

Take it out. It is not doing anything there. Only comes into play if the Hat is receiving an input signal.
Cheers Bob

Have a read of this

and this