How to Setup LTSpice IV in Wine

LTspice IV is a freeware SPICE (Simulation Program with Integrated Circuit Emphasis) published by Linear Technology for use in simulating electronic circuits, including those containing integrated circuits.

Currently, I’m working on developing a DC power supply for a 40W dual channel audio amplifier that I built and will be simulating the power supply in LTspice. Since I predominately use linux, and LTspice was designed to be able to run in WINE, here’s a quick guide on installing LTspice in WINE on linux.

Installing LTspice in WINE

Of course, first we must download LTSpice from the Linear Technology website.

Next, let’s setup a fresh WINE prefix (in my case, I installed it into a projects directory that I have). I like to install programs in WINE in their own prefixes so that if something messes up with one program, it doesn’t affect any other programs I’m running with WINE. To set up a fresh prefix:

WINEPREFIX=/path/to/directory/that/you/want winecfg 

If you do not wish to use a different prefix, don’t include the “WINEPREFIX” variable in the next steps. Now install LTspice into the freshly created prefix:

WINEPREFIX=/path/to/directory/that/you/want wine LTspiceIV.exe

and simply follow the installation wizard instructions. Just like that, LTspice is installed! Not too bad eh? Once the installation process is complet, LTSpice should start up automatically the first time. The program may prompt you about updating, which is a good idea. To do this, select the “Sync Release” option from the “Tools” menu. Now, you can get simulating those circuits. If you are in need of a tutorial to get you started, I suggest this one by Al Williams from Hackaday.

Starting LTspice

During the installation process, a desktop shortcut should automatically be made on your linux desktop. If this didn’t happen for some reason, you have two options: 1) start LTspice using the terminal with:

WINEPREFIX=/path/to/directory/that/you/want wine /path/to/directory/that/you/want/drive_c/Program\ Files\ \(x86\)/LTC/LTspiceIV/scad3.exe

or 2) create a .desktop file to use for starting up LTspice. A .desktop file with the following contents should work:

[Desktop Entry]
Name=LTspice IV
Exec=env WINEPREFIX="/path/to/directory/that/you/want" /usr/bin/wine C:\\\\Program\\ Files\\ \\(x86\\)\\\\LTC\\\\LTspiceIV\\\\scad3.exe
Comment=Linear Technology Corporation's LTspice IV
Path=/path/to/directory/that/you/want/dosdevices/c:/Program Files (x86)/LTC/LTspiceIV

Once the .desktop file is created, it can be added to the application menu by copying it into the “/usr/share/applications” directory and then executing  “update-desktop-database” both of which require root privileges.

May your simulations be extra spice-y!


Learning Bash by Building a Game

Many years ago (summer of 2010) while learning the Bourne Again Shell (Bash) on Linux I decided to build a game for fun. This made learning the cryptic syntax more enjoyable and the hangman game is kind of fun to play.

Today I uploaded the hangman game to Github.

Code Academy has a nice tutorial that teaches one how to use Bash. There’s also a great tutorial here by Mike G on The Linux Documentation Project website. Learn something new!

A ground plane antenna for the VHF aeronautical band

Last month I built my first antenna. It was a ground plane antenna constructed out of a UHF female jack panel mount connector (sometimes referred to as a SO-239, like this one) and approximately 10-gauge clothes hanger wire.

A ground plane antenna made from a panel mount UHF connector and 5 segments of clothes hanger wire.

A ground plane antenna made from a panel mount UHF connector and 5 segments of clothes hanger wire.

I also used a male UHF to female BNC adapter and built my own 10 ft coaxial cable with BNC connectors. I used RG-58 and these BNC connectors because they don’t require an expensive crimp tool.

The reason I built this antenna is that for years the Saskatoon Soaring Club has struggled establishing reliable radio communications between their winch and their gliders. It’s important to mention that at Cudworth (CJD2), we use 123.2 MHz for communications. What was happening is that while the glider is on the ground, the winch can “hear” the glider, but the glider can’t “hear” the winch. A hand held radio is used in the winch and a more powerful radio permanently mounted radio is used in the glider. Testing revealed that it was likely that the radiation pattern of the antenna on the winch poorly suited for the needs of the club (more details below). The solution was to build this ground plane antenna, since they have the radiation pattern required by the club.

The old quarter wave antenna on the winch relied on using the metal roof of the cab as the “ground plane”. So long as the ground plane is sufficiently large (at least 1/4 wavelength in radius around the feed point of the antenna) the radiation pattern will be toroidal (donut shaped) and able to cover low elevation angles.Screenshot of spectrum analyzer At 123.2 MHz, a quarter-wavelength is approximately 60.9 cm (24 inches). Unfortunately, the amount of metal on the roof of the cab was insufficient (only about 20 cm). Theoretically this means that the resulting radiation pattern will be conically-tapered in elevation resulting in very little radiation being emitted at low elevation angles (low to the ground).  This document describes the problem in greater detail and shows that for real-world situations the radiation pattern is in fact more complicated than the naive description just given. In contrast, the ground plane antenna is built to include it’s own ground plane (see the 4 radials in the picture above). While searching for antenna solutions, I also stumbled upon the inverted L antenna, very cool.

