LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating CRC Checksum

Did this instrument have a library already built on www.ni.com/idnet ?

0 Kudos
Message 11 of 18
(2,830 Views)

@bockdoug wrote:

After sending them another email asking for a detailed example, I have arrived at what they meant:

Their reply was: 

 

If the message is S3C516467K

S3C5164 – checked part

67 – CRC

K – End of message

 

  1. You take the checked part and transfer it from ASCII to HEX

    S      3       C        5       1        6       4         =>

0x53 0x33 0x43 0x35 0x31 0x36 0x34

 

  1. You do the CRC calculation (in HEX):

0 – 53 – 33 – 43 – 35 – 31 - 36 – 34 = 0xFFFFFE67 = > 0x67

0 – part of the algorithm for the calculation

FFFFFE – carries/borrows

 

  1. Transfer the result from HEX to ASCII

0x67 => 6 and 7 => S3C516467K

 

I followed this and came up with the attached algorithm.
This spits out 4A for my message of "S12" and also gives the correct CRC as in the example above.
Many thanks for all your input.

 

 


That's great!  Don't forget to mark your post as the solution!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 18
(2,821 Views)

Bockdoug
I cleaned up your code slightly. I like to use "String to Byte Array" and auto indexing the loop. Benchmark runs much faster that "Type Cast", especially for large strings (extra buffer allocations??). It probably doesn't make much of a difference for your short command strings though.

 

crussrulz almost got it right. He just forgot to initialize the shift register to ZERO.

 

CRC(Subtract).png

0 Kudos
Message 13 of 18
(2,807 Views)

@jamiva wrote:

Bockdoug
I cleaned up your code slightly. I like to use "String to Byte Array" and auto indexing the loop. Benchmark runs much faster that "Type Cast", especially for large strings (extra buffer allocations??). It probably doesn't make much of a difference for your short command strings though.


String To Byte Array is literally a no-op since the array and string use the exact same memory structure.  The Type Cast does some things to make sure it works.

 


jamiva wrote: 

crussrulz almost got it right. He just forgot to initialize the shift register to ZERO.


Actually, I initialized with the first byte and subtract the rest.  It was the best interpretation I make from the description given.  That is part of the problem with checksums, there are so many ways it can be done and you have to be very clear in describing how it is calculated.  Otherwise there is a lot of guess and check.



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 14 of 18
(2,801 Views)

Hi, I guess this is an inductive heating machine (UltraFlex), I am tiring to control it using Matlab; I did the CRC added to the string +K to turn on the heat ('S1249AK'), but nothing happened (the screen on the machine still LOCAL MANUAL). May you share a brief description of who it worked with you, and the codes to achieve that if possible? 

0 Kudos
Message 15 of 18
(2,179 Views)

Hi Assi,

 


@AssiH wrote:

I guess this is an inductive heating machine (UltraFlex), I am tiring to control it using Matlab;


Then why don't you ask in a Matlab forum? How much information do you expect from some LabVIEW code?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 18
(2,177 Views)

Hi GerdW,

I did not ask for the codes in MATLAB, it can be in any programing language, including LABVIEW. I asked about brief description of how the setup with the inductive heating machine work, and this is not a language specific question; it happed that the person that solved this issue, is using LABVIEW.

 

Best Regards

 

Assi 

0 Kudos
Message 17 of 18
(2,165 Views)

Hi Assi,

 


@AssiH wrote:

I asked about brief description of how the setup with the inductive heating machine work,  


Which "inductive heating machine (Ultraflex)" are you talking about?

The OP was asking for a (more or less) simple power supply!

 

Induction heating works this way

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 18 of 18
(2,160 Views)