Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

how to program sequence for digital in/out

I am trying to do somehting which I thought would be very simple, but I can't seem figure out how to do this: I want to control a number a valves using predefined sequences, but with some parameters controlled by inputs from the front panel. For now I am using the USB-6009 digital outs to turn a series of reed relays on/off which in turn control my valves. I want something like a sequence consisting of 5 valves states (e.g. A-E), with each state defined as 8 valves open or closed. My sequence will look something like:

 

(A(x seconds), B(y seconds) ) z times, C(5 seconds), D(10 seconds), E = final state

 

The parameters x,y & z will be entered form the front panel.

 

During the sequence I will also be collecting data from the analogue inputs.

 

Is my question understandable?

Can someone direct to resources (tutorials, etc.) that will help me do this?

 

I have already downloaded some VI's which are allowing to collect data and control valves states manually, but it is not clear to me how to get what I need quickly.

 

Thank you for your help.

0 Kudos
Message 1 of 8
(2,687 Views)

Hi rsi77-

 

It sounds like however you choose to implement this, an architecture you want to familiarize yourself with is the state machine.  The easiest way to point you in the right direction on a discussion forum is to have you look at the template that comes loaded with LabVIEW.  In LabVIEW, click on File»New»VI»From Template»Frameworks»Design Patterns»Standard State Machine.  This will allow you to establish certain states (in your case, these would be states A-E).  You have already determined how to manually control the digital lines.  You can create numerous pre-defined states where you have a pattern of booleans.  For example. state A has 00000000 as the data input of a DAQmx Write.vi.  State B has 11111111 as the data input of a DAQmx Write.vi.  You can utilize a sequence structure or other menas to enforce the timing (it won't be real deterministic, but probably close enough for your application).  Place a wait (ms).vi in a sequence with a control as an input, that way the user can select how long the Wait (ms).vi waits.

 

I hope this helps give you some ideas of how to proceed.  Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 2 of 8
(2,658 Views)

OK, I've spent some time studying state machines and am beginning to understand them. They look like they could do what I want to do.I've written some simple test programs where I can create different outcomes in an indicator based on differnt input into a control using "states".  My next problem is figuring out how to make the input originate from reading a single digital channel of my USB-6009, and then turn on and off my digital outputs based on that input. I can download VI's which allow me to switch a channel on and off, but it's not clear to me what's going on "under the hood". I agree that there's lots of help in the way of tutorials and such, but there's so much stuff that any search tends to gives reams of information which does not address what I need, or is beyond my current understanidng of the program.

State machines definately got me on the write track as far as the overall programming--can someone point me to a tutorial which will teach me the simple task of reading/writing to a single channel of a device. I don't want a completed VI unless I can understand ow to implement it into my own program.

Excuse my denseness with respect to this stuff. I feel it will be veyr powerful once I get my head around it it, but I'm not quite there yet.

Thanks for any help.

0 Kudos
Message 3 of 8
(2,647 Views)

Hi rsi77-

 

     I can understand your concern.  Here are a couple of great tutorials that will teach you the fundamentals of National Instruments data acquisition (DAQ):

 

Getting Started with NI-DAQmx

NI-DAQmx Express VI Tutorial

 

     In addition, you can check out the DAQmx examples in the LabVIEW Example Finder.  In LabVIEW, click on Help»Find Examples.  Once the Example Finder launches, click on Hardware Input and Output»DAQmx.  In here you will find numerous examples of analog/digital/counter I/O tasks.  This may help you see what is going on as each example comes with explanations and comments in the code.

 

     I hope this gets you to the next step.  Have a great day!

Gary P.
Applications Engineer
National Instruments
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 4 of 8
(2,618 Views)

Thanks for the pointers. I have been in touch with technical support and it is provin extremetly helpful. My exact question was answered by looking at the example called "Write Dig Chan.vi". From there I am able to do the very basic things I need to do, and have a foundation for building my application. Again, I've found tech support to be excellent--they answer my exact questions directly. I've was trying to learn from the tutorials and such, but the program capabilites are so expansive it's difficult to find the answers for the very specific questions I have.

I also found this resource (http://zone.ni.com/devzone/cda/tut/p/id/3024) very helpful for understanding state machines.

Ron

Message 5 of 8
(2,616 Views)

actually i want to do same thing but my requirements are quite diffrent i making a ratio control loop for that iwant to operate relay for certain desired time for pump for example my pump pumps the 100 ml water in 20 sec and i want to pump some 300 ml water then i have to make contact of relay for 60 sec i had made vi that numerically calculate the time span in ms but how could i feed it to timer and how can i program digital output to stay high for that perticular time  plz help me

0 Kudos
Message 6 of 8
(2,439 Views)

Hi ishaya-

 

     It would probably be best to create a new forum post for this question as it relates to digital timing (different from implementing a state machine).  That way, it will get answered by the right people, and others who are trying to do the same thing will be able to refer to your post. 

 

     Best of luck with your application!

Gary P.
Applications Engineer
National Instruments
Visit ni.com/gettingstarted for step-by-step help in setting up your system.
0 Kudos
Message 7 of 8
(2,400 Views)

Hi,

I'm sure there are a hundred ways to do this, and which way is best will probably depend on the logic controlling your decisions as to how much to pump. So first help me understand exactly what you're doing:

Are you choosing a number from your front panel which explicately states the mL's you want to pump? And then once you have made that choice you have already coded the calculation that gives the appropriate time required to achieve that result? So then your question is how to make LabView energize your relay for that amount of time...am I understanding the question?

 

 

So you need to figure out how to write "on" to your physical channel. Once you know how to do that there are a number of different structures you can use to write "on" for the specificed amount of time. One way would be a WHILE loop which will keep looping as long as you say "no" to the stop button. You could then place a "wait" timer inside the While loop, the input of which will determine how long the while loop waits before executing again. That will determine the time resolution of your program. Next you can use in increment (X=X+1) with a logic statement (if  X>=time(y), then stop) to stop the looping at after the desired amount of time. There may be more elegent ways to do this, but this is one way which should work.

 

Ron

 

0 Kudos
Message 8 of 8
(2,398 Views)