Week 6- Electronics Design

Overview

For this week we have two assignments:

  1. Group assignment
  2. to use the test equipment in our lab to observe the operation of a microcontroller circuit board. minimum, check operating voltage on the board with multimeter or voltmeter and use oscilloscope to check noise of operating voltage and interpret a data signal.

  3. Individual assignment
  4. Redraw one of the echo hello-world boards or something equivalent, add (at least) a button and LED (with current-limiting resistor) or equivalent input and output, check the design rules, make it, test it.

My Assignment Steps:

Step (1):Design The board (Sch- PCB Layout)

Step (2):Milling and solder the board.

Step (3): Test the board and program it.


The Process

Individual Assignments

This week is a complementary work to week 4 where we learned the Electronics Production, Now it is time to make our own PCB :).

Choose your Software

When it comes to electronics design, there is a huge number of software that we can use Eagle, EasyEDA, Kicad.. etc.

As an electronics engineer I'm pretty familier with bunch of them and my recommendation is either to use Eagle or Kicad

Kicad

Kicad is a cross platform open source Electronics Design Automation Suite.it's a little bit complex comparing to Eagle but, it's a full package program in which you are gonna find everything you need. for me it's my no.1 choice.

Kicad tutorials.
Eagle

EAGLE is a flexible and expandable EDA schematic capture, PCB layout, autorouter and CAM program. EAGLE is popular among hobbyists because of its freeware license and rich availability of component libraries on the web.

Eagle tutorials. he use an older version but, the difference is only in the GUI.

for the Redrawing assignment I' gonna use Eagle but, for my own board I'm gonna use Kicad.


Download Fab-library

Step 1:

you can find a fab-library with all the inventory component Here. download it then create a folder wherever you want the .lbr file to be kept.

Step 2:

open Eagle form option choose Directories

modify the libraries path location to tell Eagle exactly the folder location and name where it will find the library.

The path must look like -> $EAGLEDIR/lbr:/Users/yourUserName/FileLocation/LibName

Responsive image

Step 3:

finally from Libraries right click on lib-name andd choose use all.

Responsive image

Board Design

Eagle has two windows that you use simultaneously to design a board:

  • Schematic (.sch) - logical components
  • A schematic in electronics is a drawing representing a circuit. It uses symbols to represent real-world electronic components.

  • Board Layout (.brd) for the actual board that we mill
  • The board layout shows how the electrical components and traces will be laid out on the board.

    you need to keep both open all the time as closing one view while the other view is open (and making edits) will break the link between the two

    Schematic Design

    I choose to redraw the Attiny45 circuit and add an indicator LED for power. plus an switch as a sensor to start the main led to blink.

    First I add all the component I'm gonna use:

  • 1 x Attiny 45.
  • 1 x (2x3) pin header for AVRISP.
  • 1 x (1x6)pinheader for Rx,Tx,VCC,GND.
  • 1 x 1 uF Capacitor.
  • 1 x Red LED.
  • 1 x Green LED.
  • 1 x Slider Switch.
  • 2 x 10k Resistor
  • 1 x 1k Resistor
  • 2 x 499 Resistor
  • Responsive image

    Then it's time to wire the circuit. There are two ways to connect components in a schematic:

  • You can connect the components with a wire (also called a "net" in Eagle). This may make connections obvious at first, but can get really messy quickly as nets cross over each other.
  • You can also name the nets attached to components that need to be connected by the same name. Eagle will ask you if you want them to be connected. (Say yes).
  • Responsive image

    I wire my circuit using the second methods.


    PCB Layout

    Responsive image

    Switch to PCB layout, the components you just added will be jumbled up in a corner with yellow unrouted traces attached.

    Responsive image

    Start move, organize, route the component as you need.

    Design Rule check

    After designing our board we need to check that the endmill we are using (1/64 usually) is able to go between and around all the traces so the machine is able to cut successfully the board.

    a mill-bit with the diameter of 1/64 inch (~16 mil) is used; So I opened the DRC from The "Tools" menu. Then in the "Clearance" tab, I wrote "16mil" to all the fields there.

    Responsive image

    I came up with 4 errors and 2 warnnings. time to fix the circuit :)

    Responsive image

    To make sure all is good I run DCR one more time and it came out with no error as you can see in the left corner.

    Responsive image

    Hide all the layer except for the TOP in order to export the circuit as PNG.

    Responsive image

    (file -- export -- image),settings should be MONOCHROME and 500 DPI - this will export a image with white traces.

    Responsive image

    The final output ready to edit in GIMP.


    Edit image using GIMP

    Responsive image

    crop the image, add text if you want, from image choose Flatten image and export as PNG.

    Responsive image
    for the outline create a new window with the size of the circuit + 5px for the outline, from select choose all then -> border with 5px , finally choose the bucket fill tool to coler the border with black and export as PNG.

    Milling and solder the circuit

    following the same steps we did in Electronics production week I was able to solder and mill the circuit.

    Responsive image
    Responsive image

    I use the multimeter to verify the continuity of the tracks and to check the operating voltage on the board.

    Responsive image
    Responsive image

    Testing the circuit

    1) The Code:

    The idea of the board is really simple we have a switch that work as an input to the Attiny 45 in the case it's high we aria-control any kind if output to be sent to our Led.

    for rapid test I choose to write the code in ArduinoC and to use Arduino IDE to upload the code to my board.

    #define LedPin 3
    #define SwitchPin 2
    
    void setup() {
      pinMode(SwitchPin,INPUT);
      pinMode(LedPin,OUTPUT);
    
    }
    
    void loop() {
      boolean switchState;
      switchState=digitalRead(SwitchPin);
     
      if(switchState){
        digitalWrite(LedPin,HIGH);
      }
      else{
        digitalWrite(LedPin,LOW);
      }
    }
    
    Responsive image

    2) Program The board

    Time to focuse now !!

    we will going to upload the code to our board using arduino IDE and using arduino as our programmer as we did in Electronics production week

    1- Install Attiny library support for Arduino IDE

  • go to File > Preferences > Additional Boards Manager URLs field near the bottom of the dialog box.
  • paste the following URL, then click ok
  •  https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json
  • Tools >> Boards > Board Manager > search for attiny and then choose to install it.

  • 2- Prepare the arduino Board as a programmer

  • Under File > Examples > ArduinoISP you can find the code you need to upload to your Arduino in order to transform it into an ISP
  • upload the code to the arduino board.
  • After programming the arduino, connect a 10 uF capacitor between RESET and GND.
  • Responsive image

    3- Upload the Bootloader

  • you can then connect Arduino with your board. the configuration for connecting the Arduino is down here.of course VCC connected to 5V and GND connected to GND.
  • slave reset: 10
    MOSI:        11
    MISO:        12
    SCK:         13
    
  • File > new
  • Tools > Programmer >Arduino as ISP
  • Tools > Boards > ATtiny 25/45/85
  • Tools > Processor > ATtiny 45
  • Tools > Clock > internal 8 MHz
  • Tools > Burn bootloader

  • 4- Upload the Code

  • Upload the code to the board then remove the connections.
  • Responsive image

    Final Project

    Well first spiral it's all about hardware design and embedded programming by the end of it I should be able to :

  • Detect the clapping sound.
  • Control Aincrad lighting systems.
  • so without further ado let's jump to the steps.

    ELECTRONIC CIRCUITS (PCB) DESIGN AND FABRICATION

    I need to design 3 board for Aincrad:

    1. The Master board that control the sound sensor and the lighting system
    2. Sword lighting board 5 total.
    3. Sword lighting - Master interface board.

    1) Aincrad Master Board:

    Specifications (Electrical)

    Depend on this specification I could use either 2 Attiny-family board one for the input and the other for the output and let them communicate with each other through serial bus. or an atmega-family board with all in on system.

    I go for the second option in order to save space and for more neatness in the final connections.

    Specifications (Mechanical)


    2) Block Design
    Block design

    3) Schematic Design using Kicad

    I divided the master board into 3 main functioning citcuits

    1. Atmega328p-au circuit + interface
    2. Sound sensor circuit
    3. Castle RGB lighting circuit

    Atmega328p-au circuit + interface
    your number one friend through this step is the datasheet. So from the Atmega328 datasheet I was able to know:

    Atmega328p-au specifications
  • 32K bytes of in-system self-programmable flash program memory
  • 1Kbytes EEPROM, 2Kbytes internal SRAM
  • Two 8-bit Timer and One 16-bit Timer/Counter
  • Six PWM channels
  • 8-channel 10-bit ADC in TQFP
  • Communications protocols USART, SPI, I2C.
  • 32 programmable I/O lines in TQFP
  • Operating voltage: 2.7V to 5.5V and speed up to 16MHz.

  • Circuit Components
  • 1* Atmega328p-au
  • 1* 16MHz crystal
  • 2* 22pf ceramic capacitor
  • 1* 10uf ceramic capacitor
  • 1* 10 kohm resistor
  • 1* 499ohm resistor
  • 1* green led
  • 1* 2×2 pinheader
  • 1* 1×3 pinheader
  • 1* 2×3 pinheader for ISP
  • 1* 1×6 pinheader for FTDI
  • atmega328 datasheet
    atmega328 pins
    atmega328 pinout
    schematic design
    schematic design for Atmega328p-au

    Sound sensor circuit
    SPU0414HR5H-SB MIC for sound sensor specifications

    from SPU0414HR5H-SB datasheet

    • Up to 20dB of Gain
    • Maximum supply voltage 3.6V
    • Maximum Low Current 220uA
    • Signal to Noise Ratio SNR 94 dB SPL @ 1 kHz, A-weighted
    • RECOMMENDED REFLOW PROFILE Peak Temperature (TP) 260°C

    This specification means I will need to use a voltage regulator with the sensor in order to convert the 5V power to 3.5V


    Circuit Components
  • 1* Mic MEMS analog SPU0414HR5H-SB
  • 2* 0.1uf ceramic capacitor
  • 1* 10uf ceramic capacitor
  • 1* 1kohm resistor
  • 1* LM3480- 3.3V
  • atmega328 datasheet
    atmega328 datasheet
    SPU0414HR5H-SB circuit from datasheet, I choose to design my circuit with Max Gain (20db).
    atmega328 datasheet
    SPU0414HR5H-SB pin configuration

    So now in order to design the circuit I need to choose a voltage regulator to convert 5V power to 3.5V I go with LM3480 Low-Dropout Linear Voltage Regulator

    LM3480 Linear Voltage Regulator specifications

    from the datasheet

    • Input Voltage Range: up to 30 V
    • 3.3-V, 5-V, 12-V, and 15-V Versions Available
    • 100-mA Ensured Minimum Load Current
    • SOT-23 Package
    atmega328 datasheet
    atmega328 datasheet
    Vout= Vin-1.5 which means :
    Vout= 4.8-1.5= 3.3V
    atmega328 datasheet
    Knowing the detailed design procedure from datasheet
    schematic design for sound sensor

    Castle RGB lighting circuit
    Cree PLCC4 3 in 1 SMD LED specifications

    from RGB LED datasheet

    • Size (mm):3.2 x 2.8
    • Dominant Wavelength:
      - Red (619 - 624nm)
      - Green (520 - 535nm)
      - Blue (460 - 475nm)
    • Current= 20mA/Led when
      - Red (2V)
      - Green (3.2V)
      - Blue (3.2V)

    Circuit Components
  • 3* RGB led
  • 3* N-Mosfet transistor
  • 9* 1kohm resistor
  • 3* 499ohm resistor
  • rgbdatasheet

    However I would like to add 2 more LED's to my project, but I don't want to take up every single PWM. So I'm going to use n-channel transistors and duplicate per color channel pin
    At 20mA per led, 3 per channel, that's only 60mA. so make sure your power supply can support that. 60 * 3, that's 180mA on the leds alone, not including the rest of the board.

    rgbdatasheet
    schematic design for Lighting system

    Then for the master board:

    Aincrad master board
    schematic design Aincrad master board
    ERC
    ERC.
    footprint
    Add footprint to the circuit symbols

    Generate the Netlsit is the final step after finishing all the design. This step is really important in order to connect the schematic with PCBnew in which we will going to create the PCB layout. Now it's time for the layout design.


    4)PCB layout
    Challenge time

    As soon as I start reading the Netlist I got an error message about the rgb-led Pads. at first I didn't understand it's meaning then I found the issue once I move the rgb-led away It's not connected to any other component of the circuit.
    So in this section I will walk you through the steps in which I was able to solve this Challenge

    error message
    Netlist reading error message
    rgb-led is not connected
    All the pads of the rgb-led is not connected.which basically the meaning of the error message.
    rgb-led footprint
    open the footprint of the rgb-led to find that the pad name is actually a number not a letter as the message said.
    symbol library
    However when opening the symbol library I found that the pad name is a letter. so this the cause of the problem the diffrence between the footprint and the symbol libraries.
    datasheet of the rgb-led
    To be able to decide which library I should modify I opened the datasheet of the rgb-led to found the pad naming is similar to the footprint library.
    modified the symbol library
    So modified the symbol library and change the letter to a number corresponding to it's functionallity depend on the symbol datasheet
    save the Netlist
    save the Netlist one more time.
    error message has gone
    it's all looking good now.
    all is good
    time to continue =).

    Following the same process we did in electronics design weeks and After 12 hr of routing and component placment adjustment I was able to finish all the board in 1.5 layer + RST pin.

     Run ERC
    Run ERC to make everything is good. yet I ignore it's complaining about the 2 0ohm resistors.
    Layout finishing process
    Route all the components, add a copper fills and silkscreen.
    Final PCB in 3D.
    Final PCB in 3D.

    Export .svg file from kicad for the board and Edgecut layer then run our Automatic conversion using imagemagick to get the .png files ready to be used in mods.

    Final PCB in 3D.
    Aincrad final.
    Final PCB in 3D.
    Aincrad border.

    Integration hexagon and led sword interface boards

    following the same process I have created 2 boards using Kicad and implement them using the vinyl cutter following this AMAZIGN TUTORIAL

  • Led Sword interface: Simple circuit of a led&resistor to light each sword.
  • Integration hexagon: the integrated circuit that provid the power for all of my boards.
  • Final PCB in 3D.
    Integration hexagon schematic.
    Final PCB in 3D.
    Integration hexagon layout.
    Final PCB in 3D.
    Integration hexagon 3D.
    Final PCB in 3D.
    ledinterface schematic.
    Final PCB in 3D.
    ledinterface layout.
    Final PCB in 3D.
    load the copper sheet on the PVC sheet.
    Final PCB in 3D.
    Using the machine as we learn in week 3 with speed=10 cm/sec & force= 250gf.
    Final PCB in 3D.
    ledinterface output.
    Final PCB in 3D.
    Integration hexagon output.
    Responsive image
      led sword interface circuit.
    Responsive image
      integration hexagon circuit.
    Responsive image system assemply (1).
    Responsive image system assemply (2).
    Responsive image system assemply (3).

    Files
  • Attiny45-Code
  • Attiny45 Schematic
  • Attiny45 Layout
  • Attiny45.png
  • Atmega 328 Aincrad sch and layout