How to hook strange things up to your computer The HOWTO Page

The HOWTO Page

Note: This page is out of date. A new page is being developed but is currently incomplete. Visit it in construction if you dare here.

How to set up your very own WEBCAM!

The setup for this webcam operation is remarkably simple, and not terribly expensive either. The system driving the webcam is a Pentium Pro 200 running Windows 95. This system will then need a dial-up internet connection or LAN access which the PC can access the internet through. For hardware, I am using a US Robotics BigPicture Camera, which I purchased for $249.99. These are now available for around $159.00, and US Robotics is now owned by 3Com. This includes a PCI capture card and a small video camera. Note that this is NOT your only option. There are plenty of other video solutions available at a variety of prices. This camera has been my best choice since it will also allow any video input through an RCA jack and works remarkably well for watching TV. :) This camera also provides a much crisper image than others I have seen. The computer setup works well with a Pentium 133 as well, and I would imagine that lower end models would work also. Cam 2 is a Creative Labs Webcam. Its an older model of what is currently available, the Webcam II, which I have seen for as low as $69. The image from this camera isn't as clear in low light, but it certainly serves its purpose to my satisfaction. It uses the parallel port, so you don't need any additional pci slots (if that's a concern).

For software, I am using Webcam32. This is a VERY nice webcam program and the author makes frequent updates, free to anyone paying the one time registration charge which is $29.95. The homepage for information on this program is at: www.kolban.com/webcam32. This program will give you the option of either dialing up the internet and FTPing a picture to your website, or allowing a web browser to access the program directly for those of you with dedicated connections.

Although I have tried, I have yet to get this camera working under linux, even though it is supposed to be supported. When I have some time, I will put some additional efforts into getting it working and if I'm successful, I'll post information on what I needed to fix to get it working.

Beyond that, there's not much to it. If you have any questions or want help setting this up, feel free to email me at [email protected]. However, be warned that I get a LOT of email and respond to a relativly small portion of it based on my priorities in life.

How to hook your doorbell up to the internet!

Just in case you're bored and need something to do, why not make your doorbell internet accessible!

The html interface for the doorbell as I have it right now is a simple cgi script which shows the last 10 lines of a log file. Being directly connected to the internet at all times makes this whole process easier.

To get from doorbell to logfile has several stages. To emulate my setup, you will need at least 1 linux machine with a joystick port, a doorbell (duh), and some way to electronically access the doorbell (access to the chime is usually sufficient).

Chances are good that your doorbell chime is different than mine, so I leave you to figure out your own. I will show you how I mangled mine. There are 3 contacts, all wired together in the chime. One wire goes from the front door, and one wire connects to the chime (more than likely). I disconnected the wire to the front door and attached it to the current contact of a relay. The other contact of the relay then attached to the contact on the chime, completing the circut. Now, when the doorbell is pressed, it flips the relay switch. This MIGHT disable the chime on the doorbell if it can't get enough current. You will see later why this might not be a bad thing, but if you want to hear the chime ring, you will either need a relay that uses less current or figure it out some other way. Don't ask me, I'm not an electrician. :)

The joystick port on the linux box is used to detect when the relay gets switched. What we do is emulate a button being pressed, and detecting the buttonpress. On the joystick port, leads 2 and 4 connect button #0 on joystick #0, which is exactly what we want. You also want to cross leads 1, 3, and 6. 1 is +5V and 3 and 6 are resistance inputs to detect the position of the X and Y coordinates of the stick. We don't care about the stick, but if we don't show some type of input, then the driver will think the joystick isn't there. Crossing those 3 leads will emulate a joystick at <0,0>, and makes the driver happy.

Once you have the relay properly hooked up to the joystick port, you now need a way to read the data. This is probably a good time to test that your wiring is correct. An easy way to do this is to get a test program for dos and hook up to the joystick port on that machine and test it. If you're able to toggle the button #0 bit when the doorbell is rung, then so far, so good. :)

If you don't plan to use linux to read the joystick port, then the rest of this document won't be of much use to you. Accessing the joystick is pretty easy through a single bios call, and writing a program under dos to do so is pretty simple.

Under linux, you first have to have a joystick driver loaded in the kernel. If the kernel doesn't have it compiled in straight, then you can load the module in after you boot the system with no problem. You also have to make sure that there's a /dev/js0 device present.

The js.c program will test the status of the joystick just like the dos test program did. If you're able to detect a change in the button #0 bit when you ring the doorbell, then you're still in business.

The dos test program, the linux joystick driver, and the linux test programs discussed can be found here.

I've written 2 programs, a client and a server program for the doorbell. The client program detects a doorbell ring and notifies the server about it. The server program then logs the event and performs any other actions you may see fit (Like playing a wav file....this is why disconnecting the chime might make sense :).

The client/server runs over tcp/ip and may reside on different machines. They may also reside on the same machine. I chose to dedicate a machine to constantly poll the doorbell to see when it rings. Since the joystick port doesn't use interrupts, if you aren't watching the switch when it happens, you'll miss it. Therefore I decided to dedicate a machine to it. A 486 with 8 megs of ram and a 100 meg harddisk, which is more than ample to run linux, can be purchased for $30.00 used, which is what I paid for mine. Since you don't require a monitor for this project (other than for setting it up), its a cheap enough option to just dedicate a computer to the task. I also plan to use the same computer for reading other devices as I add them.

However, there's no reason you shouldn't be able to share the machine with other tasks as well, and running both server and client on the same machine works great. The advantage of running the server from a different machine is that you could, for example, while you are at work, set up the server program there so you will know when someone rings your doorbell at home. Excellent for knowing when someone comes by your house when nobody's there. Better yet, if there's an excessive number of doorbell rings in a short period of time, someone might be having a party (wink wink. :)

The server program also does not have to be run on linux. You can program a server program on any computer that supports tcp/ip. The server can also execute any scripts. Setting up a webcam looking at your porch, and doing a capture and save everytime someone rings the doorbell will give you a visual log of everyone that visits you, including when you're not home.

Of course, none of this is complete until you post it on the internet for all to see. :)

Source code for the doorbell server is now available for download. Check the links at the bottom of this page.

How to set up a computer controlled power switch

This project was relatively easy once I sat down and started it, although finding parts was a challenge. This page will provide a great deal of information on the hardware issues, as well as the schematics for building the switch. It explains it better than I could.

However, as a quick summary, the switch is composed of a relay, a transistor, a diode, and a resistor. The relay controls the current of a 120 Volt AC power source. The relay is controlled by a 9 volt power supply, which I am using a 9 volt battery, which can be easily replaced by a power supply. The 9 volt current is in turn controlled by a TTL transistor. The transistor is triggered by the output of one of the parallel port's data contacts.

I wrote a client and server program set to control the switch. The server program recieves a request to turn the switch on or off and then sends the appropriate value to the parallel port.

As with the doorbell, I have the client and server operating on different machines. The server program resides on the machine with the parallel port. Through linux, the parallel port is a standard device, easily compiled into the kernel, if you don't have it installed already by default. Programming the port is easy and only takes two lines of code. The previously mentioned site provides a demonstration program for windows and linux.

The client program I wrote will send a packet to the server with a command, telling it to turn the switch on or off. The client code can be executed on any linux machine and performed with a single command line. The code I have provided takes arguments for the IP address, port, and command, but I have also modified this code for specific operations to make it easier to use for CGI scripts. You should be able to port this code to any platform supporting TCP/IP and still be able to talk to the server.

The completed circut and program can now turn on and off any AC appliance which uses a normal wall socket and can push up to 10 amps of current. More than 10 amps can be provided, but the relay I'm using provides that as a maximum, so I'm not planning on plugging in a bunch of power strips. However, this is more than adaqute to operate a lamp, or a string of Christmas tree lights, a TV set, a fan, the possibilities are endless.

More so, the parallel port can control up to 8 switches easily, and up to 12 with additional programming. My next project will probably be a scrolling light display you can send messages to and watch as they scroll across.

Source code for the power switch server and client is now available. Check the links at the bottom of the page.

How to interface X10 lamps and appliances

