Gas station without pumps

2017 September 7

Ultrasonic transmitter and receiver impedance measurement

Filed under: Data acquisition — gasstationwithoutpumps @ 18:53
Tags: , , ,

In Ultrasonic rangefinder with Analog Discovery 2, I looked at the impedance of  an ultrasonic transmitter with the Analog Discovery 2, but I only modeled the transmitter as a capacitor, not modeling the resonances.

So today I collected new data, both for a transmitter and a receiver, using a 1nF C0G (1%) capacitor as the reference impedance, so that I could have clean data from a known pair.  I also looked at the transmitter+receiver as a network, and located the peaks of the signal transmission.  I was curious whether they corresponded more to transmitter or receiver resonances.

I could model the transmitter quite effectively as a capacitor with 4 LCR resonators in parallel.

I could model the receiver quite effectively as a capacitor with three LCR resonators in parallel.

The fitting was done with gnuplot, fitting one resonance at a time starting with the lowest frequency one, then refitting the previously fit parameters to tweak the fit. The radius of convergence for the fitting is pretty small—I needed to get the LC resonant frequency pretty close to correct before the fitting would converge. Increasing L makes the down-spike and up-spike closer together, and R controls how low the minimum gets, so I could get reasonable initial values (good enough to get convergence) without too much guessing, by plotting using the initial values, adjusting L to get the spacing between the spikes about right, adjusting C to get the resonant frequency right, and doing a rough guess that R is about the minimum value.

The peaks of the transmitter+receiver characteristic seem to correspond most closely to the minimum impedance points of the transmitter, which is reasonable when you consider that I’m driving the transmitter from a fixed voltage—the power is going to be V2/R, so power out is maximized when the impedance is lowest.  The one exception is the 331kHz peak, which seems to fall on the higher frequency of the two closely spaced transmitter resonances, and near the peak of receiver impedance. (Of course, only the 40kHz resonance of the transmitter or receiver actually gets used—the other resonances don’t provide nearly as much response in the transmitter+receiver pairing.)

Zooming in on the transmitter impedance for the high-frequency resonances, we can see that there are minor resonances that have not been modeled, but that the model does a good job of capturing the shape of the peaks. The peak of the transmitter+receiver response here falls on the higher-frequency resonance.

I did all my modeling with just the magnitudes of the signals, so it is interesting to see how well the model fits the phase response.

I got excellent matches to the phase response (even when I zoomed in on each peak), except for the low-frequency region, where the impedance seems to have a negative real part (phase < -90°).

I do have models for no resonance, single resonance, two resonances, and three resonances for the transmitter, as well as the four-resonance model. If a simplified model is needed, then it is better to take one of those fits, rather than omitting parts of the more complicated model, as each resonance affects the other parameters somewhat.
As a simple example, the receiver can be modeled as just a 739pF capacitor, but the LCR circuits contribute some of the capacitance, so 708pF gets used for the base capacitor of the model with the 3 resonances.

Advertisements

2017 August 23

Motor testing

Filed under: Data acquisition,Robotics — gasstationwithoutpumps @ 02:20
Tags: , ,

