2
\$\begingroup\$

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.

\$\endgroup\$
9
  • 2
    \$\begingroup\$ If you are a software wizard, you might be able to hack out some software to convert the binary files to something usable faster than you can retake the measurements. \$\endgroup\$
    – Mattman944
    Commented Oct 5, 2022 at 8:29
  • \$\begingroup\$ @Mattman944 something I already thought of, but I have no info about how the data is stored in the BIN. Only what I have chosen (Int32, int64…, float64). I am trying to import it with Octave right now and will try Phyton/Numpy later on. Maybe I manage to get something useful out. \$\endgroup\$ Commented Oct 5, 2022 at 9:26
  • \$\begingroup\$ Which binary format? int and uint are unambiguous. There is more than one Float format, but since this is a modern scope, it is probably IEEE-754 format. Post a hex dump with your settings, maybe someone will take on the challenge. \$\endgroup\$
    – Mattman944
    Commented Oct 5, 2022 at 13:21
  • 1
    \$\begingroup\$ @Mattman944 Challenge accepted :) You were right about the format. \$\endgroup\$
    – jonathanjo
    Commented Oct 6, 2022 at 8:48
  • 1
    \$\begingroup\$ Most spreadsheets will fail to graph 100,000-point files. You can use R to quickly make a graph (including the binary file directly, updated answer). But if you have a good viewer, nothing wrong with that! \$\endgroup\$
    – jonathanjo
    Commented Oct 6, 2022 at 13:34

2 Answers 2

3
\$\begingroup\$

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

\$\endgroup\$
2
  • \$\begingroup\$ I am expecting the waveforms I captured on site. Waveforms displaying an RS-422 communication (one direction). Files are between 79kB and 500MB, depends if I captured only on screen or used the datalogger. I mostly saved the BIN files using floar64 and using two channels. I will make a new capture for the hexdump right now and add it to main question. \$\endgroup\$ Commented Oct 6, 2022 at 6:23
  • \$\begingroup\$ Thank you! The python script is working perfectly. Not all info is saved, but at least I can look at the waveforms now. For a fast look at the waveform, I found "Flow CSV Viewer" by "Waveworks" (MS Store App) very helpful. \$\endgroup\$ Commented Oct 6, 2022 at 10:32
0
\$\begingroup\$

According to the software user's guide, you need the same Handyscope software on your computer as on the computer where you used the HS4. It can load the saved files.

The only way to tell whether or not the files contain the data you need is to open them. Both the TPS and the TPO files may contain the data you wanted, but what really lands in the files depends on what you selected as you saved the file.

If you can open the file on your computer and find the data you need, then you'll be able to analyse it using the Handyscope software. You can also export it to other formats to use the data with other programs.

\$\endgroup\$
3
  • \$\begingroup\$ The Handyscope software can load different file formats. But I have not found a way to import a .bin file. I have created a TPS file with the same settings I used to create the BIN file. But loading the TPS file doesn't load the binary, not it shows a waveform. \$\endgroup\$ Commented Oct 5, 2022 at 8:25
  • \$\begingroup\$ According to 11.3.2, exported files cannot be read by the software. \$\endgroup\$
    – Mattman944
    Commented Oct 5, 2022 at 8:25
  • \$\begingroup\$ @Mattman944 thanks for finding this. I have definitely chosen the wrong file format/export for inspecting the waveform later. \$\endgroup\$ Commented Oct 5, 2022 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.