Gas station without pumps

2018 July 9

Analog Discovery breadboard adapter

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

As I mentioned in Analog Discovery Impedance Analyzer, I recently bought two new attachments for my Analog Discovery 2.  I reviewed the Impedance Analyzer in the earlier post, so in this one I’ll review the breadboard breakout.

The breadboard breakout provides a simple way to attach the Analog Discovery 2 to a breadboard, without using the female headers that come with the device.

Here is the breadboard adapter, plugged into the end of a breadboard.

The Analog Discovery 2 can plug into the breadboard vertically, which is compact, but requires disassembly to put the test setup back in its box for carrying.  Here it is shown plugged into the last 15 rows of the breadboard, but I had to move it in two rows to keep the weight of the AD2 from tipping the breadboard.

I tried doing a little work with the breadboard adapter and found it to be a mixed blessing. I used it for testing a circuit where I needed both oscilloscope channels, one power supply, and one waveform generator, which would normally use 7 of the 30 wires on the AD2.  Some of the wires (the power, ground, and oscilloscope 1- and 2- wires) could be quite short, as they connected to the power busses on the breadboard, but the other wires had to be fairly long, as they had to skip past all the trigger and logic-analyzer inputs that I wasn’t using.  I could have plugged the adapter into the breadboard the other way around, but then the AD2 itself would interfere with convenient wiring.  It would have been nice to have the most frequently used connections at the tip of the adapter, instead of the base of the adapter.

For a fixed setup, where the oscilloscope channels are always looking at the same signals, the breadboard adapter is more convenient that the standard flywire connections, which have a tendency to slip off the double-ended male headers that I use for connecting them to the breadboard.  The female headers of the flywires are not designed for many cycles of attaching and detaching, and end up getting too loose after a while.

But for debugging, when the oscilloscope channels have to be moved rapidly from node to node, the breadboard adapter is less convenient than having the separate flywires—unless much longer wires are used (with the attendant problems of extra inductance and capacitive pickup of 60Hz interference). Losing 17 rows of the breadboard to the adapter is also a problem, as it leaves only 47 rows of a standard 64-row breadboard, or 15 rows of half-length breadboard for building the test circuit.

I think that I will use the adapter for lecture demos, where I have fixed wiring to carry around, as I can spend less time setting up the demo just before class, at the cost of slightly more time the night before. My standard lecture setup will use a full-length breadboard with the adapter in one end and a Teensy LC in the other end (for PteroDAQ demos) using up 31 of the 64 rows, leaving me with the equivalent of about a half-length breadboard in the center for the circuitry being demonstrated.

I don’t know yet whether I’ll find the adapter useful for regular debugging—probably not much.

Advertisements

2018 July 1

Analog Discovery Impedance Analyzer

Filed under: Circuits course,Data acquisition — gasstationwithoutpumps @ 17:54
Tags: ,

One of the new toys I got this week was the Impedance Analyzer board for my Analog Discovery 2 (I also got a Breadboard Breakout, but I won’t discuss that in this post).

Here they are in the bags they shipped in.

And here they are unwrapped.

I tried testing out the impedance analyzer board today, to see how well it worked, and to try to determine the precision of the reference resistors they used, since Digilent does not seem to have provided that information on their datasheets.

The impedance analyzer board is used just like any other setup for using the Analog Discovery impedance meter: you select the reference resistor and the range of frequencies, run open-circuit and short-circuit compensation, then insert the impedance to measure and do a sweep. The only difference is that the board uses latching relays to select the reference resistor, rather than having to wire it yourself. The board has 6 resistors: 10Ω, 100Ω, 1kΩ, 10kΩ, 100kΩ, and 1MΩ.

I did several tests, many of which seemed rather inconclusive. One fairly consistent result was that the open compensation saw the open circuit as essentially a 1.63pF capacitance. One exception was the 10Ω resistor, which reported 5.4pF, but I suspect that is due to measurement error from quantization—as 1.6pF at 1MHz is still about -j 100kΩ and the 10Ω resistor would have only 0.001 times the voltage across the open circuit. These capacitance measurements were only consistent above about 3kHz—at lower frequencies I had rather noisy results, probably again because of quantization problems measuring small voltages across the reference resistor.

The short-circuit compensation reported values roughly proportional to the size of the reference resistor, with a maximum around 24mΩ for the 10Ω reference to 148Ω for the 1MΩ reference. The impedance changed a lot with frequency, with a maximum around 18kHz. The phase change varied a lot with frequency also.

I used the impedance meter to measure some 0.1% resistors that I had purchased previously to use as reference resistors in my own impedance setups. The impedance measured was not constant with frequency (generally fairly flat at low frequency, then peaking a little around 70kHz, then dropping off with higher frequency). The variation with frequency was as much as 2–3%. Incidentally, the latest version of Waveforms (3.8.2) still has the bug where the impedance meter sometimes exports the frequencies as if they had been stepped linearly, instead of logarithmically. [Update 2018 July 2: Digilent says that the bug will be fixed in the next release.  Based on their rate of updates lately, that should be soon.]

The impedance of the 10kΩ±0.1% resistor is not constant with frequency. This plot has a linear y axis, to accentuate the fairly small change that is measured.

I decided to measure each of the precision resistors using each of the reference resistors at 100Hz, with settling time set to 2ms and 32 cycles. (I probably should use a longer settling time for more accuracy at low frequencies and average 10 or more measurements.) I’ve marked in red those measurements that are off by more than 1%:

Reference 100Ω ±0.1% 1kΩ ±0.1% 10kΩ ±0.1% 100kΩ ±0.1%
10Ω 98.81Ω 986.3 9955 77.97k
100Ω 99.83Ω 998.8 9936 98.91k
1kΩ 99.88Ω 998.6 9980 99.69k
10kΩ 100.4Ω 998.5 9971 99.88k
100kΩ 106.1Ω 1005 9987 99.97k
1MΩ 118.3Ω 1042 10000 99.97k

The results are best when using a reference resistor within a factor of 10 of the resistor being measured, and those results seem to be within about 0.2% of the correct value, which suggests that Digilent is using 0.2% resistors (or that they got very lucky with standard 1% resistors).  The one set of bad values is from the 10Ω reference—the resistance of the relay contacts may be big enough to throw off that measurement, though I would have expected measurements to be too big, if that were the source of the error.

2018 June 3

VCO (voltage-controlled oscillator)

Filed under: Circuits course — gasstationwithoutpumps @ 11:01
Tags: , , , ,

My students requested that I talk about voltage-controlled oscillators (VCO) and low-frequency oscillators (LFO) for audio work in my applied electronics course.  (We’re in the last week, and they have everything they need to know for the final EKG lab.)

I spent some time Friday night and this morning designing, building, and testing a couple of VCO circuits—one for which frequency is linear with voltage and one for which frequency is exponential with voltage.  Both can easily be turned into low-frequency oscillators by increasing the size of one capacitor.

The oscillators have two outputs: a square wave and a triangle wave. I chose a triangle-wave oscillator, because the design is simpler than for sine waves, and the students have all the concepts they need to understand the design.

The oscillator consists of two parts: an integrator to convert a constant current input into a constant slope: dV/dt = I/C, and a Schmitt trigger to change the current from positive to negative.  Rather than using a Schmitt-trigger inverter chip, I made the Schmitt trigger from an op amp (a comparator would give crisper transitions, but that is not important at the low speeds we’re dealing with).

This design has the frequency linear with the voltage.

The op amp in the upper-left corner is a unity-gain buffer to isolate the input from the rest of the circuit.  It isn’t really needed in this design, and it limits the input voltage range to the power-supply voltage (I used 3.3V).

The next op amp is the integrator, which turns an input current into a constant slope on the output voltage.  The current through the capacitor is 10nF dV/dt.

When the FET is turned off, the current flows through R6+R7, and I= (Vin/2 – Vin)/ (R6+R7), so dV/dt = – Vin/(2* 10nF * 6.6kΩ) = -Vin / 132µs.

When the FET is turned on, the current is the difference between the current through R8 and through R6+R7, and so is (Vin/2)/R8+(Vin/2 – Vin)/ (R6+R7), which simplifies to Vin/(2*6.6kΩ), and dV/dt = Vin/132µs.

The lower-right op amp is an inverting Schmitt trigger with thresholds at 1/3 and 2/3 of Vdd.  It turns on the nFET when the voltage of the triangle wave has dropped below the lower threshold and turns it off again when the voltage has risen above the upper threshold.

The upper-right op amp is just a unity-gain buffer to isolate the output from the oscillator.

My first attempt at this design used larger resistors for R6=R7=R8 and a smaller capacitor, but it had problems when the nFET turned off—the voltage continued to rise for a little while.  The problem was that the drain of the FET had to be charged through R6+R7 before the current through the capacitor was reversed, and this took too long.  Shrinking the resistors made the capacitance on the drain of the FET much less important.

This design has the frequency exponential with voltage (about one octave per 70mV).

The oscillator design is the same as for the linear one, but the diodes provide an exponential current from the input voltage. The input unity-gain buffer is now important, as it provides current limiting to prevent damage to the diodes.  To get double the current through the FET when it is turned on, the diodes are put in parallel on the lower leg (a series arrangement on the upper leg like for the resistors would not halve the current).

I tested both circuits and they seem to work ok, with duty cycles close to 50% for the square wave.  There are slight high-frequency glitches at the peaks of the triangle wave, so it may be worth replacing the output unity-gain buffer with a 40kHz low pass filter.

This is a fairly high frequency from the diode-controlled oscillator (15.431kHz) and the duty cycle is a bit off (59.36%), because the current has gotten large enough that the on-resistance of the nFET matters.

At 500mV, the frequency is 25.77Hz, the duty cycle is about 48%, and the glitches are not visible at this time scale.

I measured and plotted the frequency as a function of voltage for VCO with diodes:

The fit is done here omitting the lowest and highest points. I believe that the highest point has hit the current limits of the input unity-gain buffer, and so is not on the straight line.

The frequency scaling of the diode-based VCO could be changed by replacing the input unity-gain buffer with an amplifier with a different gain.

(2018 June 23: I feel compelled to point out that this circuit does not have any thermal compensation, and the exponential conversion of voltage to current in the diode junctions is highly temperature sensitive.  I’ll try this summer to redesign the circuit to have temperature compensation, though the use of 3 diodes here makes that difficult—a sawtooth oscillator, with only diode would be somewhat easier.)

2018 April 22

Leanpub changing their pricing model again

Filed under: Circuits course,Uncategorized — gasstationwithoutpumps @ 09:50
Tags: , ,

I’ve been publishing drafts of my book with Leanpub since August 2015, shortly after I first heard about them from Katrin Becker.  I took the chance with an unknown publisher largely because it cost me nothing, they took no rights to the book, and their e-book store had very generous royalties.

About  a year ago, they changed their pricing model for authors, so that there was a flat $99 fee for starting each new book, though existing books like mine were grandfathered in with no fee.

They just announced to authors another change in their pricing plan (though again, existing books are grandfathered in).  Now authors have a choice between a $99 flat fee per book or subscription plans of $8, $19, $29, or $59 a month, depending on how many books they have—the $8/month plan is for up to 3 books.  For the 32 months I’ve been with LeanPub, the new subscription pricing scheme would have cost me $256—much more than the $99 flat fee, which would have already been high enough for me to look elsewhere when I was starting.

The new subscription pricing scheme strikes me as a sucker’s deal, if you are really going to stick with a book long enough to complete the book and sell it. Unless you remove a book from Leanpub quickly (taking it to a traditional publisher, for example), the subscription fees add up fast.  Unless you are churning out books and moving them off Leanpub within 2–3 years, the $99 flat fee per book remains a better deal.

number of books months until flat fee cheaper
1 13
2 25
3 38
4 21
5 27
6 32
7 37
8 42
9 47
10 53
11 38
12 41
13 45
14 48
15 52
16 55

They do have some deals where earning sufficient royalties will provide the subscription for free, but I’m still a long way from the first breakpoint ($1000 in royalties), because I give away the book to students in my classes (235 free copies of the book vs. only 133 paid-for copies) and because I charge so little (the price is now $9.99 recommended, $4.99 minimum).  At that low price, my royalties are minimal.  I suppose that in another couple of years I’ll be up to the level that would unlock their standard plan, allowing me to do up to 3 more books without a subscription fee (unless they’ve raised their thresholds by then).

Of course, if I could get some other teacher to adopt my book for a course, my sales would go up substantially, but self-promotion has never been one of strong skills, and Leanpub provides no marketing.  Other than the authors of books on Leanpub and their students, no one knows about the website or looks for books there.

Leanpub has also changed the royalties they give, from 90%–50¢ to 80%.  For the lowest price they allow ($4.99), the royalties are the same either way, but for higher prices, they now take more (again, existing books are grandfathered in under the old agreement, though they are trying to induce authors to switch to the new royalty scheme with a not-very-exciting promotion scheme).  The new royalties are still much better than Amazon’s 35% for ebooks, but Amazon provides much more visibility for books.  Amazon does have a 70% royalty deal for ebooks in a very narrow price range.

I understand why Leanpub has been making changes to their business model—their initial pricing was a loss leader, to build up a sufficient clientele while they were developing their software for book publishing.  The main value they add (in their view) is their mark-up language for producing EPUB, MOBI, and PDF formats from the same source, and most of their development costs have been for improving their mark-up language (first Leanpub-flavored Markdown and now Markua).

But I’m not using their mark-up language, because it is not really suited for the graph-heavy, math-heavy textbook I’m writing. I’m using LaTeX to produce PDF files directly.  I gave up on EPUB and MOBI, as they are not suitable formats for graph-heavy books, even though that locks me out of many of the e-book markets. I’m using Leanpub only for their storefront, for which their 10%+50¢ charge was quite reasonable, but increasing the charges to 20% and adding a $8/month subscription fee to that would make me think twice about staying with Leanpub, if they hadn’t grandfathered in the existing books.

2018 June 4: LeanPub has updated their pricing model again.  They now do 80% royalties (no grandfathering), but they have a free plan for people doing limited numbers of book updates per month.  Overall, it doesn’t affect me much (at the minimum price, the royalties were the same either way).  They’ll probably change the pricing again before anyone reads this note.

2018 April 15

Rapid delivery

Filed under: Circuits course — gasstationwithoutpumps @ 09:37
Tags: , ,

I made a serious mistake in putting together the parts list for my Applied Electronics course this quarter—I forgot to include a potentiometer on the list. I think what happened is that in previous years I had put the trimpot on the first quarter list, but we didn’t use it until the second quarter. I had a note to move it from the first-quarter list to the second-quarter list, but the move only happened half way (it was removed from the first list, but not added to the second one).

The mistake was pointed out to me be students in my Thursday office hours (they were asking where the potentiometer they were to use was).

Late Thursday night (after the evening labs were ordered), I ordered 85 25-turn 10kΩ trimpots from DigiKey, and they arrived Saturday morning (at 36 hours, about the fastest delivery I’ve ever had for anything other than pizza—particularly good for a delivery from Minnesota to California).  The Post Office package delivery gives good service here (now that they are no longer short-staffed as they were in December).

Because the lab course fee for the Applied Electronics course has all been spent on parts and tools already, I probably won’t be able to get reimbursed for these parts. The $76.52 they cost is probably the price I’ll have to pay for my mistake. (It isn’t my most expensive mistake in the last year—I forgot to pay my first installment of property taxes on time, which cost me a couple hundred dollars in penalties.)

Although I’m very happy with DigiKey’s rapid service, I might still specify trimpots from AliExpress next year, since 100 trimpots would cost only about $12 with shipping (ePacket, not the unreliable China Post).

Next Page »

Blog at WordPress.com.

%d bloggers like this: