Sub Main REM file header 20 bytes REM byte1..byte6: 0xAA, 0x55, 0x00, 0x01, 0x00, 0x00 REM byte7: 0x00 = CH1, 0x01 = CH2 REM byte8: 0x00..0xA0 = y/DIV in steps, see switch-case below REM byte9: 0x00..0xFA = y-offset 0..250 pixels REM y-resolution: internal +- 5DIV in each direction (10DIV absolut), but upper and lower DIV not viewable REM y-resolution: value in byte9 for y-offset go from "0x00" to "0xFA" (dec 250), 0V = 0x7E (dec 126) REM byte10+11: unknown (trigger moment?) REM some values are 0x0C10, 0x7D12, 0xF413, 0xF412, 0xFA12, 0x7114, 0x0611, 0x2A0B REM byte12: 0x00 REM byte13: 0x02..0x20 = x/DIV in steps, see switch-case below REM byte14: (0x00) 0x19..0xE1 (0xFA) = x-Offset 0..250 pixel, 0s = 0x7D (dec 125) REM byte15-20: 0x0000 0x0100 0x0000 REM in x and y direction there are 25 units (or pixels) per div pixel_per_div=25 REM scaling of X axis (10 DIVs = 2500 Pixel) REM real there are 2560 data points REM should be "256" values_per_div=250 REM preset channel_name = "CH0" dim raw_data as byte sheet = thisComponent.getSheets.getByName("import single") REM Get input parameters filename = sheet.getCellByPosition(6,2).string REM open the data file open filename for binary as #1 REM get channel get #1,7,raw_data select case raw_data case 0 channel_name = "CH1" case 1 channel_name = "CH1" case else channel_name = "CH?" msgbox "Channel name not found set CH?" End Select sheet.getCellByPosition(8,4).value = raw_data sheet.getCellByPosition(6,4).string = channel_name REM ++++++++ calculate y resolution ++++++++++++++ get #1,8,raw_data select case raw_data case 0 y_per_div = 20 y_unit="mV" case 1 y_per_div = 50 y_unit="mV" case 2 y_per_div = 100 y_unit="mV" case 3 y_per_div = 200 y_unit="mV" case 4 y_per_div = 500 y_unit="mV" case 5 y_per_div = 1 y_unit="V" case 6 y_per_div = 2 y_unit="V" case 7 y_per_div = 5 y_unit="V" case 8 y_per_div =10 y_unit="V" case 9 y_per_div =20 y_unit="V" case 10 y_per_div =50 y_unit="V" case else REM 1/pixel_per_div means "1" after further calcualtion y_per_div = 1/pixel_per_div y_unit="U" msgbox "Volts/DIV not found set to 1/pixe_per_div (mostly 1/25)" End Select sheet.getCellByPosition(8,6).value = raw_data sheet.getCellByPosition(6,6).string = " " + y_per_div + " " + y_unit REM calculate y offset (126=0) get #1,9,raw_data y_offset = (126-raw_data)/pixel_per_div*y_per_div sheet.getCellByPosition(8,7).value = raw_data sheet.getCellByPosition(6,7).string = " " + y_offset + " " + y_unit REM calculate x resolution get #1,13,raw_data select case raw_data case 2 x_per_div = 5 x_unit="ns" case 3 x_per_div = 10 x_unit="ns" case 4 x_per_div = 20 x_unit="ns" case 5 x_per_div = 50 x_unit="ns" case 6 x_per_div = 100 x_unit="ns" case 7 x_per_div = 200 x_unit="ns" case 8 x_per_div = 500 x_unit="ns" case 9 x_per_div = 1 x_unit="us" case 10 x_per_div = 2 x_unit="us" case 11 x_per_div = 5 x_unit="us" case 12 x_per_div = 10 x_unit="us" case 13 x_per_div = 20 x_unit="us" case 14 x_per_div = 50 x_unit="us" case 15 x_per_div = 100 x_unit="us" case 16 x_per_div = 200 x_unit="us" case 17 x_per_div = 500 x_unit="us" case 18 x_per_div = 1 x_unit="ms" case 19 x_per_div = 2 x_unit="ms" case 20 x_per_div = 5 x_unit="ms" case 21 x_per_div = 10 x_unit="ms" case 22 x_per_div = 20 x_unit="ms" case 23 x_per_div = 50 x_unit="ms" case 24 x_per_div = 100 x_unit="ms" case 25 x_per_div = 200 x_unit="ms" case 26 x_per_div = 500 x_unit="ms" case 27 x_per_div = 1 x_unit="s" case 28 x_per_div = 2 x_unit="s" case 29 x_per_div = 5 x_unit="s" case 30 x_per_div = 10 x_unit="s" case 31 x_per_div = 20 x_unit="s" case 32 x_per_div = 50 x_unit="s" case else REM 1/pixel_per_div means "1" after further calculation x_per_div = 1/pixel_per_div x_unit="t" msgbox "Time/DIV not found set to 1/pixe_per_div (mostly 1/25)" End Select sheet.getCellByPosition(8,9).value = raw_data sheet.getCellByPosition(6,9).string = " " + x_per_div + " " + x_unit REM calculate x offset (125=0) get #1,14,raw_data x_offset = (125-raw_data)/pixel_per_div*x_per_div sheet.getCellByPosition(8,10).value = raw_data sheet.getCellByPosition(6,10).string = " " + x_offset + " " + x_unit REM import the datas sheet.getCellByPosition(0,0).string = "Zeit [" + x_unit + "]" sheet.getCellByPosition(1,0).string = "Rohdaten " + channel_name + " [-]" sheet.getCellByPosition(2,0).string = "Daten " + channel_name + " [" + y_unit + "]" REM Clear data from previous import sheet.getCellRangeByName("A2:C9999").clearContents(255) count=0 REM Skip header bytes file_pos=21 REM Read the first byte get #1,file_pos,raw_data 'ThisComponent.LockControllers while not eof(1) sheet.getCellByPosition(0,count+1).value=x_offset+x_per_div*count/values_per_div sheet.getCellByPosition(1,count+1).value=raw_data sheet.getCellByPosition(2,count+1).value=y_offset+(126-raw_data)/pixel_per_div*y_per_div REM read next byte count=count+1 file_pos=file_pos+1 get #1,file_pos,raw_data wend 'ThisComponent.UnlockControllers close #1 if count=0 then msgbox "File not found or empty" else sheet.getCellRangeByName("J2:J2561").setDataArray(sheet.getCellRangeByName("B2:B2561").getDataArray) sheet.getCellRangeByName("K2:K2561").setDataArray(sheet.getCellRangeByName("C2:C2561").getDataArray) msgbox "Ready" end if End Sub