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.
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 email@example.com
|openHAB||Apr 24, 2017|
|Omesh Tickoo and Ravi Iyer's Making Sense of Sensors (Apress)||Apr 21, 2017|
|Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi||Apr 20, 2017|
|CodeLathe's Tonido Personal Cloud||Apr 19, 2017|
|Wrapping Up the Mars Lander||Apr 18, 2017|
|MultiTaction's MT Canvus-Connect||Apr 17, 2017|
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- The Weather Outside Is Frightful (Or Is It?)
- Low Power Wireless: 6LoWPAN, IEEE802.15.4 and the Raspberry Pi
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- Bash Shell Script: Building a Better March Madness Bracket
- Non-Linux FOSS: Control Web-Based Music!
- Gordon H. Williams' Making Things Smart (Maker Media, Inc.)