Project 9 : Input Devices
For my the input device week I kept the theme of DC motors going on but decided to add two buttons to interact with the motor.
Version 1 (Failed)
My idea is simple: a board that would make a small DC motor turn clockwise when one presses a button, and turn the other way when one presses another button. As an added interest, the speed of rotation is toggled when both buttons are pressed. I
In addition to adding two buttons to the basic board, I at first set myself the challenge of using an ATtiny45 for the job. Due to the very small number of pins, I had to reuse the SCLOCK and MOSI for the button input purposes (MOSI is used over MISO as it is preferable to keep a pin as input if it was used as input when programming the board).
Making the connections on the board proved to be quite difficult. I made very convoluted paths which turned out to be too small, thin and close together. The resulting board, unusable as a result, is shown below:
To avoid this issue, I need to keep my design adapted to the capabilities of the tool used. I was influenced by how small and close the routing was when I tried using autoroute (which I did not end up using due to its use of vias).
I can ensure to keep this in mind by setting up a personalized DRC (design rules check), with 16mil distance between traces and within traces as a prerequisite (approximate size of the endmill, which is 1/64 inches).
Version 2 (Funky)
Due to worries about feasibility, I changed the Eagle logic file, reverting back to the Attiny44, allowing for more pins. When rerouting the board, I went for a more curvy, funky look for kicks. I'm glad I tried, but I still prefer the tight straight lines. Soldering the spacious was very fast though. Here is the finished board:
I also coded a script that would turn the motor in one direction when one button is pressed and in the other direction when the other is pressed. Since the user can press both buttons at once, I decided to make that toggle between different motor speeds (in a similar fashion to the "fade" program implemented on last project).
The board at first did not work. The testing took a while to figure out what was wrong, but I improved my debugging skills in the process. Most notably I developed the habit of testing with a voltmeter with one pin on ground.
At first no power came from the H-bridge so I changed it. Then the 9-volt battery I was using was actually outputting much less than 9-volts. Finally the power seemed to come out with equal voltages to the output pins, but this turned out to be an issue with the wire connecting to the motor, which I replaced as well. When all this was done, the project was up and running. Here is a demo:
Things to think about in future board designs:
- make a bigger pad on the ground wire for easier debugging
- include LEDs in strategic places to allow easy debugging
- Add an engraved board name and labels
- Traces (version 1): DC_v1_traces.png
- Outline (version 1): DC_v1_outline.png
- Eagle logic file (version 2): DC_motor_2_ways_v2.sch
- Eagle layout file (version 2): DC_motor_2_ways_v2.brd
- Traces (version 2): DC_v2_traces.png
- Outline (version 2): DC_v2_outline.png
- Code: DC_buttons_v01.c
- Roland Mill
- avr-gcc and avrdude