LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequential Line Writing to DAQPad-6507

Hi, I've been trying to write a VI that will write to the lines on a DAQPad-6507 (USB) and I'm currently using LabVIEW 7.1

I've programmed out a (rather bulky) VI that currently is able to be preprogrammed (by a user) before the VI is run. When the VI is run, each "row" of switches is read, and the corresponding lines are turned on for the specified times (in the numeric array). The file is attached and is entitled "Alternative 2D Array".

However, again, I stress that the VI is rather bulky, and it will be difficult if (say) there are 30 "rows" for every 8 lines (as each port has 8 lines). When trying to control all 96 lines (in 12 ports), there would be 12 groups of those switches, with multiple rows, which would be very space consuming in addition to being inconvenient to use.

Is there some possible way in which the user can specify a starting line (i.e. line 0 - 7), then have a VI that will turn on the first line specified by the user, then after some (set) time interval, that user specified line will turn off, and the next line will turn on.

I.e. let the user inputted start line be a

When the VI is run, a turns on, after (say) 5 seconds, a+1 will turn on, while a turns off. After another 5 seconds, a+2 turns on, while a+1 turns off. This continues until the user inputted stop line (b).

Thus, the sequence will look something like:

a, a+1, a+2 .... b-1, b

I was thinking of perhaps even modifying the current VI that I have (Alternative 2D Array) so that it can achieve what I want, but I'm not too sure how to proceed.   
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 1 of 23
(2,978 Views)
I've managed to make a program that writes to the first 8 lines in sequence for the first port.

However, I am currently having trouble expanding this program to encompass 16 or more lines (as the next 8 lines are on another port).

I've uploaded the VI for review as well.  
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 2 of 23
(2,951 Views)
Hello Anthony_Wong,

I think you have the walking high portion of your code figured out and you are just working on writing to multiple ports.  The example Write to Multiple Ports on 6507 and 6508 Devices is a good reference for writing to multiple ports on the DAQPad-6507.  The example program has an array of 8 switches for each port.  You could modify the program to work with the user specified starting and stopping points on different ports by adding a case statement that looks for the last line on a port, and on the next iteration writes a low to that line and a high to the LSB of the next port.  If you use the array controls in the above example, it would be as simple as determining what port is being written - which would give you the array row, writing a 0 to that row and a 1 to the following row in the array. 
 
Let me know if I didn't understand your question or post again if you have any other questions and we'll try to help you out.

Regards,
Micaela N
National Instruments
0 Kudos
Message 3 of 23
(2,935 Views)
Hi McKale[DE],

I took a look at the examples called "Write to 2 Dig Ports(8255).vi" and was using that to aid me when I designed the above VI.

However, my current problem is the following:

Say the user inputs the starting line to be line 7, and the finishing line to be line 10 (which is line 3 of the next port). What should supposedly happen is to have line 7 turn on, then line 8 (while line 7 turns off), then line 1 of the following port will turn on (line 8 of the previous por turns off), and so forth, until line 3 of hte second port is turned on. Of course, this situation should be reversible as well (say the user inputs line 10 to be the starting, and line 7 to be the finish).

Hopefully, the user should be able to simply type in the numbers in the two numeric control boxes, rather than using an array.

I am not too sure how to use a case statement that will be able to check to see if it is writing to the last line of the port, and if it is, proceed to write a low to it and a high to the first line of the proceeding port.

Message Edited by Anthony_Wong on 05-30-2006 02:24 PM

Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 4 of 23
(2,934 Views)
Hi Anthony_Wong,

I may be misunderstanding your question, but I think you are asking how to go about writing to the lines.  If I am going into too many details, I apologize!

You could first determine what port and line your user specifies as the starting line and ending line by dividing the starting line number (minus 1, if you use one indexing for the lines) by 8, the quotient would be the port number and the remainder would be the line number.  For example if your user said he wanted to stop on line 10 and you are using zero indexing - you would know this was port 1, line 3.  You could do that for both the starting and ending line.  Then you would be able to keep track of what line and port you were currently writing to, each iteration you could compare the line number to 7.  If you were currently writing to 7 you would set the next line to be zero and iterate your port, if you were writing to another line you would just iterate your line.  You could do this for the number of lines your user specifies to write. 

You would just do the opposite for the reverse, looking for line 0 and decrementing the port or line each iteration. 

Let me know I didn't answer your question, or if you have further questions,
Micaela N
National Instruments
0 Kudos
Message 5 of 23
(2,909 Views)
Hi McKale[DE],

Thanks for your help, I do know how to write to the lines, but I was having trouble writing to them in a sequential order [b]for more than 1 port[/b] (say lines 1-8 for the first port, then lines 1-8 for the proceeding port). However, I have no trouble writing to the 8 lines of (any) port.

Your method does make sense, however, I have been controlling the digital port input for the Port Config VI via the Traditional DAQ Channel in the I/O palette on the front panel.

Unfortunately, there does not seem to be a way to have the "remainder" portion of the Quotient and Remainder VI wired up to the Traditional DAQ Channel VI.
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 6 of 23
(2,906 Views)
Hi Anthony_Wong,

I'm not really sure I understand your question.  You will need to determine the port in software and then write to the Port Write VI for that particular port.  So first, determine the port and then second write to the port.  You can write to multiple ports at the same time; however, if you use the Group Write VI you can address all the ports and lines at the same time.  If you would like an example of using the Group Write VI, look at the Alternative 2D Array VI

Or if I'm not addressing your question, could you ask it again?

Regards,
Micaela N
National Instruments
0 Kudos
Message 7 of 23
(2,900 Views)
Hi McKale[DE],

I understand that my problem is confusing, but I will attempt to clarify as best as I can.

Attached, I have included a VI that does what I want it to do, but this only works for 8 lines (I want to be able to expand this).

On the front panel, you will notice two numeric controls "Start Position" and "Stop Position". The user will input the starting location (let's call it a) and then the stop position (let's call this b).

When run, the program will turn on (in sequential order) line a+1, then line a+2 (thus turning off line a+1), then line a+3 (thus turning off line a+2).....and so forth until line b is turned on.

By expanding the program to encompass more lines (say 16, 24, or 32 lines), I assume I will have to address multiple ports (not at the same time, but I will have to address a multiple number of ports).

For example, when expanded, the user can input the Start Position to be 1, while the Stop Position to be 16

Thus, the program should turn on line 2 on the first port (let's call it 2A). Then it will turn on 3A (thus turning off 2A). Then it will turn on 4A ....... at 8A, it will somehow "recognize" that since the Stop Position is greater than 8, it must call the next port, and thus writing to the first line of the second port (1B). This continues until the last line of the second port (16B).

Note: I have called the first line in the port as line 1, thus the last line is line 8 (rather than the first line being line 0, and the last being 7)

Hopefully, this has clarified some things.

Message Edited by Anthony_Wong on 06-02-2006 09:40 AM

Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 8 of 23
(2,899 Views)
I put this together, it takes a starting and ending line and write to each line between the two. It will go between ports using the Quotient and Remainder function.  It will only work if your starting line is smaller than the ending line, but it can easily be expanded to include both incrementing and decrementing lines.  Let me know if this idea will work for you!

Regards,

Message Edited by McKala[DE] on 06-05-2006 02:33 PM

Micaela N
National Instruments
0 Kudos
Message 9 of 23
(2,884 Views)
Hi McKala[DE],

Your idea sounds like a good one, but I can't open your VI, as I am currently only using LabVIEW 7.1

Is it possible for you to re-save it so that it can be opened by LabVIEW 7.1?

Thanks for your help  
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 10 of 23
(2,879 Views)