Computer Logic Design with KTechLab

A couple of weeks ago, I wrote an article about a digital and analog circuit simulator called ksimus. One of my readers asked what the difference was between ksimus and ktechlab so I thought I'd take a look at ktechlab. Let me just say that both of these programs are a lot of fun to play with.

My first impression of ktechlab was that it has a much richer assortment of components from which to build circuits. Unlike ksimus, ktechlab includes an addressable memory as well as DAC's, ADC's and even a PIC micro-controller! As I'll discuss later, I had to use Google to find out what some of the components were. Ktechlab's documentation seems to be reasonably complete though the program's website has a lot of broken links. The website does include a plea for help from the user community, so if you find the program useful, perhaps you can help the program's developers by helping with the website.

The components in ktechlab are roughly broken down into categories: sources, discrete components, switches, outputs, logic circuits, connections, and integrated circuits.

Amazingly, ktechlab comes with ten voltage sources, including a few I'd never heard of! I'm not an Electrical Engineer, but I did find it a bit redundant to have both a battery, and a fixed voltage source. Both components had a configurable voltage output. The voltage signal source provides a sine wave with a configurable amplitude and frequency. The square wave clock generator has a configurable frequency and duty cycle, although it's somewhat counter-intuitively categorized as a logic component and not a source.

Ktechlab also provides discrete components that let you build simple analog circuits. Here we find resistors, capacitors, inductors, diodes and transistors. We also find a wide variety of switches. We have momentary contact and momentary break switches as well as SPST, DPST, SPDT, DPDT, and a rotary switch.

The outputs that ktechlab provides are just as varied. We have simple LED's and lamps. We also have bidirectional LED's, seven segment LED's, and a dot matrix display. The dot matrix display can be made almost any size you can imagine. We also find volt meters and ammeters. Finally, we can use the logic, voltage, or current probes to get a plot at the bottom of the application screen. Figure 1 shows a trivial circuit I built to demonstrate a couple different switches, a battery, a light bulb, a volt meter, and a potentiometer.

Ktechlab has a connections section that had some unexpected goodies. Here we find serial and parallel ports with all of the pins labeled! Ktechlab also has a bus connection that allows us to combine many conductors so that they can be routed and connected as a whole. For example, all of the address lines to a memory chip could be combined into one bus. We can use external connections to build modules that can then be used in larger projects.

When we get into the digital components things begin to get really interesting. Generally speaking, you'll find all of the gates and logic levels you expect and the gates can be any size you want. Creating an OR gate with 50 inputs is just crazy, but ktechlab will let you do it. We also find JK, SR, and D flip-flops. Then we move on to more complicated integrated circuits like DAC's, ADC's, Op Amps, 2-bit Adders, Multiplexers, Demultiplexers, and Counters. At this point, you could call the parts list fairly complete, but there's still more. Ktechlab has a BCD to 7 segment display encoder as well as a matrix display driver. We can even use a 555 timer chip! Remember those?

Figure 2 shows another simple circuit that I created. This time we have a clock source that drives an 8-bit counter. The output of the counter is used as data for a dot matrix display driver, which drives a single character of a dot matrix display. As you can see, I've got an enable, up/down, and a reset button. So, when the enable button is closed, the clock starts and the display cycles through all of the possible characters. If you press the reset button, it starts over again. If you toggle the up/down button, the display cycles in the other direction. This is a simple circuit, but it's a nice demonstration of some of the nicer features of ktechlab.

Next we come across the two chips I never expected to find in a simulator. One of the circuits is a RAM chip with up to a 32 bit address bus! I stopped increasing the data word size when I got to 90 bit!

The other chip I didn't expect to find in such a general circuit simulation package is a PIC micro-controller! Ktechlab allows you to use a P16F84 PIC in your design. Not only will Ktechlab simulate the PIC, it will allow you configure and program it! On a real PIC, each pin can be configured as either an input or an output. This configuration is done by writing a particular bit pattern into a configuration register. Ktechlab makes initial PIC configuration trivial; you can set the initial logic level by clicking on each pin to toggle between high and low. You configure each pin as input or output by clicking on the pin and dragging the mouse in the direction you want data to flow on that pin. Each pin has an arrow next to it indicating whether the pin is an output or input.

