LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert string data to image data.

Solved!
Go to solution

Good day, I use a Labview to communicate with an oscilloscope Rigol.  This device use SCPI (Standard Commands for Programmable Instruments) commands and the program in the Labview  is based on VISA (Virtual Instrument Software Architecture). I need to use the command ”: DISPlay: DATA?”. After its use the following data comes back: TMC Blockheader (TMC Blockheader ::= #NXXXXXX is used to describe the length of the data stream. Wherein, # is the start denoter of the data stream; N is less than or equal to 9 and the N figures following it denote the length of the data stream in bytes. For example, #9001152054; wherein, N is 9 and 001152054 denotes that the data stream contains 1152054 bytes of effective data.) and Specific image data (BMP24 as example). In programming guide of this device there is an example of use this command:

  1. Make sure that the buffer is large enough to receive the data stream, otherwise the program might be abnormal when reading the data stream.
  2. The returned data stream contains the TMC data header which should be removed to make the data stream a standard image data stream.
  3. When the data size is larger than 1 M and the communication speed of the interface is not fast enough, you need to set an appropriate timeout time.
  4. The terminator '\n'(0X0A) at the end of the data should be removed.

I want to save the received data as an image, but have some problems. I tried to use “Write To Spreadsheet File VI” and save as BMP, but I could not open the file. I tried to use “Write BMP File VI”, but this function requires an input “image data”.

In the end, tell me please how I can convert “string data” to “image data” or other solutions of my problem?

Thank you.

0 Kudos
Message 1 of 20
(9,527 Views)

Which scope are you using? You can find a bunch of drivers here. My preferred method would be to get the data as waveform data, and then save an image of the graph in LabVIEW if you really want an image.

 

*Edit: also, great question asking skills!

Message 2 of 20
(9,518 Views)

Hello Alexdmk,

You need to use Write BMP file.vi to save the image as BMP file, Write To Spreadsheet File VI will save the data in tabular format in file which can be opened as a text file and not BMP file. In case if you have the image data then upload it so the I can check how to save it.


CLD Using LabVIEW since 2013
Message 3 of 20
(9,494 Views)

From what you've written, I'd suggest trying Write to Binary File with an appropriate file extension, after following the instructions to remove the header and termination character. 

 

The termination might be automatically removed by LabVIEW depending on how you're reading the data.


GCentral
Message 4 of 20
(9,486 Views)

Thank you. My device is DS1054Z, I'll look at the information about the driver of other oscilloscopes. I understand, that it is better to work with waveform data, but now I need to have a picture of the oscilloscope screen.

0 Kudos
Message 5 of 20
(9,463 Views)

Having reread more carefully, you should definitely go with gregoryj's suggestion. This driver might help you out: RIGOL DS1000 Series Oscilloscope.

Once you have the waveform data, you can reconstruct the image on the screen.

 

If you really want the display, then probably you can take a look at either the Draw Flattened Pixmap (using a Create > Constant for the image data, then Bundle By Name to fill the approriate fields) or perhaps more straightforwardly (but I haven't previously tried) Draw Unflattened Pixmap, which takes a 2D array of data values. If you're getting a string, you'll need to convert to the numeric values - String to Byte Array might be your friend here.

 

If you upload an example string (perhaps as a text file) I can try and figure out the appropriate handling, without it becoming a lot of back and forth guesswork 🙂 However, I would still suggest the driver and waveform 🙂


GCentral
Message 6 of 20
(9,455 Views)

Hello Alex,

I think there is more to do than just saving the stream. Can you explain what exactly ist meant by "a standard image data stream" at point 2? I doubt it is a binary stream of bmp- data, because point 3 states, the stream is terminated by 0xA, and this single binary value is very likely present in the binary representation of a rasterized image.

So you should find out what kind of data is sent by the device (very likely ASCII- coded data, perhaps like Base-64).

 

Greets, Dave
Message 7 of 20
(9,447 Views)

Does your output looks like this?

scope data.PNG

If so then upload the data file you ahve created.


CLD Using LabVIEW since 2013
Message 8 of 20
(9,435 Views)

Dear kartiknattar, I used string as indicator, display style - "Backslash (\) Codes", in the display received the following values:

#9001152054BM6\94\11\00\00\00\00\006\00\00\00(\00\00\00\s\03\00\00\E0\01\00\00\01\00\18\00\00\00\00\00\00\00\00\00\CA\b\00\00\CA\b\00\00\00\00\00\00\00\00\00\00\00$\s\00$\s\1088\00$\s\00$\s\00$\s\00$\s\1088\00$\s\00$\s\00$\s\00$\s\1088 

and so on.

How to save data in this format and what to do with them further?

0 Kudos
Message 9 of 20
(9,426 Views)

Can you save the entire data in a .txt file and upload it as I think you need to split the data and type cast it and then merge the 3 different layers to create a single image.


CLD Using LabVIEW since 2013
Message 10 of 20
(9,424 Views)