htmaa MAS 863
Victor Vina
Fab Lab Bcn

<- Home

fabarduino -> Make your own Arduino at the lab

Arduino is a very popular open source hardware platform. For more info visit Arduino's website.

As a teaching tool, the Arduino IDE offers a quick entry point for those who don't have previous experience with microcontrollers, as it hides most of the complexity of programming, providing a subset of functions based on the C language. It also simplifies the tasks of compiling and uploading. A big number tutorials based on Arduino can be found online and its supported by a growing community. As the hardware is open source, many people are developing different hardware versions of this popular platform.


This page documents some of my findings when implementing Arduino with hardware developed at the lab.
Programming

To use the Arduino language, you don't need to use the Arduino IDE, as you can compile and upload using a Make file from the command line. To use the ATmega88 stocked at the lab, I modified the core files of the Arduino distribution to include definitions of this AVR (since the Arduino board uses the ATmega168). As both AVRs have similar features, this did not prove too hard with help of the datasheet. Other modifications included adapting the Make file to the new AVR, clock speed and uploading options.

C files should be named with a .cpp extension (c++), and some headers and functions handled by the Arduino preprocessor need to be maually included when compiling from the command line. In the following folder you can find a template including required Arduino core. Remember to update the Make file to fit your IC settings, clock speed and uploading options. Please notice that in order to use new libraries you manually have to add them in the build path of the Make file.

The software could also be ported to work with the ATtiny44 and the ATtiny45, but it would require more tweaking due to the smaller number of pins present on these AVRs and different peripherals, registers, etc.


Hardware

A minimal layout for the m88 should connect VCC, GND, and the ICSP pins (-RESET, MISO, MOSI and SCK), and also a pull-up resistor on the RESET line of 10K. There are more than one VCC and GND pins, to evenly distribute power. While these pins are internally connected, it is recommended to also connect them through tracks. You should also connect AVCC to VCC if you are going to need Analog to Digital Conversion, and use a different suply (with common grounds) if your measurement needs to be clear of all noise.

If you are going to be doing time critical applications, or intensive serial communication, add the 20Mhz resonator. Notice the m88 has special hardware for serial communication on pins RX and TX.

You might want to add an RS232 - USB converter to your board, if you want to communicate with a computer or laptop with no serial port. Arduino uses the common FTDI-232, which provides a simple IC, multiplatorm drivers and minimal external components. There are some implementations of USB on AVRs, while I have not tested yet any of them. The following design is a fully featured replica of the Arduino Board ready for the Modela and using Fab tools (just the basics to later add components, sensors and actuators). Please notice you might need to decrease the tool size to mill this part, as clearance between pins is too small for the 1/64 tool. If you do not have a smaller tool, it is still possible to mill the board tweaking the tool size parameter in cad.py and using the 1/64 tool.

People at the labs often find it very useful (to simplify layout of single side boards) to route some tracks through unused pins (which are high impedance by default). Also, free pins can be used to provide GND and VCC for low power peripherals.

Programming

The Arduino boards use a bootoader in order to program the mc through RS232 - USB, overcoming the need of programmers, slow dasa adaptors or computers with parallel ports. Still, you would need a programmer to download the bootloader the first time. The original Arduino bootloader can not be easily adapted for the m88, as their memory configuration is different (16K vs 8K). While there was a bootloader version for the ATmega 8 found on the first Ardunio boards, this AVR is no longer supported. So, for now, flash your code through the parallel port. If you are going to do a lot of microcontroller programming, consider buying a programmer. I recommend the Dragon, which will also allow you to program and debug all types of AVR ICs.