LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

User specified line writing to DAQpad

Hi all,

I was wondering if there was any method for a user to specify the lines that would be written to on a DAQPad-6507 with Labview 7.1.

Say the user designs an m x n matrix with various numbers; i.e.

17    34
10    96

The program will then create the same matrix dimensions, except this time in an ON/OFF boolean switch array. However, in the m x n array, each boolean switch, when turned on, would write to the corresponding DAQPad line.

So in this case, if you had a boolean array that appeared as follows (where the O's represent on/off buttons)

O      O
O      O

Then the top left button, when pressed, would turn on line 17, the top right button would turn on line 34, and so forth.

I'm currently thinking to approach this, I should take the array, and index each value, however, I believe I would have to take each number specified by the user, and divide by 8 (rounded up) to arrive at the correct port number. Dividing by 8 and taking the remainder of each user inputted value would result in the correct line number.

Then somehow, I would need to take this modified information and feed it to the Write to Port VI.

Any help/suggestions on this topic would be appreciated,

Thanks,

Anthony Wong
University of Toronto
Chemistry Department  
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 1 of 5
(2,642 Views)
Hi Anthony,

Your idea can certainly be implemented.  The most direct way might be to take the given values you come up with.  Looking at your application I am not sure why you need to divide by 8, but each element of your 2d array will be a single boolean value or one line.  So you would have to know which port and line every element belonged on.  If you knew this, I would think taking the values of the array and creating a string based on that which would refelect the proper ports would be the most efficient way to get the information to the Write to Port VI.  I am still not sure if you need to use the write to port or write to line version of the polymorphic VI.  The two ways I see to do it are to programatically generate the string, or if you know how many different output combinations you would have to have  acase structure that based on the information in your array had the appropriate digital write pre created.

I think formulating your string would be more effective, but if you could explain the logic of dividing by eigth to get the correct port number I think I would have a better grasp of where we are going.  Please let me how I can continue to help you.

Have a great week,

Michael D
Applications Engineering
National Instruments
0 Kudos
Message 2 of 5
(2,625 Views)
Hi MickeyD,

Thanks for your response, I haven't checked this thread for a few days due to looking over some code and such.

I've been working on a program (that is attached below). In it, when the program is run, the user selects a tab delimited file with appropriate data, and it is then read and the appropriate lines written to on the DAQPad. I have also attached the tab delimited file, if you are interested in seeing the format I am currently using (the header incidates the dimension of the matrix, and each matrix is headed by the time to keep each step running for).

You will notice that each numeric value (0, 1, 2) will carry out 1 of 3 possible boolean choices: T/T, T/F, and F/F.

A major setback with the current program I have written is that the input tab delimited file can only be read in a top to bottom, left to right manner. In essence, the top left cell must represent the first 2 lines of the DAQPad, the next cell would represent lines 3 and 4, and so forth.

Ideally, a user would be able to specify beforehand which two lines each cell would activate (i.e. the user inputs the first cell to activate lines 9 or 10, and from there, can specify either a T/T, T/F or a F/F case).

Also, dividing by 8 was not required for determining and writing to the correct port; it was an oversight on my part.  

Anthony Wong
University of Toronto
Chemistry Department
Download All
0 Kudos
Message 3 of 5
(2,616 Views)
Hi Anthony,

It looks like you were busy with getting some code working. 

I was just looking at your notes and is the lack of abort button a problem, because the stop button appears like it should shut down your VI.  It is best to avoid using the abort button, because it can prevent your devices from being reset.  I also was wondering why you would want a continous run button, because that is something you can easily implement in your code if you need it to work that way. 

With regards to your setback.  You are going to have to read the text file, but you could certainly create a user interface that allowed the user to select which line each cell in their array was selecting.  You would probably have the easiest time doing it by actually creating an equivalent array and then allowing them to select the necessary line numbers, then just go through that array and select the line numbers.  The main point is that if you want to do it in your program you could create a UI to do it, but the file is giong to be read the way it is, and there is no real way around that with a tab delimited text file.

Doing that would make the group config more challenging.  I am unsure what board and version of LabVIEW you are using and if this app is working for you that is fine, but using NI DAQmx is a much easier solution and will give you better functionality with regard to picking the lines that you are writing to.

Please let me know if there is any further information you need with regards to this application.

Michael D
Applications Engineering
National Instruments
0 Kudos
Message 4 of 5
(2,603 Views)
Hi MickeyD,

I understand that currently, the "stop" program halts the entire VI, however, I was hoping to find a method of stopping the execution of the For loop (currently, I don't believe it is possible to stop in the middle of a for loop iteration). Ideally, the abort button would first reset the device (i.e. write null values to all the line), and then prevent the For loop from beginning another iteration.

Again, the "continous run" button would allow users to press the button, and the entire For loop would repeat continously (i.e. after the last n interation is run, it jumps back to the first m iteration and repeats).

If these implementations are possible, please shed some light; as far as I was made aware, it was impossible to halt the For loops in the middle of its iteration.

For the user interface that allowed them to select each line each cell in the array was writing to, I believe your suggestion is good. I was thinking along the same lines, by generating an equivalent array. The goal is to have users specify which group of lines each cell will write to, and then input a 0, 1 or 2 value. Then the program will have to figure out which lines in reality to write to (note that currently, each cell can have 3 possible values: 0, 1, and 2. This gives boolean values of T/T, T/F and F/F. With F/F, no line is written to. With T/F, line 1 is written to. With T/T, line 2 is written to).

In reality, this means that the user will be specifying in the cells numbers from 1-48, but Labview (or the programmer!) will have to interpret a user inputted value of "3" as lines 5 and 6, and, then depending on the user input again, will have to determine whether to write to line 5 or 6.

For example: In the first cell, the user specifies "2" and in the next cell, the user specifies "3". Then another identical array appears, and this time, the user inputs (right now, using a picture ring, but it really is translated to a numerical value anyways) a translated value of 1 in the first cell. In the next cell, she inputs a value of 2.

Translated through LabVIEW, the program should then be able to write to line 3 and line 6 of the DAQPad (inputting "2" indicates we are looking at either lines 3 or 4, and the next value of "1" indicates we are writing to the first line of this pair. Similarly, the value of "3" indicates we are looking at lines 5 or 6, and the next value of "2" indicates we are writing to the second line of the pair).

Ideally, this is what the program should do, but I am currently quite unfamiliar with the user interface, and would prefer to keep it as simple as possible.

Of course, I understand that implementing this would be challenging, but that challenge has been left up to me. As mentionned in my first post, I am currently using LabVIEW 7.1 with the DAQPad-6507 (USB).

Unfortunately, I have checked the DAQPad specifications in the past, and it is unable to support DAQmx. This is the reason my program appears as it is.

Please let me know if you have any further information pertaining to this,

Thanks very much
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 5 of 5
(2,592 Views)