## Wednesday, 1 July 2015

### Workshop Presentation from DAC2015: A Holistic Platform for Education in ASIC Design & Manufacturing

I was fortunate enough to be invited by Cadence to present at a Workshop 9: Interdisciplinary Academia Industry Collaboration Models and Partnerships at DAC 2015 in San Francisco.

Here is the presentation I gave, "A Holistic Platform for Education in ASIC Design & Manufacturing" on our current work with undergraduates on SoCs.

## Thursday, 5 March 2015

### Improving an LM318 Op-Amp Follower by Prototyping Techniques

 LM318 schematic for fast follower operation
This little exercise came from trying to make a differential NTSC video sender over CAT5 twisted pair from discretes (I know - don't do this at home, just get an IC that does this for you like the MAX4447 / MAX4146 pair).
Throughout this article I will be making liberal references to the online free book "Op-Amps for Everyone" Texas Instruments Document SLOD006B by Ron Mancini.
The Op-Amp I decided to base the design around (again there are discrete transistor versions of this circuit that are more capable than this) is the incredibly venerable LM318.
Its main specs are:
• Small Signal Bandwidth . . . 15 MHz Typ.
• Slew Rate . . . 50 V/µs Min
• Bias Current . . . 250 nA Max (LM118, LM218)
• Supply Voltage Range . . . ±5 V to ±20 V
• Internal Frequency Compensation
[The LM318 is a pretty incredible design for its age - it really is! Especially since high performance PNP transistors were simply not available. For more details please see p19 of "IC Op-Amps through the ages" by Thomas H. Lee, 2000 rev. 2002]

The circuit I am trying to build is from the datasheet as a "fast follower" using lead compensation (SLOD006B section 7.6) and built on a standard prototyping board (called a breadboard at times).

## Attempt 1: Standard Prototype Board

[Note: Bypassed both supplies with 0.1µF and 1µF ceramic capacitors.]
Stimulating with a 1V Pk-Pk sinewave swept from 1MHz to 20MHz we should see the perfect flat gain of 1 till approximately 15MHz. Of course, we don't!
The gain peaks at approximately 2MHz at about 3 and then crashes to zero. The good news is that I have seen this behavior before and it is particularly well explained by SLOD006B section 7.7. Stray capacitance on the inputs. On a standard breadboard the stray input capacitance between V- and V+ is a minimum of 2pF. A good discussion on this can be found on EEVBlog #568.
First - to the simulator! Now SPICE is brilliant. Models of Op-Amps are not, and vary from modelling just the gain and frequency rolloff to full with major parasitics and noise sources depending on part and manufacturer. However if the SPICE model behaves the same with appropriate parasitics added it can confirm the behavior:
 SPICE Frequency Response of the LM318 "Fast Follower" with a 10pF parasitic wired between V+ and V-
This is a pretty damn good match to the observed behavior.

## Attempt 2: Partial Air-Wire

[Refer to Linear Technologies App Note 47 p27 - a legendary app note, you should read the whole thing!]

 Partially Air Wired LM318 "Fast Follower" with V+ soldered directly to the input 10k resistor and compensation pins lifted

The results of this approach was a massive improvement. The peak in the gain has smoothed out and I can sweep the stimulus (1V Pk-Pk sinewave) from 1MHz to 11MHz before the gain is 50%. The gain now peaks at approximately 2 around 6MHz.

## Attempt 2: Full Air-Wire

In an effort to eke out further improvements the circuit was built fully air wired. I cannot emphasize the importance of removing ALL traces of glue and flux from around the pins of the Op-Amp.
 Fully Air Wired LM318 "Fast Follower". [Note that the test configuration did not use the yellow crocodile clip lead to inject the signal and all grounds were brought together in the loop at the top right.]
Results from this approach were a further improvement of approximately 20% with the gain peaking at around 1.8 at 8MHz and the 50% point pushed out to 13MHz.

## Thoughts

I have a feeling that to improve linearity it would be worth me building a circuit with a gain of 2V/V. From reading Op-Amps through the ages it seems that this design was not optimized as a follower and in fact the datasheet contains dire warnings of trying to build it without resistors and a compensation capacitor in the feedback loop.
I am continually impressed by the Op-Amp designers of old who were able to make these high performance circuits with pathetic silicon technology and little to no simulation support. I shall revisit this article and capture some more scientific measurements at a future date.

## Thursday, 4 December 2014

### Buffalo Linkstation LS-XHL as a bitorrent sync node

A long time ago I bought an LS-X1.0TL Linkstation Pro (LS-XHL) from Buffalo.  The reason I (and
many others) bought it is that it is an 1.2GHz Marvell ARMv5 with 256MB of RAM, a SATA connection, a USB 2.0 port and a gigabit wired ethernet port that you can run linux on. All for about 20W.

The great news is that dusting it off after finding it in a box I find that it is better supported than ever! There is a standard Debian wheezy disk image and kernel 3.14.4 without patches running on the SoC.

Obviously the best use is to install Bitorrent Sync on it and hide it on another network at a different physical location to provide an extra node for security and bandwidth! (grin)

Here is how I did it (based on the work of fjen from nas-central.org, original threads here and here and the lsmonitor script fix is based off Dennis82's post).

1. Cracking the case: https://www.youtube.com/watch?v=GLtY7Rb6s24. Really don't try this without seeing the video - I broke quite a lot of my case getting it open before this existed.

2. Extract the hdd and connect it to a linux system or a linux VM (this is very hard to do on windows). Using dmesg or similar locate the disk device node, e.g. /dev/sdb. Make sure you have the right disk or you might destroy your operating system hard drive.

3. Change the disklabel to GPT (GNU parted)
3.1 Create primary partition 1 at 0 to 128MB, type ext3
3.2 Create primary partition 2 at 128MB to -1024MB (yes -1024MB), type ext4
3.3 Create a swap partition 2 at -1024MB to -1s, type Linux swap

4. Format the filesystems (replace X with the letter of the ls-xhl hard disk you found earlier):
4.1 mkfs.ext3 /dev/sdX1 (the boot partition of 128MB)
4.2 mkfs.ext4 /dev/sdX2 (the main filesystem partition)

5. Mount the filesystems somewhere convenient (as root):
5.1 mkdir ls-xhl_img
5.2 mount /dev/sdX2 ./ls-xhl_img
5.3 mkdir ls-xhl_img/boot
5.4 mount /dev/sdX1 ./ls-xhl_img/boot
5.5 check that ls ./ls-xhl_img shows "boot"

6. Download the wheezy root filesystem from http://neboola.de/fjen/lschlv2/debian/wheezy/
6.1 Unpack as root using GNU tar to the ls-xhl_img/ directory (not boot/)
6.2 Unmount the partitions (ls-xhl_img/boot first)

7. Install the hard drive back onto the ls-xhl's circuit, connect the ethernet cable to a network with a DHCP server where you can find the logs (your home router typically has a page in the web interface where you can find the DHCP logs) and power on.
7.1 The LED on the front should blink blue for a while before going solid on.
7.2 Check the DHCP logs for the IP address that the LS-XHL has acquired using the name linkstation.

8. ssh into that IP address as root (password toor) and run the following commands:
dpkg-reconfigure locales
dpkg-reconfigure tzdata
rm /etc/ssh/ssh_host_* && dpkg-reconfigure openssh-server
apt-get update

8.1 Install the debian updates to ensure you have a safe, secure system.

9. Update the kernel:
http://forum.buffalo.nas-central.org/viewtopic.php?f=71&t=25971

10. Update the lsmonitor script in /etc/init.d/lsmonitor included at the end  (thanks Dennis82 for the pointer to this solution).
10.1 Install the following packages: apt-get install hddtemp lm-sensors fancontrol
10.2 Restart the lsmonitor script by /etc/init.d/lsmonitor restart

11. Create a user called btsync (or similar) to own the btsync processes and disk space for files.
11.1 Install Bitorrent Sync server packages using the unoffical .deb packages from here: http://forum.bittorrent.com/topic/18974-debian-and-ubuntu-server-unofficial-packages-for-bittorrent-sync/
11.2 Configure packages to run as user btsync.
11.3 Direct your web browser to the IP address:8888 and the Bitorrent Sync GUI should greet you.

12. Profit!

#!/bin/sh

### BEGIN INIT INFO
# Provides:          lsmonitor
# Required-Start:    $syslog # Required-Stop:$syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Monitor Linkstation LS-CHLv2 and LS-XHL
# Description:       Enable service provided by daemon.
### END INIT INFO

#
# lsmonitor:
# - handle ls complete power-on
# - monitor hdd temperature & control fan speed
# - monitor hdd status & contol function led
# - monitor function button (todo)
# - monitor power switch (todo)
#
# Changelog:
# - Modified to work with a Debian kernel on a LS-CHLv2
# - Added hdd status monitoring
# - Modified to work with a vanilla kernel >= 3.6
# - Modified to work with a vanilla kernel >= 3.8
#
# Copyright (C) 2013 Sergej Wildemann
##
# Based on:
#  blstools - Copyright (C) 2010 Michele Manzato
#
# Credits:
#  Thanks to archonfx on Buffalo NAS Central forum for HDD
#  temperature monitoring command.
##
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
##

# Location of pid file
PIDFILE=/var/run/lsmonitor_daemon.pid

# Control interfaces
LINFO="/sys/devices/gpio_leds.3/leds/lsxl:amper:info"
LPOWER="/sys/devices/gpio_leds.3/leds/lsxl:blue:power"
LBFUNC="/sys/devices/gpio_leds.3/leds/lsxl:blue:func"
LAFUNC="/sys/devices/gpio_leds.3/leds/lsxl:red:func"
LALARM="/sys/devices/gpio_leds.3/leds/lsxl:red:alarm"

#FAN_CTRL=/sys/bus/platform/drivers/gpio-fan/gpio_fan.3
FAN_CTRL=/sys/bus/platform/drivers/gpio-fan/gpio_fan.4/hwmon/hwmon0
FAN_TARGET=${FAN_CTRL}/fan1_target FAN_INPUT=${FAN_CTRL}/fan1_input

# Fan speeds
SPEED_STOP=0
SPEED_SLOW=1500
SPEED_HIGH=3250
SPEED_FULL=5000

# HDD temperature limits for fancontrol
HDDTEMP0=45
HDDTEMP1=50
HDDTEMP2=55

. /etc/default/lsmonitor

# Set and get current fan speed
fan_speed()
{
if [ $1 = "get" ]; then cat$FAN_INPUT
elif [ $1 = "set" ]; then echo$2 > $FAN_TARGET fi } # Monitor HDD temperature & control fan speed monitor_temperature() { # Retrieve HDD temp HDDTEMP=$(smartctl /dev/sda --all | awk '$1 == "194" {print$10}')

# Change fan speed accordingly
if [ $HDDTEMP -le$HDDTEMP0 ]; then
fan_speed set $SPEED_STOP elif [$HDDTEMP -le $HDDTEMP1 ]; then fan_speed set$SPEED_SLOW
elif [ $HDDTEMP -le$HDDTEMP2 ]; then
fan_speed set $SPEED_HIGH else fan_speed set$SPEED_FULL
fi
}

# Monitor HDD status and deactivate power led if idle
monitor_hdd()
{
HDDSTATUS=$(hdparm -C /dev/sda | grep "standby") if [ -z "$HDDSTATUS" ]; then
echo default-on > $LBFUNC/trigger if [$HDDSTATUSOLD -eq 0 ]; then
echo date active >> /var/log/hddstatus.log
HDDSTATUSOLD=1
fi
else
echo none > $LBFUNC/trigger if [$HDDSTATUSOLD -eq 1 ]; then
echo date standby >> /var/log/hddstatus.log
HDDSTATUSOLD=0
fi
fi
}

# Control LS switch status to power down the unit
lsmonitor_daemon()
{
COUNT=12
HDDSTATUSOLD=0

echo 1 > $FAN_CTRL/pwm1_enable fan_speed set$SPEED_STOP

while [ true ]; do
# Check switch status
#PWR_SW=cat /sys/class/gpio/gpio${GPIO_PWR_SW}/value #AUT_SW=cat /sys/class/gpio/gpio${GPIO_AUT_SW}/value

# Check HDD status
monitor_hdd

# Terminate when in OFF state
#if [ "$PWR_SW" -eq 1 ] && [ "$AUT_SW" -eq 1 ]; then
# break
#fi

# Once per minute monitor HDD temperature
if [ $COUNT -eq 12 ]; then COUNT=0 monitor_temperature else COUNT=$(( $COUNT + 1 )) fi sleep 5 done # Run the fan at low speed while halting, just in case halt hangs the unit fan_speed set$SPEED_LOW

# blink power led
echo timer > $LPOWER/trigger echo 100 >$LPOWER/delay_on
echo 100   > $LPOWER/delay_off # Initiate unit shutdown halt } # Kill the lsmonitor daemon kill_lsmonitor_daemon() { PID=cat$PIDFILE
if [ "$PID" != "" ] ; then kill$PID
rm $PIDFILE fi } case$1 in
start)
# Start the lsmonitor daemon
lsmonitor_daemon &
echo $! >$PIDFILE
;;
stop)
# Kill the lsmonitor daemon
kill_lsmonitor_daemon
;;

