The project described in this article requires basic electronics skills and is provided for information purposes. Do not attempt to replicate it or use it for any purpose unless you've got the proper knowledge and skills.
________________________________________
I'm always amused when I read articles about using microcontrollers to read data from analog devices like temperature, pressure, and other sensors. I've been doing stuff like this for over 30 years on microcomputers, going back to the original Apple II. I still use my current Windows PC as a simple analog-to-digital converter. And it's a lot less expensive and simpler than an Arduino.
The Apple II included a wonderful game I/O connector which could support two joysticks and three buttons for input, and had four TTL outputs. It was easy to attach the TTL outputs to relays to control external devices. One of the early Apple II reference manuals included a schematic diagram for hooking up a teletype to the game I/O connector for an extremely inexpensive printer interface (before Apple sold its own parallel and serial interface cards). A joystick is basically a potentiometer (a variable resistor similar to a radio's volume control) where the resistance is proportional to where it's pointed. Instead of a sophisticated analog to digital converter Steve Wozniak designed a simple circuit which used a software timer to determine the resistance of the joystick attached to the game port. The earliest Apple IIs came with a pair of paddles and Integer BASIC versions of the popular Breakout and Pong arcade games. You could build or purchase a joystick as a substitute for the paddles.
While the earliest Apple IIs included free paddles and audio cables for cassette recorders they were not included in later units. This was primarily because of FCC regulations. The Apple was extremely noisy in terms of R-F interference and any external cables would just add to the problem. Not including the cables in the box meant that the unit could be certified without the accessories and if a consumer chose to add them afterwards it was the user's responsibility to avoid interfering with other electronic devices. Other reasons for not including paddles included reducing costs, the reluctance for some consumers to purchase joysticks if they already had paddles, and Apple's efforts to concentrate on marketing the Apple II as a business machine.
Not surprisingly when the IBM PC came out its gameport copied most of the Apple II's game I/O features. (They were so similar that some manufacturers made joysticks with both Apple and PC connectors on the same cable so they could be used with either computer). One key feature the PC gameport lacks is TTL outputs.
The maximum resolution of the PC's gameport's analog inputs is just 4 bits (0-255) and it's pretty electrically noisy, but that's adequate for many applications.
The PC's gameport was usually included on sound cards. The gameport uses a DB-15 connector, typically color coded tan, which could be addressed directly via the hardware locations or through various drivers. There is a bit of confusion about the connector; the DB-15 has two rows of pins and looks like a skinnier version of the DB-25 connector (or a fatter version of the DB-9 connector). It is not the same as the sub-DB-15 connector with three rows of pins used for VGA monitors.
Later versions of the gameport added MIDI support. Many new sound cards and motherboards do not include gameports since most gamers now use USB joysticks and input devices. If your PC doesn't have a gameport you can purchase a PCI sound card with a gameport for about $5. USB to gameport adapters are available, however they are not as compatible and are more expensive.
Microsoft provided software support for the gameport through Windows XP but dropped it starting with Vista. Fortunately Daniel Kawakami figured out how to add gameport drivers to Vista.
I hadn't done anything with my gameport in many years. (I didn't even bother to hook up the gameport backplane connector on my current computer!) A friend needed a feedback system to determine which way a motorized camera was pointed. The simplest solution was to glue a potentiometer to the top of the camera, centered on its rotational axis, with the potentiometer connected to the gameport.
There's lots of documentation on the gameport with plenty of schematics and instructions. It's as simple as attaching a 100K potentiometer to pins 1 and 3 of the DB-15 connector for the X-axis and pins 1 and 6 for the Y-axis.
I had forgotten that X and Y axis inputs both have to be connected, otherwise Windows doesn't recognize that a joystick is present. The simple solution is to connect a jumper between pin 6 (the Y-axis input) and pin 1 or 8 (+5 volts). In this photo the red line connected to pin 1 is +5 volts, the white wire is connected to X1 input and the black wire is connected to ground. The jumper connects the Y1 joystick input to +5 volts. The white and red wires are connected to the potentiometer. I hooked up the ground wire just in case it's needed for some future purpose but for now it's carefully taped. Make SURE you do not let the +5 Volt and ground wires touch each other or BAD THINGS WILL HAPPEN. I only needed a single input to determine the camera's rotation but I have thought about hooking up some sensor (temperature or humidity?) to the Y-axis input just because it's there.
FreeBASIC is an excellent open source BASIC compiler which builds on QuickBASIC. Most important for this project is built-in support for the gameport. There's a sample program in the website's documentation to read the gameport's data and I rewrote the routines for my application.
It was fun to do this project and relearn some lost skills. The most amusing part was looking up trigonometry functions I had learned in high school (Pi are square, cornbread are round - no something's not right there ...).
Total cost for my parts, if I had to purchase them, would be about $5 (DB-15 Male connector, wire, 100K potentiometer) but I had everything in my junk box so I didn't have to put out any cash.
________________________________________
I'm always amused when I read articles about using microcontrollers to read data from analog devices like temperature, pressure, and other sensors. I've been doing stuff like this for over 30 years on microcomputers, going back to the original Apple II. I still use my current Windows PC as a simple analog-to-digital converter. And it's a lot less expensive and simpler than an Arduino.
The Apple II included a wonderful game I/O connector which could support two joysticks and three buttons for input, and had four TTL outputs. It was easy to attach the TTL outputs to relays to control external devices. One of the early Apple II reference manuals included a schematic diagram for hooking up a teletype to the game I/O connector for an extremely inexpensive printer interface (before Apple sold its own parallel and serial interface cards). A joystick is basically a potentiometer (a variable resistor similar to a radio's volume control) where the resistance is proportional to where it's pointed. Instead of a sophisticated analog to digital converter Steve Wozniak designed a simple circuit which used a software timer to determine the resistance of the joystick attached to the game port. The earliest Apple IIs came with a pair of paddles and Integer BASIC versions of the popular Breakout and Pong arcade games. You could build or purchase a joystick as a substitute for the paddles.
While the earliest Apple IIs included free paddles and audio cables for cassette recorders they were not included in later units. This was primarily because of FCC regulations. The Apple was extremely noisy in terms of R-F interference and any external cables would just add to the problem. Not including the cables in the box meant that the unit could be certified without the accessories and if a consumer chose to add them afterwards it was the user's responsibility to avoid interfering with other electronic devices. Other reasons for not including paddles included reducing costs, the reluctance for some consumers to purchase joysticks if they already had paddles, and Apple's efforts to concentrate on marketing the Apple II as a business machine.
Not surprisingly when the IBM PC came out its gameport copied most of the Apple II's game I/O features. (They were so similar that some manufacturers made joysticks with both Apple and PC connectors on the same cable so they could be used with either computer). One key feature the PC gameport lacks is TTL outputs.
The maximum resolution of the PC's gameport's analog inputs is just 4 bits (0-255) and it's pretty electrically noisy, but that's adequate for many applications.
The PC's gameport was usually included on sound cards. The gameport uses a DB-15 connector, typically color coded tan, which could be addressed directly via the hardware locations or through various drivers. There is a bit of confusion about the connector; the DB-15 has two rows of pins and looks like a skinnier version of the DB-25 connector (or a fatter version of the DB-9 connector). It is not the same as the sub-DB-15 connector with three rows of pins used for VGA monitors.
Later versions of the gameport added MIDI support. Many new sound cards and motherboards do not include gameports since most gamers now use USB joysticks and input devices. If your PC doesn't have a gameport you can purchase a PCI sound card with a gameport for about $5. USB to gameport adapters are available, however they are not as compatible and are more expensive.
Microsoft provided software support for the gameport through Windows XP but dropped it starting with Vista. Fortunately Daniel Kawakami figured out how to add gameport drivers to Vista.
I hadn't done anything with my gameport in many years. (I didn't even bother to hook up the gameport backplane connector on my current computer!) A friend needed a feedback system to determine which way a motorized camera was pointed. The simplest solution was to glue a potentiometer to the top of the camera, centered on its rotational axis, with the potentiometer connected to the gameport.
There's lots of documentation on the gameport with plenty of schematics and instructions. It's as simple as attaching a 100K potentiometer to pins 1 and 3 of the DB-15 connector for the X-axis and pins 1 and 6 for the Y-axis.
I had forgotten that X and Y axis inputs both have to be connected, otherwise Windows doesn't recognize that a joystick is present. The simple solution is to connect a jumper between pin 6 (the Y-axis input) and pin 1 or 8 (+5 volts). In this photo the red line connected to pin 1 is +5 volts, the white wire is connected to X1 input and the black wire is connected to ground. The jumper connects the Y1 joystick input to +5 volts. The white and red wires are connected to the potentiometer. I hooked up the ground wire just in case it's needed for some future purpose but for now it's carefully taped. Make SURE you do not let the +5 Volt and ground wires touch each other or BAD THINGS WILL HAPPEN. I only needed a single input to determine the camera's rotation but I have thought about hooking up some sensor (temperature or humidity?) to the Y-axis input just because it's there.
FreeBASIC is an excellent open source BASIC compiler which builds on QuickBASIC. Most important for this project is built-in support for the gameport. There's a sample program in the website's documentation to read the gameport's data and I rewrote the routines for my application.
It was fun to do this project and relearn some lost skills. The most amusing part was looking up trigonometry functions I had learned in high school (Pi are square, cornbread are round - no something's not right there ...).
Total cost for my parts, if I had to purchase them, would be about $5 (DB-15 Male connector, wire, 100K potentiometer) but I had everything in my junk box so I didn't have to put out any cash.
!!! Thanks for Visit !!! |