LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on complex math calculation in labview

Solved!
Go to solution

I need some help by being pointed in the right direction.  I have a piece of old lab equipment that I will be connecting to labview.  In order to send commands to the hardware, I have to calculate a checksum.  The checksum algorythm requires me to take alphanumeric characters, convert them to binary, perform binary addition, perform an Xor, mask certain digits, and convert the resultant binary string back to an ascii character.  Does labview have the capabilities to do this on it's own, or should I look at connecting to something like an external dll? 

 

I have Visual Studio 2008 and some previous VB experience, so I think I could write a program that would do the calculation, but don't really know exactly what type of project (dll, etc.) is best.  Are there any specific settings for the dll so that labview can use it.  I see an example for C++ for Visual Studio 2005, but that is as close as I can get.  I only know VB, not C# or C++

 

Can someone please point me in the right direction?

 

Tron

0 Kudos
Message 1 of 10
(3,838 Views)

Tron,

 

Labview can handle calculating checksums with ease.  A simple search on the NI webpage should turn up several examples.

0 Kudos
Message 2 of 10
(3,833 Views)

Well, I have been searching quite a bit and what I have found that talks about checksums does not appear to be what I want.  I don't think that my piece of hardware calculates checksums in any of the "standard" ways.  For example, if the command i need to send is "D4", I would need to:

 

1) Convert "D" and "4" to binary.

2) Add the two binary values together.

 

and then several steps after that, including Xor, masking digits of the binary string, convert binary back to ascii.  So far I have not even been able to figure out how to convert "D" and "4" to binary.  I have seen some mention of "string to boolean", but can't seem to find it in LabView 8.6.

0 Kudos
Message 3 of 10
(3,784 Views)
Please post make and model of instrument and any info you have on what the instrument expects for a checksum.
0 Kudos
Message 4 of 10
(3,777 Views)

TronCarter wrote:

I have seen some mention of "string to boolean", but can't seem to find it in LabView 8.6.


I assume you are referring to this thread. You can open VIs written with a previous version of LabVIEW (up to a point). It's the other direction that won't work (i.e., open a later version of a VI with an earlier version of LabVIEW).

0 Kudos
Message 5 of 10
(3,770 Views)

LabVIEW should hold all of the functions you require. Based on your first description i did this small VI which should point you in the right direction.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 10
(3,754 Views)

Yamaeda,

 

Thank you, I am a lot closer now.  The conversion to binary and binary addition works as expected.  The way the xor is calculated is that you take 1 and 2 of the binary addition sum, move them to bits 7 and 8, and then do an xor with the sum.  For instance, if the sum were 10000100, you would xor it with 00000010, if the sum were 11000100, you would xor it with 00000011.  Is there a way to automate this process versus having it be a numeric control?   Then the result of xor would need to be masked, such that bits 1 and 2 become zero's.  Then I add the binary conversion of 0 (00110000) to it and convert the result to ascii.  

0 Kudos
Message 7 of 10
(3,719 Views)

TronCarter wrote:

  Is there a way to automate this process versus having it be a numeric control?  


Yes, it's called programming.  Smiley Wink  What was given was just an example how to do the math.  You will have to figure out how to add it to your code.  Perhaps a while loop with a shift register to maintain the value from one iteration to the next.?

Message 8 of 10
(3,705 Views)
Solution
Accepted by topic author TronCarter

You basically need some logical shifts and ANDs.

 

Check version 2. 🙂

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 10
(3,688 Views)

That works PERFECTLY!!!  A few weeks ago I did a number of calculations by hand and had the proper checksum already figured out.  I ran all of them through and they all came out correct.  Now is the time for me to actually do some work and build an interface around it.  Thank you so much for your help, although I can hardly call it help... you did the whole thing !

 

Tron

0 Kudos
Message 10 of 10
(3,669 Views)