Attempting to use RS485 basic UART on RTD Data Acquisition 8-Layer Stackable HAT

pockybum522

New member
Hello,

I have purchased RTD Data Acquisition 8-Layer Stackable HAT for Raspberry Pi. RTD functionality works great, I can run "rtd 0 read 2" for example and get back temperature. I am now trying to send basic UART data over the RS-485 interface built into the RTD HAT.

Reading the documentation, it looks like I should set the 485-TERM dip switch to on (Towards the 40pin GPIO header)
As well as the 485-TX dip switch to on.
As well as the 485-RX dip switch to on.

After that, I run "rtd 0 rs485wr 0 0 0 0 0" because the docs say I need to do this to use the RS485 as passthrough. This simply returns "done" so it appears successful.

After that, I've wired B and A on the connector just to the left of the 40 pin header that says RS485 to a digital oscilloscope, I have not wired the RasPi GND to anything, as I don't believe that's necessary for RS-485, but please correct me if I'm wrong. I have no other components or wires hooked up. I'm seeing no activity when attempting to send UART with the very basic python program at the bottom of this post.

I have checked and I can see a 3.3v pulse on the DSO. As the RS485 is -7 to 12v (I believe) I should be seeing its pulses no problem, or so I would think.

How do I tell what serial port I should be using on the raspberry pi to send/recieve UART data on the RS-485 interfece built into the RTD HAT?

(I have tried /dev/tty0, /dev/ttyAMA10 (Which I think is the bluetooth controller, but I tried it anyways.) along with /dev/ttyS0, and /dev/serial0.) and I have tried various configurations of the dip switches when doing this, such as turning off/on TERM and/or turning off/on 485-TX and 485-RX. I have also tried B and A on the connector on the bottom-right of the board. (As viewed when 40-pin GPIO header is at the top) I figured it's time to ask. Thank you for your time and a great product.

When running the code below, I expect to see activity on the DSO once I get the serial port correct.

import time import serial print ("Starting") ser = serial.Serial("/dev/serial0", baudrate=9600, parity=serial.PARITY_EVEN, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) time.sleep(1) try: message = b'\xFC\x01\xFA' while True: print(message) ser.write(message) except KeyboardInterrupt: ser.close() print ("Exiting program") except: print ("Error!") finally: ser.close() pass
 

alexburcea

Moderator
Staff member
Hi,

Before doing any tests, you must ensure the Raspberry serial port works properly. I assume you enable the port from raspi-config and turn off the shell over the serial port feature.
Please hook up the DSO to pin 8 of the Raspberry 40pins connector (TX) and GND to see if you get something when your code sends data.
The usual name of the port is /dev/ttyAMA0 or /dev/serial0
There are 2 ways to measure the RS485 with the scope, either connect A to an input and B to DSO GND or connect A and B to inputs and the GND of the card with the GND of the DSO.
 

pockybum522

New member
With your suggestions, I have it working great and am able to move forward with my project. Thank you so much.

I have written up the steps I needed to take, on a Pi 5 (Although I believe it's the same steps on any model.) Feel free to use them in a tutorial note, if you wish. I might suggest a shortened version of this in the github repo somewhere.

If you're curious what newbies to the board seem to find first, I was getting all of my initial information from the DESCRIPTION and SOFTWARE tabs on https://sequentmicrosystems.com/products/rtd-data-acquisition-card-for-rpi and since there is already a section for using the RS485 in there, perhaps you may want to add this to that section.


I wrote a brand new pibian 64-bit image, then did the following, and can verify these steps work off of that:

  1. Before starting any of this, ensure DSO is set to dc-coupling

To test regular serial:

  1. Positions of dip switches does not matter for switches: 485-TERM, 485-TX, 485-RX

  2. raspi-config > Interfaces > Serial

  3. Login Shell? No

  4. Hardware enable? Yes

  5. reboot

  6. You should now have /dev/ttyAMA0 which was not there before

  7. If the RTD hat is on the Pi, run "rtd 0 rs485wr 0 0 0 0 0" (without double quotes. This seems to persist through reboots/power off, so you only need to run it once.)

  8. Hook DSO up to GND and TX0 (Pin 8) on Pi GPIO

  9. Run python with python test_serial.py (No SUDO needed.)

  10. Should see output on DSO

After above steps are working, we can verify RS485 output through the RTD HAT:

  1. Follow all of the above steps and verify normal serial on above specified pin, then:

  2. 485-TERM dip switch position doesn't really matter if you're just verifying with DSO

  3. Set 485-TX dip sw to on

  4. Set 485-RX dip sw to on

  5. Hook DSO up with GND on A or B RS485 lines and the probe hooked up to whichever (A or B) line gnd is not hooked up to. These lines have been tested from the connector just to the left of the GPIO header on the RTD HAT (left if pi GPIO header is on top of board) no shared GND needed between DSO and Pi

  6. run "rtd 0 rs485wr 0 0 0 0 0" (without double quotes. This seems to persist through reboots/power off, so you only need to run it once, no need if you already ran it in previous steps)

  7. Run python with python test_serial.py (No SUDO needed.)

  8. Should see output on DSO
 

pockybum522

New member
I created a PR for the above guide in the github repo. Feel free to disregard if you feel it is unnecessary, but it would have helped me, so I feel it may help others.

Thanks again!
 

alexburcea

Moderator
Staff member
Thank you for sharing your experience.
I merged your text in the GitHub repo and will talk with my colleague to put a link to it on the product page.
 
Top