LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Recieving Data with VISA Read Block

I'm trying to read x, y, z, and temperature readings from a magnetometer. Each of those are sent by the sensor as a two byte value in two's complement form. The sensor sends the data after a request has been made. This request is made my sending a char to the sensor. 'x' will return the x value, 'y' will return the y value, etc.

 

The problem is that the VISA read block recieves this data as a string value.This causes the VI to crash when it recieves the value 0x0A. The reason for the crash is because the 0x0A value is the enter character and the array where the data is stored gets shifted down.

 

Please look at the attached VI and let me know if there is a better way to perform this task

0 Kudos
Message 1 of 4
(2,945 Views)

You've got several problems with theVI - the seqjuence structure and all of the locals but the main problem is that you have the VISA termination character enabled. Pass a false to the VISA Configure Serial Port.

0 Kudos
Message 2 of 4
(2,939 Views)

Thanks. I'll give that a shot once I get back to the school computer.

 

Also, how do I get around using sequence structures and locals? I don't want to bombard the sensor with all of the requests at once, which is why I added the sequence stuctures. Also, an array seemed to be the best way to store that data. If you can suggest some things I read up on, I'd really appreciate it.

0 Kudos
Message 3 of 4
(2,934 Views)

MarkoP,

 

Look at the examples of State Machines.  They will allow you to do everything you are presently doing without using sequence structures or local variables.  They are also much easier to modify, troubleshoot, or add features than sequence structure-based designs.

 

Another thing to consider (again, easy in a state machine) is to try to avoid duplicated code.  Except for inputs and outputs the code for X, Y, Z, and T is identical. Make a subVI of this code. 

 

Lynn

0 Kudos
Message 4 of 4
(2,926 Views)