LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Same function between C and Labview?

Hello!

I have to implement a CRC Routine in Labview, but the source is a part of a C Programm. A collegue made some german comments in this C-code, but i am not sure, if my labview-code has the same functionality.

It would be great, if someone could give some comments!!

Attached is a pdf-dokument containing the c-code and a vi containing my trial.

thanks for your help!

christian
Download All
0 Kudos
Message 1 of 13
(4,038 Views)
Hi Christian,
I have an example of a working CRC VI that might help. It has lots of comments (in English, though)!
The VI is attached. I am sure that this algorithm works as it has been tested thoroughly.
Regards,
Gizmogal
0 Kudos
Message 2 of 13
(4,038 Views)
P.S., If you could translate the C comments into English I might be able to help determine if your LabVIEW code matches your source code. At first glance it looks like the method to get the bytes from the string may not correspond.
0 Kudos
Message 3 of 13
(4,038 Views)
Hello!

THX for your answer, i tried to translated the comments into understandable english (i hope so) 🙂

Could you please convert your vi into LV 7.0?

Thanks, Christian.
0 Kudos
Message 4 of 13
(4,038 Views)
Hi,
I haven't had a chance to look at your comments yet, but here's a copy of the VI in LV 6.1 (which is what I have handy at this moment). I'll check back after I have looked at your C code again.
Gizmogal
0 Kudos
Message 5 of 13
(4,038 Views)
Christian Matten wrote:

> I have to implement a CRC Routine in Labview, but the source is a part
> of a C Programm. A collegue made some german comments in this C-code,
> but i am not sure, if my labview-code has the same functionality.
>
> It would be great, if someone could give some comments!!
>
> Attached is a pdf-dokument containing the c-code and a vi containing
> my trial.

This would be my variant of a translation of the document into LabVIEW.
No guarantees for correct operation though. You would have to have a few
correct tests strings in order for me to verify its correct operation.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 6 of 13
(4,038 Views)
Hi again, Christian,

I did a code review on your vi. Here are my observations:

In the while loop it is unclear why two bytes are being processed at once when in the C code the while loop looks like it is processing one byte at a time. To write exactly the same code as what is in the C routine it looks like the string should be processed one byte at a time as well.

The for loop in the C code is 0-7, so the index for the LV for loop should be 7.

In the for loop, to check if the last bit in crcreg is set just wire the crcreg and the number 1 into the Compound Arithmetic vi (right-click to change mode to AND) and compare the result to 1.

In the case statement corresponding to the C if statement (both true and false), the logical shift is to the
left instead of to the right. Use -1 for y.

Also, if you worked for me, I would ask you to put in lots of comments to explain what is being done since this is such a complex arlgorithm 🙂

Hope this helps!
Gizmogal
0 Kudos
Message 7 of 13
(3,891 Views)
Oops, checked on te for loop and N should be 8. Sorry.
0 Kudos
Message 8 of 13
(3,891 Views)
Hello Rolf,

thanks for your answer!

Here are some test-strings:

05 02 05 00 --> CRC Low A2, HI 5C

05 02 01 02 0A 00 --> CRC Low DF, Hi 09

05 02 01 02 14 00 --> CRC Low D6, Hi A9

05 02 01 02 05 00 --> CRC Low DA, Hi F9

CRC over a whole string (e.g. 05 02 01 02 05 00 DA F9) mußt be 0.

Christian
0 Kudos
Message 9 of 13
(4,038 Views)
Christian wrote:

> Hello Rolf,
>
> thanks for your answer!
>
> Here are some test-strings:
>
> 05 02 05 00 --> CRC Low A2, HI 5C
>
> 05 02 01 02 0A 00 --> CRC Low DF, Hi 09
>
> 05 02 01 02 14 00 --> CRC Low D6, Hi A9
>
> 05 02 01 02 05 00 --> CRC Low DA, Hi F9
>
> CRC over a whole string (e.g. 05 02 01 02 05 00 DA F9) mußt be 0.
>
> Christian

I just dropped those strings in and everything seems to be alright.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 13
(4,038 Views)