Search This Blog

Sunday, October 7, 2018


                           

BEGINNERS GUIDE FOR PRINTED CIRCUIT BOARD LAYOUT DESIGN


1. Introduction:

This blog presents a simple, detailed and lucid presentation on designing printed circuit board using a layout tool called as 'Eagle-CAD'. A simple single sided board layout is illustrated as an example.


2. Overview:

The overview starts with the question, 'What is a printed circuit board'?
A printed circuit board is an 'electro - mechanical' board, used as a mechanical support for electronic components, and for electric conduction between these components.

3. Anatomy of a PCB

The figure to the left presents a simple view of a PCB. 

The PCB is made from a 'fiberglass' base material that acts as the substrate. A standard PCB houses various layers of conducting and non conducting materials. These materials are sandwitched together to give a 'lasagna' type appearance.

A PCB as mentioned earlier is constructed from a base substrate material, which is covered with a conducting layer of copper, on either sides of the board. On top of the copper, a layer of silkscreen is being provided, which provides information about the 'lettering' which is done.

Based on the number of layers, a PCB can be classified as



1. Single-sided PCB: A single-sided PCB has only one layer of conductor being deposited on the board. The copper conductor is usually deposited on the 'top side', while components are mounted on the 'bottom side' of the board.






2. Double-sided PCB: A double sided PCB has two layers of conductors, being deposited on the board. Copper is deposited both on the top and bottom layers of the PCB.
A double layer board becomes viable, as the number of components increases on a board, This increases the number of tracks / routing on the board. Hence tracks has to be routed to the second layer,.

3. Multi layer board: A multi layer board is one, which has multiple layers of conducting and non conducting materials, which are being stacked up on top of one another. This board becomes inevitable, when hundreds of closely spaced leads / components are being used on the board.



The diagram to the left represents a PCB. Any PCB would consist of the following.

1. Pads: Pads are the location, where the components are soldered to the PCB. For example, the LED heading given in the diagram has a round and square pad.

2. Tracks: Tracks are the conducting paths / lines that connects the pads together. The vertical lines on the board are the various tracks

3. Vias:  Vias are small holes that runs thru the board for linking tracks between different layers

4. Solder mask: Solder mask , also called as solder resist is a layer of polymer applied on the PCB, that prevents the copper tracks from short circuits.

5. Silkscreen: Silkscreen is a process, of naming various parts/ components that are to be used in the PCB assembly. d21, d16, d13 are the silkscreens that are applied for the diodes in the figure.

The goal of any PCB design is to create a set of files that accurately describes various features of a board, such as number of layers, set of tracks, position of the pads, placement of vias etc.

4. Designing Circuit Boards using EAGLE CAD

Eagle CAD is a Electronic design automation (EDA) tool, which is used for designing schematics / circuit diagrams, board layouts. The EAGLE software can be downloaded directly from the site. https://www.autodesk.com/products/eagle/overview

This tutorial will walk around the construction of a simple single sided board of an inverting amplifier.


4.1 Circuit board design process

Designing a circuit board involves the following process.

1. Design the schematic, using the schematic editor.
2. Design the board layout for the designed schematic
3. Generate the design files / gerber files from the board layout


4.2. Schematic design using EAGLE schematic editor


A schematic is a high level description of a circuit's structure. It provides details about the circuit components, and the connections between them.

STEP 1: Open the eagle cad software. Create a new project




STEP 2: Create a new schematic inside the project folder that has been created in STEP 1




STEP 3: Insert the components required from the EAGLE library into the schematic. There is an 'Add part option' that enables us to add the components into the schematic. This schematic makes use of the following components.

1. 741 Opamp - SMD type.
2. Two resistors - SMD type.
3. 6 pin external connector for signals.
4. Power and ground connections.



 STEP 4: Once the part symbols are inserted, complete the schematic by providing the required connections.

