Uzzors2k Banner

COM Port Laser Turret

COM Port Laser Turret


21.05.09
UART is a standard communications protocol used by many devices, such as computers, microcontrollers and various modules such as GPS or bluetooth. The beauty of this is that establishing a communications link between two devices is incredibly easy. The UART present in PCs use RS-232 which uses increased voltage differences between high and low signals. So all that needs to be done to connect a microcontroller to a PC is add some level-shifting. I had dissasembled some CD-ROM drives earlier, which contain gear-reduction DC motors for the CD tray. I also had an old laser pen, with a high intensity LED. The speed of the motors seemed to be slow enough to rotate the laser at a steerable speed, so I started designing a turret.

Schematic

The circuit uses a MAX232 for level shifting, from the 0-5V from the ATTiny2313 to the -10 to +10V of the PC, and also helps isolate the ATTiny2313 from any problems which may occur with a faulty RS-232 cable. Two gate drivers for MOSFETs are used to control the motors. Otherwise the circuit is fairly straight-forward, consisting of amplifiers for driving the laser and LED, and a regulator for the chips. The firmware for the ATTiny2313 was written in MikroC Pro, since I had used MikroBasic for PICs previously. I used the built in UART library, which made programing the µC a one-hour job, including troubleshooting. The entire code is also very short, and easy to understand. I decided to use a basic control protocol, in which each bit corresponds to an output. Since only 6 outputs are used this works well, and the final two bits can be used to detect bytes which are obviously errorous.

gutted CD-ROMs, laser pen 

Program screenshotIn addition to programming the ATTiny2313, I also had to make a windows program to ease control of the turret. This was the real programming exercise in this project, as I had never programmed for windows before. I started out using Visual Studio C++, thinking it would be similar to C. How wrong I was! I've never had a tougher time programming, and just as I was about to give up on this project, and tried Visual Basic instead. Talk about a difference! I don't know if it's a newb thing, but I found Basic and the complier much more intuitive, and the code examples would actually work. At any rate the small program I had made in C++ which didn't work, was quickly ported to basic where it worked almost instantly. After much trail and error, learning, and revisions I created a rather simple program which makes controlling the turret a breeze. A wide range of COM ports can be selected, though the baud-rate and other settings are preset- why change them? The ATTiny2313 will send back the received command, and it is veiwable in the turret control software as well. The directional buttons for the motors can also be controlled via standard gamer layout on the keyboard, or W for up, S for down, and A or D for left or right. I also created a program for port relaying. It will allow you to select two COM ports that can be connected together virtually by the computer. This has allowed me to control the turret from my cell-phone, over bluetooth. :-O I'm still working out some bugs in the bluetooth app, so it's not released yet, but the port relay software is. I'm not sure if the program requires that you download some .NET package, or if it's stand-alone. I've zipped the sources files so making your own serial applications is easier. All of the files needed for this project have been zipped here. That includes schematic, firmware and PC software.

In the end the motors weren't slow enough and the turret is hard to steer with any precision. It does prove that the concept works however, and by using either stepper motors or servos it can be made much more fun to steer. I plan on upgrading this turret some time in the future.

finished hardware  complete turret


Youtube Flickr Twitter LinkedIn


Disclaimer: I do not take responsibility for any injury, death, hurt ego, or other forms of personal damage which may result from recreating these experiments. Projects are merely presented as a source of inspiration, and should only be conducted by responsible individuals, or under the supervision of responsible individuals. It is your own life, so proceed at your own risk! All projects are for noncommercial use only.


Creative Commons License This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.


3527 unique visitors since 28th June 2020.