Daily Archives: 12/27/2009

Modelling the NT7S code practice oscillator with LTSpice

As I was chatting on the QRP Echolink conference tonight, the subject of code practice oscillators came up.   I think it was Bob, AD7BP who first mentioned the  NT7S Code Practice Oscillator which I hadn’t seen before, but seemed like a very simple and easy to assemble circuit.  We also discussed the fact that the latest issue of QST has started to use LTSpice in their Hands On Radio column.   As I was waiting for my turn at the round table, I went ahead and entered the circuit into LTSpice to see how it worked.     Here’s the schematic I came up with.

nt7s

Go ahead and click on it to make it bigger.   There are some small changes.    I went ahead and added a load resistor R9 (I set it to 32 ohms here, with the idea that the oscillator would be hooked to a set of low impedance earphones) and instead of modelling the key switch, I instead powered it with a pulsed voltage.   I was mainly interested in seeing what the shape of the output signal was, so I set it up to a transient analysis.   Sure enough, it generates a nice sine wave.    I set the input pulses to be about 50ms long, which should be about the same as the dits at 24wpm.

Here’s the resulting simulated circuit:

NT7S Code Practice Oscillator Waveform

NT7S Code Practice Oscillator Waveform

Running an FFT on this output data shows that the oscillator frequency is right around 680 Hz, with an output power of about 0.5mw, and the second harmonic over 20db down, and the 3rd harmonic 30db down.   I’d say that qualifies as a pretty reasonable waveform.  I thought that the output power was a bit low, but the oscillator is normally used with either ear buds, or with an external amplifier.   I suspect it will work reasonably well.

It was a fun experiment in using LTSpice.

Addendum: It dawned on me that simulating the keying by pulsing the input voltage wasn’t entirely correct: in the original circuit, the keying is provided by grounding the 560 ohm resistor, while power is continuously applied.   Even intuitively, one might see how that makes a difference, because various capacitors in the circuit will remain continuously charged.   This morning, I decided to go back to a straight DC power supply for Vcc, but then installed a small switching transistor between the 560 ohm resistor and ground, and fed <em>that</em> with a pulse through a current limiting resistor.   The waveform cleans up a bit at the beginning: we have a nicely shaped ramp up, without the overshoot that we saw previously.

Addendum: I was wondering if I could use this information to find out what this circuit would really sound like: in other words, I wanted to convert the raw LTSpice output into a .WAV file that you could play back on your PC.   It turns out that LTSpice can export the waveform in an ASCII format, which includes a bunch of lines which have two numbers: a time, and a value.   The slightly annoying thing is that the times are not evenly spaced.   So, I wrote a tiny chunk of Python that takes in this file, and resamples it to evenly spaced times.   I write this out again as an ASCII file, adding a small header so that the “sox” sound utility can read it, and convert it into a wav.    I then use my normal “lame” command line mp3 encoder to convert it into an mp3 file.

The following sound file was converted from the real data, and consists of three groups of ten dits, sent at 24 words per minute, with some space in between:

Simulated sounds of the NT7S code practice oscillator

I also found out that sox can actually draw spectrograms of wav files. It’s not quite as versatile as the homebrew code that I wrote, but it works. Here, the individual dits kind of run together, but it shows that the second harmonic is at least 40db below the primary frequency, so the dits are pretty clean:

Spectrogram of the NT7S Code Practice Oscillator

Spectrogram of the NT7S Code Practice Oscillator

Movie Review: Sherlock Holmes

I’ve mentioned before that I’m a pretty big fan of Sherlock Holmes. Every couple of years, I dust off my copy of his stories and read them, or load them as audio books onto my iPhone and listen to them all over again. I could go on and on, but let’s just say “I’m a fan”, probably in a way that differs in relatively small degrees from fans of Marvel comics, or DC comics, or Star Wars, or Star Trek.

So, it was with some trepidation that I went to go see the new Christmas release of Sherlock Holmes starring Robert Downey Jr, Jude Law and Rachel McAdam. It’s never easy to see something that you hold in such esteem “reinterpreted”. I’m pleased to say that on the whole, I found their reinterpretation to be reasonable, if not entirely faithful to the original corpus of work. The only truly serious deviation would be the introduction of Irene Adler as romantic interest and as a thief. Irene Adler makes an appearance in Conan Doyle’s first Sherlock Holmes story, A Scandal in Bohemia, which begins:

To Sherlock Holmes she is always the woman. I have seldom heard him mention her under any other name. In his eyes she eclipses and predominates the whole of her sex. It was not that he felt any emotion akin to love for Irene Adler. All emotions, and that one particularly, were abhorrent to his cold, precise but admirably balanced mind. He was, I take it, the most perfect reasoning and observing machine that the world has seen, but as a lover he would have placed himself in a false position. He never spoke of the softer passions, save with a gibe and a sneer. They were admirable things for the observer — excellent for drawing the veil from men’s motives and actions. But for the trained reasoner to admit such intrusions into his own delicate and finely adjusted temperament was to introduce a distracting factor which might throw a doubt upon all his mental results. Grit in a sensitive instrument, or a crack in one of his own high-power lenses, would not be more disturbing than a strong emotion in a nature such as his. And yet there was but one woman to him, and that woman was the late Irene Adler, of dubious and questionable memory.

This basic tenet of the psyche of Sherlock Holmes is tragically violated in this interpretation, where there is a romantic back story between Adler and Holmes. I understand why a screenwriter might choose to introduce this in the interest of marketability, but I think it rather seriously undermines the basic premise of all the Sherlock Holmes stories. There are a number of other subtle variances from the canonical tales, but none seem as serious to me.

But I tried to drop my rigid requirements for faithfulness, and view the movie in the same way that the recent reinterpretation of Star Trek by J. J. Abrams might be viewed: are the characters interpreted in a rich, robust way which isn’t completely at odds with the original characters. And, with the exception I listed above, I’d say “yes”, but not as successfully as was done with Star Trek. Downey Jr. and Law give solid performances, but not inspired ones (we’ve seen better work from both of them). I found Rachel McAdams to be almost a distraction from the plotline, and one that really doesn’t pay off emotionally or even structurally. There are a couple of very odd continuity changes in the movie which I found inexplicable (and unable to explain without giving away too much of the plot), but on the whole, I still enjoyed the film.   If you want to see a truly great, faithful adaptation of the original stories, stick to the  version starring  Jeremy Brett and David Burke:

Sherlock Holmes (1984 TV Series) – Wikipedia, the free encyclopedia

But if you want to see some appealing, attractive and talented actors give decent performance in a decent but not outstanding script, and if you can overlook the deviations from the original, you’ll probably be entertained and amused enough to justify the ticket price.

I give it a 7 out of 10.    If I was less of a nutcase over Sherlock Holmes, I might give it another point, but I think that even barring my adoration for the original material, there are some issues with the script and story which kept it from being a stronger film.    When I saw <em>Iron Man</em>, I was thinking about why I liked it afterwards, and had a difficult time describing why I enjoyed it, and this movie is similar, except with perhaps a little less compelling action sequences, and an even less convincing love story.  Still, it’s an amusing time at the movies.