Cutting the vertical wireAfter building the antenna, I needed to tune it. Thankfully, I was allowed to use a network spectrum analyzer at work to do this. The antenna started at a resonant frequency of 98.995 MHz (with the vertical wire at a length of about 30 inches). Of course, tuning the antenna to a higher frequency required me to shorten the vertical wire and the radials. It was interesting to shorten the antenna wire by 2 inches at a time and observe the resulting change to the resonant frequency measured by the spectrum analyzer. By carefully trimming the wires of the antenna, I was able to tune it to a resonate frequency of 123.7 MHz with a bandwidth of approximately 20 MHz or so.

Finally, the antenna was tested in by mounting it to the winch. This was accomplished using U-bolts, tape, and 5 feet of PVC pipe.

The ground plane antenna temporarily mounted on the SSC's winch for real-world testing.

The ground plane antenna temporarily mounted on the SSC’s winch for real-world testing.

Testing was performed by first attempting to communicate with a grounded glider using the old antenna on the winch and then mounting the new antenna and attempting communication. As before, using the old antenna, 2-way communication could not be established, but when using the new antenna the problem was resolved!

The antenna works well and club members are very happy to be able to now communicate more easily with the winch. This has made the winch launching operation safer too.

Gliding with the Saskatoon Soaring Club

The SSC's L-23 coming in for a landing.

The SSC’s L-23 coming in for a landing.

This March I joined the Saskatoon Soaring Club (SSC) and started attending the glider ground school. Hearing gliding stories from John Toles who led the instruction only bolstered the excitement I felt about the prospect of learning to fly a glider (one of my favourites is how he was “beat by a bladder”). Little did I know the excitement I felt was only the beginning. My first flight was on May 9th at the Cudworth Aerodrome. It was a cool Saturday morning with clear skies and a light breeze. Fernando Garza was the Pilot in Command and we were flying in SSC’s Super Blanik L-23 (a beautiful glider with a wise and confident appearance). We launched via aerotow and on my first ever flight Fernando taught me how to do co-ordinated turns. On my third training flight I learned how to thermal as Fernando and I reached over 6000ft AGL!

A view from the cockpit of the SSC's Schweizer SGS 1-26. This plane was built from a kit in 1956 and still flies like a champion.

A view from the cockpit of the SSC’s Schweizer SGS 1-26. This plane was built from a kit in 1956 and still flies like a champion.

Since then I have managed a 52 minute solo flight from a release altitude of 1300ft AGL (and soared with Fernando who was in another glider) and I only need 3 more solo flights to get my glider pilot license. I have had the opportunity to fly solo in each of the club’s three gliders, the L-23, a Blanik L-33, and a Schweizer 1-26 (acquired this summer). It has been a fantastic summer!

As a final hurrah of this gliding season, some of us flew up to Birch Hills (CJD3) on a cross-country aerotow with the L-23. We visited with the Prince Albert Soaring Club and were able to fly winch launches in their K-7.

Gliding is an exhilarating and freeing experience. The raw mechanical feel of the glider enables the plane to somehow become an extension of yourself; as if you were the one with wings. Each flight provides the opportunity to learn and a chance to hone your skills. Gliding can also be a relaxing escape into the vertical

Fernando (in a Super Blanik L-23) and I (in a Schweizer 1-26, you can see my wing) soaring together 2500ft above Cudworth, SK.

Fernando (in a Super Blanik L-23) and I (in a Schweizer 1-26, you can see my wing) soaring together 2500ft above Cudworth, SK.

dimension, where far below one leaves the everyday things to be replaced with eagles and hawks (they show you where the thermals are!) and stunning views of the clouds and the prairie below. Perhaps more importantly, gliding is a social sport. It is about teamwork and camaraderie; we take pride in each other’s accomplishments. It’s a bit like joining a second family. Even though this gliding season is ending, the Club is making plans to keep active over the winter season. This is only the beginning of my gliding adventures!

Below you can see more pictures of the SSC gliders. If you are interested, I have an album on Flickr with even more photos.

The Schweizer SGS 1-26 purchased this summer by the SSC.

The Schweizer SGS 1-26 purchased this summer by the SSC.

The L-33 Blanik Solo glider owned by the SSC.

The L-33 Blanik Solo glider owned by the SSC.

A cross-country aerotow from the low position. Heading to CJD3!

A cross-country aerotow from the low position. Heading to CJD3!

Members of the Prince Albert Soaring Club and the SSC with the Prince Albert Soaring Club's K7.

Members of the Prince Albert Soaring Club and the SSC with the Prince Albert Soaring Club’s K7.

ASUS z97-E/USB 3.1: Motherboard Sensors and Thermal Control on OpenSUSE 13.2

I recently put together a new desktop computer at work for data analysis for my supervisor. Here’s the parts list:

  • ASUS Z97-E/USB 3.1 motherboard
  • Intel i7-4790 processor
  • 32GB Crucial CAS 8 RAM
  • 2 Western Digital Black Series 1 TB HDDs
  • Rosewill Glacier 500M Power Supply
  • ASUS DVD Writer
  • NZXT S210-001 ATX Tower Case
  • Arctic Freezer 7 Pro CPU Fan/Heatsink

