From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine three 8 bit data to 24 bit and do the convert


@altenbach wrote:

You could have an array in a shift register with three elements where you replace the oldest index (high three bits shifted)  and rotate the array to have them in historical order, oldest first (for example). Only if the array is [0,1,2] we have valid data to be displayed and further processed, so used this comparison for the condition of the case structure.


 

Here's what I had in mind. (you still need to verify that it works correctly for negative numbers and modify as needed!)

 

altenbach_0-1606080662139.png

 

0 Kudos
Message 11 of 20
(864 Views)

Hi Altenbach,

 

I think to identify the array and then the process works for my case. I will check the negative case and modify it.

 

Thanks,

Mars

0 Kudos
Message 12 of 20
(861 Views)

Hi altenbach,

 

For your solution, the three rows of 11bits are used to store the data. I used a digital 1d boolean to sample the data. I tried to build an array and store the 1D data into 2D but did not make it. It will be great if you have some comments about the data type.

 

Thanks,

Mars

0 Kudos
Message 13 of 20
(836 Views)

@Mars3315 wrote:

For your solution, the three rows of 11bits are used to store the data. I used a digital 1d boolean to sample the data. I tried to build an array and store the 1D data into 2D but did not make it. It will be great if you have some comments about the data type.

 


 

My 2D array contains three data packets matching your example. You only get a 1D array with each iteration Which is exactly modeled here. Note that the red box in my image simulates your instrument and spits out a 1D boolean array with each iteration of the while loop. That's all you have (anything before that in my code just picks one of the sample data 1D rows from the 2D array to simulate the instrument. This is completely irrelevant for the final program involving real data).

0 Kudos
Message 14 of 20
(827 Views)

Hi altenbach,

 

I checked the negative case e.g.111100110111001101011100, the decimal is -822436, the capacitance is --1.568672180176. 

 

I assume your program can be trigered under '012' order. When I connected to the dynamic data, the last three window always show 0 and 2, not 1. Do you think it is becasue of the sample rate? I guess The input data are faster than the sample, so it miss the '1' part.

 

Thanks,

Mars

0 Kudos
Message 15 of 20
(802 Views)

@Mars3315 wrote:

I assume your program can be trigered under '012' order. When I connected to the dynamic data, the last three window always show 0 and 2, not 1. Do you think it is becasue of the sample rate? I guess The input data are faster than the sample, so it miss the '1' part.

 


Sorry, it is not clear what you are talking about. "Dynamic data" has a very special meaning in LabVIEW, and I doubt this is it. How do you read the data? What IS the "sample rate"? How is the rest of the program?

0 Kudos
Message 16 of 20
(787 Views)

I'm sorry to cause you a misunderstanding. I use a microcontroller to send the data following [0,1,2] order to the NI DAQ. The input data should be valid. Current, the LabVIEW shows [0,2,2] or [222] instead of the [0,1,2]. Some screenshots were attached. Another question, if the input data changes, the calculated decimal, and capacitance did not update. Thanks.

Block_dia.jpg

Front_panel.jpg

  

0 Kudos
Message 17 of 20
(775 Views)

You are reading digital data every 300ms and this does not seem to be synchronized on how often signals are updated by the microcontroller. You have two independent free running clocks, one that updates the digital signal with new data an one where you read these signals (~ every 300ms). You need to find a way to sync things up.

 

Another possibility would be to read the signals at a very high rate and only accept a value once the three top bits have changed.

 

The displayed values will ONLY update if all three parts have been received in the correct order. Since this does not seem to be the case here because of design flaws, they will never update.

 

0 Kudos
Message 18 of 20
(767 Views)

Hi, altenbach,

 

If I change the microcontroller to send the data faster (2us), data 0,1,2 can be read occasionally. If the speed is lower to 300ms, only '2' can be read. I am struggling with the clock of the NI USB. It will be great if you have some advice on adjusting the reading speed of NI USB DAQ. 

 

Thanks,

Hongyu

0 Kudos
Message 19 of 20
(743 Views)

Hi altenbach,

 

I am wondering how can you know DAQ USB 6009 reading digital data every 300ms. In the USB-6009 spec, I can see rate limits for Analog input and output, but not digital output. 

 

Thank you for any help or advice you can provide regarding this.

0 Kudos
Message 20 of 20
(726 Views)