Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Data format from VISA (serial) read / converstion of data

Hi everyone,
      I am a student in UC Davsis and working on my seninor project. We try to build a profilometer,  which is to scaning material surface and contruct its 3D map.  right now, I am trying to get the output data from our laser sensor. The sensor is from micro-esiplon,  model number is ILD-1800. The sensor are hood up with computer through serial port. However, when I send command to sensor through  the adavance serial  sample in labview and see sensor's respond. I only get some ramdon meaningless charaters. In addition, I use the string to number  conversation VI to see if it can automatically convert it to a acutal number.  No number acutal come up unital  I change the read bit to 32. But those number are meanless too.

I think the VISA serial read function has automatically converted the binary output from sensor into string. This convesation cause my problem. So I am wandering if I can get the directly bianry output from sensor with the VISA serail read function, or do I have to use some other function.

In additon, since I have no previous pragraming experience, I cannot distinguish what  hi/lo bit are and how i should convert them correctly back to number in Labview. Can anyone please help me out, I have been stucked with this problem for two weeks. Also, I will attached the manual of sensor. They talk about how to make it communicate from Page 30 to  40. Can anyone take a look at it and tell me what I should in labveiw to convert these datas? Or simply, how can I get the bianry data instead of string, so i convert them later.

Thanks
0 Kudos
Message 1 of 7
(5,140 Views)

Hi Zhao.lin,

I just confirmed this with a VISA person and VISA Read does not do any conversion.  It simply fetches the data and assumes that it is a string type.  If you are fetching the data properly, you would only have to cast the string data type into the desired data type.  You can use the "typecast" block for that.

I am not sure if you are talking about high and low bits or if you mean high and low bytes.  They would mean different things depending on the platform you are developing in.

I will look at the manual and let you know if you need to do anything special on top of typecasting the data you fetch.

Regards,
Berk
Instrument Drivers / IVI
0 Kudos
Message 2 of 7
(5,136 Views)

Hi again Zhao.lin,

The manual refers to high and low bytes, not bits.  A Byte consists of 8 bits.  For communication purposes the instrument will send out the data in frames (fancy word for packaging the data so that the computer would know where one package finishes and the other starts).

Now each data piece is packaged into 10 bit frames, 1 bit to indicate new data chunk has started, following 1 bit to indicate if it is a high byte or if it is a low byte (more on these later), 7 bits that contain the data you will be working on and one last bit to indicate the end of that specific package.

The manual tells you to convert 2 packages at a time to create one 16 bit word (first 2 bits being 0 and the rest varying according to what the data is).

First of all, to be able to properly read data from the instrument (package by package) you would have to properly adjust your VISA settings.  More specifically enter the parameters that your instrument works on such as the number of stop bits, data bits etc. so that VISA will know when a new package starts or stops.

Now when you put 2 packages together (after conversion, or getting rid of the start and stop bits) you get a 16 bit number with the first 2 bits from the left are 0s.  If you look at the converted data diagram on page 31 of the manual, the data identified as the high byte is the data in bits D13 through D7.  The data identified as the low byte is the data in bits D6 - D0.

I hope it helps.

For more information on how serial interface works you can refer to this source.

Good luck with the project!

Regards,
Berk
Instrument Drivers / IVI
0 Kudos
Message 3 of 7
(5,129 Views)

Thanks, I will work on it and see how it is going. Thanks again.

 

0 Kudos
Message 4 of 7
(5,105 Views)
Hi berk,
    After your explaination, everything become clear to me.  The first thing I need to do is make sure the handware handshaking process are set up properly. Then, I have to type cast it into a right format in order to the converstion, am I correct? 


The problem are how do archieve this goal of coverting data, from the hi/lo bytes. I really have no idea because I never work with any kind of data converation. Do you have any similar example that I can do it?

zhao.lin
0 Kudos
Message 5 of 7
(5,094 Views)
hi, berk,
      I have tried the converting the data output from the sensor by combining samples of  adavance serial  read/write.VI  and read flattened data.VI. I get the nubmers, but they are not the correct number. I have attached a screenshot of the screenshot the VI that I have combined.  Can you or anyone take a look at it, and telll me what to do in correctly convecting data. At least, tell me if I am goin in a right direction. Thanks
 
 
zhao.lin


Message Edited by zhao.lin on 04-22-2008 09:51 PM

Message Edited by zhao.lin on 04-22-2008 09:51 PM
Download All
0 Kudos
Message 6 of 7
(5,083 Views)
Hi zhao.lin,
 
I believe you are on the right track, but most importantly you have to come up with a way to test and compare to see if you are properly converting the packages you are receiving from the instrument.  A great example that a colleague of mine forwarded to me can be found here and please look at that (specifically waveform_parsing_lv80_no_hw.vi) to see how data parsing is done.

Most importantly, make sure you are setting your serial settings (Data bits, stop bits, baud rate) etc. correctly and try to compare the result of your data interpretetion with what you expect it to be to make sure it is working correctly.
Please let us know if you have any more questions.
Regards,
Berk
Instrument Drivers / IVI
0 Kudos
Message 7 of 7
(5,042 Views)