STEP 5: Once the schematic is completed, check the circuit, by running an ERC (Electrical rule check'). This test the circuit for any unconnected , shorted traces or any schematic level errors.


This completes creation of a simple schematic for our inverting amplifier.


4.3 Designing board layout for inverting amplifier

Once the schematic is completed, next, design the board layout from the existing schematic layout that was created in step 1.
The basic procedure for creating a board layout consists of the following steps

STEP 1: From the file menu, click File -> Switch to Board.




Once the 'Switch to Board' is chosen, a board layout is seen. To the left, we can see various, circuit packages of the respective symbols, which was created in the schematic design.

Designing a board layout consists of the following steps

1. Position / Placement of circuit packages inside the board
2. Routing connections between various circuit packages
3. Test / Verifying the layout
4. Generation of gerber files for the layout

STEP 2:  Before placement, set the GRID spacing, and align the board size accordingly for the above circuit. Since it is a small circuit, we can position the above elements, inside a 0.75" by 0.75" area.



Open the grid dialog by selecting the grid tool on the horizontal toolbar. Set the primary grid spacing to 0.05 inches and press OK.

Next activate the 'Move' tool and click the right line of the board's rectangle, preferably close to the center. Move the line to the left until it's x-coordinate equals to 0.75 inches. Similarly click the top line of the rectangle and move it downward until it;s y-coordinate equals 0.75 inches.


STEP 3: Move the circuit packages into the board area.

In the above layout, the layout area is re-positioned to 0.75 by 0.75 inches, and has been zoomed in for better clarity. The elements to the left of the board represents the various circuit packages that are to be moved into the board.

STEP 4: Route the circuit traces: Once the circuit packages are positioned, the next is to create connections between their pads. The yellow wires connecting the various pads represent the physical connections, also called as 'air-wires', also called as traces. There are some ground rules on routing the tracks in a layout. Additional information on routing can be found.

In routing there are two techniques, which are commonly employed.

1. Auto-routing
2. Manual routing

1. Auto-router: This tool is used by EAGLE to automatically route the traces in a circuit. This is employed, for small circuits, where the number of air wires are minimum.


Some of the auto router settings are

1. Choose the * setting for 1. 'top' layer. This performs auto routing on the top layer.
2. Choose N/A setting for 16. Bottom. This tells auto router not to form traces on the bottom board.
3. Set the routing grid to 1 mil. This reduces the spacing of the auto router's  internal grid.



The above picture shows a layout which is being auto-routed by the auto-router. As mentioned previously, this might not be the right way to route, in case of complex designs, we need to use the manual way of routing.

2. Manual routing: The manual routing process involves a series of steps to create the final board. Use the 'route' tool from the left pane, and start routing the traces one by one. Two basic rules for routing involves that no two traces should cross -over one other, ( on the same layer ). The second rule is to make sure that traces are to be routed using a 45 degree bend around corners in order to avoid fringing and EMI (Electro-magnetic interference). This is important in order to retain signal integrity in the board.



STEP 5: Design rule check (DRC) : DRC is a tool used to test the layout for any errors committed during the course of the layout. This tool tests the completed layout against a set of standard design rules, for laying out a circuit board. In the 'tools' category, click on 'DRC' to verify the layout.

STEP 6: Generate Gerber files: Once the layout is completed, a set of files, called as CAM files are generated which are used for manufacturing the board layout. The CAM files are a set of design files, which are generated by a tool called as 'CAM processor'. The tool generates a set of design files, which are in a special format called as the 'gerber' format. These files are also called as 'gerber files'.
To generate these files in EAGLE, you need the CAM processor. To launch this, go to file -> CAM processor on the main menu.


The dialog box for the CAM processor looks like the above diagram. Since the inverting amplifier, has only the 'top' side, the circuit can be described using only three gerber files.

1. Copper: Defines pattern of copper, which forms the pads and traces.
2. Solder mask: Defines the region, where the solder mask is to be applied.
3. Silk screen: Defines the area, where the text is to be printed on the circuit.

The CAM processor generates a gerber file, for each of the above three materials. The files are processed as a series of jobs. A 'job' is defined as a sequence of tasks for the CAM processor.

In the left pane of the dialog box given, select the gerber files required to be generated for the three materials one at a time. Click on the 'process Job' in the bottom of the dialog box. This generates three files required for processing the layout board. These files are sent to a 'fab' house for designing the board layout.





























Sunday, January 22, 2017

Tutorial on ARM Mbed


                                   
 BEGINNERS GUIDE TO ARM MBED PLATFORM



This tutorial provides an introduction on ARM Mbed based microcontrollers. The tutorial focusses on LPC1768 microcontroller.


Introduction: ARM Mbed is an operating system and platform , by large developed by ARM for a group of microcontrollers under the cortex M series. It is a platform for internet connected devices.
This platform encompasses development tools, cloud services and operating system support for creation and development of 'internet of thing'(Iot) systems on ARM platform. 
This development ecosystem boasts of a well defined online compiler support for the software code, tools for building and testing ,and a host of development boards, which can be deployed for any type of application. 

SECTION1
Introducing ARM Mbed LPC1768 MCU

The ARM Mbed LPC1768 is a ARM cortex M3 microcontroller developed by NXP systems. The mbed takes the form of a 2 inch by 1 inch PCB, with 40 pins arranged in two rows of 20 with 0.2 inch spacing between the pins. It is to be noted that even though LPC1768 has 100 pins, board projects out only 40 pins, which are currently usable.

External view of the mbed board with pinouts

As  seen from the above picture, the board houses the cortex M3 core, whose pins are connected to the different peripherals. A reset switch is seen on the centre of the board, to force restart of the current program. 
Downloading the program onto the mbed core is acheived through a universal serial bus (USB) connector, and this also is used for powering the mbed.
There are five LEDS on the board, one is used for status, while other four are connected to the microcontroller digital outputs. 
To the extreme left of the board are the power pins. The board works with a DC voltage range of 4.5 to 9V. Since some of the internal units in the board worls with 3.3V, there is an onboard voltage regulator (LM1117), which drops the voltage to 3.3V. There is also a +5V pin which can be used. 
There are also analog inputs, used for reading sensor values, and there exists PWM ouputs, used for controlling external power devices such as motors. The board supports five serial interfaces, I2C, SPI, CAN, USB and ethernet, which can be used for various applications.


Front view of Mbed board

Beneath the board, there exists another microcontroller called as 'interface microcontroller' which interfaces with the USB. This controller acts as the USB terminal to the host computer. It receives the program code through the USB, and transfers those programs to a inbuilt 16Mbit 'flash memory'. This memory is also called as the 'USB disk'. This controller communicates with LPC1768 through a UART serial data link.

Bottom view of Mbed board

The above diagram shows the bottom view of the board, which houses the interface controller' and other supporting peripherals. We can also see bergsticks/ connectors projecting out of the board. 


Section-2: Getting started with the mbed LPC1768 board

This section of the article explains as to how to get started creating applications using the mbed board

Materials required

1. Mbed LPC1768 board with the USB cable
2. PC with any operating system

Step 1: Create an mbed account using 'mbed.org' website. Use the 'signup' option.



Step 2:  Select 'Compiler' from the site. This directs you to the online compiler.



Step 3: Open an existing project from the project workspace. Select 'Blink_Internal_LED project.























Step 4:  Connect the mbed board to the computer through the USB cable. The mbed is recognized by the computer as a removable drive. As mentioned earlier, this is the 16Mbit flash drive. Open the folder which contains a HTML 'mbed' image. You can as well open the mbed site from this image, else you can do it from a separate window. ( As you have done from the previous step)


















Step 5:  Once the mbed board is connected, the board checks automatically for USB to UART drivers, in the system. If the board is not enumerated/ recognized by the computer, then the respective USB to UART (CP2102 driver) driver is to be downloaded. Once this driver is installed, the board is identified.

Step 6:  We see that from step 3, a program named Blink_Internal_LED is open. ( main.cpp file). Compile the program as shown in the diagram below.



Step 7: After a successfull compilation, it is seen that a binary file gets created ( .hex file ). This file would be available in 'downloads' page of the system.  Copy this image / file and paste it in the mbed drive ( Refer to step 4 ). The picture below shows the image being created in the bottom end.



Step 8: Once the image is copied, the image lies inside the mbed drive. Now press the reset switch, in the middle of the mbed board. Once pressed, the application starts running on the board.
















Wednesday, February 3, 2016

The communication gateway of an MCU




  THE COMMUNICATION GATEWAY OF AN MCU


This is my first tech blog, on understanding communication principles between a micro controller unit (MCU) and it's peripherals. It explains the basic facts and principles and does not delve deep into system level details, but would provide a foundation which would aid the reader to move ahead with MCU programming using interrupts.






Introduction

So you want the MCU to talk  right??. So your MCU has to respond to other devices, and share their (device's) feelings, and understand it's requests. So you have to set a communication link between the MCU and all its subordinates , i.e other devices in total. We can use two techniques to setup the communication. They are

1. Polling
2. Interrupt

1. Polling: Polling is a technique of communication between the MCU, and it's peripherals, wherein the MCU keeps checking / asking / requesting it's peripherals if the latter ( peripherals ) needs any kind of service . This technique is considered to be very inefficient since it wastes MCU's time, and hence the MCU gets tied down checking by not doing anything useful.
To give a real time example, if I imagine a teacher as a MCU, and students in a class like the peripherals, the teacher asking every moment if the students do have any queries / questions, and hence the teacher gets tied down with this without proceeding ahead with the class.

2. Interrupts:

An interrupt is a method of communication in which, the peripherals send a signal to tell the MCU (microcontroller / processor /CPU) that it needs some kind of service. Following the message received from the peripheral, the MCU stops whatever activity it is doing, and attends / services the interrupt request. This method is efficient in practice, since the MCU is not tied down checking if any peripheral needs any service or not. It is performing it's job, and it responds to the peripheral only after receiving a request signal from the peripheral.
Unlike the earlier example, the teacher will not ask any students if they have any queries or not. He/ she keeps doing their job. They will respond to students, only if they receive any questions from the students. A question here in this case is compared  to an  interrupt signal.
If there are multiple interrupts which are received by the processor at a time, then it prioritizes the interrupts based on the level of importance of the interrupt.


Working principles of polling and interrupts

Polling: As mentioned earlier, polling is a system of communication in which the MCU repeatedly checks for the occurrence of an event.

Working principle: The working principle is explained in brief, as to how polling can be generated thru a piece of software code. Usually we create a polling mechanism using a simple loop, wherein the MCU keeps checking inside the loop, for the occurrence of an event.
Consider an example of a timer. As we know, a timer times out ( overflows ) after it reaches it's maximum count. MCU monitors a overflow flag inside the loop, to check if the flag is raised or not. Raise of the flag indicates that the timer has timed out, else it keeps polling the flag, until the flag is set high (raised ).
A crude structure of polling in 'C' can be written as given below. In the loop given below, the MCU checks the flag until the flag is raised high.

Code format of a polling mechanism in 'C'

while(1)               // Infinite loop
{
     while( overflow_flag==0);   // Polling
      overflow_flag=0;                //  Disable the overflow flag
}

As we see the code above, inside an infinite loop, we poll the overflow flag inside a time delay loop. Here the MCU keeps polling the overflow flag as long as it is equal to zero. Once the timer overflows, the flag is set high. We have to clear (make it zero) the flag otherwise, we cannot poll again for another timer overflow. As we see here in this case, MCU keeps polling the overflow flag and hence gets tied down, only for checking.

Interrupts: Interrupts are defined as external signals which are communicated to the MCU, by other peripheral devices. They indicate occurrence of an event.

Understanding basic operation of an interrupt mechanism

Working principle: Execution of an interrupt in an MCU is done by a separate unit called as an 'Interrupt controller'. Once an interrupt signal is received by the interrupt controller, the MCU ( processor ) stops / suspends its current activity and jumps / transfers to a separate program / sub routine. This routine / program ( separate program ) is called as an interrupt service routine (ISR), also called as an interrupt handler. These routines are stored separately in a different address location / table called as interrupt vector table (IVT). Once an interrupt is generated, the MCU jumps to the sub routine by knowing it's address which is stored inside the IVT. The process of switching the  MCU from its current activity to the sub routine is called as ' context switching'.
The MCU services/ responds back to the  interrupt in the sub-routine and after completion, the MCU transfers it's control back to it's current activity which it was performing earlier (before occurrence of the interrupt) and continues with its work.
Interrupt unlike polling would not keep checking continuously for the occurrence of an event / status of a flag. This saves the processor time, since the processor would be working on other functions. The processor would respond once it receives interrupt signals.

Code format of an interrupt mechanism in 'C'

main( )
{
    init code //    initialization routines
    while(1)   //  Infinite loop:
    {              //  Be here until interrupt signal is received

    }

void ISR_routine( )
{
    if (overflow_flag)  // check if flag is set
    {
         overflow_flag=0;
         // process the function required, if flag is set
    }

}

Conclusion

This article provides a basic understanding of communication techniques between the MCU and peripherals and outlines some fundamental working principles of polling and interrupts.








Sunday, January 17, 2016

This is my first blog




This is my first blog, and am really excited to be a part of the blogger community. More often I would be sharing my know -how knowledge, and hands on experiments and experiences in embedded electronics ,switching power supplies, development boards and peripherals. Even though my inclination rests on writing a blog on experimental experiences, I would be sharing in detail the conceptual background which supports the experiments in all. I would get back to write and share a lot of stuff with you guys..