Category Archives: linux

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
Type=Application
StartupNotify=true
Comment=Linear Technology Corporation's LTspice IV
Path=/path/to/directory/that/you/want/dosdevices/c:/Program Files (x86)/LTC/LTspiceIV
Icon=0E18_scad3.0

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!

Advertisements

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!

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 http://lists.lm-sensors.org/pipermail/lm-sensors/2014-November/042908.html 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:

sensors

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:
      /System/Library/Extensions/IOUSBFamily.kext/Contents/PlugIns/AppleUSBVideoSupport.kext/Contents/MacOS/AppleUSBVideoSupport
    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.