Jump to content

packing and unpacking serial data, fast


Recommended Posts

I am using the latest version of Labview 2009 with all of it's wizz bang super functions.

What I am attempting to do take an array of 32-bit data and convert it to a different size. The data is packed. So, for example say I have an array of UINT32 numbers and I want to convert them to 18 bits. The first number would be represented by the first UNIT32. The remaining bits are the start of the next number.

I tried to flatten the 32-bit data to a 1-bit array and then decimate the 1-bit array to form multiple bit arrays of the target size. I then convert these back to single numbers. It works but is very slow. The quickest conversion we have found was using the replace array subset. I have attached the example. On my PC, this takes about a half second to run, not including the time to create the dataset. I need to get this down into the 10-50mS range.

Is there a slick way to do bit packing and unpacking in labview that's fast?

DMAunpack4c.vi

Link to comment

I am using the latest version of Labview 2009 with all of it's wizz bang super functions.

What I am attempting to do take an array of 32-bit data and convert it to a different size. The data is packed. So, for example say I have an array of UINT32 numbers and I want to convert them to 18 bits. The first number would be represented by the first UNIT32. The remaining bits are the start of the next number.

I tried to flatten the 32-bit data to a 1-bit array and then decimate the 1-bit array to form multiple bit arrays of the target size. I then convert these back to single numbers. It works but is very slow. The quickest conversion we have found was using the replace array subset. I have attached the example. On my PC, this takes about a half second to run, not including the time to create the dataset. I need to get this down into the 10-50mS range.

Is there a slick way to do bit packing and unpacking in labview that's fast?

the Bit Twiddler challenge is probably a good place to start.

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

This tag cloud on the Inplacness-algorithm may also help.

http://forums.ni.com/ni/tagging/view_tag?tag.text=Inplaceness-Algorithm

Ben

Link to comment

I wasn't really looking for a how to do it as much as if they had a function like this already built in.

An interesting side note, I plan to just code this function in C and be done with it. Before I did this, I wrote the function the same way I plan do code it but in labview. For fun, I benchmarked this and it cut the time in half. A couple of quick tweeks got it into the 200mS range. Not bad considering where I started but not good enough to be useful.

C still has it's place.

Link to comment

Been a few days so figured I would see if anyone knew of a trick for this. Looks like bit packing is not something people use.

Using the MSVS 2005, optimized for speed, release the time to run this function is now in the 30mS range. Much better than the two and a half seconds I saw using the array decimate function. This is good enough for what I need.

The updated benchmarks

packer_new.zip

Edited by lecroy
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.