Robo Atmega328p project

17,212

Circuit Image

This project was designed to introduce a friend to microcontrollers and circuits using various functionalities and spare parts. A PS2 numpad was utilized as the key entry mechanism, which was found at a thrift store and included the necessary connector. Decoupling capacitors were omitted without adverse effects, and a pull-up resistor on the reset circuit was likely unnecessary. A 220µF capacitor was essential to prevent voltage dips caused by the servo, which would reset the microcontroller. Initially, the microcontroller drove a speaker through a resistor, but it was too quiet, prompting the addition of a MOSFET to allow higher current output. Writing code was straightforward, as the Arduino IDE provided libraries for generating tones and controlling servos, as well as a library for the PS2 keyboard. It was noted that the IRQ pin for the keyboard corresponds to the external interrupt number of the pin connected to the keyboard's clock signal. The digital pin number was incorrectly specified initially. To avoid wasting an Arduino, components were soldered directly to an ATmega328P. An AVR programmer was available for direct programming of the hex file from the Arduino IDE, but a bootloader was burned for easier future updates. An updated version of the board.txt file was created to accommodate software changes. The first inch of the book's pages was glued together to create a space for the electronics, ensuring it was large enough for the motor and microcontroller. Clamps were used to assist with the drying process, after which the inner section of the pages was cut out, leaving about an inch border. Drilling into the pages allowed for threading a coping saw, although cutting was slow, and an X-Acto knife was used for the second cavity. This process took several hours, and a Dremel or band saw could expedite it. The electrical build commenced after the code was functioning. A voltage regulator, specifically an LM340, was added to the keyboard circuit using recommended capacitors from the datasheet. The circuit was fitted inside the keyboard and soldered to a 5V and ground pad on the circuit board, with the numlock LED removed to accommodate a 9V battery connection. The latch was attached to the servo motor, which was identified as a potential weak point, resolved with super glue. The electronics were soldered together in a "dead bug" style, though a prototyping board or PCB would be advisable for greater robustness.

The project integrates various electronic components and programming techniques, making it an excellent educational tool for understanding microcontroller applications. The choice of a PS2 numpad as an input device highlights the versatility of reusing existing electronic parts, promoting sustainability in electronic design. The decision to omit certain components, such as the decoupling capacitors and pull-up resistor, demonstrates an understanding of circuit design and the ability to troubleshoot effectively.

The use of the ATmega328P microcontroller, coupled with the Arduino IDE, facilitates rapid development and testing of the code. The libraries provided by the IDE streamline the process of generating audio signals and controlling servos, significantly reducing the complexity of the programming task. The importance of correctly identifying the IRQ pin for the PS2 keyboard is a critical lesson in microcontroller interfacing, as it emphasizes the need for precise connections in circuit design.

The physical construction of the project, particularly the modification of the book to house the electronics, showcases creativity in integrating technology with everyday objects. The careful planning in creating cavities for the motor and microcontroller reflects an understanding of spatial constraints and the need for a secure fit for the components.

In terms of the electrical design, the addition of the voltage regulator ensures stable operation of the keyboard and microcontroller, which is crucial for reliable performance. The decision to use super glue for attaching the servo motor latch, while a temporary solution, illustrates practical problem-solving in the absence of more robust mechanical options.

Overall, this project serves as a comprehensive introduction to microcontroller-based systems, combining programming, circuit design, and creative physical construction, making it a valuable educational experience.This project was used to introduce a friend of mine to microcontrollers and circuits. I wanted something that used a variety of microcontroller functionalities and used only parts that I had lying around. I ended up using a PS2 numpad as the key entry mechanism since it was what I happened to see in the thrift store, and it happened to come with t

he connector it mated to. I left the decoupling capacitors off without any ill effect, and you could most likely get away without a pull up resistor on the reset circuit. The 220uF capacitor was a must though. Without it the servo would cause large dips in the voltage causing the microcontroller to reset. Originally, I had the microcontroller drive the speaker through a resistor, but this turned out to be too quiet to hear through the book.

To fix this I added a MOSFET to allow a larger current than the microcontroller could output directly. Writing the code turned out to be extremely easy. The arduino IDE comes with libraries to handle producing tones and controlling servos. I was also able to find a library for PS2 keyboard. A couple of things to note using these libraries: TheIRQpin specified for the keyboardcorrespondsto the externalinterruptnumber of the pin you attach the keyboard`s clock signal to.

I originally specified the digital pin number which was incorrect. Since I didn`t want to actually waste an Arduino on this project, I ended up soldering the components directly to an Atmega328p. I had an AVR programmer so I could have just directly programmed the hex file produced by the Arduino IDE, but I decided to burn on a boot loader to make future updates easier.

I followed the guide here using theminimal configuration. Unfortunately, the board. txt file that site supplies seems to be for an older version of the software. Here is an updated version that I made: boards. txt. To use it add the contents of that file to the end of the hardwarearduinooards. txt in your Arduino IDE folder and restart the IDE. Then select ATmega328 on a breadboard (8 MHz internal clock)  as your board. Glue the first inch or so of the book`s pages together. This will be the space that will house the electronics, so make it big enough for the motor and microcontroller. Clamps help a lot. Once the glue is dry, cut out the inner section of the pages. We left about an inch border. We drilled into the pages so we could thread a coping saw. Cutting through the pages was slow going, and for the second cavity, we ended up using an exacto knife.

Each cavity took several hours. A dremel or band saw might make this easier. Repeat this process for the remaining bottom pages. This should leave you with the cover, the hollow top pages, the hollow bottom pages, and the back still able to move independently. Once we got the code working, we started on the electrical build. First we added the voltage regulator to the keyboard. We used aLM340 with the capacitors suggested in its datasheet`s application notes. We were able to fit the circuit inside the keyboard and soldered it to a 5V and ground pad on the circuit board.

We removed the numlock LED and fed the 9V battery connection in through the hole. Next we attached the latch to the servo motor. This connection is probably the weakest point in the project, but we couldn`t come up with a better idea than super glue. After that, we soldered together the electronics. We did this dead bug style  but this should probably be done more robustly with a prototyping board or a PCB if you want to be super fancy.

🔗 External reference