LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Bit Fields

I am working on an application where I am going to be using the FPGA on a sbRIO to interface with an ADC (Linear LTC2480). The data from the ADC is going to come into the FPGA via SPI in a 24 bit number. I am thinking of throwing that number into a FIFO and pick it up and process it on either the RT or host. According to the data sheet for the LTC2480, the least significant four bits are the configuration, the next 17 are the conversion result, and the final three are the status information. My questions is around what is the most efficient way to extract these bit fields from the number in the FIFO? I have been playing around with converting a fixed point number to a Boolean array, then sub-setting the three bit fields (VI attached), but I am not sure if this is the most efficient way to do the processing. I am not sure of my data rates yet, but I think that speed of processing will be of the essence. Thoughts?

0 Kudos
Message 1 of 4
(3,829 Views)

The most efficient way is boolean logic. That involves AND, OR, NOT and the SHIFT or ROTATE functions.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(3,804 Views)

I would do the bit-level manipulation in the FPGA.  Bit-level manipulation isn't a strong point in LabVIEW RT, because as you modify the number to pull out the necessary bits, you will likely make unecessary copies of the data.  Manipulating in the FPGA will be very fast, probably just a clock cycle or two before you push the data into the DMA FIFO.

 

Regards,

 

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 3 of 4
(3,775 Views)

As Rolf mentioned, you can SHIFT the integer 4-bits to remove the 4LSBs, then AND the integer with a constant that has the top 15-bits set to 0 (assuming you are in 32-bit integer) to remove any data in the MSBs.  At that point you should have 17 bits of data contained in a 32-bit integer.

 

Scaling to floating point is often done on the RT processor, but there is also a VI available on ni.com to convert fixed-point data to floating.  This will also save a good bit of processing time from your RT app.

 

Fixed-Point (FXP) to Single (SGL) Conversion on LabVIEW FPGA

http://zone.ni.com/devzone/cda/tut/p/id/9221

 

Hope this helps,

 

 

Spex
National Instruments

To the pessimist, the glass is half empty; to the optimist, the glass is half full; to the engineer, the glass is twice as big as it needs to be has a 2x safety factor...
0 Kudos
Message 4 of 4
(3,761 Views)