Output Devices

Outputing via Speaker and Servo Motor

This week's assignment is to add output devices to a microcontroller board that I have designed and programmed. As part of it, I designed a microcontroller board with 2 output devices; a speaker and a servo motor.

Actually its kind of overwhelming for me to design a board by myself since Im not for the electronics background. My intention was to try couple of output devices by myself. So I refered the speaker and servo board designs that Neil provided to design my board which integrates both of them. I used Attiny 44 microcontroller for mine. So there is quite a good amount of overall change involved in this design. This allowed me to figure out the needed changes all by myself.

The following is the schematic diagram and my board design I created on Eagle. I used auto route option to create the board trace path. I made mistakes when I drew the schematic; I did not notice that the voltage regulator diagram did not get properly transfered to board airwires.



Milling and Cut Traces



Cutting the board



Assembling the board

I soldered jumper pins at the speaker pads.



Programming the board - Challenges Faced

I had some problems with my schematic design. I did not supply Vcc to the mosfet. I had to break the trace path and short Vcc to Drain of the mosfet. I refered the following diagram provided by Ajith to redo my board.



I also referred the datasheet of the mosfet to verify the design change.



These link1 and link2 are pretty useful for learning Pulse Width Modulation. I started of with basic delay.c I used earlier I did in Embedded Programming, which only the delay changed from 1 sec to 2 millisecond.

#include < avr/io.h > #define F_CPU 20000000 #include < util/delay.h > main() { DDRA = 0xFF; while(1) { PORTA |= (1 << 2); _delay_ms(2); PORTA &= (!(1<<2)); _delay_ms(2); } return 0; }

Output of this code,



Then tried out speaker.c.

#include < avr/io.h> #define F_CPU 20000000 #include < util/delay.h> int main(void) { DDRA = 0xFF; int i; while(1) { for( i=0; i <=100; i++ ) { PORTA |= (1 << 5); _delay_ms(.5); PORTA &= (!(1<<5)); _delay_ms(2); } for( i=0; i <=100; i++ ) { PORTA |= (1 << 5); _delay_ms(.10); PORTA &= (!(1<<5)); _delay_ms(.30); } } return 0; } I used the makefile to burn the code into the microcontroller. Ran make to create the hex file of speaker.c



Ran make program-usbtiny-fuses



Ran make program-usbtiny



The following video is the output I received on the speaker.


Download the design files

Output.brd
Output.sch