myRIO Student Projects

cancel
Showing results for 
Search instead for 
Did you mean: 

Using USB-RS485 or other USB-to-COM devices on myRIO.

In some applications, we simulate the USB port to be a COM port (or serial port) with a ttyUSB adapter to communicate with a COM device, and USB-RS485 is one of such devices.

FTD0036-USB-RS485-WE.jpg

Figure 1. USB-RS485 USB to COM adapter.

This article will give steps to use such devices on myRIO using LabVIEW.

1. Make sure your divce is a ttyUSB device that can be supported by myRIO. You can validate this by the following steps.

    • Plugin your device to the USB port of myRIO.
    • Using a ssh tool such as putty to login myRIO.
    • Type the following commands.

               #ls /dev/ttyUSB*

    • If you can see listed files such as ttyUSB0 ( the postfix number may vary on different myRIOs), then it is a supported device and you can continue with the following steps, or you have to install other drivers for this device to enable to use it.

2. Make LabVIEW recognize the device.

    • Open /etc/mdev.conf and add the following line under "#typical devices" section. You can edit this file by vi editor on myRIO or copy it to your PC through FTP and send it back after editting it.

               ttyUSB[0-9]*     root:tty 666

    • Copy the attached script file "S10SetLnUSB" to /etc/rc5.d/
    • Change the file to be executable by commands:

               #chmod a+x /etc/rc5.d/S10SetLnUSB

    • Reboot myRIO and open NI MAX to find the myRIO. You will see there is a new "ASRL" device listed under "Devices and Interfaces" of the myRIO, e.g. in the following figure, it is "ASRL3::INSTR". Originally, thre are only 2 "ASRL" devices listed.

myRIO USB-RS485.PNG

Figure 2. Listed devices under myRIO in NI MAX

If you see the new "ASRL" item under "Devices and Interfaces" section of the myRIO, you will be able to use the device now. If it is a USB-RS485, you can take it as a normal COM resource and use LabVIEW VISA APIs

Capture.PNG

Figure 3. How to use ttyUSB device in LabVIEW

Comments
Member
Member
on

Hi, I'm trying to do this with a joystick, and it pops up as usbdev1.2, if I unplug it and plug it again then it goes to 1.3,1.4, etc. I was wondering if this is because I don't have the right driver? If so, how would I go about installing the driver? I also don't know how to copy that script file, would I just download it and then tell putty to install it with the chmod command? Sorry, I'm fairly new linux.

Thanks

NI Employee
on

Hi,

    This tutorial and driver are only for USB-RS485 device, not for the joystick. To download file to myRIO, you can use a FTP client tool like FileZilla. Then you can use putty to input those commands.

Active Participant
Active Participant
on

dess1088,

Unfortunately the kernel on (my|robo)RIO does not have joystick support enabled. Not sure if you can build the module separately and load it into the shipping kernel, it seems like it should be fine based on the dependencies that it has and what is already enabled in the kernel that is on the targets...

/* One quick compile later */

It does look like the module does indeed insert without error, so I would imagine that USB joystick/gamepad support is something that you can indeed add to the kernel that is on the myRIO.

Now, as for the support for joystick devices in LVRT, I don't believe we have that, that's a different group that works on what is supported through VISA

Member
Member
on

Hi,

ASRL3 do show up, but status is showing Not Present. Is it supposed to be like that?

Member
Member
on

Sorry to say, but this thing actually dont work. Linux RT do recognize the device and load the driver for it, but as he occupied the device, NI-VISA don't have access of it. Also NI-MAX depict this device's status as "Not Present".

So if we unload the FTDI driver (ssh->rmmod) then NI-Max can detect the device but as an USB raw device. That mean, I can't use the already available RS485 library. Because they look for any serial port.

I wish there were some PORT for RS485 like sbRIO.

NI Employee
on

Hi,

   Can you give your device name and the version of LabVIEW/myRIO? I didn't try this on too many USB-RS485 devices but just several and they all work. As I remember, I also encouter your problem when there is problem setting the symbol link of ttySn to ttyUSBn. Off cause, maybe there is also the case that myRIO 2013 only supports several USB-RS485 devices.

Member
Member
on

The device is from ROBOTIS, called USB2DYNAMIXEL, which is actually an USB to FTDI device. So when I connect that to myRIO, it load two modules "ftdi_soi" and "usbserial". Also ttyUSB0 shows up as well as the symbolic link. So it shows up in NI-Max (ASRL3) with the status "Not present".

So when I tried to access that with NI-VISA, it says resource is not available. That's why I thought maybe if I release them from the occupation of Linux RT, that might help NI-VISA get the hold of it. But then it shows up with a RAW USB.

I am using myRIO 1900 and Labview 2013.

NI Employee
on

It seems this device is not a "standard" FTDI device, or at least not directly supported by the current myRIO existing driver. You may notice, you still need to install a driver on windows for this device. While the RS485 device in the above tutorial can directly work without any additional driver on Windows. I also find there is driver source code provided by ROBOTIS and the procedure of compiling it on a linux system. You can use the myRIO C compiler to compile the driver for the myRIO system.

