Saturday, January 11, 2014

Design and fabricate a Printed Circuit Board (PCB) with Fritzing and cheat’s method to customize an Arduino shield

Design and fabricate a Printed Circuit Board (PCB) with Fritzing and cheat’s method to customize an Arduino shieldA sample screenshot of the Fritzing GUI, and a designed PCB ready to be fabricated.
Step 0: Download and install Fritzing, and familiarization with the GUI.
  1. Navigate to this URL
  2. Download the Fritzing package according to your computing platform
  3. Extract the downloaded file into a folder of choice
  4. Install and launch by double clicking on the Fritzing Icon
  5. Familiarization with the Fritzing GUI. There are three tabs in the Main window panel, which offers electronics circuit in three different view. The “breadboard”, the “schematic”, and the “PCB”. Top RHS window panel offers pre-defined size of most commonly used electronics components, and also components from a myriad of vendors which include Arduino, Sparkfun, and more.
  6. The beauty of Fritzing. User can start by placing electronics components in the breadboard view or schematic view. Magically, the components will appear in the other 2 tabs that are not used. It is just a matter of preference where to start placing the electronic components.
  7. Once the electronics components are placed in the tab of choice, wiring to form the electrical connections between the electronic components can be made. The wiring connections will then be reflected in the corresponding two tabs.
  8. At the moment of writing, Fritzing does not offer simulation of circuits
Step1: Define an electronic schematic in Fritzing’s “schematics” tab
In this guide, The electronics schematic for ATtinyXX ISP shield will be assumed. While the methodology is generic, the electronics circuits should be user defined in the future use.
  1. Using the schematic above as a guide, call out the corresponding electronics components on Fritzing via the “Parts” window that is conveniently located at the top RHS panel into the “schematics” tab on Fritzing.
  2. Wiring for the connection of the components can be performed by click and hold on the point of one component, then release the click at the corresponding point of the other component. A wire will then appear.
  3. Check all wirings are done correctly and accordingly to the given schematic, in Fritzing.
  4. Now it is ready to proceed to PCB design by clicking on the PCB tab.
Step2. Design and Fabricate a PCB
In this guide, the ATtinyXX ISP shield will be assumed as an example to demonstrate the how-to of designing a PCB. A few points to note: PCB unit cost is related to two pricing components, the PCB footprint (the size of the board), and the number of layers (the copper threads layer). In other words, a smaller PCB foot print with single layer is cheaper than a bigger PCB foot print with double layer.
  1. Start PCB design by clicking on the “PCB” tab.
  2. The following screen shot best describes the designing process.
PCB resized and manual routes for double layer                       full size Arduino PCB foot print without routes
  1. In the screenshot above, the green box is the foot print of the PCB, the colour coded wiring corresponds to the wiring of electronic components made earlier. The human readable white colour text on the PCB is referred to as the “silk screen”, and it is customizable. The white colour shape outlines the physical perimeter of an Arduino and the relative position of the two rows of header pins. Using this predefined template from Fritzing, the to-be-created Arduino shield will fit the Arduino in a snug fit.
  2. Next is to add the routes. Routes on the PCB refer to the wiring of copper threads that connects electronic components. There are two camps or school of thoughts when it comes to placing routes on a PCB. First is the “auto-route” that requires minimal human intervention. Lastly the manual route that requires a lot of human attention. Placing of routes requires both functionality, and aesthetics. The routes must not be not too close to each other, and not overlapping to each other causing a short circuit.
  3. At any time when designing the routes in Fritzing, routes can be deleted or undo.
  4. Auto route by pressing the “Auto Route” button in Fritzing
  5. Manual route by clicking on the individual wires from one end to the other end.
  6. When route design is finalized, perform a design rule check by pressing Ctrl+Shift+D. Fritzing will recommend if the PCB design is ready to be fabricated.
  7. Export the PCB design into gerber files (RS-274X) by clicking on the “Export for PCB” button and send it to your local vendor to fabricate.
  8. The generated gerber files can be view using open source software such as gerbv.
