• 0

# Impedance Analyzer and Network Analyzr step size

## Question

When sweeping frequency in the network or impedance analyzers, the default number of samples is 100, but this usually results in awkward values, as it corresponds to 99 steps (fencepost error).  It would be better to make the default be 101 samples.

It might also be nice to have a way of setting the step size, rather than the number of samples.  For linear spacing, this is just a value in Hz (for example, 10Hz–100Hz in steps of 1Hz is 91 samples).  For logarithmic spacing, specifying a ratio is awkward, but steps/decade is simple.  For example, the 1 kHz–1 MHz at 50 steps/decade is 151 samples).  I'm usually more interested in controlling the steps/decade than the total number of samples.

## Recommended Posts

• 0

I added the default +1 for samples/steps.

I will try to implement the step size and steps/decate too. These are a bit complicated since steps = (stop-start)/step_size should be natural, so start or stop might needs to be changed when setting steps size.

Thank you for the idea, observation.

##### Share on other sites
• 0

Steps = (stop-start)/step_size

samples=1+ (stop-start)/step_size

steps = (log10(stop) - log10(start)) * steps_per_decade

samples = 1 + (log10(stop) - log10(start)) * steps_per_decade

This works exactly as expected,  if someone requests an integer number of decades, which is a fairly common use case.

The main question is how to handle non-integer results.  For example, if someone asks for 100 steps per decade from 20Hz to 400Hz, there are 130.1 steps desired, which rounds to 131 samples.  If you start at 20Hz and make the ratio exactly 10^0.01=10.02329, you get 200Hz hit precisely, but the top frequency is 399.1 Hz rather than 400Hz. If the start and stop are made precise, then the ratio is 1.02331, and the 200Hz intermediate point gets changed to 200.4Hz.

Probably the safest thing to do is to keep the start and stop frequencies correct and sacrifice the ratio a little bit.

##### Share on other sites
• 0

Thanks,  3.8.17 interface for impedance analyzer looks good.