# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Need help with this VI

I have this VI which calculates CRC for SPI communication. Someone provided a formula node to calculate CRC. The system has been upgrade so now the formula node is my choke point. I need to convert this to a VI so it will run faster. Can anyone help with this?

I have tried a few different things but none of them give me the correct answer.

Tim
GHSP
Message 1 of 11
(1,900 Views)
Solution
Accepted by topic author aeastet

## Re: Need help with this VI

Here.  There are probably some optimizations available, but here's both a literal translation of the logic and a slight tweak to give you a starting point to explore benchmarking with different bit-manipulation functions.

-Kevin P

Message 2 of 11
(1,866 Views)

## Re: Need help with this VI

With code very similar to Kevin's I found that the speed is dependent on the size of the message. For small messages the formula node is faster. With messages of 255 elements the native code is almost 10 times faster. With messages longer than 255 elements the formula node hangs. (Loop counters i and j are U8).

Lynn

Message 3 of 11
(1,859 Views)

## Re: Need help with this VI

THe messages should be around 85 so I think we are good for now.

Tim
GHSP
Message 4 of 11
(1,857 Views)

## Re: Need help with this VI

@Kevin_Price wrote:

Here.  There are probably some optimizations available, but here's both a literal translation of the logic and a slight tweak to give you a starting point to explore benchmarking with different bit-manipulation functions.

-Kevin P

Thank you very much for the help.

Tim
GHSP
Message 5 of 11
(1,856 Views)

## Re: Need help with this VI

At a message length of 85 I find the native LV code about 3 times faster than the formula node.

Lynn

Message 6 of 11
(1,827 Views)

## Re: Need help with this VI

That is good to know. My time to complete my generate command, write, read, check for error and store data is about 5 msec. and I would like to have a little time left. Right now witht eh CRC turned on witht he formula node I am seeing prcess times of around 8-10 msec. This will help greatly. I am sure that I will have to still find more places to get the extra loop process time I need, but this was my biggest problem.

Tim
GHSP
Message 7 of 11
(1,821 Views)

## Re: Need help with this VI

Turn that inner loop into a lookup table (array constant) since there are only 256 possible values.

Message 8 of 11
(1,803 Views)

## Re: Need help with this VI

I'll second Darin.K 's suggestion to use a U8 array constant as a lookup table.

-Kevin P

Message 9 of 11
(1,775 Views)

## Re: Need help with this VI

The LUT version runs in less than half the time of the nested for loop version for 85 element message and four times faster for 255 elements.

Lynn

Message 10 of 11
(1,752 Views)