Step3. Design a custom foot print PCB Arduino Shield using cheat’s method
From the previous step, it is not difficult to notice something is amiss from the foot print of the PCB relatively to the size of the electronic schematic, and also the number of holes need to be drilled. In this guide, a non-conventional method will be used to generate custom small foot print PCB for Arduino that fits like a glove. The three diagrams below best describe the process of digital fabrication of a custom foot print Arduino shield PCB from software to physical prototype. The diagram on the left is the final design of the custom foot print PCB with this cheat’s method. The gerber file from the PCB design is then used to produce a prototype with the PCB milling machine, the sample is the center diagram. Lastly the diagram on the right describes the operational custom foot print PCB Arduino shield.   
  1. In this guide, the same electronic components as assumed as per the previous step.
  2. The wiring between Arduino and the rest of the components are not connected in the “schematic” tab.
  3. From the “Parts” window panel, add the customizable “mystery part – 3 pin” into the PCB tab. This “mystery part – 3 pin” can be customized accordingly to the number of pins required by the design of the PCB. In this example, two rows of custom header of 10 pins and 8pins each are added. The following diagram describes the use of “mystery part”.
  4. Using the unconnected Arduino as a reference template, overlap with the 8pin and 10pin “mystery part” correspondingly. This shall give the relative position of the pin headers on the custom foot print PCB to the actual Arduino.   The
  5. Connect the routes as per the previous step from the electronic components to the “mystery parts” as if it is the Arduino. Once completed, delete the reference Arduino.
  6. Now a custom foot print PCB as Arduino shield is ready. The net effect is the savings on the unit cost and time taken to produce this shield commercially.
  1. Fritzing help and tutorials
  2. Gerbv, a gerber file viewer.

Sunday, January 5, 2014

Setting up the hardware for using Arduino as the In System Programmer (ISP) to download program onto ATtiny85

Setting up the hardware for using Arduino as the In System Programmer (ISP) to download program onto ATtiny85
Parts Needed
1x Arduino Uno R3
1x Breadboard or 1x Veroboard
1x ATtiny85 (or ATtiny45)
1x 10uF 25V electrolytic capacitor
1x 220ohm watt resistor
1x LED
  1. The following electronic circuit schematic describes the wiring of an Arduino to program an ATtinyXX chip. The LED and Resistor in the circuit are good to have, but not necessary. Warning: Orientation of the ATtiny85 chip DIP8 package relatively to Arduino is important during wiring.
  2. There are four possible choices of wiring up ATtiny85 chip to Arduino, each with its advantages and disadvantages. In this how to guide, the two most commonly used methods by enthusiast will be discussed.
    1. Breadboard
    2. Veroboard
    3. Printed Circuit Board (PCB) custom milled
    4. Printed Circuit Board (PCB) commercialized
Setting up the hardware with BreadboardThis method is the easiest, effortless, least time consuming of the whole lot of methods. However, it comes with a few caveats. Question: What is the disadvantage of using a breadboard?
  1. Make sure Arduino is unplugged from USB when wiring.
  2. Refer to the schematic given above, wire up the Arduino and ATtiny85 accordingly.
  3. The following diagram describes the wiring on breadboard
  4. The ATTiny85 chip is now ready to be programmed.  Refer to the how to guide “Setting up the software for using Arduino as the In System Programmer (ISP) to download program onto ATtinyXX” for the steps.
Setting up the hardware with Veroboard
This method is slightly challenging from the breadboard method. Skills require to make this veroboard is soldering, understanding of electronics principles, and also troubleshooting methodology.
Question: What are the advantages as compared to the breadboard method mentioned above?
  1. Prepare a piece of veroboard that is 20 columns wide horizontally.
  2. Align the components such as female header pins, 8pin DIP chip holder (for ATtiny85 chip), capacitor, LED, Resistor, and jumper wires with Arduino Uno R3 accordingly to the schematic given above.
  3. Solder the components to the veroboard.
  4. Refer to the following diagram for the reverse side of veroboard, i.e not the component side.
  5. The following diagram describes the veroboard ready for programming ATtinyXX chip.
  6. The “shield” (veroboard soldered with components to be used with Arduino) is now ready to be used to program an ATTinyXX chip.
