07-22-2014 11:02 AM
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
07-22-2014 11:07 AM
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:
07-22-2014 11:15 AM - edited 07-22-2014 11:16 AM
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:
07-23-2014 02:09 AM
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
07-23-2014 02:23 AM
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?
07-23-2014 04:14 AM
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.
Best regards,
Nis
07-23-2014 05:43 AM
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
07-23-2014 08:30 AM - edited 07-23-2014 08:31 AM
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:
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?
07-23-2014 09:15 AM
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 ?
If you have a list of the software you installed on the driver, I could try to dublicate that on my system ?
Thanks,
Nis
07-24-2014 01:34 AM
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: