LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB6008 multiple line output with DAQmx

Solved!
Go to solution

Hello,

     I'm trying to hook up and control only the direction of a 12V DC geared motor using a Critical Velocty H-Bridge microcontroller which requires digital input from 3 lines of our NI USB 6008.  I have been able to use the DAQ assistant to power the motor using 3 separate assistant functions to execute the 1 task of controlling the high/low output of each line separately, but this requires that I input manually the needed output of each line; i.e. 3 boolean switches must be selected the correct way to move the motor in one direction or the other. 

 

What I aim to do is use a boolean control to cause the motor to turn clockwise or counter-clockwise but am having trouble converting this boolean control into the data form that the DAQ assistant requires.  Do I need to take my input and then build the 1x3 array needed to drive the motor?  But then how do I let the DAQ know that i want each value in the array to control a different digital output line of the DAQ?

 

Thank you for your help!       
0 Kudos
Message 1 of 13
(5,256 Views)
Not familiar with that instrument, but with a lot of NI Digital IO (I won't say all because I haven't used all of it), you can pass in a word (8, 16, or 32 bits).  So you would just have to set the bits you are interested (which may be 0, 1, 2 or 1, 3,7)...  Does that make sense or do you need more assistance?
-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 2 of 13
(5,255 Views)

No problem.  Specify your channels as shown in the following VI, build your digital array, and write it.  I'm not a fan of any kind of Assistant since I like to know exactly what my code is doing, so this is not configured using the DAQ Assistant, but it should tell you what you need to know.

 

The keys here are: 

 

Channel:  Dev1/port0/line0:2  (specifies that you'll be writing to lines 0, 1, and 2...put your actual hardware lines in here)

"One channel for each line"  (specifies that each of the lines above is its own separate channel, so that the number of channels in the task will agree with the number of Boolean elements in your array)

 

Hope this is helpful.  You should also take a look at the shipping examples that come with LabVIEW, and consult the LabVIEW help for additional information correct syntax for specifying DAQ channels.

 

 

0 Kudos
Message 3 of 13
(5,238 Views)

Hello DianeS,

 

I'm working with LabVIEW 8.0 so I could not open the 8.6 format that the VI you posted is written in.  I'm also very new to LabVIEW so I'm having trouble understanding your key points without the visual VI in front of me.  I'm trying to work on it now though, but any additional information would be greatly appreciated.

 

Thanks for your time,

Leanne

0 Kudos
Message 4 of 13
(5,218 Views)
Solution
Accepted by topic author leannee

Hi Leanne,

 

Try this.  If you have further questions, give a holler.  Also, please do look at the DAQmx examples that ship with LabVIEW...under "Help", click on "Find Examples".

 

Diane

Message 5 of 13
(5,205 Views)

Hello DianeS,

 

Thank you for all your help!  After visually seeing an example of the basis for our code I can better understand how LabVIEW works.  I know see that the DAQ programming was not where I was going wrong, it was the use of the different programming structures. 

 

I do have one more question about using a case structure.  Right now the code that you wrote has a boolean input into the structure, but I should be able to change that to include as many cases that I want, correct?  I thought that if I want to have more than 2 cases within the structure, I could just use a numeric control and then assign each case to a number in the loop of the case strucure.  However, the data types are different and can't serve as an input.  Do I need to convert the data before entering it in the case structure?  

 

Thank you again!!

 

Best,

 

Leanne    

0 Kudos
Message 6 of 13
(5,172 Views)

Hi Leanne,

 

I'm glad my little example was helpful!

 

You are quite right that a case structure can have many different cases, depending upon what you use as a case selector.  (in the vi I posted, the "case selector" is the Boolean that you asked about)  If you use a number as a case selector, you can have an infinite number of cases.  You can also use a string as your case selector, or an enumerated constant (my personal favorite). 

 

I am not entirely certain what you mean when you say "the data types are different".  The data types of what? 

 

Diane

0 Kudos
Message 7 of 13
(5,157 Views)

I thought that the different wire colors represent different types of data or the number of bits running through that wire.  What I meant to say is that the wire coming out of a numeric control is orange, but the wire going into the case structure cannot be.  Is this true?

 

Thanks,

 

Leanne 

0 Kudos
Message 8 of 13
(5,121 Views)

Why not give it a try and see what happens?  🙂

 

I'm not trying to be difficult -- I'm trying to encourage you to experiment and try things (particularly when they're really simple) and then ask questions if they don't work or behave strangely.  That's the best way to learn LabVIEW.

 

In answer to your question, yes, a case structure will work fine with a DBL as the case selector.  You'll get a coercion dot, though, because LabVIEW wants the numeric data type for a case selector to be I32.

 

Diane

0 Kudos
Message 9 of 13
(5,113 Views)

DianeS wrote:

 

In answer to your question, yes, a case structure will work fine with a DBL as the case selector.  You'll get a coercion dot, though, because LabVIEW wants the numeric data type for a case selector to be I32.


I wouldn't quite say that.  Wiring a double to a case selector will probably work fine in most cases, but you can't guarantee it always will.  A floating point number in a computer doesn't always precisely define an integer.  There can be roundoff errors in the internal representation of the number.  So you could run into problems whenever you are trying to comparing a double representation number with another number for equality.  It is always better to define the control to be the matching datatype and stay away from the floating point number when working with a case selector.

0 Kudos
Message 10 of 13
(5,102 Views)