Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
ngspice linear AC simulation?
Until KiCAD 6 I was able to define a linear ngspice AC simulation by including a text .ac lin 101 100 1meg for simulating a linear frequency range from 100 Hz to 1 MHz with 101 samples/decade but with the current KiCAD 7.0.11 freshly installed on Debian GNU/Linux and ngspice-42 the display remains with a logarithmic frequency scale despite Sim Command -> Custom properly detecting my request. In ngspice I would .control ac lin 101 100 1meg .endc but these statements are not detected as custom commands, even when setting LTSpice compatibility flag. Is there a way to achieve a linear frequency AC simulation with KiCAD as graphical frontend to ngspice? Thanks, Jean-Michel |
Hi Jean-Michel,
You are correct. At least in KiCad 8, the simulation plot window for an AC simulation always shows a decade logarithmic frequency scale. The ngspice simulator executes the linear frequency sweep if that is what you ask for, but KiCad always displays a logarithmic frequency scale. The plot settings dialog is incorrect when it says "Number of points per decade" for a linear sweep. It should say "Number of points" for a linear sweep, and that is why you probably don't want to do that.? Your command ".ac lin 101 100 1meg"?is?asking for 101 equally spaced points between 100 Hz and 1 MHz. If you subtract 100 from 1M you get a frequency span of 999,900 Hz. To get 101 points this span is divided by 100 to get a frequency step size of 9,999 Hz. So the first step is 100 Hz, the second is at 100 + 9999 = 10099 Hz, the third is at 10099 + 9999 = 20098 Hz, etc. until the final steps are at 990,001 Hz and 1 MHz. So your first three decades contain only two data points, one at 100 Hz, and one just past 10 kHz.? Open the Simulation/Sallen_Key demo project (using File->Open Demo Project...) and simply change the command from ".ac dec 10 1 1meg" to?".ac lin 101 1 1meg"?and look at the difference in the plots. The original uses 60 points spread equally across the 6 decades with 10 points per decade. The second has two points in the first 3 decades and the other 98 spread over the last three decades with most of the points crammed up near the? 1 MHz frequency end. That is why linear frequency sweeps are usually used over a fairly narrow range of frequencies not over multiple decades.? Until KiCad allows displaying a linear frequency scale to plot the results there is no reason to use a linear frequency sweep unless you want to see the data over a narrow range of frequencies in which case you can zoom in to see those frequencies only (but still on a logarithmic frequency scale). You could put in a feature request to allow selecting linear frequency scales for display which would make using linear frequency sweeps more attractive. HTH |
Thank you for your reply: indeed my test was poorly designed by transposing to the linear range the parameters I used in the log scale. I was emphasizing on the lack of linear X-axis (which was working with KiCAD 5 and 6): my use case as shown in on slide 24 is the characterization of high quality quartz resonators which do require narrowband simulation but also a linear frequency scale since the quality factor is derived from the width at half height of admittance. I will file a feature request accordingly. Thank you, Jean-Michel De: "Dennis" <dennisc@...> ?: "kicad-users" <[email protected]> 贰苍惫辞测é: Vendredi 1 Mars 2024 18:45:09 Objet: Re: [kicad-users] ngspice linear AC simulation? Hi Jean-Michel, You are correct. At least in KiCad 8, the simulation plot window for an AC simulation always shows a decade logarithmic frequency scale. The ngspice simulator executes the linear frequency sweep if that is what you ask for, but KiCad always displays a logarithmic frequency scale. The plot settings dialog is incorrect when it says "Number of points per decade" for a linear sweep. It should say "Number of points" for a linear sweep, and that is why you probably don't want to do that.? Your command ".ac lin 101 100 1meg"?is?asking for 101 equally spaced points between 100 Hz and 1 MHz. If you subtract 100 from 1M you get a frequency span of 999,900 Hz. To get 101 points this span is divided by 100 to get a frequency step size of 9,999 Hz. So the first step is 100 Hz, the second is at 100 + 9999 = 10099 Hz, the third is at 10099 + 9999 = 20098 Hz, etc. until the final steps are at 990,001 Hz and 1 MHz. So your first three decades contain only two data points, one at 100 Hz, and one just past 10 kHz.? Open the Simulation/Sallen_Key demo project (using File->Open Demo Project...) and simply change the command from ".ac dec 10 1 1meg" to?".ac lin 101 1 1meg"?and look at the difference in the plots. The original uses 60 points spread equally across the 6 decades with 10 points per decade. The second has two points in the first 3 decades and the other 98 spread over the last three decades with most of the points crammed up near the? 1 MHz frequency end. That is why linear frequency sweeps are usually used over a fairly narrow range of frequencies not over multiple decades.? Until KiCad allows displaying a linear frequency scale to plot the results there is no reason to use a linear frequency sweep unless you want to see the data over a narrow range of frequencies in which case you can zoom in to see those frequencies only (but still on a logarithmic frequency scale). You could put in a feature request to allow selecting linear frequency scales for display which would make using linear frequency sweeps more attractive. HTH |
to navigate to use esc to dismiss