This is almost so simple it defies explaination. Simply put, you take an X10 module, plug an appliance into it, set the house and unit code, and you're all set. A small serial port dongle included with a starter kit provides all the computer interfacing you require. For linux, I'm using the bottlerocket X10 command line interface program, which I call from the lampserver program. The lampserver takes commands to turn on and off X10 appliances the same way it takes them to turn on and off the relays.

The only disadvantage to using X10 is the loss of the computer interfacing experience. Its also slightly more expensive than homebrewed solutions. However, what you lose in experience you gain in convienence. With X10, you don't need to run wires throughout your house. You don't need to do any assembly. You don't need to do any crazy programming. And best of all, it wins out in astetics. So I feel justified in selling out in this one aspect.

How to pan the camera

This contraption is certainly my most interesting so far. Since the camera itself provides no method of mounting, it was hard to create a simple adaption to allow for rotation. This is my adventure.

A quick summary: The camera is contained in a self made brace which is superglued to the shaft of a stepper motor which is connected to a circut of 4 transistors which are controlled by the parallel port.

I modified the server program I use for the lamp and it now controls both the lamp and the stepper motor. The lamp required one data line, the motor required 4. Since the motor can be operating while the lamp is on, and since both devices are controlled by the same parallel port, it now became necessary to have a "state" variable which keeps track of which data lines on the parallel port are currently active, so the lamp doesn't get shut off during a motor routine.

Each of the 4 transistors for the motor is triggered by one of the data lines from the parallel port. Each transistor then controls power to one of the 4 stepper motor contacts. Each contact must be given power in sequence to make the motor turn in one direction or another. So, in addition to remembering what the parallel port currently looks like, its also important to remember which contact was touched last. The server controls all of this to make the circutry as simple as possible.

The power driving the motor is a simple 9V DC power source, provided by an AC 9V battery adapter.

The motor is built into a radio shack project box, to give it the required support. The motor was obtained from a dead floppy drive. Floppy drives are wonderful sources of stepper motors and I'm willing to bet you can obtain them for free if you look hard enough. The end of the shaft has a gear well attached, so I decided to simply glue this gear onto the brace I built rather than trying to get the gear off by force (which won't be happening anytime soon).

The brace is a very high tech contraption I built from my old erector set. It simply holds the camera and keeps it from twisting around too much. I still have a problem with the cable leading from the camera, as it tends to pull on the camera if the motor turns it too far. I therefore set a maximum rotation angle to 90 degrees. This is adaquate to view most of the room and everyone in it.

Your Very Own Computer Controlled RC Car

Before you start, be warned. This project can get EXPENSIVE. At least much more expensive than the other projects are. However, this project can be done in stages so you don't have to spend all your money at once.

First of all, a list of equipment you're going to need. The most obvious of course, is an RC car. To truely be an RC car, it needs a remote. You WILL be doing some serious surgury on the remote, so consider that fact before purchasing anything expensive and make sure the remotes can be replaced easily and inexpensively.

You will also need either 4 SPDT relays or 5 SPST relays. They don't need to be able to push much current, so any $2 radio shack brand will work just fine. Of course, you need a computer with a parallel port. If you did any of the previous projects, the same program that controls the lamp controls the car as well. You will need a total of 4 data ports from the parallel port, or more if you have other things you want to control other than movement, such as headlights. The relay connections to the computer are the same as used with the lamp circut, so refer to that for instructions, and supplies.

Now you will have to decide if you want to retain the original use of the remote control even though you've got it wired to the computer. Wiring up this puppy will NOT be easy for the inexperienced. Unless you get the EXACT same model of car that I did, its also likely that the remote control's insides will look or even possibly work differently. In fact, you may require an entirely different approach to make it work. For that reason, and for the fact that I'm currently lazy, I will give an overview and let you figure it out on your own.

The remote has 2 levers. One will move the car forwards or backwards and the other turns the wheels left or right. When you take the remote apart, you will notice that the lever actually is nothing more than a fancy looking switch. It pushes a small metal slider on a track which causes it to make contact with the circutboard in different places. When these contacts are crossed, the transmitter then sends the appropriate signal to the car and the car does something.

