LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

crc16 problems

I`m currently trying to communicate with a conductivity controller over RS485. I can receive data when the communication is set to one-way, so I`m assuming I`ve wired the connection properly. My problems occur when I try two-way comms (set on the controller).

The device requires a crc16 to be appended to the send-string. I don`t seem to be able to produce this function in LAbVIEW (Even though the manufacturer ships C code...). Now, I`m not the best C coder in the world, but I THINK I am doing the same thing in my LabVIEW code as in the examples shown here (one VI and two txt files).

Can someone please help me? I have found modbus CRC routines which at least fulfill the crc(text+crc)=0 criteria (but still doesn`t work). The v
ersion I have coded doesn`t even do this.

As a result, I have several questions (Which I have tried to answer myself, but have failed)

1) can I assume I have my communication wired properly (2-wire DTR control, NI 1-Port USB-485 Adapter)?
2) Does anyone knoow how to (or have an example of) a "CRC16 (CCITT-X.25)" routine? This SHOULD be what I am posting here, but it doesn`t work.
3) Should I just give up programming altogether and declare insanity?

Thanks for anyone who has gotten this far in the message.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Download All
0 Kudos
Message 1 of 4
(5,055 Views)
There are links to some CRC VI's here:

http://www.mooregoodideas.com/FAVIs/Strings.htm

I haven't tried them (except for icrc32.vi, which isn't what you want - but might be worth examining so you can see how it calculates) but hopefully it will get you started.

Are you sure it's the CRC that's the problem though, and not the serial communication? Do you get an error back, or just nothing? I don't know how the NI converter handles enabling/disabling the RS-485 transmitter, so check that the settings you're using are correct for what your device is expecting. (I scanned the online documentation for the NI converter and it didn't help 😞 )
0 Kudos
Message 2 of 4
(5,055 Views)
Thanks for the link, there are some useful things there, but the CRC routine there I already have seen.

The problem is that the controller simply ignores my command if the CRC isn`t correct. This means no error, nothing. If I set the controller to send data every 4 sec or so, I receive the data no problem, so I don`t think it`s my RS485 port.

My second problem is that I can`t get the supplied C-Code for the CRC to work as expected (in LabVIEW). I don`t have a C compiler, so I can`t test the C-Code directly....

Thanx

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 3 of 4
(5,055 Views)
Well, here I go answering my own questions........

I got it sorted. turns out the C-Code is simply wrong. I got another source on the web (Don`t actually recognise the language, but I understood the logic), tried it out and presto! Everything works.

For anyone else who might need this, the VI is included.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Message 4 of 4
(5,055 Views)