Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading 7 Byte data from Transducer via RS485 (converted to USB)

Hi all,

 

I have a little problem reading data from a transducer with RS485 output (converted to USB but seen as a COM port in Labview). The transducer gives torque, thrust, RPM and supply voltage in packages of 7 Bytes size @ 100 Hz output rate. The problem is that I get spurious readings with Labview compared to the manufacturers software. Now I wonder whether the Labview SubVI I programmed is rubbish...maybe it's the way I use the VISA components? The way the VI crops the Bytes in order to get Torque thrust rpm def. works - it's just the VISA or the CASE structure (too slow?). I have not much experience with Labview so if anyone could have a quick look and tell me what the problem could be?

 

many thanks in advance

 

Jens

Download All
0 Kudos
Message 1 of 4
(3,031 Views)

One problem that I see is that you assume that the very first byte you read is the very first byte in the frame. Since the instrument is constantly transmitting, that is not a valid assumption at all. Your first read is completely random. To synchronize, you will have to keep doing a 1 byte read until you find that bit 7 is true. Your comparison should be inside the loop. Discard all data until it is. Then you can proceed to read the next 6 bytes.

 

Since it seems you would want to do this continuously, you would need to place the read of byte 1 and the read of the remaining bytes inside a loop. The VISA Open and VISA Clear would be outside the loop and would only be run once. My guess is that right now, you are using the run continuous button. DO NOT USE THIS. It is not a normal way to run a VI.

 

p.s. You also posted this question to the Multifunction DAQ board. It is not an NI multifunction DAQ board. Question like this should be posted to the Instrument Control board.

Message Edited by Dennis Knutson on 06-02-2009 08:24 AM
0 Kudos
Message 2 of 4
(3,019 Views)

Hi Dennis, thanks for your opinion. Inside the loop the VISA Read reads 1 byte and converts it into a number. If this number is greater or equal 128 (means last bit must be 1) it starts the CASE structure where it reads the other 6 bytes. If not it reads the next byte. So it really reads a random byte at the start but checks whether the last bit is a 1 and only then it reads the other 6 bytes. This Sub VI is placed inside a loop in the main VI. All that works but I get drop outs of the Torque thrust rpm and supply voltage readings and it must have something to do with the way I use the case structure or some setting. (I'm not using the continuous run button) For example, do I need to choose synchronous or asynchronous reading for the VISA Read? Or is the execution of the SubVi too slow so that it actually can't read the next packet of 7 bytes and therefore the drop out in readings? I also have other things going on in the loop of the main VI which would slow down the iteration time of the loop. What do you think about this? The problem is that the Sub VI needs to catch up with the 100 Hz output rate of the transducer....

 

Jens

0 Kudos
Message 3 of 4
(3,012 Views)

If it's in a loop, I don't think you should be doing a VISA Open and VISA Clear each time. That should probably be done only once in the main. Doing it each time could be the cause of your dropouts since you are deleting data in the buffer.

 

In order to keep the data rate up, you could place this code in a separate while loop and pass the data to the other with a queue.

0 Kudos
Message 4 of 4
(3,010 Views)