RPIQS
Posts: 10
Joined: Wed Jul 22, 2015 10:38 pm

Sending hexadecimal data through UART RX/TX pins to myRIO

Thu Jul 30, 2015 7:43 pm

Hi,

So I have created a setup where my Raspberry Pi obtains some data (in the form of hexadecimal) through a Bluetooth serial connection. I need to now output the hexadecimal data through the UART RX/TX ports into a myRIO platform (which then carries out some tasks). I have connected the corresponding UART ports between the myRIO and the RPI, but how can I assign a serial port to those pins and then know that data is being transferred? Is there a way to check for live serial ports? Are jumper cables enough between the pins or do some other settings need to be configured for a successful serial configuration? This is only my third week using Linux or the RPI, so I do not know all the configurations.

Thanks,
Mark

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 8:03 pm

Perhaps the very similar current forum thread here viewtopic.php?f=91&t=117020 might give you some ideas?

You need to take care with the signal levels used by the 2 devices. The RPi UART operates at the 3.3v logic levels used by the other gpio pins. Those are not the same as, or compatible with, RS232 signal levels. Do you know what signal levels are used by the myRIO device? Some implementations of rs232 are capable of destroying the gpio pins on an RPi.

RPIQS
Posts: 10
Joined: Wed Jul 22, 2015 10:38 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 8:23 pm

B.Goode wrote:Perhaps the very similar current forum thread here viewtopic.php?f=91&t=117020 might give you some ideas?

You need to take care with the signal levels used by the 2 devices. The RPi UART operates at the 3.3v logic levels used by the other gpio pins. Those are not the same as, or compatible with, RS232 signal levels. Do you know what signal levels are used by the myRIO device? Some implementations of rs232 are capable of destroying the gpio pins on an RPi.

Hey,

Thank you so much for your prompt reply. Yes, it's a nice coincidence that someone else happened to post about a similar topic, and I saw that I have used a similar python program in order to read/write data from the serial ports. I also did some research and it seems like both the myRIO and RPI GPIO pins run on the same voltage, so nothing should be damaged.

However, as I am not using a RS232 cable, but rather just two jumper wires between the two sets of UART RX/TX pins, would it be enough? Also, is the default serial port for something plugged into these pins /dev/ttyAMA0? Or else how can I find/assign a serial port number to those pins?

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 8:36 pm

You don't need to assign anything to those pins. They show up as /dev/ttyAMA0 and that is it.

Do be sure to disable use of those pins as a console port by the kernel and OS. This can be set in the options in the raspi-config program.

If you are connecting to external devices directly then ensure you do not exceed the 3.3 volts max on the pins. I am generally "rude and crude" about this and put 200 ohm resistors in series with Tx and RX. I have used such direct connections to other, near by, micro controllers and devices with no problems. Others will expound on this interfacing issue in many more complex ways.
Memory in C++ is a leaky abstraction .

RPIQS
Posts: 10
Joined: Wed Jul 22, 2015 10:38 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 8:49 pm

Heater wrote:You don't need to assign anything to those pins. They show up as /dev/ttyAMA0 and that is it.

Do be sure to disable use of those pins as a console port by the kernel and OS. This can be set in the options in the raspi-config program.

If you are connecting to external devices directly then ensure you do not exceed the 3.3 volts max on the pins. I am generally "rude and crude" about this and put 200 ohm resistors in series with Tx and RX. I have used such direct connections to other, near by, micro controllers and devices with no problems. Others will expound on this interfacing issue in many more complex ways.
Hi Heater,

Thank you so much for your help. That was the answer I was looking for. :D

Okay, I will attach resistors in between the ports in order to prevent any damage.

Also, I saw that the RS232 connectors were connecting to four of the pins on the RPI, but I am only connected to two of them using jumpers. My questions are:

A. Between the RPI and myRIO, are only two jumper cables between the UART ports enough? Or do I need to connect the other two ports which the RS232 cable uses to the myRIO also? I am asking this as I do not have access to that type of cable now.

B. Between the RPI and myRIO, do I connect the UART TX port of the RPI to the UART RX port of the myRIO and vice versa? Or do I pair the TX and TX together and the RX and RX together?

Thanks,
Mark

User avatar
davidcoton
Posts: 5026
Joined: Mon Sep 01, 2014 2:37 pm
Location: Cambridge, UK
Contact: Website

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 9:20 pm