I bought some 6V motors with mounting brackets, wheels, and Hall-effect rotary encoders from Ali Express (https://www.aliexpress.com/item/1-set-2-set-High-torque-Electric-Encoder-Gear-Motor-DC-6V-210RPM-0-13A-Mayitr/32820157282.html), which arrived today, so I spent most of the day playing with them and trying to characterize them.

The first thing to do was to try to relate voltage, current, and speed.  I used the power supply in the Analog Discovery 2 to drive the motor through a resistor, monitoring both the voltage across the motor and the current through the resistor.  I used a Teensy LC board running PteroDAQ to monitor the frequency of the pulses from one of the Hall-effect sensor.  Initially I had tried looking at the pulses with the logic analyzer of the Analog Discovery 2, which gave me a fine short trace from which I could look at individual pulse widths and periods, but not get a long-term average frequency.

Varying the voltage on the motor gave different speeds, and the speed was linear with the voltage.  The current also went up with the voltage, but not linearly (it remained around 40mA even for very low voltages, and only went up to about 67mA at the highest voltages).

The standard simplified model for a motor is an “RLV” model: a resistor, an inductor, and a speed-dependent voltage source (referred to as the back-EMF).  V(s) = R I + L dI/dt + V_s s, where the speed is s, and the current is I. With a constant input voltage, the inductor is not really modelable, so I came up with an RV model:

The speed here is represented by the Hall-effect sensor, which gives 11 ticks per turn of the motor shaft. The back-emf is about 7.64 mV/Hz and the resistance is about 4.8Ω.

I needed about 2.5–3V to start the motor, but once it was running I could reduce the voltage to around 0.667V before the motor stopped (the lower speeds in the plot above were done by reducing the voltage with the motor running).

I tried measuring the impedance of the motor with the new impedance tool of Waveforms 2015. I got somewhat different results depending on the frequency used and the test voltage. For ±1V and low frequencies (under 300Hz), I got around 3.5–3.6mH+4.25Ω, but at higher frequencies the inductance dropped and the resistance increased: at 40kHz I had 1.946mH+438.5Ω. With a 5V signal I got 5.1mH+4.88Ω around 20Hz and down to 1.62mH+484Ω at 40kHz. The resistances at low frequencies are fairly consistent with the resistance I inferred from the back-EMF+IR model. So I’m reasonably comfortable in modeling the motor as having
V(s) = (7.64 mV/Hz) s + 4.8\Omega \,I + 4mH \,dI/dt.

I may have to tweak that inductance, though, as I’m not sure which frequency’s inductance is relevant.

I also recorded the turn-on transients of the motor. I tried first doing this by turning on the power supplies while the oscilloscope was waiting for a trigger, but the power supplies turn on quite slowly, so I added an nFET to the negative rail and controlled the gate with a pushbutton. The pushbutton connected the gate to a positive voltage and the gate had a large pulldown resistor to ground. The large pulldown resistor eventually turns the FET off when the button is released, but slowly enough that contact bounce does not result in turning the nFET on and off.

The voltage initially spikes up to the supply voltage, then the current increases through the inductor, until the resistive voltage divider controls the voltage. Then the motor starts moving and the back emf increases. The initial spike is very short (about 2ms), but spinning up the motor takes over 200ms.

You can see the enormous commutator signal in the voltage and the current. The current is directly controlled by the commutation—the voltage signal is only affected because of the IR drop across the 10Ω sense resistor I used for sensing the current.

We can use the initial turn-on spike to estimate the inductance, by looking at the exponential curve for the growth of the current:

The current is growing towards 412.5mA with a time constant of 311.76µs.

The inductance is just R times the time constant, where R is the series resistance (the 10Ω sense resistor and the 4.8Ω internal resistance—I’ll ignore the on-resistance of the MOSFET). L = 311.76 \mu s 14.8\Omega = 4.61 mH.

All the speed measurements here were in terms of how fast the Hall-effect sensor on the motor shaft was pulsing, but how fast is the output shaft of the gearbox turning? There are two questions: what is the ratio of sensor pulses to motor rotations, and what is the ratio of motor rotations to output shaft rotations?

The website for the motor claimed “Encoder motor end: 11 signals”, which I took to mean that there were 11 pulses per rotation.  I confirmed this by doing a Fourier transform of the commutation signal (the current) and of the pulse signal.  The fundamental of the pulse corresponded to the 11th harmonic of the current, so there were 11 pulses per turn of the motor shaft.

Determining the gear ratio (ratio of motor speed to output shaft speed) was more difficult.  I set up an optical interrupter to be blocked by a bit of electrical tape on the end of the output shaft once per revolution, and recorded the optical signal on every rising edge of the Hall-effect pulse using PteroDAQ.  By recording for a while, I could count the number of Hall-effect pulses for some integer number of shaft rotations.  Taking the pulses/output rotation and dividing by 11 gave me the motor-shaft rotations per output shaft rotation (the gear ratio I was seeking).  Getting a real number for this was fairly straightforward, but I wanted a rational number using products of small integers, corresponding to the gear teeth on the gears!

For one run, I had 856 shaft rotations with 200523 or 200524 pulses (depending whether I counted between rising edges or falling edges of the optical signal), giving me 234.255841121 to 234.257009346 pulses per rotation, or a gear ratio of 21.2959855565 to 21.2960917587.

I did a longer run with 4811 shaft rotations with 1126978 pulses or 1127000 pulses , giving me 234.250259821 to 234.254832675 pulses per rotation or a gear ratio of 21.2954781655 to 21.2958938795.

I converted the gear ratio to a continued fraction using my pocket calculator, getting

21+\frac{1}{3+\frac{1}{3+\frac{1}{-3+\frac{1}{2+\cdots}}}},

which expands to

21 + 1/3 = 21.3333333…

21 + 3/10 =21.3

21 + 8/27 = 21.29630…

21 + 37/125 = 21.296  = 2662/125 = 2 * 11^3 / 5^3   

The last ratio factors nicely, and looks feasible for a gear ratio.  To confirm my estimate, I carefully took apart one of the gearboxes and counted the teeth on the gears.  I got

  • motor shaft 12T
  • engages 22T linked to 10T
  • engages 22T linked to 10T
  • engages 22T linked to 10T
  • engages 24T on output shaft

This gearing does indeed give me the 2 (11/5)^3 gearing I calculated!

So my gear ratio is exactly 21.296 and I have exactly 234.256 pulses per rotation of the output shaft (with the quadrature coding from two Hall effect sensors, I get exactly 937.024 transitions per rotation).

With 6.0364V across the motor, I got 752.37Hz from the sensor, so the output shaft was rotating at 3.212Hz, or 192.7 rpm (somewhat slower than the claimed 210 rpm for 6V no load). The wheels that came with the motors have a circumference of 215mm, so the maximum speed would be 69cm/s, which is about 1.54 mph—not a real zippy machine, but more than fast enough for a small robot.

The tires are pretty squishy, though, and if I want to use the wheel turns to keep track of location, I’ll probably want wheels whose diameter doesn’t vary with the load—perhaps I could wrap the hubs with friction tape. The hub circumference is only 161mm. I could also laser-cut some wheels to get whatever diameter I want.

2017 July 13

Analog Discovery 2 oscilloscope input impedance fixed

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 23:25
Tags: , ,

This morning in Analog Discovery 2 oscilloscope input impedance, I wrote

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

This evening I figured out what I was missing. The model I was trying to fit was the following one for the oscilloscope, with a 2MΩ resistor in series as the reference impedance:

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

What I was missing was parasitic capacitance from the breadboard and scope wiring. If I model a capacitor (Cref) in parallel with the 2MΩ resistor and another capacitor (Cextra) in parallel with the scope, I can get a good fit.  I can leave all the internal resistors and capacitors at their nominal values, and fit for several different values for the trim capacitor C8:

I can get an excellent fit with Rref being only a little over 1% off and reasonable parasitic capacitance values.

Analog Discovery 2 oscilloscope input impedance

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 11:43
Tags: ,

I have been blindly trusting the documentation for the Analog Discovery 2 that claims that the input impedance of the differential oscilloscope channels is 1MΩ || 24pF.  Yesterday, when my son was measuring the input impedance of the reference inputs of a sigma-delta ADC, we had reason for a while to doubt that claim, so I measured the input impedance in a simple way:  I put a 2MΩ 1% resistor in series with one input channel and used the other input channel to measure the voltage across the series pair. I swept the network analyzer from 10Hz to 1MHz, and recorded the voltage gain (and the phase).  The voltage gain is not well-fit by a simple (1MΩ || 24 pF) model, as the impedance does not keep decreasing.  It seems to be well modeled by a model with Rs+(Cp||Rp), though.

The reported voltage gain for Channel 2/Channel 1 is well fit by a voltage divider.

Because the Analog Discovery 2 reports gain for Channel 2/Channel 1, I had to invert the data to get it in the form I wanted for my model (I could, alternatively, have swapped the legs of the voltage divider in the model).

The phases were also well fit by the models, though I did not use the phase information in the fitting. (I tried refitting using just the phase information, but that did not change the parameters by much, nor did it visibly improve the fit of the measured phases, so I left the parameters with just the amplitude fit.)

The DC impedances are both 1.044MΩ, very close to the specified value, but the capacitor is over twice the specified value, and not directly in parallel with the resistance.  The reference resistor I used is supposed to be a 2MΩ±1% resistor, but it was part of a cheap assortment, and we’ve found these cheap assortments to often be slightly out of spec, so I’d not trust it to be better than ±2%.

The 200kΩ/800kΩ split is not very surprising, when we look at the circuit for the input divider of the oscilloscope (from the hardware reference manual):

There is a natural, internal split into an 820kΩ and 220kΩ resistance in the input voltage divider (component numbers here are for channel 1, but channel 2 is identically designed).

The appearance of the 200kΩ/800kΩ split in the model for the input impedance suggests that the trimmer capacitor C8 is not properly adjusted.  If all capacitance and resistance values were nominal, then C8 should be set to 39.59pF, to provide a flat response from the voltage divider (at the high-gain setting), producing an input impedance of (1.04MΩ || 26pF).  But C8 only has a 5–20pF range, so perhaps there are some other, parasitic capacitances that change the desired trimming.

I cannot fit a model based on the input divider circuit to the data—I keep getting a negative capacitance for C9 or C8, so that they can cancel each other.  These models also make C1 around 50pF.

So I can reconcile the DC behavior (1.044MΩ is well within the ±2% measurement error of the nominal 1.04MΩ), but not the AC behavior of the scope inputs.

I must be missing something, but what?  Any useful suggestions (which don’t involve modifying the Analog Discovery 2) are welcome.

2017 June 28

Changing the loudspeaker lab

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 21:38
Tags: ,

I’ve started looking at how the loudspeaker lab in the applied-electronics course will change, given that we will have the Analog Discovery 2 USB oscilloscope in the labs.  There are two main changes in capabilities:

  • hundreds of measurements can be made in a couple of minutes from 10Hz to 1MHz
  • phase information is available, not just amplitude information.

The availability of phase information means that we can try fitting complex impedance, and not just the magnitude of impedance.  Unfortunately, the gnuplot curve fitting that we’ve been using is only set up for fitting real-valued functions, not complex-valued ones, and I don’t really want to switch to a more full-featured model fitting program, as they get hard to use.

Today I gathered data from two loudspeakers: the tiny 1cm one that I have posted about before (Ultrasonic rangefinder tests with tiny loudspeaker and Redoing impedance test for tiny loudspeaker) and an 8Ω oval loudspeaker that we used to use in the class until Parts Express sold out of them (Loudspeaker analysisBetter model for loudspeaker). I only collected data out to 1MHz, since my previous experience indicated that the network analyzer was not very useful past that frequency (Loudspeaker impedance with Analog Discovery 2). I put a 22Ω resistor in series with the loudspeaker and measured the voltage across it on channel 1, with the voltage across the loudspeaker on channel 2.  I recorded the “gain”, which is channel2/channel1, and the phase for channel 2 relative to channel 1.  The gain times 22Ω is the magnitude of the impedance of the loudspeaker.

The formula that I’ve been using for impedance modeling, R + ja\omega^\beta + (R_m || Z_{L_m} || Z_{C_m}), turned out not to be a good fit for the phase.  I played around for a couple of hours with different, more complicated models, before finally settling on a model that is as simple as the one I’ve been using, but that fits pretty well:

R + a (j\omega)^\beta + (R_m || Z_{L_m} || Z_{C_m})

The difference is just that I’m including the j inside the exponentiation, so that the “inductor-like” component is now in direction j^\beta instead of j—that is, the asymptotic phase angle is \sin^{-1}(\beta) instead of 90°.

To do the fitting, I alternated between fitting some of the parameters to the magnitude of the impedance and some to the phase. After I had layed around a bit and gotten ball-park estimates of the parameters, I did a more careful fitting. I started by fitting the series R to just the low-frequency end of the data, then fitting the resonance peak without the “inductor-like” component in the model with data collected in just a decade of frequency around the resonance peak (I used a separate data file that had 600 data points for just that decade).  I fit the three parallel parameters using the phase data, then refit the parallel resistance using the amplitude data.  To start in the right region, I set initial values R_m = R_{peak}-R, C_m = 0.3/\omega, and L_m = 3.3/\omega, with R_{peak} being the magnitude of the impedance at the top of the peak, located at frequency  f, with \omega = 2 \pi f.

With those parameters set, I fit \beta with phase information for the high frequencies, and a with amplitude information.

I then tweaked the fit by refitting the resonance peak, refitting \beta and a, and repeating the refits.

The 6-parameter fit for the magnitude is pretty good.

The 6-parameter fit for the oval loudspeaker is not great for phase, but is not too bad.

The 6-parameter fit for the tiny loudspeaker is pretty good, though I did not attempt to model the two higher frequency resonances that are visible, despite knowing that the resonance around 9kHz rings seriously.

The resonances are somewhat more visible in the phase plot for the tiny loudspeaker than they are in the magnitude plot.

I’m going to have to write up a tutorial for the book on using a real-valued fitting method for fitting a complex-valued function.

Next Page »

Create a free website or blog at WordPress.com.

%d bloggers like this: