Monthly Archives: August 2013

10. Line the Fractions up (In Order)

I remember once in a computer class, a fellow student asked the lecturer about “vulgar fractions”. It immediately became obvious that the lecturer didn’t know what a vulgar fraction was. I would not expect that a reader of this post didn’t know what a vulgar fraction is, but the lesson of that class was that one has to allow for the possibility. A vulgar fraction is one that has a horizontal line with a numerator on top and a denominator below. When I was little, this was just called a “fraction”, but in that class all those years ago, the default format for a fraction was a decimal fraction.

One thing about decimal fractions: you know what order they go in. They really do serve us best for many practical purposes for which vulgar fractions used to be more common. I have to admit that I cannot immediately imagine seventeen sixty fourths of an inch. (To save you scratching your head, it is 6.746875 mm) On the other hand, sometimes the vulgar fraction is more natural. My first career was as an acoustician. There used to be a rule of thumb for the design of a rectangular room for listening to music in. The adage used to be “avoid whole number ratios of room dimensions”. There were two things wrong with this. The first, that as a rule of thumb, it really wasn’t good enough, and the second was that it wasn’t really obvious how to do that.

The size and shape of a cuboidal room can be fully specified by three numbers: height h, width w, and length l. The shape (without the size) can be specified by any two of three ratios: w/h, l/w, and l/h. The relationships between these ratios are determined by a single multiplication:
l/h = w/h  x  l/w
The task of exploring this relationship with a single multiplication suggested a slide rule to me. I converted to decimal all vulgar fractions with integer numerators and denominators in the range 1 to 16. There were some simplifications. I chose to look only at fractions that were greater then one. (I could have looked at fractions that were all less than one, and then hung it upside down.) I then sorted the fraction values into numerical order. I placed these on two strips of paper with a log scale. These worked like the “C” and “D” scales on an ordinary slide rule. If you chose a value for (say) the ratio of width to height for a room (w/h), and placed the “1” of the top scale on that value on the lower scale, then complying with the adage amounted to finding a spot where both scales were free of vulgar fractions. This point would correspond to l/h on the top scale, and l/w on the bottom scale.

It was interesting that the vulgar fractions were not evenly spaced, and there were gaps: that is there were opportunities to “avoid whole number ratios”

I have recently recalculated the value of vulgar fractions with numerators and denominators in the range 1 to 16, and I have tabulated them. Here is just a tiny bit of the table I generated:

You can see the whole table here .

In the application, it seemed that the lower the whole numbers were, the more significant the whole number ratio was. I devised the “weight” to give each ratio, evaluated as follows:
Weight = 1/(Numerator * Denominator)
A strange and interesting pattern emerged on my slide rule. I might figure out how to reproduce this pattern to show it to you. I will come back to this.

Some years later, another application for the slide rule emerged. The task was to design a frequency shift keyed (FSK) modulator. The usual scheme at that time was to use a VCO from a phase locked loop chip, and feed the data stream into the voltage control pin. This was easy to set up to nominally give the correct frequencies for a Mark and for a Space, but in the days when the usual tolerances (without paying lots extra) for resistors was plus or minus 5%, and for capacitors was plus or minus 10%, the error budget for the modulator didn’t look too good.

An alternative scheme, was to divide a crystal derived frequency, and to change the divide ratio according to whether a Mark or a Space is required. In principle, this is easy. If the two specified frequencies are:
Mark Frequency = fM
Space frequency = fS,
Then we find the smallest frequency fC for which we can write:
fM =  fC / kM                     (1)
and
fS =  fC / kS                       (2)
where kM and kS are integers.
We can then start with a clock at frequency fC and divide it by kM to get a Mark, and divide it by kS to get a space.
This is all very well in principle. In practice, we might find that it is not convenient to obtain a clock at exactly fC, but it is convenient to get a clock at some frequency that is close to it. Another problem is that if the integer constants (divide ratios) kM and kS are large numbers, then the hardware required to implement the frequency divisions become excessive, and the frequency fC is inconveniently high. Our error budgeting, will easily show that we can allow ourselves to get pretty sloppy and yet still produce a much more accurate result than with the VCO. How would we choose constants so that instead of the equations (1) and (2), we establish close approximations that give us a very much simpler design. The result might be simpler, but how do we arrive at it? With the reverberant room slide rule! I dug that out, and chose very close approximations for kM and kS, which yielded a design with frequency errors that were a decade lower then with the VCO design, and at lower cost, and no value-critical passive components.

These days we could do all this in software. If we have a spare pin on a processor that is already on the board, we might build the modulator at zero cost. The method for obtaining kM and k might still apply.

Recently I was reminded of all this when another completely different application arose for a clear picture of how the vulgar fractions fall when placed in order. I wonder how many different applications there might be.

Time Passes 1

“Time Passes, but will You?” – Graffito on university lavatory wall.

Time does seem to just go on and on, and there is nothing much we can do about that. There are some restricted senses in which we can make it look as if the pace at which time passes varies. “Look as if” that is, to a particular circuit.

I have two examples. One clever one which was not thought up by me, and another one which was not quite as clever as it looked, which was thought up by me. We will look only at the first one in this post.

I was leading a small development team working on a driverless towing tractor system. These battery electric towing tractors followed a wire set in epoxy in a slot in the concrete warehouse floor. The “guidepath” was the magnetic field around the wire from a 6.25kHz sine wave current. Part of the system was that two way communications were required between the controller on the tractor and the central system controller. The communications scheme chosen for the communication from the tractor to the central control (We called this the “Up” direction) was phase reversal keying of a carrier at (if I recall correctly)  15.625kHz, which was obtained at the transmitter by multiplying the guidepath frequency by 2.5 with a phase locked loop. The transmit modulator was an exclusive OR gate. I was fortunate to engage Roger Riordan, a consulting contractor at the time. Roger is famous for having invented a gyrator (Google “Riordan Gyrator”) and will be known to some readers as the person who set up and ran the business which offered the “VET” anti-virus software for many years. Roger was assigned the task of designing a transmitter to impress the signal onto the guidepath wire. His scheme was to use a winding around a ferrite rod of the type used for a.m. radio reception. The arrangement was roughly as shown here.

In this sketch, “1” is the guidepath wire set in epoxy in a slot about 4 mm wide and 10 mm deep cut in the floor. I do not recall how many turns were wound on the rod, but the full winding had a capacitor across and resonated with a high Q. The drive was by way of a tap near the bottom end of the coil.

All that is just background. Now for the real story. As the Q of the tuned circuit was high, it was necessary to tune it. I do not recall the capacitor value, but it might have been 470nF or so. Certainly far too large to make much impact with a trimmer capacitor. Roger’s trick was to make the tuned circuit “pause” for a short while each cycle. In this way, an LC combination with a resonance period that was a little short, could have that period extended to match the excitation frequency. I used to like to say that “Time stands still for the resonant circuit”.

Consider this circuit, which we will imagine for the moment to be made of ideal components.

This seems to be a funny place to put a switch, and one would imagine that closure of the switch would be a disaster. It would discharge the capacitor pretty promptly! The trick is, that the switch is closed when the capacitor has no charge anyway: at a voltage zero crossing. When the switch is closed, the inductor current flows through the switch, and as we are considering ideal components, this current flows forever, until the switch is opened, when the resonance of the L and the C will go on just as if it hadn’t been interfered with. If we use real world components, there will be losses, but if the switch is not kept closed for too long, the loss will not be too great. The picture below shows the voltage waveform that we get with a short duration switch closure.

 

The time tD is added to the natural period of the LC to give a new “synthetic” resonant period. The transmitted waveform will look like this:

The delay time was only short: just long enough to ensure that the entire production run could be tuned to the transmit carrier frequency. The distortion of the waveform was of no importance in this application.

Here is a block diagram of the scheme. There could well be records extant with more details, but they are not to hand as I write this.

I have corresponded with Roger recently about this clever trick, just to make sure that I should not have been giving someone else credit for the idea. Roger tells me that it was all his own. He also played a major part in the receiver design. There were many troublesome aspects to that project, but once we worked out what phases to expect the signal at at the receiver, this communications channel facility was a trouble free design.

I will come to the other example of the interfering with the passage of time for a circuit in another posting.

 

Learning about LTspice

(An aside. I have had terrible trouble getting this Blog post to you. WordPress has fought me all the way. I still don’t know why so much user hostility has been programmed into it, but work-arounds have been found and here we are. I would like to acknowledge the help of the people from my site provider, Zuver. Thanks, Guys!)

On Tuesday the 23rd of July, I attended a seminar on LTspice. This was put on by the Arrow people. The speaker was Mike Engelhardt, the author/creator of LTspice. Mike is a proficient and entertaining speaker. We could tell that he was enjoying himself. Well he might, as it seems that he has a lot to crow about. He listed the respects in which he can claim that LTspice is superior to any other spice simulation package that is available to the public. The claims really are big. In taking in the Engelhardt story, we face a stark choice. We have to make one interpretation or the other – seems to me that there is no middle ground. The choice is this: Either we have to conclude that Mike really is laying it on a bit thick, or that LTspice is pretty special, and really is superior to other spice invocations – in spite of the fact that it is free. My bullshit detector did not go off, and I am inclined to the second view.

Mike Engelhardt in funny hat
(The hat wasn’t worn at the seminar)

I think that Mike finds an Australian audience a bit strange. He lists his achievements with this package, and these are achievements that anyone would be proud of, and the audience just sits there like stunned mullets. I get the impression that audiences in other places might be a little more demonstrative about being impressed. At one time, Mike said “Now I am going to step out of ‘Humble Mode’ ”. He then described some feature of the software that he is quite proud of. This was the second time that I had heard Mike speak, and I remembered that the first time ’round, I noted the way the Australian audience did not show appreciation. Thus when Mike made his brief statement whilst out of ‘Humble Mode’, I started the clapping off. Once it was started, the whole audience joined in. It was as if Australian audience members are a little embarrassed about showing that they are impressed, but once given permission, they let loose.

I remember the day, it would have been in 1989, that my colleague Tino Vescovi explained the significance of current mode control in a switched mode power supply to me. He explained that the supplies (topologies that we were looking at) had an inductor in series and a capacitor in shunt at the output. This is two poles in the control loop for voltage control. On the other hand, if we had current mode control, then the inductor was effectively being fed with a current. A current source in series with an inductor is just a current source. In other words the inductor disappears as far as the (outer) voltage control loop is concerned. This means that the loop has one less pole. There was more to it than that, in the Vescovi story, of course, but that was “Point Number One”. This is pretty fundamental in the world of switched mode supply design, and if you gathered a bunch of people who claimed to be switched mode power supply designers, then I would expect them all to know this: either that, or they had delusions of grandeur in claiming to be in the group.

On the first occasion that I heard Mike (2011), mates of mine who, like me, are switched mode power supply designers, Bob Sheehy and Nigel Machin were in the audience. When Mike asked what phase shift was caused by the inductor, one of us (I can’t remember which one), called out “None”. At the time, Mike said that he was impressed to find someone who knew that. Mike is a good speaker, and finding an excuse to flatter an audience member, is a ploy in his tool box of presentation tricks. On that ground, we can forgive him for making a fuss, but strictly, we should expect all of the audience to know this.

This time around, Mike again asked how much phase shift the inductor caused, and Bob and Nigel were not there, so it fell to me to call out “None”. Mike repeated his speil about how impressed he was to find someone who knew that. He obviously didn’t remember his first visit as well as I did. That didn’t matter. I went up a couple of hat sizes and enjoyed the rest of the seminar even more.

During the talk, Mike explained how we should draw conclusions about stability by identifying poles and zeros in the circuitry surrounding a switched mode controller chip. One pin on the chip was the output of a transconductance error amplifier. Attached to this was a capacitor and resistor in series to ground. His talk proceeded on the assumptions that the audience knew what the error amplifier was and its role in the scheme of things. These assumptions seems strangely incongruous with the assumption that the audience member did not realise that a current source in series with an inductor is just a current source.

I didn’t make notes to cover the whole substance of the talk, wanting only to record the information that was either new to me and I wanted to use, or, if not exactly new, then nice to be reminded of.

*** One was a method for investigating a system with feedback which requires the feedback for stable operation. There are many examples where we cannot just “open the loop”. A switched mode power supply would be an example. Another example is the Photo Diode Amplifier that I looked at in the posting to this blog More Photo Diode Amplifier – Investigating Miller Capacitance.

Mike’s method is to place the voltage generator that will introduce a disturbance in series with the feedback impedance.

*** Mike urged us to not use vendor’s spice models. He painted a word picture of a scenario in which a component manufacturer finds he is forced to provide spice models, and employs an intern to do the job. As presented to us, the story was entertaining. The horrible thing is that it could quite often be true!

*** If a circuit is complex and run-time might be an issue, don’t put capacitor esr in as a separate component, but put it in as an attribute of the capacitor. This reduces the number of nodes.

*** jfet op amps have a noisy tail current source, so need the same impedance on both inputs so that noise via source-gate capacitance will be (all) common mode. This is not a spice trick, but it is worthwhile point to remember.

*** One is usually better off not using initial conditions ( .ic ). Provide a circuit to add charge (to a capacitor, say) at the start of a run. Mike gave an example with a piecewise linear current source.

Placing one volt on a capacitor at the start of a run
without using the .ic statement.

 It is not clear to me why this is a curved line: I had expected a linear ramp.
(On reflection later, I realised that this had been a very clever way of steering us away from using the .ic command. I wonder what problems there are with the .ic command implementation in LTspice.)

A bunch of files relating to the seminar are to be found in this zip file:

http://ltspice.linear.com/LTspiceWorldTour.zip.

In a Readme, Mike has written:
The .zip archive usually doesn’t preserve the executeability of the .exe files contained therein. You will have to make them executable if you want to be able to use the links in the PowerPoint presentation like I did during the seminar.”

Still nothing worked for me, and after placing a query with John Simpson at Arrow, the following message came through:

It depends on the version of PowerPoint.  Often on has to
hardwire the absolute URL into the links.  The easiest way
to find the file is to right click on the link(in edit mode,
not presentation mode), note the name of the file, and then
open that file.  The file will be in the .zip file.”

I can’t really understand this. I can open the Power Point file in Power Point or in Open Office, but cannot work the hyperlinks off the slides. I don’t regard this as an LTspice matter. I have never before taken any interest in Power Point, being content to just use it as a slideshow viewer, and now I suppose I pay the price.

Another Way?
Apart from attending excellent seminars featuring Mike Engelhardt, there appears to be another way to learn more about LTspice. This is by purchasing a heavy hard cover book that is published by Wurth Elektronik who are another Linear Technology dealer. Wurth Elektronik are a German company. They have several factories, and I could not identify a “Head Office” location on their website, so I can’t say where they are from. I bought my copy from the local Wurth Elektronik office, or perhaps I should say I “picked up” my copy from the local office, as the transaction turned out to be an international transaction in US dollars with an office in Singapore.

It is immediately obvious that the book was not originally written in English. Indeed it is obvious that the translator is not familiar with English idiom. Many a turn of phrase makes strange reading until you realise that some probably popular and common expression in German has been translated word for word into English. The writing style reminds me of the writing style that is prevalent in Elektor magazine.

Quite apart from our languages being different, I think such things as conventions about how material should be laid out for a reader’s convenience are very different. I have enjoyed reading the book: it is a bit like reading Finnegans Wake (sic): you read the actual words, and then you think a bit about what the words mean. I found a couple of what seemed to be errors, but then again, perhaps I was not converting the words into my own vernacular correctly! It is easy to understand how these difficulties arise. Just imagine the distinction that we make between the words “valuable” and “invaluable”. If I employed a youngster to translate my words into German and then where I wrote “invaluable” a German reader read the German equivalent of “not valuable”, then she might reckon that I had made an error.

I had two particular questions about LTspice that had arisen when actually working with it. The first was that I wanted to know how to make an assignment statement. I had been using stepping in spice for some time:

.step param R 1 10 3

(that sort of thing)

but when I am exploring a multidimensional concept space, I might want to step through one parameter at a time whilst keeping all the others constant. My idea was that I could step on R (as above) whilst assigning values to R2, R3 and R4 (say), and then later step on R2 and assign a fixed value to R.

After a quick and casual (no written method) attempt to find out how to do this in the Wurth book, I wrote down all the words that I could think of that were synonyms of “assignment statement”. I probably have to admit here that my imagination wasn’t very good. I then searched the index. None of them were there.

My second question was to do with the FFT plot. Could I show this with a linear frequency scale?

The index of the book has four entries for “FFT” (pages 43, 36, 36, and 76). Page 36 has nothing about FFT except that we should look at Chapter 8.
Page 43 has nothing about FFT, but the text string “FFT” does appear in a list of file types that LTspice works with.
Page 76 contains instructions for a parrot to repeat some steps which lead to an FFT to appear on the screen. This is fine as long as the parrot doesn’t want to know what it is all about.
Chapter 8 starts on page 170 (a page not mentioned under “FFT” in the index) and is headed:
MEASUREMENTS, VIRTUAL OSCILLOSCOPE AND FFT EDITORS”

At first, one might not worry just what this chapter title means. Notice that the word “editor” is in the plural. I didn’t worry about this when I first encountered it, but later I came to believe that I had been informed that there are three editors:

(i) Measurements Editor
(ii) Virtual Oscilloscope Editor
(iii) FFT Editor

When reading the chapter, I encountered a sub heading:
8.3.1 Virtual oscilloscope and FFT analyser editor”

Does the singular form of the noun here tell us that one editor serves both?

Then again, what does “Editor” mean? This seems pretty unambiguous, but I remember when I first encountered the word “Editor” in a computer context. It would have been about 1978, and I had just purchased my first Editor and Assembler (both came as punched paper tape, and ran on a Motorola 6800 system). I had great difficulty getting these going, not because of any technical problem, but because of a semantic one. In my mind, editing meant changing some written material. This meant that before you could edit something, you had to write it. In the days when the text i/o was by way of a teletype, editing was a tricky business. You had to print out the document and then identify the place for a change by line number, and then type in a replacement or additional line to go in that spot. A cumbersome business. I could understand that as programs that would fit on a punch paper tape went, this was tricky and I would need a program for that. But how the hell do I enter my text document in the first place? Then I discovered that in the world of the computer, editing does not mean editing! No, it means writing AND editing. This would all be so obvious to young people that the story must seem strange. It is just the way the language goes. What was the German author thinking of when he wrote the German word that was later translated as “Editor”? We don’t know. Could it have been ‘Pop-Down Menu”?

The reason for this musing, is that I have read Chapter 8 very carefully, and cannot find any evidence of an FFT Editor apart form the heading quoted above!

On the day of the seminar, whilst school was out for play time, I collared Mike Engelhardt and asked him my two questions. these were answered in less than a minute.

So far the Wurth Elektronik book has cost me more in time than in purchase price, and I haven’t learned anything from it yet. In spite of this, I do not regret owning it. The fact that it exists probably reduces the probability that someone else will write a book on just this topic. Thus it is the ONLY book on this. That probably makes it a bit special, even if nothing else does.

The answers to my questions were:
(i) The assignment statement in spice is “.param” as in “.param R=5k”
(This IS in the Wurth Elektronik book: one just had to know which word to search on.)

(ii) If you move the cursor towards the bottom of the FFT plot, at some point it will turn into a little ruler. Click and a pop up menu will offer you some options. One of these is a box with a tick in it labelled “Logarithmic”. Remove the tick with a click. This is not exclusive to the FFT plot.

There is a third way to obtain information about LTspice. The program is very popular, and there are many tutorials and even videos to help that are only a Google search away.

Then there are the help screen in the program. I gather from my Googling that these have a bad reputation. They were mentioned several times by Mike in the seminar, but always in the context of the one statement:

I would not be so condescending as to suggest that a person look at the Help screens”. If you can figure out what that means, you should have no trouble with the Wurth Elektronik book.