All posts by Per Magnusson

Installing ATLC on Windows

This post describes how to compile and run ATLC under Cygwin on Windows.

ATLC is an open source 2D transmission line field solver. This means that it can calculate the characteristic impedance and some other parameters of arbitrary single-ended and differential transmission lines. It was written by radio amateur  Dr. David Kirkby (G8WRB) and it is very useful when designing RF and high-speed PCBs since it allows accurate calculation of the impedance of pretty much any geometry of transmission line. It is not limited to the simplified geometries that the various closed form approximation formulas deal with, so you can easily (well) include e.g. the effect of the solder mask on top of microstrips or the different permittivity of the resin that is pressed in between the traces of a tightly coupled differential stripline.

ATLC is however not a program with a graphical user interface. Instead it is a command line program written for Unix-like environments that you need to compile yourself from the source code and run from the command line. This creates a perhaps daunting threshold for non-Linux/Unix users. The intention of this post is to describe how to anyway make ATLC work on Windows computers by compiling it under the Linux-like environment Cygwin.

Installing Cygwin

The first step is to download and install Cygwin. This is a two-step process. First you download the setup-executable, either setup-x86_64.exe (64-bit installation) or setup-x86.exe (32-bit installation) from the Cygwin home page.

Then you run the executable. There are a series of questions to answer during the installation. Typically it is best to select to “Install from Internet”, to set the root directory to C:\cygwin64 (assuming a 64-bit installation), select some reasonable folder to store the installation files (perhaps the same place where you saved the setup executable) and select whether or not you are using a proxy to connect to the Internet. Then you come to the first less obvious choice; which download server to use. A good idea might be to try someone that you think is close to home and has decent bandwidth. Then the fun begins, namely the process to select which packages of Cygwin to install. There are many. Very many.

To compile ATLC you need at least the following packages: Devel/gcc-core and Devel/make. I would also recommend Graphics/netpbm since it is a package that can be useful for manipulating images that form the input and output data of ATLC. If you later find out that you want to add more packages, you just rerun the install file and it will remember what you have previously installed and allow you to install more packages.

Downloading and Compiling ATLC

Now you need to download the source files for ATLC. They are available on Sourceforge, http://sourceforge.net/projects/atlc/. To get the source code you need to click on Files, then on atlc (do not click on the link to the Windows binaries as they currently are for an outdated version of ATLC which does not produce correct results in many cases), then click on the most recent version (currently atlc-4.6.1), finally click on atlc-4.6.1.tar.bz2 and wait for the mandatory Sourceforge download delay to expire. There is also a .tar.gz package of source files, but that archive seemed to be broken when I tried to unpack it, while the bz2 archive was OK.

Save the source package in some directory (I chose D:\download\ATLC) and then unpack it using e.g. 7-zip, first the bz2 level and then the tar level to get a directory tree of all the source files. You may want to move the folder that contains the proper top level folder up to the same level as the bz2 file. Now we have the folder D:\download\ATLC\atlc-4.6.1 with the top level of the source tree.

Start Cygwin and change directory to the source files. Cygwin maps the Windows drive letters to folders called /cygdrive/<driveletter>, so to change to the desired folder, you need to type in the following command:

cd /cygdrive/d/download/ATLC/atlc-4.6.1

To prepare for building the exe file, type:

./configure

This performs some checks on the target system (your Windows PC) and creates a suitable makefile. Hopefully every check goes well (it did for me) so then it is time to build the whole thing by typing:

make

This takes a little while, but if everything goes well, the result are some .exe files in the src directory, the most important of which is atlc.exe. It is then a good idea to also run an automatic test to see if everything went well:

make check

The last lines of output when I run the check are:

Run times: T_sequential is 26 s. Not configured for parallel operation.
PASS: benchmark.test
======================
All 82 tests passed
(2 tests were not run)
======================

This looks good to me.

Then we can “install” ATLC, which mostly means copying files to suitable locations. This is done by:

make install

Trying It Out

Now, cd to a directory where you want to work with ATLC. You can type:

man atlc

to get some information about how the program works. You can also read about it on the ATLC page, primarily under the headings Tutorial, Bitmaps, Man pages and Examples.

Use Paint, Gimp, Photoshop, some other drawing programs, a script or one of the other .exe files that were compiled along with atlc.exe to create suitable input data to ATLC. Basically, the input data consists of a 24-bit BMP image which represents the cross section of the transmission line. Specific colors represent different materials as described in the man page. Red (0xFF0000) represents the conductor of a line, green (0x00FF00) is the ground conductor, white is vacuum (a good enough approximation of air) some other colors represent predefined dielectrics while most colors are free to use as custom dielectrics with permittivity that can be defined on the command line.

Below is a (scaled down) example picture I created. It represents a 0.52 mm wide microstrip line without solder mask on a 0.3 mm thick FR-4 substrate.

Cross section of a microstrip to be used as input to ATLC.
Cross section of a microstrip to be used as input to ATLC. (Click on the image to download the actual full resolution BMP file.)

I have put a ground plane not only under the FR-4, but also all around the edges of the image. This helps with ATLC convergence. Such a boundary ground plane should not be placed too close to the actual transmission line in order not to affect the impedance significantly. I chose to use a scale of 200 pixels per mm in this case, but you do not need to tell ATLC that since the impedance is scale invariant. Using more pixels per mm gives a more accurate result.

To feed this picture to ATLC, the following command can be issued:

atlc -d d2ff00=4.2 052_030_microstrip.bmp

The option “-d d2ff00=4.2” tells ATLC that the color 0xd2ff00 represents a dielectric with a relative permittivity of 4.2. The other colors that were used (white, green and red) have predefined properties.

The output data from ATLC (after a few seconds) is:

052_030_microstrip.bmp 2 Er=  3.03 Zo=  51.457 Ohms C=  112.9 pF/m L=  298.8 nH/m v= 1.722e+08 m/s v_f= 0.574 VERSION= 4.6.1

This means that ATLC has calculated that the effective permittivity of the line is 3.03, the characteristic impedance is 51.457 ohms, the capacitance is 112.9 pF/m, the inductance is 298.8 nH/m, the propagation velocity is 172.2*106 m/s, which is 0.574 times the speed of light in free space.

A number of output files are generated as well, both BMP-images that represent the electrical and magnetic fields and binary files that represent the same thing, but with higher accuracy. See the Files section on the ATLC home page for descriptions of these files.

As mentioned above, a higher resolution (more pixels per mm) results in more accurate results, but the downside is that the runtime increases steeply. I seem to remember (cannot find it right now) that the run time of ATLC is roughly proportional to the square of the number of pixels in the input image, so doubling the resolution (in pixels per mm) creates four times as many pixels and hence 16 times as long execution time.

Elektronikforum

Ikväll stod jag och SP Devices som värd för en träff i mötesserien “Elektronikforum” som dragits igång av Joacim Frisk på Prevas. Elektronikforum riktar sig till elektronikkonstruktörer i Linköping. “En plats att träffas, ta en fika, diskutera elektronik och lyssna på intressanta föredrag.”

Föredraget jag höll var i stort sett en repris på ett föredrag jag höll för knappt tre år sedan och hade titeln “Filtrering av matningsspänningar för känsliga analoga tillämpningar”. Bilderna från presentationen finns här:

Filtrering av matningsspänningar för känsliga analoga tillämpningar

Drygt 20 personer hade mött upp och både före och efter själva föredraget diskuterades det elektronik (och kanske en del annat) i mindre grupper. Det verkar som om deltagarna uppskattade tillställningen.

Jag hann inte gå runt och delta i alla diskussionerna, men här följer några länkar till sådant som nämndes i samband med föredraget eller i de samtal jag var med i:

Tack till alla som kom och bidrog till de intressanta samtalen! Hoppas det blir en ny träff i mötesserien snart.

 

Getting Started with Teensy

I just bought a couple of Teensy 3.1 boards to play with. The Teensy is a pretty small processor board that looks to be quite capable. It is smaller than the Arduino Nano boards I have been using for various other projects and still it has more I/Os, is cheaper and has a much more powerful processor, an MK20DX256, which is a 32-bit ARM Cortex-M4 from Freescale running at 72 MHz with 256 kB flash and 64 kB RAM.

Teensy 3.1
Teensy 3.1

The downside is perhaps that it is a proprietary design and while the schematics is available, the bootloader running on it is not, so unlike with the Arduino Nano, it is not possible to start out with a Teensy for prototypes and then move to a custom layout while still being able to use the same bootloader.

It is possible to develop programs for the Teensy using both an adapted version of the Arduino environment as well as using Eclipse. There are quite a few libraries available, including NeoPixel, OneWire, Xbee, capacitive sensing, IR remote controls, LCD displays, PS2 keyboard input, CAN, stepper motor control etc.

First you need to install the normal Arduino environment, and then the above mentioned adaptations. When you subsequently run the Arduino environment, a number of Teensy board versions are now available as target boards. Also several example programs are available in the menu  File -> Examples -> Teensy.

To get started I took the very simple LED-blinking program Blinky and added some parameters to modify the blinking to make it easy to see if I was successful in uploading the new program. Here is the code I came up with:

/* LED Blink, Teensy Tutorial #1
   http://www.pjrc.com/teensy/tutorial.html
 
   This example code is in the public domain.
   Modified by Per Magnusson
*/

// Teensy 3.1 has the LED on pin 13
const int ledPin = 13;
const int ontime = 50;     // LED on time in ms
const int offtime = 50;    // LED off time in ms
const int pausetime = 1000; // Pause time between bursts
const int blinks = 10;       // Number of blinks per burst

// the setup() function runs once, when the sketch starts

void setup() {
  // initialize the digital pin as an output.
  pinMode(ledPin, OUTPUT);
}

// the loop() function runs over and over again,
// as long as the board has power

void loop() {
  for(int i=1; i<=blinks; i++) 
  {
    digitalWrite(ledPin, HIGH);     // turn the LED on
    delay(ontime);                  // wait
    digitalWrite(ledPin, LOW);      // turn the LED off
    delay(offtime);                 // wait
  }
  delay(pausetime-offtime);         // wait for the next burst of blinks
}

Uploading of the sketch to the device turned out to be a bit messy. It seems to be necessary to press the button on the Teensy prior to uploading. Pressing the Auto button in a small window that appears on the screen might also help. Just uploading without doing anything special results in a timeout and the previous sketch being stopped.

Anyway, so far so good. Getting to the equivalent of Hello World turned out to be almost as easy as with an Arduino.