LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bitwise left shift in formula node.

Solved!
Go to solution

Additional: The CRC, which I am attempting to emulate, is encoded in this site: 

 

https://www.lammertbies.nl/comm/info/crc-calculation.html

 

This version :    CRC-CCITT (0xFFFF)

0 Kudos
Message 11 of 21
(1,793 Views)

Trick for snippets 

 

Use the picture viewer to download the snippet then poof code.

 

And either of the should do a CRC 16 ITT


"Should be" isn't "Is" -Jay
0 Kudos
Message 12 of 21
(1,790 Views)
Solution
Accepted by topic author Barionics

Found the right combination of settings.  So here is a reduced version of my code that will work with your algorithm.  It does not use the lookup table, but it is simple and works.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 21
(1,782 Views)

Tim I swear that code is in my reuse library. 

 

You may need to byteswap the output 


"Should be" isn't "Is" -Jay
0 Kudos
Message 14 of 21
(1,778 Views)

Fantastic!   Thanks for your efforts.  I can't wait to try it!

 

But I must ask the question again, how to get it into LabVIEW without having to draft it all in line by line?   I tried cutting and pasting the PNG and looked for a POOF option (or even PROOF?) but no joy. 

 

I must be one of those daft things which you have to just know and I'll be slapping myself. 

0 Kudos
Message 15 of 21
(1,776 Views)

@Barionics wrote:

I am attempting to convert a CRC calculator, written in C, to a LabVIEW VI.

 

It looked easy to cut and paste the relevant calculations into a formula node, but I have come unstuck.

in C I can do:

ushort value = (ushort)(I<<8)

 

The second 'ushort' is there to remove any overflow characters by chopping it back to 8 bits.  I tried replacing the ushort with uInt8 but no joy. 

If I do without the (ushort) LabVIEW recognises the overflow and rounds the byte down to FF, which is not what I want.

 

The LabVIEW logical shift operator does work correctly, but, as the code is more subtle and clever than I am, I don't really want to go down the spaghetti route if I can avoid it. 

 

BTW, don't think I hadn't thought to convert the C code to a DLL and import it that way, but I would need outside help with that, plus the complication of supporting the code.

 

Any help much appreciated,

 

  Regards,

 

  Ian


Is this what you are trying to do?

fn.png

"If you weren't supposed to push it, it wouldn't be a button."
Message 16 of 21
(1,773 Views)

@Barionics wrote:

Fantastic!   Thanks for your efforts.  I can't wait to try it!

 

But I must ask the question again, how to get it into LabVIEW without having to draft it all in line by line?   I tried cutting and pasting the PNG and looked for a POOF option (or even PROOF?) but no joy. 

 

I must be one of those daft things which you have to just know and I'll be slapping myself. 


I think the use of "poof" was meant to be exclamatory, like a magician saying "POOF!"

 

The problem is that changes made last year to the forum software have broken snippets. Most of the time the image the forum shows you has been rescaled or had the LabVIEW code stripped from it, so you can't just drag or copy-and-paste it into LabVIEW anymore. It is still possible to save the image to disk and then open it in LabVIEW. There's a whole discussion about it here: https://forums.ni.com/t5/Feedback-on-NI-Community/Snippets-are-broken/td-p/3658760

0 Kudos
Message 17 of 21
(1,771 Views)

Here

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 18 of 21
(1,767 Views)

Also, what version of LabVIEW do you have?  Crossrulz's snippet is in LV 2016.  Paul's is LV 2018.

 

If your LabVIEW is older than the picture you are trying to drop in, it will not turn to code, but remain an image.

 

And as arteitle said, changes made to the forum in how it handles images have made things more complicated.  And exact procedures may vary depending on which browser you use.  But essentially, download the image file to your desktop.  Then drag and drop the file to your block diagram.

0 Kudos
Message 19 of 21
(1,758 Views)

@JÞB wrote:

Tim I swear that code is in my reuse library.


It (the generic version) has been in mine for around a decade now.

 


@JÞB wrote:

You may need to byteswap the output 


Nope.  It perfectly matched the example from the web site.  The Byte Swap will only be needed if the OP needs it to be Little Endian.  But, yes, I have seen that variation on CRCs as well.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 20 of 21
(1,752 Views)