Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Append CRC to a Serial command

Hi everybody,
 
I am trying to use a flow controller with Labview using the Serial port, but I have some problems.
 
Using the different vis I have been able to understand that I can read in Labview what the flow controller sends (for example, using the Advanced Read and Write vi, when I switch on the instrument, I can actually read some strings that can only come from the instrument itself. I think it is the start-up procedure that scans all the functions and I can read all the name of those functions for a litlle while... After I keep on getting something like: "Flow0.0000>" which is correct btw 🙂 ).
 
The main problem is that the command I have to send to the instrument has this format:
"
commandCCR
"
where CC are two Cycle Check bytes, and R stand for Carriage Return.
 
Now, let's say I'd like to read the serial number of the instrument... the command is:
?SrnCCR
 
How can I append to the command the right value of CC ?
 
I have been reading extensively the forum, and I found out that for R I need to type "\r" , but I have no clue about the CRC.
 
Thank a lot.
 
 
 
0 Kudos
Message 1 of 15
(6,982 Views)
Hi

Calculating a crc is best done by conveting the string into an array of byte and then calculate the correct crc.
This should be explained in the manual. Often an xor of the bytes of the array is used but the starting byte can be changed or even a word is used.

greetings from the Netherlands
0 Kudos
Message 2 of 15
(6,976 Views)

So you mean, like I have seen on some examples on the web, getting the crc from the command string, then getting the first and the last of the exadecimal value of crc, and then appending those value to the command?

 

By the way, the instrument's company, beside the 5 pages in the manual in which there are two visual basic code example for getting the crc, does not give any further support because they have their own graphical interface...

Gaetano

0 Kudos
Message 3 of 15
(6,973 Views)
If you show us the visual basic examples I can translate them into LabVIEW coding.

greetings from the Netherlands
0 Kudos
Message 4 of 15
(6,968 Views)
I am attaching the only instructions I got from the company. The visual basic code is on the last page!

Thanks a lot, I appreciate it!
Gaetano
0 Kudos
Message 5 of 15
(6,963 Views)

Hi there. I've got to do the same thing. Was there an example made for this post?

Thanx.

0 Kudos
Message 6 of 15
(6,681 Views)
Hey punkmonkey,

Here is a forum post that will help you out. There is a CRC example VI that was posted as part of the Modbus LLB by Gurdas. That should get you going.
Rasheel
0 Kudos
Message 7 of 15
(6,641 Views)
that forum post points to itself, so not much help
greetings from the Netherlands
0 Kudos
Message 8 of 15
(6,624 Views)
Hi

If I find the time I'll implement the C-version. That is closest to LabVIEW programming.

greetings from the Netherlands
0 Kudos
Message 9 of 15
(6,623 Views)
Hi,
 
I use this VI for my ModBus communication. For your application change the XOR word from 0xA001 to 0x1021.
Input is the string to send. Output is the string with the CRC word (string with bytes)
 
Also from The Netherlands  Smiley Wink
0 Kudos
Message 10 of 15
(6,610 Views)