LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to Digital Port (8255)

Hi, I'm new to LabVIEW and have some questions that may seem very basic, but please bare with me.

I am currently running LabVIEW 7.1 and using the DAQPad-6507 on WindowsXP Professional with SP2.

I am running the "Write to Digital Port (8255).vi" template that is found with LabVIEW, and when I connect the DAQPad-6507 via USB cable to my computer, I can successfully write to a port (i.e. when the switch is turned on, using a voltmeter, I can detect 5V; when the switch is off, the voltmeter reads 0V).

However, is there a possible way to configure the VI such that after (preferably a user inputted) some time, the switch will turn off automatically, thus writing a null value to the array and causing the voltmeter to measure 0V?

Ideally, from being able to turn off one port, I would like to be able to sequentially turn on/off multiple ports in a specific order. For example, at time=0 seconds, port 1 turns on. At time = 5 seconds, port 1 turns off, while port 2 turns on. At time = 10 seconds, port 2 turns off, while port 3 turns on, and so forth.

If there are any other template VI's that I could look at it, or if anyone has any suggestions please let me know   
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 1 of 13
(3,856 Views)

Sure, you can do everything you want with a little programming. I don't know of a specific example but you want to look at the wait and time delay functions on the Time & Dialog palette. A sequence structure could be used or you could use something more sophisticated and flexible called a state machine. There are shipping examples of both. Try to write something in LabVIEW and if you get stuck, post what you've written.

You might also want to check into the learning LabVIEW options available at http://www.ni.com/devzone/lvzone/fundamentals.htm.

0 Kudos
Message 2 of 13
(3,832 Views)
Well, I've configured the VI to do the following so far:

In the case structure for the "false" case, I have added in an addition Port Write and wired it up to the Port Config. When the VI is run, and the switch(es) toggled, this results in an immediate spike in voltage followed by a drop off (i.e. turns on, then turns off).

Afterwards, I have added a Numeric Control wired to a Wait (in milliseconds) to the "True" case in the case structure. However, when the numeric control that specified the Wait time was set to (say) 3000 milliseconds (or 3 seconds), and the VI run, there is an unwanted 3 second delay when the switch is toggled, then the voltage is on for 3 seconds, and then turns off.

I have managed to get rid of this 3 second delay for the first iteration of the loop, but I have not managed to be able to get rid of it for the proceeding iterations (i.e. if the delay is set to 3 seconds, for the first time the switch is toggled, I will get an immediate voltage being read for 3 seconds, and then it will turn off. However, if I were to toggle the switch again, there would be a 3 second delay.)

Is there any way to fix this problem? I was thinking of using a state machine, but am unsure as to how to proceed with its usage. (Please see attached VI "Write to Digital Port Auto off. vi")

On another note, is there a way to be able to control the writing of the lines on the DAQPad-6507? For reference, I have attached another file that does a (much) better job of what I am about to describe:

In essence, there is a numeric array that has many "cells". Each cell is in unsigned 8 digit binary format. In essence, what I want is to have the user input a series of values, i.e.

00000001

Followed by

00000011

Followed by

00000010

This should (theoretically) then be formatted in such a way so that at time = 0 seconds, the first line is written to for some user specified time (i.e. 3 seconds). Then LabVIEW should be able to "read" the next cell, and see that it should write to the second line as well (for some user specified time, say 1 second). Finally, LabVIEW should then read the final cell, and see that it should write to the third line, while turning off the first line.

All in all, I'd like to know if any of this is possible, and if it is, are there any hints that can be provided?  
Anthony Wong
University of Toronto
Chemistry Department
Download All
0 Kudos
Message 3 of 13
(3,823 Views)
If you have a 2D array of Booleans that define a series of patterns to write to a port, then all you need is something like the attached. A for loop automatically will index a 2D array into a 1D array and that is converted to a single port write. The for loop will iterate for the number of rows in the 2D array. If you want to modify the modify of patterns written (i.e. the number of rows), then put that logic in a while loop that runs before the for loop so it can be modified by the user. A run button in the while loop can terminate that loop and then the for loop will run.
0 Kudos
Message 4 of 13
(3,818 Views)
This is a 2D array with something that is similar to what I want, however, I am unsure if this will work.

