Introduction: Turn Any PC Into a Microcontroller for Free in 4 Steps
There are millions of hobbyists of electronics and robotics and I surely am one of them. In such fields of engineering, programmable circuits are very important and so are they to me too, because I like to make different kinds of projects and most of them require a source of intelligence such as a program which can control the circuits involved. I have wondered a lot about how I could cheaply make my own programmable circuits for my projects. It meant that I would have to spend money on some kind of microcontroller and its programming board. Although I did not want to spend much money on buying stuff, I wanted to make cool projects.Then I gave some thought on what exactly I needed a microcontroller for. Basically, a microcontroller is also a computer but at a smaller scale; it has its own memory, processor, ROM, etc. So I thought that it would be a great idea to use my PC itself to make programmable circuits. But when I began working on it nothing went in the way I would have wanted it to. I spent almost a month trying to figure out how to do it in the easiest way possible. Most of the problems that I faced while finding the right way to do it, have not been mentioned in this instructable but it includes only the most convenient way for any newbie or budding hobbyist to make a microcontroller-like device of his'her own using what they might already have, a PC.
This meant that the circuit would have to interface with the PC somehow. There were three options - USB, Parallel Port (LPT port), or the Serial Port. I found that Parallel port was the best one for the job as it was the easiest to control and had 17 I/O pins (available for circuit interfacing) with 12 output pins and 5 input pins, enough to make really cool projects. But merely thinking up such a way wasn't enough as to make it possible I had a lot more to do. Fortunately, I've successfully made it, along with some cool projects using it and put how to DIY in the easiest way possible, here.
This is one of the cheapest ways to make great circuit programming device to make cool projects. Have a look at how to do it and if you like the idea, please votefor this instructabe.
The following instructrable will show you how to turn any computer with a parallel port into a device which has similar functionality as any micro-controller in just 4 Simple Steps.
Step 1: Get All Stuff Required
- Parallel Port (Or PCI card for parallel port expansion ( http://www.amazon.com/Printer-Parallel-Device-Adap...)
- An Old LPT Cable (http://www.amazon.com/F2A032-06-Centronics-Paralle...)
- A Pen Drive
- Some Jumper wires
- A breadboard
That is all you need along with some patience with which to carry out this instructable. In case you are lucky and already have a PC with a parallel port and an old LPT cable already, it is all free for you. This project then costs you nothing.
I'll give a brief overview of the following set of steps here. This project uses the registers allocated to the parallel port on a PC to send any signal consisting of voltage HIGHs and LOWs to the parallel port. First of all, not all the Operating Systems that came after the Windows NT as Windows 96, 2000, XP, Vista, etc provided access to the parallel port easily. I found that the OS which provides the access to the parallel port fully and in the easiest way is actually the oldest, Microsoft Disk Operating System or MS-DOS. We are going to use DOS-on-USB to install MS-DOS on the PC. Then a little more configuration will give you all the access to the parallel port you require.and control all the circuits in your project through a program which can be made and run on the BASIC compiler which comes already with the DOS-on-USB.
I will also show a real project which I've made which consist of a three digit display using some 7-Segment Displays and some BCD to 7-Segment Decoder ICs and how to make it using this parallel port programming device.
Step 2: Installing MS-DOS
This method is called the DOS-on-USB method and is easiest for installing MS-DOS on any PC, quickly and without any problems.Anything you really need for this is a pen drive which you are willing to format and use for this purpose. If you carefully follow each of the following steps, you will have created a pen drive which will boot up your computer with the MS-DOS boot-loader every time you select to boot using the USB storage in your BIOS settings.
Do the following steps to install DOS-on-USB
1. Extract contents of the zip file attached
2. Plug in your USB Storage Device
3. Open James' Format Tool.exe
4. Select your USB drive under "Device"
5. Select FAT file system
6. Type in a label for the drive
7. Select "Format Device"
8. Select "Create a DOS startup disk"
9. Locate DOS files in the /DOS-on-USB/boot/ directory
10. Be sure that you have removed all important files off of your pen drive
11. Click "Start"
12. After the format has completed successfully, copy all of \DOS-on-USB\ to the root directory of your USB Drive
13. Shut-down your computer
14.Boot up your computer, with the USB drive plugged in.
15. Enter your computer's BIOS (usually F1, F8, F12, DEL, or ESC)
16. Navigate to the Boot Order section
17. Make USB the first choice for boot device.
18. After a reboot, it will tell you that DOS-on-USB has been installed.
19. To continue installing DOS, press ENTER
20. You should hopefully come to the DOS setup wizard
21. Follow all prompts (click OK)
22. When it asks for the location of setup files, type: C:\dos\DOS71\
23. Say YES to rewriting the MBR
24. When asked for the install location, type: C:\dos71
25. When asked what type of installation: select Full Installation, then deselect Addon Package
26. Say YES to Access DOS
27. Continue to install DOS 7.1, then reboot
28. Unplug the USB Drive before it loads to enter Windows
29. Plug in, and delete the \dos\ and \boot\ folders on your USB drive
After having done all this, you must have your PC booted up with MS-DOS in which you can open up QBASIC simply by the command "qbasic" . The QBASIC screen which appears next will allow you to control all the pins on your parallel port.I will give a picture of how this works in the next Step
Step 3: Understanding How It All Works
- Memory allotted to the PARALLEL PORT
The memory inside the computer to which the lines in DB25 connector correspond, is divided into three 8-bit registers. This means that we can send any number from 0 to 255 to anyone of these registers and voltage HIGHs and LOWs will appear on the pins of the parallel port corresponding to the registers, which are
1) Data Register
2) Control Register
3) Status Register
The Data, Control and status lines are connected to there corresponding registers inside the computer. So by manipulating these registers in program , one can easily read or write to parallel port with programming languages like 'C' and BASIC. The registers found in standard parallel port are , 1) data register 2) Status register 3) Control register As there names specify, Data register is connected to Data lines, Control register is connected to control lines and Status register is connected to Status lines. (Here the word connection does not mean that there is some physical connection between data/control/status lines. The registers are virtually connected to the corresponding lines.). So what ever you write to these registers , will appear in corresponding lines as voltages, Of course, you can measure it with a multimeter. And What ever you give to Parallel port as voltages can be read from these registers
These registers are IO mapped and will have unique address. We have to find these addresses to work with parallel port. For a typical PC , the base address of LPT1 is 0x378 and of LPT2 is 0x278. The data register resides at this base address , status register at baseaddress + 1 and the control register is at baseaddress + 2.But if you have a PCI card for parallel port expansion, a different set of registers might be allotted to the extension port on your PC(The baseaddress can be easily found in the device manager in the properties of Serial and LPT ports) So once we have the base address , we can calculate the address of each registers in this manner.
Now to send any number in binary to these 8 bit registers we need to write a program to the computer and this is where MS-DOS comes into play. Since on MS-DOS we get the full access to the registers corresponding to the parallel port of our computer, we can write a code and run the program on the in-built BASIC compiler in the MS-DOS, the installation of which was described in Step 2.
Step 4: A Successful Project : 3 Digit 7-Seg LED Display
Just to show you that this set up of the PC as a circuit programming device works perfectly fine, I've made this 3-Digit display project. This display consists of 3 BCD to 7-Segment LED decoder ICs (7448), 3 7-Segment LED displays themselves and some jumper wires. After having hooked up all these components to the parallel port as shown in the circuit schematic, it can be directly controlled through MS-DOS using the QBASIC compiler.I have posted both the circuit schematic diagram and the BASIC source code for this project below.
The commands on QBASIC that are used to send and receive signal to parallel port registers are:
- INP ()
- OUT ()
Syntax for the commands:
- INP() - INP (address of the status register in Hex).For example, 'INP(HD481)', given that the base address is D480 and that of my status register which is (baseaddress+1) is D481 in Hexadecimal system. It returns the value currently being read from the Status pins of the parallel port. It can be any value from 0 to 255 which may be coming out of a digital sensor or another device such as a micro-controller.
- OUT() - OUT address of the Data register in Hex, x X can be any number from 0 to 255 which you want to send to the Data pins on the parallel port. For example, my baseaddress or the address of the Data register on my PC is HD480, and I want to send a LOW voltage to D0 pin and a HIGH voltage to all the other Data pins from D1-D7, then I will have to write the command - 'OUT HD480, 254' without quotation marks.
Other details on how to program the parallel port using BASIC can be found out from various websites such as:
For other projects involving higher power components such as Servos, Stepper motors, Relays or Speakers, additional amplifier circuits may need to be made for the output pins to amplify the current coming out of the parallel port because it is very low.
Safety tip: Do not draw too much of current from the parallel port and always use the appropriate values of resistors if required to be sure that you do not damage any internal circuitry of your motherboard. The ones who don't have a parallel port integrated on the motherboard and have an expansion of parallel port using the PCI card may have a slight advantage here, that even if there is any sudden fluctuation in the voltage/current level(s) at the port, the motherboard will remain safe even if the PCI card gets damaged.