Week 10 Output Devices

This week we are going to make a board and the programation of an output device

Materials
  • Spray Paint
  • Solvent
  • Copper Board
  • Ferric Perchloride

  • Electronic Component
  • Solder Paste
  • Tweezers
  • Antistatic table

  • Designing the Board


    I follow the same process as Week 6 using Eagle and routing by hand

  • Making the schematic

  • In this step we need to add components by typing add and we could choose them from a list part. We also could make change of position by dragging them, change of value or name by typing the respective command.

    via GIPHY





  • Routing the board

  • On this enviroment we can place elements dragging them, we can also rotate them typing rot and clicking or dragging them to the desire angle. We have to type route and clicking one pad and this will show to which pad is connected, you can select between different types of lines and nodes; and we can delete a wire writting ripup and clicking it.


    via GIPHY



    Making the Board


    I follow the same method and steps as Week 6 to make the board to control a speaker (You can seleect anyone you want from Fab Academy web site)



  • Cut a vinil stencil, paste it to the board and paint it with black spray paint
  • Etch the board and clean it
  • Put the tin paste, place the components and solder


  • Programming the board


    I have to say that you could program the board from Arduino IDE or from your OS Terminal (You need to instal Cygwin Terminal for Windows).

    I used the second way, and what we have to do first is download C file and Make file from Fab Academy web site. I decided to program a speaker so I had to download its respectives files.

    But before doing anything it's better to understando what we are doing.

  • C file it's the file that contents the configuration and indications for speaker's function, on C programming language.
  • Make file contents the indications for the make command to generate certain types of file that we expect to obtain. But basically we expect to get an HEX file, that is a file with the C commands translated to Hexadecimal commands, that is the "language" that microcontroller understands.
  • Make command is a Linux tool that make the revision and compilation of the code, but also charge it to the microcontroller if is indicated.

  • Now that we know that, this is the make file that we need to use on Windows, bold lines indicate the changes I needed to do to work. If you are working on Mac or Linux you need to erase those changes.


    PROJECT=speaker
    SOURCES=$(PROJECT).c
    MMCU=attiny45
    F_CPU = 8000000
    CONFIG = C:/Program\ Files\ \(x86\)/Arduino/hardware/tools/avr/etc/avrdude.conf
    CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU)

    $(PROJECT).hex: $(PROJECT).out
        avr-objcopy -O ihex $(PROJECT).out $(PROJECT).c.hex;\
        avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out

    $(PROJECT).out: $(SOURCES)
        avr-gcc $(CFLAGS) -I./ -o $(PROJECT).out $(SOURCES)

    program-bsd: $(PROJECT).hex
        avrdude -p t45 -c bsd -U flash:w:$(PROJECT).c.hex

    program-dasa: $(PROJECT).hex
        avrdude -p t45 -P /dev/ttyUSB0 -c dasa -U flash:w:$(PROJECT).c.hex

    program-avrisp2: $(PROJECT).hex
        avrdude -p t45 -P usb -c avrisp2 -U flash:w:$(PROJECT).c.hex

    program-usbtiny: $(PROJECT).hex
        avrdude -p t45 -P usb -c usbtiny -U flash:w:$(PROJECT).c.hex -C $(CONFIG)

    program-dragon: $(PROJECT).hex
        avrdude -p t45 -P usb -c dragon_isp -U flash:w:$(PROJECT).c.hex


    These changes are because sometimes (in my case) make couldn't find the configuration file, so we have to help it.

  • Tip 1 - If you don't know where is the file neither, you can type whereis.exe avrdude on the Terminal that you are using, this will tell you where is installed AVRDude and you can look for the configuration at the folders of the same level. This means that if you find AVRDude on "avr/bin/avrdude.exe" you need to go up to the "avr" directory.

  • The C file that is on the FabAcademy web page is a random sound generator by PWM (Pulse Width Modulation), on this way to produce sound we need to modify the delay to modify the pitch and the quantity of cycles to modify the duration.


  • Tip 2 - If you want the speakers to make a different thing, you can edit the C file that you have donwloaded or you can create another C file but make sure to save it in the same folder as the make file. You will need to edit the Make file too, in the first row PROJECT=speaker, you have to change speaker for the name of the new C file, without the file extension .c

  • To program this C code on the board we need to follow this steps:

  • Open Cygwin Terminal
  • Type cd cygdrive, enter
  • Type cd C (or your hard drive name), enter
  • And so on until you get to the file where you have the C file and Make file


  • Type make -f speaker.make program-usbtiny, enter


  • Results

    I continued making changes to the code and finally I could play this song:


    Week 10 - Output Devices from Ivan López on Vimeo.