Skip to main content
29 events
when toggle format what by license comment
Aug 5, 2021 at 5:21 comment added Bruce Abbott With pure sine sine waves in a linear circuit all you need to determine phase is the zero crossing points. But you may not have samples exactly on the zero point. So take two consecutive samples, one on one side and the other on the other side of zero, extrapolate linearly between them (almost no difference from a sine wave at this small distance) and find the time at which that line crosses zero. This is much more accurate than trying to measure phase using the peaks of the sine waves.
Aug 5, 2021 at 1:16 comment added jrive @Bruce Abbot, I still don't understand how extrapolating between the zero crossings gives me uniform sampling.....
Sep 26, 2020 at 19:24 comment added Neil_UK @jrive I used to use a different spice, Simetrix, which definitely had this facility, called print_step. However, the free version was crippleware, limited to 50 nodes, which was enough for one opamp model, but not two, so completely unscalable, so I switched to LT. It's likely that I never tried to use it in LTSpice, andgot confused between the two simulators. If you read the LTwiki it says the step parameter is of no use. It's a pity in the 2 FFT trick, it won't give you the interpolated data without doing the FFTs!
Sep 26, 2020 at 18:37 comment added Neil_UK @jrive I've now come across this in my searches and see where you're getting your FFT process from, it wasn't clear from your OP that it was internal to LTSpice, or was a documented trick. Do check that the time data exported from this 2xFFT trick is consistent with the time data exported normally, things can go wrong with FFT implementations (excel xy scatter plot automatically interpolates). Also, read through the other answers to the question linked in my previous comment, ltsputil seems worth a look.
Sep 26, 2020 at 18:29 comment added Neil_UK @jrive Hmm. I'm convinced it used to work, but it doesn't appear to work now. See this question that I answer, I seem to be very sure there. LTSpice IV does not have this facility. LTSpice XVII claims to, but it's only settable in text, not in the edit simulation GUI, and then it doesn't appear to work now. I'd recommend interpolating the output file to your desired time steps, that will work. I'll carry on experimenting for a bit, it would be useful.
Sep 26, 2020 at 17:38 comment added jrive @Neil_UK -- thank you --I looked and I can't figure out where to set it to uniform sampling per your suggestion. The only modifiers are: UIC, steady, nodiscard, startup, and step. And in the actual trans simulation card, I can only do: stop time, time to start saving data, max step, ext dc start at 0, stop sim when ss is reached, step the load current source, and skip initial operating point solution. I'm really interested in this, so if you can figure it out, please let me know. Thank you.
Sep 24, 2020 at 13:14 comment added Neil_UK You can force LTSpice to output samples at uniform intervals, in the .TRANS setup tab, IIRC it's an entry field called something like 'print every xxx'
Mar 5, 2020 at 14:31 history edited jrive CC BY-SA 4.0
FFT Method solution in summary incorrectly displayed Z-phase for the phase delay of Vo
Mar 4, 2020 at 21:52 history edited jrive CC BY-SA 4.0
added FFT method, summarized results
Mar 4, 2020 at 21:00 history tweeted twitter.com/StackElectronix/status/1235309180652859397
Mar 4, 2020 at 15:38 answer added Huisman timeline score: 1
Mar 4, 2020 at 15:08 vote accept jrive
Mar 4, 2020 at 14:29 comment added Bruce Abbott Extract the zero crossing time of each sine wave by getting the smallest positive and negative values and extrapolating between them.
Mar 4, 2020 at 14:05 comment added jrive @Bruce Abbot not sure I understand your comment. What is the simple solution for solving the non-uniform time-steps from an LTSpice transient analysis?
Mar 4, 2020 at 13:09 answer added ocspro timeline score: 2
Mar 4, 2020 at 2:03 comment added Bruce Abbott "LTSpice does not sample at uniform intervals, so a trick to recover uniformedly sampled data is to take an FFT of the signals, and then take another FFT of the FFT'd signals to recover the time domain data" - that seems like a ridiculously complicated way to solve a simple problem.
Mar 3, 2020 at 22:26 history edited jrive CC BY-SA 4.0
added 109 characters in body
Mar 3, 2020 at 22:01 comment added jrive @BrianDrummond --I just reread your comment, and I realized that you might have been asking about the cross correlation approach which uses the FFT and inverse FFT. Still, I do not know how many points numpy.fft uses.....I'll look at the documentation for it. Thank you.
Mar 3, 2020 at 21:58 comment added jrive Ok...I added the code....It's too much i think. It would be better if I could share the Jupyter Notebook --it would be clearer. I'm surprised this StackExchange does not provide an easy way to share this kind of stuff. If I could share my data, and my notebook, it would be easier for people to help, I think.... Thank you for your help so far.
Mar 3, 2020 at 21:57 history edited jrive CC BY-SA 4.0
Added multiple snippets of code.
Mar 3, 2020 at 21:38 comment added The Photon There's a button to format code as code (i.e. with a monospace font, indented and with a different background color) in the question editor. If you post a large block of code it will make a scrollable window. But you should try to focus on the code that causes the actual problem, because volunteers mostly won't read through pages and pages of stuff to get to the real problem.
Mar 3, 2020 at 21:36 comment added jrive @The Photon --- that is what I"m asking....And, I would like to share all the code, and the data ---do you know how I can do that?
Mar 3, 2020 at 21:35 comment added jrive @BrianDrummond, I"m using the FFT capabilities in LTPSice -- I"m not sure how many points it uses. The other alternative is to export the time domain signals "as is" and then do some cubic spline interpolation or something similar to that to and compare the result I get from that approach to the approach where I rely on the interpolation LTspice does on the data in the process of computing the FFTs. LTSpice claims their method has very high precision, though.....I may try the interpolation approach next. Thank you for your response
Mar 3, 2020 at 21:33 comment added The Photon Wait, but now that I read more carefully, I notice you said "I think the problem stems from the fact that I can't seem to accurately determine the amplitudes of Vo, Vi, and the phase delay between them from the processed samples.". So don't jump the gun and ask about the formulas that calculate the component values from the amplitudes and phases. Ask why you aren't estimating the amplitudes and phases accurately. (And if you want useful answers, include your code that estimates the amplitudes and phases)
Mar 3, 2020 at 21:29 comment added jrive @ThePhoton, yes -- the estimates are all good...it is the accuracy that seems to be the issue. Frequency is known ahead of time.
Mar 3, 2020 at 21:00 comment added user16324 How many point FFT? Have you experimented with different FFT lengths and seen any trend betweenFFT length and accuracy?
Mar 3, 2020 at 20:52 comment added The Photon Also, does your Python code assume the frequency of the signal is known a priori, or do you also have to estimate the frequency from the data?
Mar 3, 2020 at 20:51 comment added The Photon Step 1: Can you read the LTspice output file into your Python code and just re-plot it to verify you are reading it correctly. Step 2: Can you estimate the magnitude and phase of \$V_i\$ and \$V_o\$ correctly? Only after making sure you can do steps 1 and 2 should you worry about step 3: Use \$V_i\$ and \$V_o\$ to estimate the circuit variables \$R_s\$, \$L_s\$, and \$R_1\$.
Mar 3, 2020 at 20:21 history asked jrive CC BY-SA 4.0