restart)
$0 stop && sleep 2 &&$0 start
;;

*)
echo "Usage: $0 {start|stop|restart}" exit 2 ;; esac  ## Thursday, 2 October 2014 ### Modding a Lattice CPLD ispMACH 4256ZE breakout board for an external clock  4256ZE Breakout Board with CLK PCB Operating Taking a quote from the Lattice website this board is probably the best way of getting started with a CPLD I know of with 5V tolerant I/Os: "The ispMACH 4256ZE Breakout Board is a simple, low-cost board that provides convenient access to densely-spaced IOs. Each I/O on the device is connected to 100-mil header holes. By adding test probes, jumper wires, or pin headers to the board, you can easily evaluate function and performace of the IO cells of the ispMACH 4256ZE." The only issue I have with this board is that unlike its more modern version, the MachXO2 Breakout Board (note that its IOs are only 3.3V tolerant), it has no site for an external clock crystal on the PCB. This means you are limited to the internal 5MHz oscillator. Or not if you are clever and have access to PCB design software and are willing to spend$1 with OSH Park community PCB service.
The Oscillator series chosen for this project was the Fox FXO-HC53 series, a SMT crystal measuring 5mm by 3.2mm. Since this chip doesn't support LVDS we are using a HCMOS output. The two speeds chosen were 80MHz and 200MHz.
Note the oscillator is specified to drive up to 15pF and a CLK input pin on the ispMACH 4256ZE is 6pF max. The traces on the board are going to contribute further capacitance but it should be within spec.