Figure 3 shows a fictional circuit featuring a PIC micro-controller and a parallel port. It's easy to see that with just a little bit of research, building a parallel interface circuit using a PIC could be trivial. Ktechlab allows you to design and model such a circuit.

Once you've got the PIC configured, which ktechlab will help you do, you can load a program onto it in either .asm, .c, or .microbe format. If your program is in .asm format, ktechlab will simulate the program while it's in the circuit.

PIC assembly language can be a bit daunting, but ktechlab helps make PIC programming easier. With ktechlab, you can actually create simple programs by combining flowchart elements. It's actually easier to show than to describe, so take a look at figure 4. In the left-hand corner, you see the PIC, with it's pins labeled. Each pin has an arrow next to it that indicates whether the pin is an output or an input. You also see the skeleton of a simple program and a subroutine. So, ktechlab gives you a unified environment where you can program, simulate and interface with PIC micro-controllers.

Once thing that I find conspicuously missing from ktechlab, as well as ksimus, is the ability to output signal levels to a file or read them in as circuit inputs. This would open the door to being able to simulate a circuit using real-world inputs. You'd also be able to compare the output of a simulation to known-correct results. Sadly, neither ktechlab nor ksimus offer this feature.

I came across ksimus and installed it out of curiosity. Ktechlab was pointed out to me by a reader. Both programs are fun to use and quite functional. Ksimus is probably better at modeling analog circuits using it's superior floating point functions. Ktechlab is vastly superior for doing computer logic design because it offers a wider range of components.

Fig1.png4.62 KB
Fig2.png13.12 KB
Fig3.png14.98 KB
Fig4.png17.31 KB

Mike Diehl is a freelance Computer Nerd specializing in Linux administration, programing, and VoIP. Mike lives in Albuquerque, NM. with his wife and 3 sons. He can be reached at


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Maigke's picture

ktechlab is a great tool for simulation designed for begginers and not that beggineer users, but is exist a fork about this software, in our comunity, an effort has made, tha costruccion, the site is in Spanish, but i don't belive that's a problem :D

only search in google ktechlab-gcb and you can find debian packages was make Pikitin


ktechlab is very interesting

Maigke's picture

Is true u tell about ktechlab, but in this forum,

a fork from ktechlab was make

the effort made by Pikitin, et al. who are the authors of this fork, are great

The forum is in Espanish. but may be you can found interesting.

For AlonzoTG

LucaT's picture

Hello Alonzo,
you say that you are the current main developer of Ktechlab so i hope that you can address some serious issues that IMO are slowing down the adoption of this excellent piece of software that we call ktechlab.
Before adding new functionalities i think there are stability problems to be addressed.
I use the precompiled RPM of Mandriva 2009 and ktechlab sometimes crashes without warning, i also have some friends who use Gentoo and compile it by themselves who experience the same kind of stability issues. The same stability problems have been observed by other people that i know using different distros and ktechlab's versions.

Do you experience them too? Because it is pretty bothering to spend time connecting components together and then lose all your work for a sudden and unexpected crash. This is the main reason that keeps me away from ktechlab. It is a very good simulator and it is a shame that it keeps crashing when you less expect it.

It would be great to see it used in schools but until it is not stable enough to be usable i doubt anyone will adopt it.

Adding new functions is cool... but if the software keeps crashing no one will really use it. Also... i have noticed that disabling the simulation while building the circuit prevents most crashes... why does ktechlab start with simulation enabled by default?

Thank you,

Current development

AlonzoTG's picture

I'm the current main developer. A KDE 4 port is in progress.

The battery in ktechlab is the ideal abstract battery, if you require a voltage drop, you need to explicitly add a resistor to it.

When you simply want a single fixed voltage point, you could use a battery and a ground, however it's simpler, and common practice!, to indicate a fixed voltage point on a schematic. The actual computational matrix for both the single fixed voltage point and the battery combined with a ground should be identical though the code for the fixed voltage point is far more compact. Ideally, this would create a second circuit to allow you to manage the return currents.

KTechlab is death

Purpur's picture

KTechlab was a really impressive project.
But since David Saxton left the project a few years ago there is nearly zero progress.
There will probably never be a KDE4 version.

Battery not constant

jhansonxi's picture

It's internal resistance increases as charge depletes but I'm not sure KTechLab models that.

Interesting program anyways. Thanks for the review.