Advanced Design Techniques with Altium Designer

Created: April 20, 2020
Updated: October 29, 2020

In this article, we’ll learn how to use Altium Designer® to implement extra functionalities that are not available by default. We’ll discover a powerful aspect of Altium Designer that when mastered can bring your design skills to a higher level. In this article, we’ll discuss how to implement a script to perform design verification for you.

We will learn:

  • How to create rules to verify some design requirements.
  • To verify those rules using a script in Altium Designer 19.

A Typical Problem

These days, designs are very complex. In general, customers have expectations of their PCB designers that their boards will work the first time. For this to be achieved, attention to detail is critical.

In this example let’s see how to create a script that can be used in a real-life design. Consider the following design problem:

We need to design a high-resolution ADC board using a 16 bits ADC converter. The ADC converter has an input impedance of 1 kΩ. “What is the maximum trace impedance between driver and ADC to achieve an error below 1 LSB?“ “Can we design a Script that can help us?”

Figure 1 design a trace of a High-resolution ADC

To answer this question, we need to calculate the trace’s resistivity and check if the voltage drop on the trace is higher than 1 LSB.

To calculate the trace resistivity, we can use the following formula:


For example:

Let’s assume our trace has the following dimension: L = 10 cm, h =  0.035mm, w = 0.381mm. Using the [1], and assuming the ambient temperature is 25 °C the DC trace impedance is 129 mΩ, this will produce a voltage error of 0.013% ., well above 1 LSB (0.0015%)  of a 16 bit ADC. So, the above track will give us an offset error of almost 9 LSB!

Is it possible to ask Altium Designer to do all the above checks for us? Possibly in real-time?

The answer is obviously yes.

Let’s design a script that gives us this information.

We want to be able to click on a trace, and we want Altium Designer to do some checks for us like calculating the trace resistance, calculating the voltage drop, etc.

Figure 2 example of information from our demo script

How To Design A Script In Altium Designer

Altium Designer accepts script in a few languages, during my career I have used many languages, but one of the first languages I used in my professional life was Delphi, therefore I decided to write this script in Pascal. However, you can use other scripting languages like Visual Basic if you prefer.

Let’s see how to design a script in Altium Designer that solves the above problem.

In our script we want to:

  1. Load our PCB Board
  2. Load all the Layers Stack (to get information like trace width, height, etc.)
  3. Load the trace that the user has selected with the mouse
  4. Calculate the resistance using the formula [1]
  5. Display the trace error and the ADC error

How to Implement A Script In Altium Designer


The first instruction we want to execute is to load our PCB design and save it in a variable called Board. We can do this with the following instruction:



Once the Board is loaded, we want to load the Layer Stack and save into a variable called Stackup:



We can now use the method GetObjectAtCursor () to get the trace selected and save it into a variable called Trace.



Once the user selects a trace with the mouse, we want to calculate the trace width, length, and height, and save them in 3 variables  called TraceThickness, TraceWidth, and TraceLength:




We can finally calculate the trace resistor Res using the [1], calculate the voltage drop (assuming the ADC has a Vref of 1V).



Once all the calculations are done we can display on the screen. An easy way to do this is by using the MessageDlg() windows.

OutputString := 'Trace thickness = ' + FloatToStrF(TraceThickness,0,5,4) + ' mm' + #13#10;

OutputString := OutputString + 'Trace Width = ' +   FloatToStrF( TraceWidth,0,5,4) + ' mm' + #13#10;

OutputString  := OutputString + 'Trace Length = ' + FloatToStrF(TraceLength,0,5,4) + ' mm' + #13#10#13#10#13#10;

OutputSTring :=  OutputString + 'Trace Resistor = ' +  FloatToStrF(Res,0,5,4) + ' mohm' + #13#10;

OutputSTring :=  OutputString + 'Trace Voltage drop  = ' + FloatToStrF(VoltageDrop,0,2,2) + ' %'  + #13#10;

OutputSTring :=  OutputString + 'ADC LSB = ' +  FloatToStrF(ADCLSB,0,2,2) + ' %';



How To Run The Script

To test the script, from your PCB Document click on File->RunScript…

Then select your script:

You should see now a large cross:

Click on the trace you want to analyze.

Now you should see the message windows with the calculations:

It is possible to extend this script and add a more sophisticated check, for example, to extend the tracks to arch and add the effect of temperature, etc. I will leave this to you as an exercise.

What Have We Learned?

We have seen that Altium Designer, once mastered, can be used to perform complex actions for us. In this example, we have seen how it is possible to measure the DC trace impedance with just a click and how to estimate the voltage error in a High-resolution ADC design.

This demo script has a lot of limitations but can be used as a base for your own Altium Designer extensions.

Have more questions? Call an expert at Altium or discover more about the best PCB design software features and trace impedance calculator in Altium Designer.

most recent articles

Back to Home