In my remote unit, the slider acts as a Double Pole, Triple Throw switch. Since its unlikely you're going to find any triple throw relays and since the center throw position, which is also the default position, is always in a non-contact state, the same thing can be achieved by two DPST relays. There are two contact positions for movement (forward and backwards) and perhaps a third as well for turbo speed (you decide if you want to hook it up separately. It will require another data port/transistor/relay/etc etc). There are also two contact positions for steering, left and right. On all four contact positions one pole is identical. Therefore, you can subsitute the 4 DPST relays for 4 SPST relays (which are cheaper) and add a fifth SPST relay to make contact with the other pole position when any of the other 4 relays are triggered.

The next important issue is speed. The RC car is probably quite capable of achieving adaquate speed to cause damage if it hits a solid surface (a wall for instance). While the car itself can probably handle it, remember, we are also mounting a camera on top of the car and the camera is far more delicate. Therefore, you want to force the car to not go faster than a certain velocity. The easiest way to do this (and its already in the code) is to simply put a delay between the time you make the contact and the time you stop it. A delay of 500 ms is a nice speed. Of course you may want different speeds. That is completely up to you.

The camera part itself was much easier, although more expensive. First, you'll need a capture card or a Snappy or some video input device that will take an RCA jack as input. Then you will need to purchase a transmitter/receiver kit that can send/recieve video and a small, low powered camera. I purchased both these items from MatCo. The model numbers there are CNL-100 and ASK-2000TR. I also purchased the enclosure for the camera, model number A-300. You may have to browse the pages a bit to find the actual model numbers. They don't all appear on top. Please note that I am in no way affiliated with MatCo, I simply found that their products were the least expensive for what I needed to do and so far I have had no problems with the products.

The receiver has a female RCA jack for video out. Take any RCA cable and hook that puppy up to your capture card. Take the camera, which has 4 wires. READ THE INSTRUCTIONS THAT COME WITH THE CAMERA. They are vague, but they tell you which wires do what. Two of the wires are for power, and the other two are for the video signal. The video wires can be directly wired to an RCA plug, which can then be plugged into the transmitter. Then go to radio shack and find yourself a power adapter plug which fits the transmitter. Wire the camera's power wires to this plug as well as another set of wires which will then go to your power source. Plug it into the transmitter and now you have power to the camera and transmitter. For a power source, you can either use any 12V power supply (a battery pack works great), or you can just wire it directly up to the RC Car's battery pack. If the car isn't moving, this will last about 3 hours. If the car is larger you can put more battery packs in parallel and get longer lasting juice.

The transmitter and the camera then get attached to the car by this amazing hi-tech product known as CONTACT TAPE. No, its not really hi-tech, it just sticks well. Any hardware store or crafts shop should have it. Its also cheap.

I will eventually provide schematics and diagrams of the process to make this process easier. Someday I have to clean up the mess of wires I've created here and redo the electronics into a nice neat project box which won't look as pretty but I wont' have to worry about tripping over wires.

Tracking Consumables

This project was exceedingly simple to get working, but took me over 2 years to implement, mostly due to laziness, but partially due to the unavailability of equipment. I also kept brooding over the project thinking of the hard way of doing things and when I finally got done thinking it over, I sat down and in one hour wrote a 100 line program that did the job. I've done some revisions since then and added some features, and I'm still developing it some more, but getting the core system working was simple.

First off, I don't use a Cuecat: or whatever they're called. I'm certain that these would be viable alternatives to the commercial barcode scanner I'm using, but since I don't even own one, I wouldn't have the slightest idea how to use them for this purpose, and I'm not going to pretend that I do. What I AM using is a barcode scanner that I picked up at First Saturday for $30 one rainy day several months ago. It daisychains in with a PS/2 keyboard connector, gets power that way, and feeds the data in through the keyboard.

Software wise, I wrote a little program that accepts a UPC code as input for each line, then processes that UPC depending on if we're currently in add or discard mode. When I have the software in a stable state I will be releasing it as well. Right now, this is all the software does. In the future, I plan to extract the UPC product information from one of the free online databases, if that data already exists, and thereby save me the trouble of entering everything thats already been entered. I could probably go the other direction as well and feed back the data entered in the event that the UPC code is not found in that database, thereby adding to it.

Scrolling Marquee Sign

