LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU - CRC Calculation

Solved!
Go to solution

I use the attached VI to calculate the CRC for the regular 16 Bit parameter value and generate the full command to be transmitted by a Modbus -RTU master. 

 

I now have a requirement to handle 32 Bit parameter for a Bonfiglioli VFD command. The required structure is given below.

 

Query is whether I can use the same VI to generate the CRC and  form the required command by only modifying the 16 bit parameter value to 32 bit parameter value?

FunctionCode100.PNG

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 9
(8,037 Views)

@MogaRaghu wrote:

Query is whether I can use the same VI to generate the CRC and  form the required command by only modifying the 16 bit parameter value to 32 bit parameter value?


I don't see how, unless you have the password to that VI.

 

There should be plenty of CRC for Modbus RTU on the forum... They usually are not password protected.

0 Kudos
Message 2 of 9
(8,007 Views)

Oh... sorry. Now its opened up ! 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 9
(7,968 Views)
Solution
Accepted by topic author MogaRaghu

Hi MogaRaghu,

 


@MogaRaghu wrote:

I use the attached VI to calculate the CRC for the regular 16 Bit parameter value and generate the full command to be transmitted by a Modbus -RTU master. 

I now have a requirement to handle 32 Bit parameter for a Bonfiglioli VFD command. The required structure is given below.

Query is whether I can use the same VI to generate the CRC and  form the required command by only modifying the 16 bit parameter value to 32 bit parameter value?


Your VI currently already calculates the CRC for a 32bit input: the input is just splitted into 2 16bit controls…

 

See this:

It's the correct result according to your example image!

 

Right now the problem is to calculate the correct CRC for 16bit input data.

Other problems are all those Rube-Goldbergs in the block diagram…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(7,962 Views)

Other problems are all those Rube-Goldbergs in the block diagram…

 

So bad ?!  Well the logic for the CRC calculation was helped by someone here in the forum and I have been using it for long.  Never pondered to study / simply it. 

 

Why fix something that is not broke 😄

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 9
(7,911 Views)

@MogaRaghu wrote:

Why fix something that is not broke 😄


To improve it.

0 Kudos
Message 6 of 9
(7,905 Views)

@MogaRaghu wrote:

Other problems are all those Rube-Goldbergs in the block diagram…

 

So bad ?!  Well the logic for the CRC calculation was helped by someone here in the forum and I have been using it for long.  Never pondered to study / simply it. 

I also wander about this.

 

It's messy (bended wires) but there isn't that much code, and I don't see much that can be done more easily.  

0 Kudos
Message 7 of 9
(7,904 Views)
Solution
Accepted by topic author MogaRaghu

RubeGoldberg:

  • determine last iteration by comparing the loop iterator for "==" when you could check for "<>"
  • negating the result of that check using a NOT when you can switch the conditional terminal
  • using a while loop when you should use a FOR loop!

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(7,902 Views)

@GerdW wrote:

RubeGoldberg:

  • determine last iteration by comparing the loop iterator for "==" when you could check for "<>"
  • negating the result of that check using a NOT when you can switch the conditional terminal
  • using a while loop when you should use a FOR loop!

That's really one point... If you change the last one, the others simply go away.

 

Sure some room for improvement.

 

Let's define Rube Goldberg Code as "exceedingly complex LabVIEW code that perform simple tasks in very indirect and convoluted ways"

It's not that bad.

 

0 Kudos
Message 9 of 9
(7,896 Views)