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.
| Attachment | Size |
|---|---|
| Fig1.png | 4.62 KB |
| Fig2.png | 13.12 KB |
| Fig3.png | 14.98 KB |
| Fig4.png | 17.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 mdiehl@diehlnet.com
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Home, My Backup Data Center
- A Topic for Discussion - Open Source Feature-Richness?
- What's the tweeting protocol?
- Dart: a New Web Programming Experience
- Developer Poll
- May 2013 Issue of Linux Journal: Raspberry Pi
- Reply to comment | Linux Journal
1 hour 5 min ago - Reply to comment | Linux Journal
3 hours 37 min ago - Reply to comment | Linux Journal
4 hours 55 min ago - great post
5 hours 29 min ago - Google Docs
5 hours 52 min ago - Reply to comment | Linux Journal
10 hours 40 min ago - Reply to comment | Linux Journal
11 hours 27 min ago - Web Hosting IQ
13 hours 1 min ago - Thanks for taking the time to
14 hours 38 min ago - Linux is good
16 hours 35 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



Comments
kteclab-gcb
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
Greetings
ktechlab is very interesting
Is true u tell about ktechlab, but in this forum,
http://pic-linux.foroactivo.net/ktechlab-f6/
a fork from ktechlab was make
http://pic-linux.foroactivo.net/ktechlab-f6/ktechlab-gcb-t233.htm
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
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,
Luca
Current development
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
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
It's internal resistance increases as charge depletes but I'm not sure KTechLab models that.
Interesting program anyways. Thanks for the review.