You know what I'm talking about. Those scrolling light displays. Well, I'm going to build one, and if you want to tag along, so can you. This project is for novelty purposes and experience more than a means to save money on a professionally built marquee sign. For the same amount of money you can get something that works out of the box with a warranty and probably a self-contained programmable interface. But what fun would all that be?

First things first. Know something about electronics and TTL logic circuity. I THOUGHT I knew before I started. I learned a lot along the way. I've had to basically start from scratch 3 times as I encountered various obstacles, and I'm not finished yet, but I think I've crossed all the major hurdles now and all that remains is the timeconsuming monotonous work.

First gather your supplies. You'll need a computer with a parallel port (a linux system if you want to use my code verbatim, although it should be portable with minimal fuss). I've purchased pre-etched boards that convienently have 8 columns to work with. Each character is 8x8, so you'll need 64 LEDs, probably all the same color, but its your sign, so do as you please. You'll also need one 74LS273 Octal D-Flipflop IC and 8 switching transistors (2n2222 work). Add a 7805 voltage regulator and a power supply that pushes at least 8 volts DC (a 9V battery can suffice for a while). The design is modular. To extend the sign, you simply append another 8x8 array board, minus the regulator.

The theory behind this sign is as follows. Each LED has an anode and a cathode. Each LED in a column shares the cathode and each LED in a row shares the anode. The 8 data lines from the parallel port connect to the 8 anode rows. Each cathode column is connected to the collector of a transistor. These transistors are triggered by the D flipflop which is wired to ripple a single bit through the 8 bits of that circuit. This way, one and only one transistor is active at any time. The computer will output whatever LED's need to be lit on the current column, wait a few microseconds, turn off the LED's, pulse the 74ls273 then turn on the LED's for the next column. This process repeats until the end of the sign is reached. The cycle then repeats. An 8 character sign should be able to refresh about 120 times per second easily.

To create a monochrome effect, some LED's can be lit only every other refresh. This will result in a LED that appears to be only half the brightness of the others. Several levels of brightness may be achieved by this effect, but if a more broad range is required multiple bits per LED will be required and filtered through resistors to get the desired brightness.

To add additional characters, simply carry over the 8 data lines, the output from the 8th flipflop, the +/- lines and the clock line. The regulator can handle up to 1A of current which will be plenty for a sign of any concievable length since only the flipflops need to be powered at any one time. All the LED's are powered by the computer itself.

For multiple colors instead of just shades of a single color, take a red, green, and blue LED, wedge them together, then center a spacer above them. cover the board except for the spacers so you see the combined light only. You then need to provide each individual LED the desired shade, instead of only one LED per position. This means you'll need 3 bits of information for each position instead of only 1. This isn't bad considering you can get 64 colors easily from those 3 bits. Your mileage may vary.

Take a sharp object and scratch off the contacts on the top and bottom of the board so that each column is electrically separate from the others To be continued......

Source Code Now Available

I am now making the source code for the lamp, doorbell, and stepper motor available for download. You may make any use of this source code you like, but if you make changes that are useful, please send me updates so I can incorporate them back into my system as well.

None of the source is complete. Its in a working state, but there's still a lot I want to do with it, so it will be updated from time to time as I incorporate those changes.

As for functionality, I only make the following statement: It works for me. You're welcome to ask questions if you have problems, and I will try to help if I can. Also, before you even THINK about hooking up some homemade circut to your computer, consider the fact that its very possible to fry computer components, especially with the parallel port circuts, if you don't construct them properly. Therefore, it would be wise not to hook your lamp circut up to your new PII 400. 486's can be had for less than $30 these days. All you need is a network card and you can control all the devices from remate. This software has been written to take advantage of a network.

The basic requirements are a linux system, a joystick port (for the doorbell), and a parallel port (for the lamp & motor). You also need kernel support for the joystick port and parallel port. Kernel versions 2.2 and up have joystick support built in, but I know 2.0.30 did not and needed to be added separately as a module. I leave you to figure out your configuration issues.

Doorbell Files:

Client

Server

Lamp Files:

Client

Server

Barcode Files: (Warning, these are a MESS and don't even work right. :)

Text based client

CGI program to generate the Inventory page

Program to generate the individual inventory tracking log

Comments(0)