C/C++ Development Tools for NI Linux Real-Time:

http://www.ni.com/download/labview-real-time-module-2013/4286/en/

Member
Member
on

Actually, no. At least for windows 7, you don't need to install driver. It automatically detects the driver (not from windows update).

The procedure of compiling driver is for "ftdi_sio" and "usbserial", but those are the same modules that automatically load when I connect my RS485 with myRIO. Do i really need to do that? Wont it be redundant?

Also any kernel after 2.6 already has FTDI drivers. I already checked with Ubuntu. It works fine. Ubuntu also load this two modules, and I can send-receive data through minicom.

Any suggestion?

NI Employee
on

I am afraid not all such devices are supported by myRIO now. I didn't test this device yet, since I don't have one. Here is a list of devices that tested on myRIO: https://decibel.ni.com/content/docs/DOC-37389

This tutorial just tell you how to show the supported USB device in MAX and use it in your LabVIEW program.

Member
Member
on

Thank you so much for helping me out.

Member
Member
on

If anyone doesnt get the expected result from the tutorial, you can check this discussion, this solved my problem. All I had to is change the permission of ttyUSB0 for read and write, publically ( I did that through Filezilla ).

https://forums.ni.com/t5/Academic-Hardware-Products-ELVIS/FTDI-interfacing-With-myRIO-Linux-RT/m-p/2...

xkingkiller: Now i need your help on the permission part. I have to do that everytime, is there anyway to automate that everytime myRIO starts or detect the ttyUSB0.

NI Employee
on

If you are using the latest firmware (2.0.0f2) of myRIO 2014, you can add a udev rule by adding a file: ttyUSB.rules under /etc/udev/rules.d/ folder with content:

KERNEL=="ttyUSB*", MODE="666"

You can get the latest firmware by installing myRIO 2014.

Member
Member
on

"ttyUSB.rules" should be the file name, right?

NI Employee
on

Yes, you need to create this file. You also should be able to see some other *.rules files in that folder.

Member
Member
on

hi xkingkiller

I used the USB devices called USB2DYNAMIXEL.The device is from ROBOTIS,I want to connet it between AX-12A motor and myRIO .

So I follow the steps from your topics,but in the step 1 I use the putty to login

myRIO and type the following commands #ls /dev/ttyUSB*  but I cannot see anything about ttyUSB0.Did I miss something?  I was new to Linux and I tried my best

to search for something that could be help But it didn't work...... 

Can you give me some advices about this

1.png

Active Participant
Active Participant
on

Hi roger_741.

Can you log into the target (either by the serial console or over ssh) and report back what the kernel shows when you plug in the device? You can access that by running the commanddmesg right after you've plugged in the device.

Member
Member
on

Hi BradM

Really thank for your replied.I type the command dmesg after i plugged in the device in myRIO.Then it show up below.

12.png13.png14.png15.png16.png17.png18.png

Active Participant
Active Participant
on

roger_741,

Can you edit your previous post, removing the images since they don't really give me any information and, further, it seems that the messages indicate that you don't have the USB2DYNAMIXEL device plugged in.

Now, for further digging, remove the USB2DYNAMIXEL if it's plugged in. Plug it back in and (within a minute or so of plugging it back in) issue the command dmesg | tail. Post those results.

Alternately, you could install lsusb to the system to list usb devices, but if you can get the info without needing to install anything, no reason to. Just letting you know it's an option.

Note, from PuTTY, you can just select text with your mouse and that puts it in your text clipboard (so you can paste it) as I recall, it's been a while since I've used it.

Member
Member
on

I am trying to interface MyRIO with a Bluetooth 4.0 mini USB adapter (BTA800) (Cirago BT 4.0)

This device is listed as part of USB devices tested with NI Linux RT at:

https://decibel.ni.com/content/docs/DOC-37389

Following the instructions from:

http://digital.ni.com/public.nsf/allkb/94A534CA79F​F8A7E86257C670068ED2B

It seems that the BTA8000 is being recognized and usable by the NI Linux RT in MyRio. Here is what I get after running "dmesg":

[ 222.681942] Bluetooth: Core ver 2.16

[  222.689417] NET: Registered protocol family 31

[  222.689438] Bluetooth: HCI device and connection manager initialized

[  222.689463] Bluetooth: HCI socket layer initialized

[  222.689481] Bluetooth: L2CAP socket layer initialized

[  222.689571] Bluetooth: SCO socket layer initialized

[  222.696644] Bluetooth: Generic Bluetooth USB driver ver 0.6

[  222.709461] usbcore: registered new interface driver btusb

And here is what I get after runnig "lsmod" command:

btusb 10618 0 - Live 0xbf3bf000 (O)

bluetooth 155346 1 btusb, Live 0xbf35b000 (O)

Then, when I check for ls /dev/ttyUSB*, I can't find ttyUSB0

What am I missing?

Active Participant
Active Participant
on

