PP logo

 

Importing Measured Data into Spice.

Contents


Introduction.

To get scope data into Spice, the data is converted to a piecewise linear voltage or current source.
The example here use a Hantek 6022BE oscilloscope and LTspice, but it can be used with other oscilloscopes and spice variants too.


Importing Measured Data into Spice.

The acsii export files from the scope has the following format:

#CHANNEL:CH1
#CLOCK=50.0mS
#SIZE=1047552
#UNITS:V

0.0000
0.0000


#CHANNEL:CH2
#CLOCK=50.0mS
#SIZE=1047552
#UNITS:V

0.0627
0.0000
Clock is the horizontal Time/Division.
Size is the number of samples. This file contains around 2 million samples which is more than most spread-sheets will handle, so for this to work each channel must be saved to separate files.
For some reason, this scope do not include the sample-rate in the file.

Table 1: 6022BE sample-rate vs. Time/Div.
Time/Div.Sample-rateSamples/channelTotal sample time
1 µs to 2 µs48 MHz101621 µs
5 µs16 MHz1300488.1 ms
10 µs8 MHz13004816 ms
20 µs4 MHz13004833 ms
50 µs to 2 ms1 MHz130048130 ms
5 ms to 20 ms1 MHz523264520 ms
50 ms to 100 ms1 MHz10475521.1 s
200 ms500 kHz10475522.1 s
500 ms200 kHz10475525.1 s
1 s to 5000 s100 kHz104755211 s

As the table above shows, this scope always output a fixed file length ( it can actually output a 2 million line .xls file, but I do not have anything that can read it ).
I many cases this is a lot more data than you need, so reduce the amount of data to what you need.
Copy-paste all data to the same spread-sheet, reduce the number of lines to what you need, add time information and information for spice.

Table 2: Example spread-sheet.

ABCDE
1#CHANNEL:CH1#CHANNEL:CH2TimeChannel 1 Spice dataChannel 2 Spice data
2#CLOCK=50.0mS#CLOCK=50.0mS
Note that 1. and last lines
are different from the rest.
Note that 1. and last lines
are different from the rest.
3#SIZE=1047552#SIZE=1047552


4#UNITS:V#UNITS:V


5




6000Vchannel1 CH1 0 pwl(0 0Vchannel2 CH2 0 pwl(0 0
7000.000001+ 0.000001 0+ 0.000001 0
800.03140.000002+ 0.000002 0+ 0.000002 0.0314
900.03140.000003+ 0.000003 0+ 0.000003 0.0314
1000.03140.000004+ 0.000004 0+ 0.000004 0.0314
1100.03140.000005+ 0.000005 0+ 0.000005 0.0314
1200.03140.000006+ 0.000006 0+ 0.000006 0.0314
1300.03140.000007+ 0.000007 0 )+ 0.000007 0.0314 )

Columns A and B are data from the scope.
Column C is the time. C6 is the number "0" and C7 and up are the line above with 1/samplerate added.
D6 is the expression ="Vchannel1 CH1 0 pwl("&C6&" "&A6
D7 is the expression ="+ "&C7&" "&A7
D8 to D12 are the same as D7, but with the respective row numbers.
D13 is the expression ="+ "&C13&" "&A13&" )"

This is a Spice voltage source named "Vchannel1" with output on nodes "CH1" and "0".
Copy D6 to D13 to an ascii file and save it as f.ex. "Channel 1.cir".
In your Spice file , include the directive: ".include Channel 1.cir", and you have your measured waveform on node "CH1".


Downloads.

An example of importing measured data into Spice.


Copyright and disclaimer.

Copyright Notice.
This web-page, including but not limited to all text, drawings and photos, is the intellectual property of Poul Petersen, and is Copyright ©.
Reproduction or re-publication by any means whatsoever is strictly prohibited under International Copyright laws.
The author grants the reader the right to use this information for personal use only.
Any commercial use is prohibited without express written authorization from Poul Petersen.

The information is provided on an "as-is" basis and is believed to be correct, however any use of the information is your own responsibility.

This web-site may contain links to web-sites outside Poul Petersen domain ( www.poulpetersen.dk ).
Poul Petersen has no control over and assumes no responsibility for the content of any web-site outside Poul Petersen own domain.

Poul Petersen does not use cookies to "enhance your experience" on this website.


Poul Petersen, C/Faya 14, 35120 Arguineguín, Las Palmas, Spain.
E-mail: pp@poulpetersen.dk

Poul Petersen notes index

Poul Petersen diy index


Copyright © Poul Petersen 2019..2020. Last update: 20200118. Valid HTML!