Use exported binary files of TiePie oscilloscope

importoscilloscope

I used a Handyscope HS4 by TiePie to measure some data and used the export function to save it as binary files to view later at my desk.

Sadly, I didn't look to SSE how to use these files afterwards before returning to desk, nor did I read the manual to see if I should have saved the TiePie settings files in the same run. It was the first time I used the oscilloscope to save data. I made notes about the settings I used, so I still have hope to be able to use the data.

If I had the TPS-Files (settings files), how are the binary files used after export?

I want to view the waveforms and maybe run a protocol decoder on it. Is this still possible or is all hope lost, and do I need to get new data, this time saved as CSV or similar?

Edit: The files I need to import are waveforms displaying RS-422 communication (one-way). Between 79kB and 500MB in size (one-shot captures and data logs). I have saved in float64 data format.

Sample file (only noise)
https://www.mediafire.com/file/irr4gihdw6vfbtf/2_channel_test_data_50MHz_100kSa_200usdiv.bin/file

Sample file waveform
https://www.mediafire.com/view/koz6c859ezhh99e/2_channel_test_data_50MHz_100kSa_200usdiv.png/file

I was able to load the file in Audacity, but the vertical scale limit off +/- 2 is cutting most of the waveform.

Best Answer

Updated after question edited to include sample files

Tie Pie documents the binary files, which says, in particular, that the datastreams are interleaved.

Analysis

Your uploaded bin file 2 channel test data 50MHz 100kSa 200usdiv.bin is 100,000 pairs of 64-bit floats, exactly as we expect. They are in the most common format: IEEE 754 64-bit floats , low byte first.

It begins:

00000000  00 00 00 a0 01 a0 29 3f  00 00 00 c2 5e f9 94 bf  |......)?....^...|
00000010  00 00 00 04 01 04 80 bf  00 00 c0 7d 41 94 95 bf  |...........}A...|
00000020  00 00 80 58 81 38 85 bf  00 00 40 50 83 fb 95 bf  |...X.8....@P....|
00000030  00 00 c0 75 c1 05 87 bf  00 00 e0 c4 53 15 96 bf  |...u........S...|

Convert to CSV with hexdump

We can convert it to CSV with standard Linux tool hexdump as follows:

$ hexdump -v -e '"%g,%g\n"' '2 channel test data 50MHz 100kSa 200usdiv.bin' \
  > testfile.csv
# likely to vary on others systems, tested on 64-bit Linux on Intel hardware

Put the first 1000 lines into a spreadsheet it looks like this: enter image description here

Most spreadsheet programs will fail to graph 100,000-point data.

Convert to CV with Python

There are also endless ways of doing this in, for example, Python. The following gives an identical result as the hexdump method above. (Tested on Python 3.6.9, 64-bit Linux, Intel CPU).

The thing that would change for different numebr of samples is 'dd', which means "two double-precision floats" in the struct library

>>> import struct
>>> fi = open("input.bin", "rb")
>>> fo = open("output.csv", "w")
>>> rawbytes = fi.read()
>>> pairiter = struct.iter_unpack('dd', rawbytes)
>>> for pair in pairiter:
...     print("%g,%g" % pair, file=fo)
... 
>>> fo.close()
>>> fi.close()

Directly view and graph in R

The statistical language R is good for larger files and can easily graph 100,000-point data; it also can read binary float files (and many other things). You could easily convert to CSV, or can graph directly:

> fi = file("input.bin", "rb")
> samples = readBin(fi, "double", 200000)
> close(fi)
> v1 = samples[c(TRUE, FALSE)]
> v2 = samples[c(FALSE, TRUE)]
> plot(v1, type="l", col="blue", ylim=c(min(samples), max(samples)))
> lines(v2, type="l", col="red")

Tested in R 3.4.4 on 64-bit Linux, Intel CPU.

Produces this graph: enter image description here

Documentation

This is the documentation of the file format:

enter image description here