Parting Notes:
Congratulations for making thus far!! You are now equipped with the necessary know how-to knowledge to quickly prototype an electronics circuit, and also making the circuit robust under unfriendly operating condition. The journey from schematics to breadboard and then to the veroboard is not the end; it is a starting point to an even more exiting journey of making your very own PCB. Allow me to put a teaser or two on the PCB making skills you are going to acquire in very soon into the future. See you at the other side of the rainbow.

ATTiny XX for Arduino 00XX

Saturday, January 4, 2014

Setting up the software for using Arduino as the In System Programmer (ISP) to download program onto ATtiny85

Setting up the software for using Arduino as the In System Programmer (ISP) to download program onto ATtiny85

Step0: Install ATTiny Cores
NOTE: This Tutorial assumes Arduino v1.0.x and above has been installed on the computer.
Go to this URL and download this file:  
Extract this file and copy the entire folder to the “hardware” folder of your Arduino installation directory. Note: The following screen is mine and might differ from yours.
Restart the Arduino IDE programming environment. 
Verify the new cores (ATtinyXX series) loaded in Arduino IDE.
Note that there are also other core files for a variety of ATtiny chips loaded e.g ATting85. This page is a good starting point for interfacing with a wide range of the ATtiny or ATtiny85 using the Arduino.

Click on Tools , Board to verify the variety of ATtiny chips.

Programming the ATtinyXX chip with Arduino as the ISP
Note: This is a 1 + N step. Step 1 requires setting up the Arduino as the ISP for the first time progamming of an ATtiny. Step N has to be repeated every time to program an ATtiny. The ATtiny chip has to be placed on the ATtinyXX ISP shield, and then connected to the Arduino. The program will then be downloaded to ATtiny instead of Arduino.

Step1: Setting up Arduino as the ISP
  1. Connect usb cable to Arduino
  2. Go to Tools->Board and make sure Arduino Uno is selected.
  3. Make sure that the correct serial port is selected.
  4. Go to Tools->Programmer -> Arduino as ISP
  5. Go to Examples -> ArduinoISP
  6. Click  to upload the ISP program to the Arduino
  7. Now your arduino is ready to be used to program it's poor cousin, the ATtiny85.

Step N part1: ATtinyXX chip is inserted into ATtinyXX ISP shield; shield is then connected to the Arduino.
  1. Confirm USB cable is unplugged from Arduino when inserting the ISP shield
  2. Align ATtiny85 DIP8 package chip to ATtiny85 ISP shield
  3. Insert ATtiny85 chip firmly onto the ISP shield
  4. Align ISP shield to Arduino
  5. Insert ISP shield firmly onto Arduino
Question: What is the model of the ATtiny chip in the picture above?
Note: ATtiny45/85-PU is 20MHz (with external clock). refer to the datasheet at References.

Click here for highres picture

Step N part 2: Download your programming code to ATtiny85
  1. Confirm chip, shield, and Arduino is plugged into USB.
  2. Select the corresponding code of choice (e.g *.ino) file to be programmed onto the ATtiny85 chip by clicking File-> Open.
  3. Go to Tools -> Board and make sure this time you choose ATtiny85(internal 1 MHz clock)
  4. Click  to upload the program.
  5. Upon success, you should see the message below. Ignore the warnings. The ATtiny chip has been programmed.
  6. Observe the output of the operational ATtiny85 programmed with the code specified.

NOTE: by default ATtiny85 comes with 1MHz clock internal. This clock can be modified to 8MHz internal by the selecting option "Burn Bootloader" while selecting the option "ATtiny85(internal 8MHz clock)". Subsequent programming of ATtiny85 need to choose the board option "ATtiny85(internal 8MHz clock)"

Addendum: Old version of Arduino, e.g Arduino 0022

New ATtiny cores eg ATtiny85 on Arduino 0022

Select ATtiny45-20PU as the board (requires external oscilator to function at 20MHz)

Download RGB LED code to ATtiny45