LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

9014 detecting USB memory

Hi,

 

I have a problem detecting if a USB drive is present on my NI cRIO 9014 controller. I have datalogging application where I want to save the data to the USB drive when the user switch is triggered if a USB stick is in the slot. I have tried to use many of the build-in file functions but they don't produce an error when no USB drive is present... ? In fact the controller can save files to \u\ and I can see the files when I use the List Folder.vi. To my understanding from the documentation that is availiable the USB drive root should be at /u/ and /c/ should be the system root? What can cause this behavior ?

 

-Nis

0 Kudos
Message 1 of 11
(3,196 Views)

Make sure your device is formatted in FAT16 or FAT32 file system.  The cRIO will not work with anything else.

 

Per your manual on page 8:

 

Untitled.png

 

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 2 of 11
(3,192 Views)

Also, you can try to use the Get Volume Info function to see if the U drive is mounted correctly or not:

 

Returns information about the volume containing the file or directory specified by path, including the total storage space provided by the volume and the amount free in bytes.

 

 

For example:

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If someone helped you out, please select their post as the solution and/or give them Kudos!
0 Kudos
Message 3 of 11
(3,185 Views)

Hi MrHappyAsthma,

 

Thanks for the input, but as I wrote I already tried all the different file I/O functions to use their error signal as indicator for the USB drive. I should also mention that my code works fine when the USB drive is there and the files are saved correctly to the driver. The problem is that the controller generes its own "virtual /u/ drive" when the USB stick is not there and saves the files there. And as I mentioned before the files on the "virtual /u/ drive" can be found with the List Folder function. Thus, the controller behaves as if a USB stick is present at all times which is not the case.

 

Best regards,

 

Nis

0 Kudos
Message 4 of 11
(3,158 Views)

Hi Nis.

 

 

That is expected behaviour.

 

The following KB describes it in details, and explains how to avoid it.

Why Does My cRIO Continue Logging Data when I Remove My USB Storage Device?

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
0 Kudos
Message 5 of 11
(3,153 Views)

Hi Alex,

 

Thanks for your reply. The solution you are linking to is very similar to what I initially did with didn't work. I have tried to run the following simple vi. And the results is that when the USB drive is removed the only things that are changing is the size of the volumen! The loop stopped has twice out of ten runs because an error was generated. When the status indicator was not connected to the loop stop, I never saw a "green light". So I am quite puzzeled by this.    

 

USB status test.png

Best regards,

 

Nis

 

0 Kudos
Message 6 of 11
(3,142 Views)

Hi,

 

I have found a work around which is less than perfect but it does the job. I have simply placed a file "Drivepresent.txt" on the USB drive which the system cannot find on the controller internal memory. Thus, an error is generated when the file is opened and the USB stick is not there. If a more rigid solution is possible I would very much like to hear about it, because I am working on something which is intended for more users and possibly more USB sticks.

 

All the best,

 

Nis

0 Kudos
Message 7 of 11
(3,133 Views)

Hi Nis.

 

 

I'm glad you found a work-around you can use.

 

In the meantime I tried the steps in the KnowledgeBase I linked to ealier. I grapped a 9014 and installed LabVIEW2013 and ran this code:

RT VI.png

 

 

When I run the code, and the USB is mounted, the code is running fine; Data is written to the USB and no errors. As soon as I remove the USB stick, the boolean "USB Detected" turns off and an error shows up. Since the error cluster is not wired to the stop condition, the code keep running, giving the same error in each iteration. As soon as I insert the USB stick again, the error goes away, and the application starts logging again.

 

Do you get a different behaviour if you run this VI?

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
Message 8 of 11
(3,116 Views)

Hi Alex,

 

I just tried running the script but I don't observe any changes when the USB stick is removed as before. Perhaps I should re-install the software on the controller ? The image below shows the software currently installed on the controller. If you can see something obvious missing then it migth be that ?

cRIO-9014 - software installed.png

 

If you have a list of the software you installed on the driver, I could try to dublicate that on my system ?

 

Thanks,

 

Nis

 

 

0 Kudos
Message 9 of 11
(3,107 Views)

Hi Nis.

 

It seems weird. Try to format your controller (but set a checkmark in the preserve network settings) and install the software again.

 

This is the list of software I have currently installed:

Software9014.PNG

 

Best Regards

Alex E. Munkhaus
Certified LabVIEW Developer (CLD)
System Engineer
Message 10 of 11
(3,095 Views)