LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to transfer a 4*4 digital array into 4 1*4 digital array and then send to DAQmx Write cyclically?

Solved!
Go to solution

Hi GerdW,

 

Do you want to output the "digital arrays" to your 4 DO lines simultanuously (each row to one DO line, at the very same time)?

Each DO line will connect to a Shift register and DAC for converting to voltage. For example, for the first row, first data will send to first line ... 4th data send to 4th line. 

Or do you want to output the data "each row time after time"? (Why would you need 4 lines then?)

As you know, When the first row is scanned, I hope to send the first row of data. first data will send to first line ... 4th data send to 4th line. 

 

Thanks a lot!

 

Best,

 

Jason

0 Kudos
Message 11 of 14
(554 Views)
Solution
Accepted by topic author leo321

Hi Jason,

 

For example, for the first row, first data will send to first line ... 4th data send to 4th line. 

Then you need to reorganize your data!

Create 4 lines of data, with each line holding the data for that specific DO pin!

 

Your example:

For example, a 4*4 4-bit digital array:

 1111 1110 1101 1100

1011 1010 1001 1000

0111 0110 0101 0100

0011 0010 0001 0000

changes to:

1111 1011 0111 0011

1110 1010 0110 0010

1101 1001 0101 0001

1100 1000 0100 0000

All "first data" in first line, all "4th data" in 4th line…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 12 of 14
(547 Views)

I'm still trying to understand your Task and your Hardware.

 

Let's consider outputting one row, say 0000 0001 0010 0011.  There are 4 4-bit "registers" here, and you speak of 4 DO "lines".  Now, in DAQmx, a Digital Output "line" means a single bit for what is usually a Digital Output Port that can variously be configured to consist of 4, 8, 16, or 32 bits, or "lines".  When you do a DAQmx Write to a Digital Output, you write the entire "unit" all at once.  If you have configured the the DO as a Port, then you write a U8, U16, or U32 to it and all of the bits are set at the same time.  If configured as multiple Lines, you can write a single Channel and manipulate one Line, or multiple Channels and do them all together.

 

I have no idea which scenario you are using.  Given that you are writing 4 4-bit quantities at a time, I also am unclear (this is basically the same question as above) if you want to write them a bit at a time (say 1 bit per second), in groups of 4 bits (or a 4-bit "simultaneous write" at 1 group a second) or all 4 groups of 4 bits at the same time (again, at 1 group-of-16 a second).  [i"m keeping the "update" rate fixed at 1Hz for convenience).

 

Once we clarify this, the next bit, doing this over and over with a cyclic pattern of 4 "rows" of (4 columns of 4 bits each) is very simple.  There are multiple ways to cyclically "pull out" a row from a 2D array -- the simplest is to take the Loop index ("i"), pass it through the Remainder/Quotient function with divisor of 4, and use the Remainer to Index Array and return the selected row.  It will return 0, 1, 2, 3, 0, 1, 2, etc.  Now send this to your DAQ (where you'll do the timing, easy once you clarify what you are going to do with the Row and the so-far-mysterious DAQ Hardware).

 

Bob Schor

0 Kudos
Message 13 of 14
(540 Views)

Dear Bob,

 

As you can see in the picture below, I hope to use LabVIEW to generate digital data and control the timing to achieve the functions.

 

Thanks!

 

Best,

 

Jason

微信截图_20180806113047.png

0 Kudos
Message 14 of 14
(521 Views)