It’s a really solid processing machine and the Z97 is capable of clocking the RAM up to 1600MHz from 1333MHz using the built-in XMP. With water cooling, the Z97 could probably stably overclock the i7 up to 4.5 GHz (currently at 4 GHz). Since this machine will be used for heavy and prolonged computations, I wanted to make sure the fans were running sufficiently well to keep the i7 cool. To do this, we need to be able to monitor the fan speed and CPU temperature sensors.

The machine is running linux, specifically OpenSUSE 13.2. While I’ll focus on SUSE, this should work on any linux distribution so long as one uses the appropriate distribution specific commands. I am going to assume that the reader knows how to install software packages on SUSE 13.2. To read the CPU temperature and fan speeds, this is what I did:

1. Install lm-sensors

First I installed the lm-sensors package. The Z97-E has a Nuvoton NCT5538D that is used for fan speed measurements and control. In order for lm-sensors to read the NCT5538D we need to make sure the nct6775 kernel module is loaded (use modprobe nct6775 to immediately load it). To load the module on system start up we can either add nct6775 module to the /etc/modprobe.d/99-local.conf, or by running sensors-detect and following the instructions. If you use sensors-detect then you must make sure that the lm_sensors service is enabled and running:

systemctl enable lm_sensors
systemctl start lm_sensors

2. Modify grub Boot Options

Next we need to add the following to the GRUB_CMDLINE_LINUX_DEFAULT variable in the /etc/default/grub file: acpi_enforce_resources=lax (Many thanks to for the tip). After modifying the file, we have to make sure that grub is updated by using: grub2-mkconfig -o /boot/grub2/grub.cfg.

3. Add an Entry to lm-sensors Config File (Fixed dead link: 6 December, 2015)

We now need to add an entry to the sensors configuration file. The nct6775 kernel module supports the NCT5538D chip via code for the Nuvoton NCT6791D, but we need to tell lm-sensors how to display the data it reads from the chip. Someone else already figured out the configuration for the Z97-A so I just used that and it seems to work. I added the entry discussed in the link for the Z97-A to the /etc/sensors3.conf file.

4. See If lm-sensors Works

You may want to reboot the computer at this point. We can now test to see if lm-sensors is set up correctly. If it is, when we run the sensors command in a terminal, we should see something that looks like this:


Terminal output from executing the sensors command.

5. Optional: Set the Fan Speeds

First, BE VERY CAREFUL WITH THIS. You can easily damage your processor if you mess up the fan control. Also, it’s not my fault if you do.

Now we can modify the modes that the fan speeds will be adjusted with. For example, to set the fans to Smart Fan Mode 4, we can use a command like echo 5 > /sys/class/hwmon/hwmon3/pwm2_enable for each of the fans by replacing pwm2 with the appropriate number (see here for the location of the PWM for the fans and here for information on the supported fan modes for the nct6775 kernel module). Be VERY careful while doing this. I recommend having a terminal open running watch -n1 sensors so that you can monitor fan speed and CPU temperature while playing with the fan control. It took me some trial and error to figure out which pwm# controlled which fan. If you have any questions about this process, feel free to leave a comment.

Ubuntu 14.04 on a Macbook 2.1

The hard drive on an old white Macbook (v2.1) died recently so I went through the adventure of recovering data from it (needed to image the drive with dd conv=sync,noerror) and then reinstalling the OS. But I ran into some troubles with OS X 10.5. Some of the programs that one may like to use (e.g. Skype) are no longer supported and I would have had to buy the upgrade to at least 10.6. Rather than do that, I opted to install Ubuntu 14.04 instead.

First step in the installation was to burn a copy of Ubuntu 14.04 onto a DVD. Weird thing to do since I’m used the USB installation stuff that we typically now do. I grabbed the “64-bit Mac (AMD64) desktop” image DVD image file from here. It is important to grab the mac specific image because you may find the regular image will fail to install due to a firmware incompatibility with the EFI bootloader (lost the citation on this one). With the DVD in the Macbook, start it up and hold “c” to boot from the DVD.

The Ubuntu installation will be typical. Once finished, there’s a couple things you need to do post install:

  1. Install the mactel team’s fan support, otherwise you may notice your macbook fan runs at 100% all the time.
  2. Install the iSight firmware so that you can use your webcam. To do this, you must:
    1. Grab the firmware file (AppleUSBVideoSupport) from here (remove the .pdf first, wordpress wouldn’t let me host it without), or if you have a Mac OSX 10.4 or 10.5 installed, you can get the firmware file at:
    2. Make sure you know where you’ve downloaded/copied the AppleUSBVideoSupport to.
    3. Install the iSight firmware tools with: sudo apt-get install isight-firmware-tools. This will cause the software to ask for the path to the firmware file. If you have it on your desktop, the path would be /home/username/Desktop/AppleUSBVideoSupport.
    4. Reboot, and you are done!
  3. That’s it! Everything else seems to work just fine right out of the box.

Now one can get more life out of that Macbook without having to spend any cash on upgrading OS X.