When I use probes to check the VI, the probe placed immediately before the Port Write returns as a TRUE value, but the (physical) voltmeter connected to the DAQPad-6507 does not read a voltage at all.  

Message Edited by Anthony_Wong on 05-19-2006 12:39 PM

Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 5 of 13
(3,812 Views)
This will work if all you want to do is write the value of bit 0 in each row of the array and then keep writing long after the number of defined rows that is there. The example I posted will take the value of all bits in row 0, write that, then write the value of all bits in row 1, and continue until all of the rows have been written and then automatically stop. Your first array indexing, then the transposing, and another index array doesn't work the way I understand you want it. Why don't you set the values the forn panel Boolean array to what you want, select Operate>Make Current Values Default, and save the VI. Post that VI and explain exactly what pattern you want written to the digital I/O with each iteration.
0 Kudos
Message 6 of 13
(3,805 Views)
Here is the VI that I have written following your advice (I have titled it "Alternative 2D Array")

A small problem first, when I try to run the VI, I get a DAQ error, code is 10613:

Error -10613 occurred at DIO Port Write
Possible reason(s):
NI-DAQ LV:  The specified channel does not support the specified transfer direction, or you have performed an operation on a digital port or line configured for the opposite direction.

I am unsure of how to fix this problem, as I have never encountered it before, all the other VIs I have used work fine, without this error.

Now to explain the Front Panel.

There are 8 "columns" and 7 "rows". For simplicity's sake, I will refer to the left most switches as "switch 1" and the far right switches as "switch 8"

i.e.

1  2   3   4   5   6   7   8
9 10 11  12 13 14 15 16

and so forth.

What I want to be able to do is, for example, at time = 0, the VI will write to the DAQPad by "reading" the switches that are turned on in the first "row" on the Front Panel. In this case, the first and second lines will be written to. These lines must be continously written to (say for 5 seconds), such that a voltage can be read by a voltmeter. After this, the VI will read the next "row" on the Front Panel, and it will see that the first and second lines are to be turned off, while the third and fourth lines are turned on (and continously written to for say another 5 seconds).

This proceeds for the next 5 rows; after turning on the 3rd and 4th lines, the 5th and 6th lines are written to, then turned off while the 7th and 8th lines are written to. This then goes in reverse.

Ideally, the Front Panel Controls should be dynamic, i.e. regardless of the "pattern" that the user inputs on the Front Panel, the VI will be able to "read" the "rows" and write to the corresponding lines on the DAQPad.  

Message Edited by Anthony_Wong on 05-23-2006 09:40 AM

Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 7 of 13
(3,789 Views)
Interestingly enough, the forums refuse to allow me to edit my message anymore...

I have managed to fix the DAQ10613 error (a silly mistake on my part, I had set the Wired OR Map constant to be -1 rather than the Line Direction Map constant to be -1).  
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 8 of 13
(3,775 Views)
You've wired the -1 constant to the wired Or input. You should wire this value to the line direction map input to make the pins outputs.
0 Kudos
Message 9 of 13
(3,774 Views)
Thanks for your help Dennis!

It was a silly mistake on my part.

Currently, the Wait VI (milliseconds) applies a time delay between the reading of each "row". However, this is constant for all iterations; is there some way to make it possible for the user to specify how long the delay between each iteration should be?

I was thinking of a two dimensional numeric array that is wired to the Wait VI. Would I need another For Loop with another tunnel that has Index enabled?  
Anthony Wong
University of Toronto
Chemistry Department
0 Kudos
Message 10 of 13
(3,765 Views)