The adapter you listed is a more traditional bluetooth device, doing more than just serial (and, consequently, doesn't automatically assume anything about the BT adapter).

You should probably do a bit of research on how you want to use the thing and the tools to interact with bluetooth on linux (as I recall, bluez on current releases of the base OS for NI Linux Real-Time). Ultimately, when configured properly, you'll configure a device file called something like /dev/rfcommN where N is a number. This device file will behave much like the /dev/ttyUSBN device that is automatically created on the (much more limited, functionality-wise) USB-to-serial adapters out there.

Member
Member
on

Where can I find bluez version that works in NI Linux RT?

I installed bluez4 package in MyRIO that I found at: http://feeds.angstrom-distribution.org/feeds/next/ipk/eglibc/armv7a/base/Packages using opkg, but it doesn't seem to be working properly. Is there a proven package somewhere?

Active Participant
Active Participant
on

Updated: forgot that you are using the earlier release of the MyRIO kernel with the backports with BT support

As noted in the linked document, the Cirago adapter noted is "in-work", as in the person who put together that document was unable to get the adapter working satisfactorily.

Fundamentally, what is it that you're trying to accomplish, with what hardware (what BT device do you want to connect the Cirago adapter to?) and what software?

Member
Member
on

I am trying to connect MyRIO directly with a Thalmic Myo gesture control armband ( https://www.thalmic.com/en/myo/ ), without a Windows host computer to implement the interface, and use this armband to control an i-Robot (i.e. use a Labview VI running in MyRio to receive data from the armband, interpret the gesture information and send the corresponding command to the i-Robot through serial communication).

I just learned that the Myo Armband only works with its own USB BT dongle, and not with 3rd party USB BT dongles.

I connected Myo armband USB BT dongle into MyRIO, then I tried to configure it using hciconfing commands and hcitool commands, but they are not working for this BT dongle, as they did for the Cigaro BT dongle.

It seems MyRIO is detecting the Myo Armband BT dongle as a serial port (ttyACM0), instead of a BTUSB (hci0).

I will  follow instructions on above document to make Labview recognize the Myo BT dongle as an ASRL.

Still I need to figure out how to interpret data coming from the armband, if I can actually see it in Labview... first step first.

Another scenario I am considering is to use an application running in an android phone that uses the phone accelerometer  to control the i-Robot through BT.  For this case, I need to make the Cirago USB BT dongle pair with my Android phone... I can configure Cirago USB BT dongle connected to MyRIO using hciconfig comands and hcitool comands, from the command prompt / SSH terminal, but I can't make it pair with my phone, using a BT-Agent python script. It seems I am missing something: Bluetooth service is not starting for Cigaro USB BT adapter. I have not figure it out how to properly start a BT service in NI Linux RT??

Active Participant
Active Participant
on

It seems like there is enough prior work for you to get where you need to be for the Myo Armband.

For the other use-case, were you also planning on creating/using an application to export the accelerometer values over one of the BT profiles supported by your phone? I'm unaware that a profile for that exists, specifically, unless some vendors already bake that into some flexible profile (e.g. GATT, HID, etc.) and handle that for you.

Where did you get the "BT-Agent python script"? Is it part of the pybluez package?

Member
Member
on

BradM,

I found the "BT-Agent python script" at:

https://gitorious.org/bluez/mainline/source/a04f48420ffc2c1a33e743d5075f24809161b2fd:test/simple-age...

I am getting an error when I try to run this script in NI Linux RT MyRio, using SSH command prompt, to pair Cigaro BT dongle connected to MyRIO USB port, with another BT elabled device:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.bluez was not provided by any .service files 

For more details please look at my question at the NI Linux RT community:

https://decibel.ni.com/content/thread/27722

I need help to figure it out how to add org.bluez to a .service file, in NI Linux RT??

Active Participant
Active Participant
on

You need bluez to be running as a service/daemon which will advertise the org.bluez service on the system DBUS (inter-process message passing system)

Member
Member
on

i need to use a usb to com device from ftdi with a myrio. do you know the path where to safe the file in windows instead of linux? hope you can help me.

Member
Member
on

I am having a similar issue as yours.

My application needs direct connection between myRIO and the SHIMMER sensing device without PC in between, however we could not establish the Bluetooth connection neither with the BT dongle nor BT module. Did you manage to connect it?

Member
Member
on

Hola a todos, soy tratrando para comunicarse con cRIO USB2Dynamixel conrolador 9014 por purto USB. La comunicación no puede alcanzar ningún tipo de ayuda, gracias a cualquier tipo de colaboración.

Active Participant
Active Participant
on

Hola Rlara,

Desafortunadamente el 9014 controlador no usar Linux,  así que lo que estamos tratando no es compatible

Member
Member
on

Hola Brand, Gracias por responder, afortunadamente cuendo con un cRIO 9031 con NI Linux RT y funciono perfectamente. Ahora el problema es, estoy tratando de conectar un Logitech Gamepad en el puerto USB y no lo reconoce.

No entiendo porque en el cRIO 9014 si lo reconoce.

Contributors