LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ, controlling a range of lines with numerics

Hello,

 

I have a problem with a program of my DAQ USB 6501.

The program is a multiplex program in which I have to set 17 adresses (binary) on the DAQ port.

I could easy fix this with selecting the whole port . But then I lose three lines, and I really need those.

E.g: Numeric 8 would give 00001000 on the whole port 

 

So is there a way to select only a range from: line 0.0 to line 0.4 and controlling them like I did with only selecting port 0?

 

Thanks a lot!

 

Greetings,

 

Joran

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

I'm not completely sure I know what you want to do.  The 6501 has 3 8-bit Digital I/O ports, so by doing 3 DAQmx Writes, you can set 3*8 = 24 Digital Outputs (and if you only want to use 17, don't wire the remaining 7, or set them to all 0's).

 

Do you want to program them by setting a single U32 number and have its low 17 bits sent to the three ports?  You can use the Split Number function (three times) to get this split into 4 bytes (or use a TypeCast to change the U32 to an array of 4 U8s), then send the low 3 bytes to Ports 0..2.

 

If you want to do "something else", please explain more clearly what you want to do (and don't worry about the "how").

 

Bob Schor

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

The address I want to set on my DAQ is only 5 bit long ( I only want to use 5 lines). The number 17 isn't really important.

This number means I want to set an address until number 17 (decimal), so until '10001'.

 

But I think I've already solved the problem by setting 5 DAQ assistants and converting the numeric into a Boolean array and uploading every single bit separately to the lines

 

I thought there was a more ergonomic way of doing this (with less blocks). That way, I still haven't found.

 

But thanks for the answer! It works now, but if you know a better solution...

 

In the file you can see the way I tried to solve it.

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

Perhaps this will slow the program down and speed is really important.

0 Kudos
Message 4 of 8
(2,640 Views)

Wow!  You really need to learn LabVIEW, the idea of Data Flow, get rid of the Sequence Frames, use Shift Registers, etc.  I still don't quite understand how you use an index (1 .. 17) to select patterns from 5 channels (namely "why stop at 17?  Why not allow 31 activation patterns?).

 

  • I presume you know that you have no idea what value Voorwaarde will be when the Loop first uses it (it will probably be True, but if so, it is a "lucky accident", as there is no reason that this takes place before the loop starts).
  • Aha!  After removing the Frame, simplifying your code, and getting rid of most of the Local Variables, I now understand (a little better) what you are doing.

So here's a question -- in the first iteration of the For loop, when the Index is 0 and this evaluates to 00000, which I presume turns all 5 channels "off", do you really want to do this?  Do you have an "off-by-one" error?

 

Learn some LabVIEW.  Learn about Loops.  Learn to "almost never" use Local Variables, preferring Shift Registers (and maybe not feeling you need to show all the intermediate values on the Front Panel -- use a Probe instead). 

 

Bob Schor

0 Kudos
Message 5 of 8
(2,630 Views)

Number 17 just stands for the amount of inputs I want to multiplex.

I started LabVIEW last year, and I only know the basics.

 

I'll do some more research. (Shift registers etc.)

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

Here's a little routine you might find amusing/instructive for your Multiplexer.  It indexes through the 17 Multiplexer channels (starting with Channel 1, ending with Channel 17).

  • Be sure you understand why there's an increment function!
  • Why did I change to U8?
  • What does the last function before the For loop do?

Next, there's a loop that indexes through the Multiplexers chosen bit-wise by the Multiplexer Index/

  • How many times will this loop run before it finishes?
  • Does this matter?  [Hint -- the correct answer is "No", but you need to think about why it doesn't matter].
  • What the heck is going on inside that loop?  How is the Boolean value being used?
  • What values are being output?

Finally, we get an array out, sum the array, and get "N".

  • What can you say about the size of the Array?  What is its smallest size?  What is its largest size?
  • What value(s) is(are) displayed in N?
  • Why is there a Wait function inside the loop?  How long does this code take to execute?


Multiplexer.png

Here's a Snippet, and I'll also attach the VI (in LabVIEW 2016, but it's so simple you can code it yourself).

 

Bob Schor

0 Kudos
Message 7 of 8
(2,599 Views)

Alright.

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