A. Between the RPI and myRIO, are only two jumper cables between the UART ports enough? Or do I need to connect the other two ports which the RS232 cable uses to the myRIO also? I am asking this as I do not have access to that type of cable now.
Try it and see. You may or may not need additional control signals depending on how the RS232 protocol is implemented. RS232 is one of the best non-standards ever devised. You will need a ground (0V) connection (without a resistor).
B. Between the RPI and myRIO, do I connect the UART TX port of the RPI to the UART RX port of the myRIO and vice versa? Or do I pair the TX and TX together and the RX and RX together?

The first option.
Signature retired

RPIQS
Posts: 10
Joined: Wed Jul 22, 2015 10:38 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 9:28 pm

davidcoton wrote:
A. Between the RPI and myRIO, are only two jumper cables between the UART ports enough? Or do I need to connect the other two ports which the RS232 cable uses to the myRIO also? I am asking this as I do not have access to that type of cable now.
Try it and see. You may or may not need additional control signals depending on how the RS232 protocol is implemented. RS232 is one of the best non-standards ever devised. You will need a ground (0V) connection (without a resistor).
B. Between the RPI and myRIO, do I connect the UART TX port of the RPI to the UART RX port of the myRIO and vice versa? Or do I pair the TX and TX together and the RX and RX together?

The first option.
Thank you so much David! You solved an issue I've been trying to fix for the past two weeks!

Heater
Posts: 15949
Joined: Tue Jul 17, 2012 3:02 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 9:47 pm

As a minimum you will need three connections:

1) GND. Ground. 0v. It's better that all such connected systems have a common reference point. Ground. Zero volts.

2) Tx

3) Rx

I put a 200 ohm or 1K resistor in series with Tx and Rx just in case of mishaps. Even when connecting to other devices that are operating at 3.3v.

I have used this scheme successfully many times but be aware that other devices may need other control signals to be operative. CTS (Clear To Send), DTR (Data Terminal Ready), RTS (Request To Send) and whatever else. Historically serial links used all kind of weird set ups. Now a days not so much. But I do use the Pi to reprogram a certain micro-controller that needs a control signal to cause a reset and start the reprogramming sequence. For that I have to control another GPIO pin on the Pi header to provide that reset signal.
Memory in C++ is a leaky abstraction .

RPIQS
Posts: 10
Joined: Wed Jul 22, 2015 10:38 pm

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Thu Jul 30, 2015 9:58 pm

Heater wrote:As a minimum you will need three connections:

1) GND. Ground. 0v. It's better that all such connected systems have a common reference point. Ground. Zero volts.

2) Tx

3) Rx

I put a 200 ohm or 1K resistor in series with Tx and Rx just in case of mishaps. Even when connecting to other devices that are operating at 3.3v.

I have used this scheme successfully many times but be aware that other devices may need other control signals to be operative. CTS (Clear To Send), DTR (Data Terminal Ready), RTS (Request To Send) and whatever else. Historically serial links used all kind of weird set ups. Now a days not so much. But I do use the Pi to reprogram a certain micro-controller that needs a control signal to cause a reset and start the reprogramming sequence. For that I have to control another GPIO pin on the Pi header to provide that reset signal.
Oh....that's a little unusual. Alright, I will definitely take that into account when using the myRIO, but I am pretty sure it doesn't need those additional signals as the official website says, "Please note that RTS/CTS hardware handshaking is not implemented in standard UART on NI myRIO."

Anyways, thank you so much for your input! (no pun intended)

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13092
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Fri Jul 31, 2015 1:23 am

if you are going to connect to a device that uses 5V logic, (like an Arduino) you MUST prevent 5V from reaching the PIs RX GPIO, or the 5V on it will cause the GPIO to "latch up", which destroys the PI!

either use an extra resistor between RX and GND to divide (lower) the signal below 3v3, or place a 3V3 zener over the RX GPIO (with anode to GND, and cathode to the GPIO pin), keep the (220 Ohm) series resistor.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: New Zealand

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Fri Jul 31, 2015 1:33 am

mahjongg wrote:if you are going to connect to a device that uses 5V logic, (like an Arduino) you MUST prevent 5V from reaching the PIs RX GPIO, or the 5V on it will cause the GPIO to "latch up", which destroys the PI!

either use an extra resistor between RX and GND to divide (lower) the signal below 3v3, or place a 3V3 zener over the RX GPIO (with anode to GND, and cathode to the GPIO pin), keep the (220 Ohm) series resistor.
OP has already researched and confirmed that his device (myRIO) operates at 3.3V, same as the Pi.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13092
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Sending hexadecimal data through UART RX/TX pins to myRI

Fri Jul 31, 2015 8:58 pm

indeed my quick sweep of what he wrote missed that, in any case it is still good to explicitly say it, as applying 5V to a GPIO can easily happen if you are not careful. I'm assuming its the major reason for fatally damaging your PI.

Return to “General discussion”