Discussion:
Open valve digitally
(too old to reply)
sheranko
2008-08-12 13:40:20 UTC
Permalink
I need to write a VI that will send a 5V signal over one of my 8 digital pins and a ground. In turn this will open a valve when the 5V is across these two and close when there is no voltage. I have been learning LabVIEW but haven't really received or found anything that is sufficient on working with the external things.  Can anyone help me out?
Dennis Knutson
2008-08-12 14:10:12 UTC
Permalink
I'm pretty certain that the Getting Started with DAQmx link I provided goes over this but in case you missed it, it's really quite simple. Shown below is code using the DAQmx functions and using the DAQ Assistant. The object between the control and the DAQ Assistant is a Build Array function. Note that these are for controlling a single line. You can also control multiple lines at the same time.
All of the functions are on the Measurement I/O>DAQmx palette. The functions are polymorphic. That means that in order to select the actual function you want, you need to right click and select - Select Type. Or, you click on the arrow of the Plolymorphic VI Selector (the little box below the function. The DAQ Assistant walks you through the creation of a DAQ task.
<img src="Loading Image..."> Message Edited by Dennis Knutson on 08-12-2008 07:48 AM


Basic Digital Output.PNG:
http://forums.ni.com/attachments/ni/250/42249/1/Basic Digital Output.PNG
sheranko
2008-08-12 14:10:12 UTC
Permalink
I was looking through all those links and I guess I'm not looking in the right place. I have no idea what most of these things do on this picture. It is not at all trivial to me.
Dennis Knutson
2008-08-12 14:40:26 UTC
Permalink
You will need some time (at least a week) to go through the tutorials and all of the lessons before you can start writing any code of your own. The specific tutorial on Digital I/O with the DAQ Assistant can be found at <a href="http://zone.ni.com/devzone/cda/tut/p/id/2744#toc5" target="_blank">http://zone.ni.com/devzone/cda/tut/p/id/2744#toc5</a>. This covers digital input but digital output is similar.
When you do start writing code, you should always have the context help window open (Help&gt;Show Context Help). As you move your mouse over a function on a palette, you get a brief description. Fully detailed help is also available.
wkc3348
2008-08-12 20:40:26 UTC
Permalink
Hi Dennis,
&nbsp;
This case might be applicable to my problem as well.&nbsp; Do you mind attaching the vi?&nbsp; I was trying to set it up in LabView but can't link the Channel to the Lines in DAQmx though.
&nbsp;
thx
wkc
Dennis Knutson
2008-08-12 20:40:26 UTC
Permalink
The code is above. I don't know what you mean by linking the channel to the lines. Why don't you post your code.
sheranko
2008-08-12 14:40:27 UTC
Permalink
I went through that page and tried it but I don't understand how to make it work. I just go through the steps then always end up with this box on my screen that says DAQ assistant. I have no idea how to turn it on or what to connect to it to do so.
Dennis Knutson
2008-08-12 18:10:09 UTC
Permalink
With the DAQ Assistant and a digital output task, the data input expects an array of Booleans. This is default behavior and not really all that useful for controlling just a single line. What you should do after configuring the assistant, is go to the front panel and create a Boolean control. Any type of Boolean will do. If you do not know how to create a Boolean control or do not what the front apnel is, you really, really need to spend some time with the LabVIEW basics class.
&nbsp;
Anyway, after you have the Boolean control, go to the block diagram and from the Array palette, place a Build Array function on the diagram. Wire from the Boolean to the Build Array input and from the Build Array output, wire to the data input of the DAQ Assistant. Go to the front panel and set the Boolean control to what you want. Run the VI. If you have a scope or DMM connected to the DAQ card output, you should see the output change when you change the front panel control and run the VI.
&nbsp;
You might also want to mention the type of DAQ board you are using if you have any problems.
sheranko
2008-08-12 19:40:09 UTC
Permalink
Thank you so much, it works. I tried to connect the Boolean to it before but it produced an error as I didn't know there had to be an array between it. Now it is completely successful. Thanks for the time. M. Sheranko
sheranko
2008-08-13 13:40:11 UTC
Permalink
Here is what my code is. It turns on and off 8 individual digital I/O channels. Now I have to make it so I can have them turned on for an inputted amount of time and off for an inputted amount of time. Then I need to put that in a loop.


PCI 6023E Digitial IO on-off.vi:
http://forums.ni.com/ni/attachments/ni/250/42288/1/PCI 6023E Digitial IO on-off.vi
sheranko
2008-08-13 18:10:11 UTC
Permalink
Ok, I am having trouble doing what I said I needed to do in the last post, Dennis can you help me out?
Dennis Knutson
2008-08-13 18:40:10 UTC
Permalink
Do you want all of them to be the same state. In other words, all 8 on for a certain time and then all 8 off for a certain time? If that's the case, I wouldn't even use front panel controls. Just an array constant wired to the DAQ Assistant. Then a Delay function followed by another DAQ Assistant followed by another Delay.


On_Off.PNG:
Loading Image...
sheranko
2008-08-13 18:40:10 UTC
Permalink
This should work for my first experiment but I want to be able to hook up multiple valves and run them at different times, so I will need a time on and a time off for each one. Should I hvae the setup there you showed me but each one for a different channel?
Dennis Knutson
2008-08-13 19:10:12 UTC
Permalink
Basically, yes.
wkc3348
2008-08-13 20:40:09 UTC
Permalink
Thanks for the replies - they are helpful.&nbsp; I figure out my problem.&nbsp; I am wiring global channel to physical channel but in fact all I need is the line constant.&nbsp; I am attaching the screenshot of my vi here.&nbsp;wkc


relay_pump.JPG:
Loading Image...
Loading...