LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect NI-USB 6501 Device to Front Panel Diagram

I am new to labview. I am trying to use a NI-USB 6501 Device to automatically start my Touch Panel Project vi but I can not find any information on how to do this. I am using DAQ Assistant and can see the device in the measurement and automation explorer and it runs and toggles the switch from green to black. But how do I connect it to my block diagram to automatically run my vi when the pulse is high?

 

I have attached my vi also.

 

Thanks

0 Kudos
Message 1 of 14
(3,444 Views)

I'm not an expert. But probably u can call it as sub VI and use for example a Case Structure with the boolean (pulse is high) as case selector.

0 Kudos
Message 2 of 14
(3,432 Views)

I'm not an expert. But probably u can call it as sub VI and use for example a Case Structure with the boolean (pulse is high) as case selector.

0 Kudos
Message 3 of 14
(3,431 Views)

Do not use DAQ Assistant.  Read this excellent White Paper.  Think about how you toggled the Digital Output port you wanted to use in MAX.  If you save what you did as a Task, then you can simply use the Start function from DAQmx, wire a constant to the Task input, click the drop-down box on that constant and find the Task you saved in MAX.  Alternatively, use the minimum set of configuraion functions (as discussed in the White Paper) to select your device, the port you want to use, and write to the port.

 

Bob Schor

0 Kudos
Message 4 of 14
(3,419 Views)

Thank you for the response. I have read this white paper I have followed your suggestions. I can see the pulse go on and off in the measurement and automation explorer but again I do not understand how to add this device to my vi to automatically make it run (instead of having to select the run arrow). How do I wire the DAQmx Start? Do I add a case structure?

 

Thanks.

0 Kudos
Message 5 of 14
(3,382 Views)

I don't think I understood what it is that you want to do.  See if this is correct -- you want to start running the code inside the While loop (which reads data from a VISA port, adds stuff to a Waveform Chart, and does a Write to Measurement File) when MyDigitalTaskIn_0 goes high.  Did you want to do all of the code (including enabling/disabling VISA) or only the stuff in the While loop?  Do you want to do anything special if the bit goes low?  Should that function like a Stop?

 

The answer to those questions will inform how you handle the While loop.  I'll do one example, and if it's the wrong one, I'm sure you'll be able to figure the rest out.

 

So this is "Start While loop if/when Bit 0 goes High".  The first question to ask is how synchronized do you want things to be.  I'm going to say "within a tenth of a second".  So after I start MyDigitalTaskIn, I pass the Task line to a DAQmx Read request and read that bit.  I put this in its own While loop, with a 100-msec Wait (to make the loop run every tenth of a second), and output the value of the bit (bring it out of the While loop).  I also wire the bit to the Stop indicator of this loop, so this loop will stop when the bit becomes True.

 

Now put a Case statement around your bottom While loop and wire the output of your top While into its Selector port.  The lower loop cannot run until it gets a value in the Selector, which doesn't happen until the top loop exits, outputs True, and lets the bottom loop run.

 

Now, this is very simple, and is a "Do Once" scheme.  A better (but more advanced) approach would be to create a Queue going into both loops.  The top (Digital DAQ) loop puts the value (or the change in value) on the Queue, the bottom loop takes it off and wires it to the Case statement.

 

You can come up with more involved schemes, such as checking the state of the Digital line before or after each VISA read, but this also (I was going to say "requires", but there are other ways) "benefits from" having a Queue handle the communication between loops.

 

A key step here is Different Tasks Running in Parallel Loops, something that LabVIEW does in a superb fashion.

 

Bob Schor

0 Kudos
Message 6 of 14
(3,371 Views)
You can set a VI to automatically run when opened or build an exe. Is that what you want to do?
0 Kudos
Message 7 of 14
(3,367 Views)

Thanks Bob, yes you are correct in that I want to start running the code inside the While loop when MyDigitalTaskIn_0 goes high. I did not think about enabling/disabling VISA, so yes I want to do all of the code. When the bit goes low the function should stop. I am looking at your example now.

0 Kudos
Message 8 of 14
(3,353 Views)

@Dennis_Knutson wrote:
You can set a VI to automatically run when opened

Personally I hate this.

 

 

0 Kudos
Message 9 of 14
(3,343 Views)

@nyc_(is_out_of_here) wrote:

@Dennis_Knutson wrote:
You can set a VI to automatically run when opened

Personally I hate this. 


Yes this isn't really the correct way of accomplishing what you want.  Generally you'll want to build an EXE which then starts running when you run the program.  But I have seen on some cases where it was just one guy developing it and he didn't want to pay for application builder.  So he just set the VI to run when opened and make a shortcut to it on the desktop.  He just showed others to double click the shortcut and change the controls.

 

Of course this has many problems like change control, running from source, many debugging features like CTRL+. for abort existed, and he had to set it up to Exit LabVIEW on close.  Otherwise a user would be presented with the Getting Started Window and they could mess with a source.

 

But I did appreciate the simplicity, like using duct tape as dress material, or building a house of cards, while it is still standing.

0 Kudos
Message 10 of 14
(3,333 Views)