Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the USB Port on cRIOs/sbRIOs

Hi all,

 

I’ve got a burning question about the USB port on CompactRIOs.  I know besides storage devices, the USB on cRIOs and sbRIOs right now don’t support much, mainly due to an RTOS instead of Windows.  But I’ve played with using the USB port from a cRIO to connect to Hokuyo LIDARs, and they work, thanks to NI’s instrument driver.

 

I was curious to see what was the going on under the hood – after all, people have begged for it here and here.  It turns out the Hokuyo LIDAR actually has a USB-Serial chip built in, you’ll see this if you hook up a Hokuyo via USB to a PC, another COM port shows up in the Windows Device Manager.  So I thought, maybe if I took something else with a USB-Serial built-in (an Arduino board, for ex) and hooked that to the cRIO’s USB, I could keep using plain VISA to get them to communicate as well.

 

My hopes were raised even higher when I peeked inside Initialize.vi (cRIO-USB) from the Hokuyo instrument driver to see what was going on (see pic), and the only change was that the USB Raw VISA Resource into an Instr type.  The rest of it looks like the regular Hokuyo initialize VI from before.  Nothing else changes.

 

So I uploaded a simple program on the Arduino which all it does is spit out “1023” from its serial port in ASCII.  The Arduino is set at 9600 baud.  I hooked the Arduino to my PC and read the data back in LabVIEW, here’s what I saw:

 

ASCII:

1023 <CR><LF>

1023 <CR><LF>

(repeating endlessly…)

 

The same thing in Hex:

3130 3233 0D0A 3130 3233 0D0A ….

 

However when I do the same thing from my cRIO, the data looked very different:

Hex:

0172 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0172 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0162 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0162 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0170 0000 0000 0000 0000 0000

 

(A pic of my cRIO code is attached as well)

 

So the real question is, why is it in Hokuyo’s case, only a type cast was added to use the USB and the resultant data from the device remains the same, yet I did the same for an Arduino but the resultant data is altered?  Can someone give an explanation to this?  Is it because the Hokuyo runs at 500kbaud, while my Arduino only runs at 9600?  This would explain the padding, but I can't make sense of the 0172's.

 

It seems as though Brian Powell from NI might know something about this.  I'm hoping he might jump in on this thread.

 

John Wu

Riobotics Consulting

Download All
0 Kudos
Message 1 of 1
(5,500 Views)