The electronics must be able to handle the follow tasks:
Design Considerations
To use the Atmega 328 microcontroller properly, the first step is naturally to read the datasheet and study the pinout diagram.
The detailed datasheet is available from Microchip Website. Click HERE to download
Since the voltage from the microbial fuelcell (MFC) is very small, special attention must be paid to the design. I referred to John Errington's webpage on precise voltage measurement with the Arduino board.
From the datasheet as well as from John Errington's page, the ATmega 328 is provided with a successive approximation type Analog to Digital converter (ADC) which has has an absolute accuracy of ± 2 LSB (Least Significant Bit). Hence the maximum error is 2 bits (4 decimal) in 10 bits (1024 decimal) and the worst case accuracy of the converter is 4/1024 or 0.25%. However the limit of the measurement accuracy largely depends largely on the voltage reference used. For high accuracy voltage measurement, external reference voltage is recommended as with internal reference voltage, accuracy is at best 5%. Below is an example from John Errington's webpage on how an external voltage can be setup.
Since I planned to use the ATmega 328, the best resource to get started it would be the Satshakit which is an Arduino compatible and most importantly fabbable board. Using this board as a starting point, I can get to design my board in EAGLES.
Having identified the requirements for the circuit board, the next step is to select/determine the pins required. Besides PWM, ADC, TX and RX, I have also decided to include a ISP header on my board so that I can upload programs to my board easily using the USBTiny ISP that I have made a several weeks ago. I decided to use the 3.7V Li-ion battery to power my device. For the water pump which requires the L298 H-bridge a supply voltage of around 7V is required. Hence I have also include a buck boost converter.
Using Sashakit as the starting point and having fabricated 2 boards, the drawing of the schematic is quite smooth now. Right Click to save Schematic FileAfter clearing ERC check, the next step was to develop the board. Again using Sashakit's design as a guide, laying out and routing the board was much less daunting now. The design is as follows:
Right Click to save Board design (*.brd) fileOnce the routing of the board was completed, DRC was run. For the DRC, a spacing of 12 mils was used as the spacings between the pins for the ATmega 328P mcu are only 14 mils apart. After rectifying routing mistakes and approving airwires for the Zero-ohm resistors, the design was ready for fabrication.
To fabricate the board, StepCraft 420 milling machine was used. mods was used to generate the gcode (nc file). THe procedures for machine operation as well as gcode file generation were the same as when I fabricated my USBTiny ISP programmer and hence not documented here. The toolpath is as follows
Right Click to save gcode (*.NC) fileFor milling 0.1mm 10 degree tool was used. After milling, the next mammoth task is the stuffing. Soldering Atmega 328P was a nightmare. I failed in my first attempt and when using the hot air gun for rework, I burnt the board and had to start all over again. The second attempt was successful and the image of the completed stuffed board is as follows:
To test that the board is working properly a small servo motor (SG90) was connected to the pins one at a time and the Sketch program was amended, compiled and run for each of the pin. The video below showed that the PWM pin was working properly.
To power the 5V water pump, the L298 H-bridge is required and since a voltage drop of 2V across the H-bridge is expected (refer to Output Device Assignment for more details), a buck/boost converter was used, so that the voltage of 8V can be supplied to the H-bridge.