Instrument Control (GPIB, Serial, VISA, IVI)

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 ve
rsion 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 2
(2,911 Views)
Looks like you were left-shifting the CRC after you compare the byte's MSB, but the C code had this shift before. I've updated the vi, but have no way to test this (I don't have a C compiler handy right now). The answer does change however.

Regarding the port setup, if you use DTR-controlled mode make sure you assert DTR when you want to transmit and deassert when you want to receive. Most applications can use the "Auto" mode which switches the transmitter on/off for you.
0 Kudos
Message 2 of 2
(2,911 Views)