Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to build an array of boolean data type?

Hello,

 

I am using NI9474 Digital Output Module to control 4  valves. The valves are connected to digital output ports of NI9474 and are controlled manually using boolean controls from front pannel. Suppose initially all the four valves are swirched off, i.e., all the four boolean controls are off. Now as soon as any one of the four valves is opened/closed (any one of the boolean control is turned on/off), I need to record at what time this valve was opened/closed and the positions of all the four valves at this particular instant of time.

 

Suppose, Valve 2 is opened at time 10.5 seconds from the start of program, then Valve 4 is opened at t=21 s, then Valve 1 opened at t=24.3 s and closed at t=45 s. The data should be exported to an excel sheet in the following format:

 

 

Time Valve 1 Valve 2 Valve 3 Valve 4
10.5 s OFF ON OFF OFF
21 s OFF ON OFF ON
24.3 s ON ON OFF ON
45 s OFF ON OFF ON

 

 Can anyone please help me in this regard? I will be very thankful to you.

 

Vilas

 

0 Kudos
Message 1 of 8
(5,906 Views)

Vilas,

 

Thank you for posting to the NI Forums. I have constructed a simple program that will record when you changed the controls of a boolean array and save the time and values to a spreadsheet file. Hope this helps. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 2 of 8
(5,887 Views)

Hello Aaron,

 

Thank you very much for your reply. I tried to execute the VI, however it gives an error message when I click on either 2nd, 3rd or 4th Boolean button. Please find the attached screenshot of the error message and output file. I m using LabVIEW 8.6 and 7.1.

 

Also I am a beginner in LabVIEW programming and am using it my research project. I am trying to learn it myself by referring to LabVIEW Help and Examples. Please find the attached LabVIEW program written by me to record valve states (1 or 0)  after every 5 second time interval. Please pass your comments on the logic used ad whether I am going on right track or not. Previously I used to do C programming, so I am a bit confused between LabVIEW and C programming. I am quite good at text based programming, but graphical programming and the parallel processing features of LabVIEW make me confused. Please guide me.

 

Thanking you in anticipation,

Vilas V Jangale

0 Kudos
Message 3 of 8
(5,876 Views)

Vilas,

 

Looking at the error that you sent me, it was caused because you need to give the file path for where the document will save. I had saved the program for LabVIEW 8.0, which should work for LabVIEW 8.6, but I will attach the LabVIEW 8.6 Version that I wrote the program in. As far as the program that I have attached goes, it takes an initial system clock reading and whenever a change is made in the boolean controls it takes note of the current system clock time and finds out how long it has been since the program started, this giving you a time in seconds in which one of the inputs were changed. 

 

When learning LabVIEW it is a good idea to look at the Help and Examples as they have some very good examples that you can use to build just about any program. I will rarely build a program from scratch and will almost always adapt an example program for what I need. We do have some good tutorials online that you can search for that will go over different concepts. I would recommend starting with the LabVIEW 3 Hour Tutorial that will take you through the basics of LabVIEW for beginners. This tutorial will give you a better insight into the graphical programming language. 

 

Getting Started with NI LabVIEW Student Training: 

http://zone.ni.com/devzone/cda/tut/p/id/7466

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 4 of 8
(5,866 Views)

Vilas,

 

I forgot to attach that VI, sorry, here it is. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 5 of 8
(5,862 Views)

Please find the attached file for error message screenshot. I selected a file in the “Choose file to write.” dialogue box. However after successfully selecting a file to write, as soon I click on any Boolean control, an error  message is displayed as follows.

 

“Error 7 occurred at Open/Create/Replace File in Write Spreadsheet String.vi->Write To Spreadsheet File (string).vi->Clock Boolean Control_8.6.vi

 

Possible reason(s):

 

LabVIEW:  File not found. The file might have been moved or deleted, or the file path might be incorrectly formatted for the operating system. For example, use \ as path separators on Windows, : on Mac OS, and / on Linux. Verify that the path is correct using the command prompt or file explorer.

=========================

NI-488:  Nonexistent GPIB interface.

 

C:\Documents and Settings\awiseman\Desktop\test.xls

 

Why the path “C:\Documents and Settings\awiseman\Desktop\test.xls” is displayed in error message? Is it where you selected to save your output file? If it is the path selected by you, while running this VI, why is that displayed in this error message?

0 Kudos
Message 6 of 8
(5,792 Views)

There are a couple of mistakes in the example VI. First is that in the Array value change event, the path is as you mention. Second mistake is to use a local variable in the Stop value change event. The New File Path output of the Write to Spreadsheet in the first frame should be wired to the File Path inputs of the Write to Spreadsheet functions in both events.

 

Oh, and while you are at it, remove the sequence structure, move the stop button into the Stop event, and wire that through the structure to the termination terminal. Also, right click on the Browse button and change the options from New to New or Existing. Optional is to combine the Array value change and Stop value change into a single event. Two separate events that do exactly the same thing are not really necessary.

 

 


 

Message Edited by Dennis Knutson on 02-28-2009 04:01 PM
0 Kudos
Message 7 of 8
(5,789 Views)

Villas,

 

That document path is where I had saved the test file on my computer that I created. The error was caused because it could not find that specific file directory on your computer. Just make sure that the path you give the program is an existing directory on your computer and that error should go away. Let me know if you have any other questions. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 8 of 8
(5,759 Views)