The board design is detailed below:
 CLK Board Schematic
The PCB design has a few features that are worth noting:
• The output pin of the oscillator is placed as close as possible to the output pin hole and the ground pin hole is as close as possible to the ground pin of the oscillator. This is to minimize impedance and coupling of the high frequency on the board.
• There are two ground pins - one for the power supply and the other for the CLK return current to make it easier to interface.
• A pullup resistor 0805 position is available in case the internal pullup proves insufficient or a different crystal is chosen.
• The footprint of the crystal has the pad size extended outside the normal footprint by twice the length to allow manual soldering.
• The power and output pins are in a row on a 0.1" spacing to allow compatibility with standard prototyping boards and systems.
• The bottom of the board under the crystal and high frequency traces is one large ground plane.
• Total board size is 525mil x 375mil.
 CLK Board Top Layer

 CLK Board Bottom Layer (Text not reversed)

 OSH Park Rendering of the Manufactured PCB

## Wednesday, 17 September 2014

### Installing LaTeXML into a local directory...

I have been working for a while on a document management system that will use MathJax and .tex inputs to create pretty PDF output and good websites.

Researching the available converters the one that is most attractive and most maintained is LaTeXML.

Firstly I have to setup perl to install packages locally for me to use:

PATH="$PATH:~/perl5/bin" export PERL5LIB=~/perl5/lib/perl5 export PERL_MB_OPT="--install_base '$HOME/perl5'"
export PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" curl -L http://cpanmin.us | perl - -l ~/perl5 App::cpanminus local::lib  I now have to fetch and install LaTeXML: cpanm http://search.cpan.org/CPAN/authors/id/B/BR/BRMILLER/LaTeXML-0.8.0.tar.gz --force   Note that you will need the prerequisite system libraries installed onto the system - this approach doesn't provide copies of LibXML etc. as needed. Command lines: latexml --dest=example.xml example.tex latexmlpost --format=html5 --javascript='../MathJax_down/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --destination=example.html example.xml   The results are really quite impressive - no links yet as they are behind our 'paywall' but hopefully soon. ### A Blast From the Past: Valve/Tube/Electro-optic LA2A  Drip Electronics OPTO 6 version of the 1968 LA2A When a friend of mine came and asked if I would help him build out an audio compressor that is based on tube amplification and some custom electro-optical cells I, of course, agreed! The full details of the device are online at Drip Electronics: OPTO 6 (LA2A). They build a PCB to approximate the old point to point wiring typically found under tube systems as well as build the custom electro-optical cells. Now I am not a tube guy nor an audio guy but any electronics that glows when it is working is good electronics.  Yours truly, (Matthew Swabey) testing the system with safety glasses in case one of the tubes or big caps "pops" I really enjoyed the different construction style but testing was a real problem - the system is so non-linear, clips all the time and distorts it is almost impossible to know if I built it right. The current owner had to take it home and test with a microphone and speakers before it could be signed off. ## Tuesday, 15 July 2014 ### Making ModelSim vsim and Questa vco work on Ubuntu 14.04 In my previous article, http://mattaw.blogspot.com/2014/05/making-modelsim-altera-starter-edition.html, I covered how to install and run the ModelSim-ALTERA starter edition on Ubuntu 14.04. Subsequently it turns out this fix also applies to Mentor Graphic's ModelSim and Mentor Graphic's Questa (not that surprising as Questa is a superset of ModelSim with far greater capabilities). The previous instructions for ModelSim ALTERA work for ModelSim. Here are the detailed instructions to apply the fix to Questa: Firstly complete installing everything including compiling the new libfreetype libraries and copying them into the questasim directory. Now we need to edit the vco launch script to ensure the new freetype libraries are used: sudo vim bin/vco  Search for the following line: dir=dirname$arg0

and underneath add the following new line:
export LD_LIBRARY_PATH=\${dir}/lib32

Test by running vco and hopefully you will be greeted by the Questa GUI.

Please email me any fixes or changes you would like so I can update this post and give credit.