Category Archives: Arduino小组

(中文) 超声波雷达-创客开源 Arduino项目

//淘宝『创元素店』https://shop423015102.taobao.com/ //更新日期 2021/03/06 //MiniRadar 超声波雷达 程序 //本程序对应商品 https://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-23815833841.8.4f231fe7qvLFZi&id=649834806872

//Github版链接: https://github.com/johnsonwust/MiniRadar

include

include

include "Ucglib.h"

//显示屏的lib 如果没有该lib请按Ctrl+Shift+I 从 库管理器中搜索 ucglib,并安装

define trigPin 6 //超声波模块的Trig口 6

define echoPin 5 //超声波模块的echo口 5

define ServoPin 3 //底座舵机端口 3

int Ymax = 128; //屏幕的竖向像素数 int Xmax = 160; //屏幕的横向像素数 int Xcent = Xmax / 2; //x中位 int base = 118; //基线高度 int scanline = 105; //雷达扫描线长度

Servo baseServo; Ucglib_ST7735_18x128x160_HWSPI ucg(/cd=/ 9, /cs=/ 10, /reset=/ 8);

void setup(void) {

  ucg.begin(UCG_FONT_MODE_SOLID); //初始化屏幕
  ucg.setRotate90();              //设置成横屏  如果屏幕显示方向是反的,可以修改函数 setRotate90 或 setRotate270

  pinMode(trigPin, OUTPUT);       //设置trigPin端口模式
  pinMode(echoPin, INPUT);        //设置echoPin端口模式
  Serial.begin(115200);             //设置串口传输率
  baseServo.attach(ServoPin);     //初始化舵机

  //欢迎屏幕
  ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
  ucg.setColor(0, 0, 100, 0);
  ucg.setColor(1, 0, 100, 0);
  ucg.setColor(2, 20, 20,20);
  ucg.setColor(3, 20, 20, 20);
  ucg.drawGradientBox(0, 0, 160, 128);
  ucg.setPrintDir(0);
  ucg.setColor(0, 5, 0);
  ucg.setPrintPos(27,42);
  ucg.setFont(ucg_font_logisoso18_tf);  
  ucg.print("Mini Radar");
  ucg.setColor(0, 255, 0);
  ucg.setPrintPos(25,40);
  ucg.print("Mini Radar");
  ucg.setFont(ucg_font_helvB08_tf);
  ucg.setColor(20, 255, 20);
  ucg.setPrintPos(40,100);
  ucg.print("Testing...");
  baseServo.write(90);

  //测试底座的运行情况,注意检测底座位置和转动姿态,是否有卡住(或者导线缠绕)的情况。
  for(int x=0;x<180;x+=5)
      { baseServo.write(x);
        delay(50);
       }
  ucg.print("OK!");
  delay(500);

  //清屏
  //ucg.clearScreen();
  cls();
  ucg.setFontMode(UCG_FONT_MODE_SOLID);
  ucg.setFont(ucg_font_orgv01_hr);

}

void cls() { //清屏 ucg.setColor(0, 0, 0, 0);

for(int s=0;s<128;s+=8) for(int t=0;t<160;t+=16) { ucg.drawBox(t,s,16,8); // delay(1); }

}

int calculateDistance() { long duration; //trigPin断电 并 等待2微妙 digitalWrite(trigPin, LOW); delayMicroseconds(2); //trigPin加电 延时 10微妙 再断电 digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); //读取echoPin返回声波的传播时间(微妙) duration = pulseIn(echoPin, HIGH); //将回声时间转换成距离数值 return duration*0.034/2; }

void fix_font() { ucg.setColor(0, 180, 0); ucg.setPrintPos(70,14); ucg.print("1.00"); ucg.setPrintPos(70,52); ucg.print("0.50"); ucg.setPrintPos(70,90); ucg.print("0.25"); }

void fix() {

  ucg.setColor(0, 40, 0);
  //画基线圆盘
  ucg.drawDisc(Xcent, base+1, 3, UCG_DRAW_ALL); 
  ucg.drawCircle(Xcent, base+1, 115, UCG_DRAW_UPPER_LEFT);
  ucg.drawCircle(Xcent, base+1, 115, UCG_DRAW_UPPER_RIGHT);
  ucg.drawCircle(Xcent, base+1, 78, UCG_DRAW_UPPER_LEFT);
  ucg.drawCircle(Xcent, base+1, 78, UCG_DRAW_UPPER_RIGHT);
  ucg.drawCircle(Xcent, base+1, 40, UCG_DRAW_UPPER_LEFT);
  ucg.drawCircle(Xcent, base+1, 40, UCG_DRAW_UPPER_RIGHT);
  ucg.drawLine(0, base+1, Xmax,base+1);

  ucg.setColor(0, 120, 0);
  //画刻度表
   for(int i= 40;i < 140; i+=2)
   {

    if (i % 10 == 0) 
      ucg.drawLine(105*cos(radians(i))+Xcent,base - 105*sin(radians(i)) , 113*cos(radians(i))+Xcent,base - 113*sin(radians(i)));
    else

     ucg.drawLine(110*cos(radians(i))+Xcent,base - 110*sin(radians(i)) , 113*cos(radians(i))+Xcent,base - 113*sin(radians(i)));
   }

   //画一些装饰性图案 
   ucg.setColor(0,200,0);
   ucg.drawLine(0,0,0,18);
   for(int i= 0;i < 5; i++)
   {
      ucg.setColor(0,random(200)+50,0);
      ucg.drawBox(2,i*4,random(14)+2,3);
   }

   ucg.setColor(0,180,0);
   ucg.drawFrame(146,0,14,14);
   ucg.setColor(0,60,0);
   ucg.drawHLine(148,0,10);
   ucg.drawVLine(146,2,10);
   ucg.drawHLine(148,13,10);
   ucg.drawVLine(159,2,10);

   ucg.setColor(0,220,0);
   ucg.drawBox(148,2,4,4);
   ucg.drawBox(148,8,4,4);
   ucg.drawBox(154,8,4,4);
   ucg.setColor(0,100,0);
   ucg.drawBox(154,2,4,4);

   ucg.setColor(0,90,0);
   ucg.drawTetragon(62,123,58,127,98,127,102,123);
   ucg.setColor(0,160,0);
   ucg.drawTetragon(67,123,63,127,93,127,97,123);
   ucg.setColor(0,210,0);
   ucg.drawTetragon(72,123,68,127,88,127,92,123);

}

void loop(void) {

int distance;

fix(); fix_font(); //重绘屏幕背景元素

for (int x=180; x > 4; x-=2){ //底座舵机从180~0度循环

  baseServo.write(x);             //调整舵机角度

  //绘制雷达扫描线
  int f = x - 4; 
  ucg.setColor(0, 255, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  f+=2;
  ucg.setColor(0, 128, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  f+=2;
  ucg.setColor(0, 0, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  ucg.setColor(0,200, 0);
  //测距
  distance = calculateDistance();

  //根据测得距离在对应位置画点
  if (distance < 100)
  {
    ucg.setColor(255,0,0);
    ucg.drawDisc(distance*cos(radians(x))+Xcent,-distance*sin(radians(x))+base, 1, UCG_DRAW_ALL);
  }
  else
  { //超过1米以上的,用黄色画在边缘区域示意
    ucg.setColor(255,255,0);
    ucg.drawDisc(116*cos(radians(x))+Xcent,-116*sin(radians(x))+base, 1, UCG_DRAW_ALL);
  }

  //调试代码,输出角度和测距值  
  Serial.print(x); 
  Serial.print("    ,   ");
  Serial.println(distance); 

  if (x > 70 and x < 110)  fix_font();  //扫描线和数字重合时,重绘数字

  ucg.setColor(0,155,  0);
  ucg.setPrintPos(0,126);
  ucg.print("DEG: "); 
  ucg.setPrintPos(24,126);
  ucg.print(x);
  ucg.print("  ");
  ucg.setPrintPos(125,126);
  ucg.print("  ");
  ucg.print(distance);
  ucg.print("cm  "); 

} //ucg.clearScreen(); //清屏 如果arduino供电不足,可能会引起白屏(显示信号中断)可以用 cls();函数代替 ucg.clearScreen(); delay(50); cls(); //如有频繁白屏情况,可以使用该函数 。或者增加外部供电

fix(); fix_font(); //重绘屏幕背景元素

for (int x=1; x < 176; x+=2){
baseServo.write(x); //调整舵机角度

  //绘制雷达扫描线
  int f = x + 4;
  ucg.setColor(0, 255, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  f-=2;
  ucg.setColor(0, 128, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  f-=2;
  ucg.setColor(0, 0, 0);
  ucg.drawLine(Xcent, base, scanline*cos(radians(f))+Xcent,base - scanline*sin(radians(f)));
  ucg.setColor(0, 200, 0);
  //测距
  distance = calculateDistance();

  //根据测得距离在对应位置画点
  if (distance < 100)
  {
    ucg.setColor(255,0,0);
    ucg.drawDisc(distance*cos(radians(x))+Xcent,-distance*sin(radians(x))+base, 1, UCG_DRAW_ALL);
  }
  else
  { //超过1米以上的,用黄色画在边缘区域示意
    ucg.setColor(255,255,0);
    ucg.drawDisc(116*cos(radians(x))+Xcent,-116*sin(radians(x))+base, 1, UCG_DRAW_ALL);
  }

  //调试代码,输出角度和测距值  
  Serial.print(x); 
  Serial.print("    ,   ");
  Serial.println(distance); 

  if (x > 70 and x < 110)  fix_font();  //扫描线和数字重合时,重绘数字

  ucg.setColor(0,155,  0);
  ucg.setPrintPos(0,126);
  ucg.print("DEG: "); 
  ucg.setPrintPos(24,126);
  ucg.print(x);
  ucg.print("   ");
  ucg.setPrintPos(125,126);
  ucg.print("   ");
  ucg.print(distance);
  ucg.print("cm   "); 

} //ucg.clearScreen(); // delay(50); cls();

}

SIM900 GPRS GSM Arduino Shiled

欧美出口品质,国产价格,限时特价,限量促销,机不可失

 

原理图: http://i-element.org/makerstudio/GPRS/GPRS_GSM%20Shield%20v1.0%20sch.pdf

 

使用手册: http://i-element.org/makerstudio/GPRS/MakerStudio%20GPRS%20GSM%20Shield%20User%20Guide%20r1%20.pdf

 

Arduino使用范例代码: http://i-element.org/makerstudio/GPRS/GPRS_Shield.zip

 

芯片相关参考手册: http://i-element.org/makerstudio/GPRS/SIM900datasheeet.zip

Arduino创客手表套件

Description:

The Solder : Time™ watch kit.

The Solder : Time is an original design watch kit that you solder and assemble yourself.  Delivered as a through-hole kit, you solder the components to the PCB, and enclose it all in four layers of laser cut acrylic.

Introduced at Maker Faire Bay Area in Mid 2011, an instant hit.  The supplied battery lasts a really long time, and the onboard Dallas RTC keeps impeccable time.  This is the first SpikenzieLabs Kit that is a 'wearable'.

Solder : Time is not only a wristwatch. Set it up as a desk clock, badge clip-it to your clothes, thread a chain, and you've got a pocket watch.

More advanced tinkerers will see the bottom side I2C lines broken out, for hacking, and integrating RTC into other projects. There are also pads on the backside of the PCB for DC supply, as well as an 'always-on' function.

Resistors:

Start by bending the leads to all three resistors to look like these in the photo.

Solder them in place and trim the leads. They go in either direction.

Clock crystal:

The crystal for the real time clock is the very small silver part with two leads.

Solder this as in the photo.

IC and Capacitors:

Note:

  1. 1.The notches on the two IC chips (RTC and PIC) must match-up with the notches printed on the white silk screen.

  2. 2.These two ICs are soldered directly onto the PCB. For best results, only apply heat from your soldering iron for 1 to 3 seconds per leg.

Solder the two orange-yellow capacitors in place.

Trim all leads.

LED:

Place the 4 digit 7 segment LED onto the PCB. Push flat, making sure all the legs go through the holes.

NOTE: Make sure that the LED is installed up-side right. Check that the decimal points are on the bottom as in this photo.

Solder and trim the leads.

You may want to peel the thin clear protective layer from the LED. Use your finger nail to lift an edge and then gently peel it off.

Button:

Push the button into the PCB. It should almost click into place.

Solder and trim the leads.

Assemble the watch body:

Battery holder:

The battery holder is very light and likes to move around as you solder it. Solder it in place with the open edge facing down.

Taping the battery holder in place, with masking tape, while soldering it works best.

Another way to solder the battery holder without tape is to heat the pad and battery holder by placing the tip of your soldering iron on the PCB’s battery pad and just barely touching the battery holder. After a second or two add some solder. Once one pad is soldered, do the other one, and come back to add more solder to the first one if required.

I’ve tried soldering a blob of solder onto one of the pads, and then heating the battery holder ... this didn’t work.

Building the circuit board: This is an easy to solder kit.

Peel the protective layer on the plastic parts:

In order to protect the plastic parts during manufacturing they come covered by a thin plastic / tape layer. These should be removed before you assemble the watch.

NOTE:

  1. 1.Only use something soft like your finger nail to scrape the edge of the protective layer and then peel it off.

  2. 2.VERY IMPORTANT: Some of the layers have very thin parts that can crack easily. The best way we have found to peel the protective layer off of these parts is to hold the part down evenly on a flat surface with one hand and peel with the other hand. Holding the part in the air while you peel may snap the part you are peeling. (Don’t worry after the watch is assembled and screwed together it is very strong.)

Stacking the watch:

With the battery in the battery holder start making a stack of parts.

Close up of button details:

Battery:

Slide the battery into the battery holder on the Solder : Time PCB with the CR2032 “+” label text facing up. When the battery goes into the holder the watch should turn on and display 12:00. If not, remove the battery and check your work. After about five seconds the display will go out, this is normal.

NOTE: As tempting as it may be, don’t touch the battery holder while soldering - you will burn your finger!

  1. 5.Place the front face of the Solder : Time on the top of the stack.

  2. 6.Using your fingers, screw the layers together with the included screws. Don’t tighten them fully until all four screws are installed (this will help you align the layers).

  3. 7.Almost done, slide the wrist band in from the bottom edge, under the bottom and up through the other hole in the bottom and out the top edge.

  1. 1.Start with the plastic watch back oriented with the two larger holes at the top and bottom and place the PCB over it.

  2. 2.Next, place the plastic PCB layer part around the PCB, with the open end facing down.

  3. 3.Place the plastic switch layer on top of the PCB layer plastic. The opening for the switch is on the right side.

  4. 4.Place the switch lever into the space on the right side of the Switch Layer. Make sure that the switch touches the Solder : Time button and does not bind. Test it, the Solder : Time should turn on when pressed and off after a few seconds when released.

How does it work ?:

Parts Selection:

When we came up with the idea for the Solder : Time, one of our big concerns was battery life. We knew that we would need a RTC and some type of micro-controller. After experimenting with a bunch of different RTCs we decided to go with the Dallas Semiconductors DS1337+. This RTC clock runs at over a range of voltages which included our required voltage of 3v. It has extremely low current when in standby mode and uses I2C to communicate with the master micro-controller.

For the micro-controller we chose the PIC16F631. This IC has only a few peripheral functions built in (with keeps the cost down), and since we didn’t need many this also saves some power. The PIC16F631 has a very low power sleep mode, has enough pins for our project (and only one spare one), and also runs at 3volts. The PIC16F631 does not have built in I2C, so we used a bit banged version to control the RTC.

Battery Life:

In order to maximize battery life, we also used a couple of tricks. For the I2C bus we used higher value pull-up resistors (10k vs 4.7k) to reduce current and for the one unused pin on the PIC we set it to be a low logic value output (Microchip’s spec sheets, recommend this as a power saving set up). In testing the watch’s current draw, we estimated that given the average power of a CR2032 battery, the watch should keep the time for five years, before needing a battery swap in stand-by mode. Overall battery life will depend on how often the display is turned on.

Seven Segment Display:

The LEDs: One of the objectives when designing the Solder : Time was to make sure that all of the segments of the digits had equal brightness. In some cases only two segments are lit, as is the case for the number “1”, When the “8” is on, all seven segments are lit. Battery power was also a concern, the battery we chose for this project is the CR2032 which is a 3v low current battery. Our solution was to light only one single segment at a time, this way if the digit being displayed was a “1” or an “8” all the segments would be equally bright and we wouldn’t over tax the battery by drawing too much current. (If you wave the watch in the dark, you may be able to see the flashing pattern.)

Use a timer:

To light only one segment at a time we used one of the internal timer peripherals in the PIC. A timer may also be used as a counter, but in this case we used it as a timer to time the on time of each segment. When the timer runs out, the PIC programming jumps into a interrupt routine. To display a number, the PIC looks up the segments in a table that stores the on and off values for the segments. It starts with the first segment of whichever number it is displaying and then turns the segment on (or not, if that segment isn’t on). After this, the program returns to the normal main loop of the program and waits for the timer to run out again. When it does, the PIC turns on the next segment of the current digit. Even if the segment of the current digit is not turned on, the timer still waits.

After all of the segments of a digit are displayed, the next digit is displayed, and after the last digit is displayed the colon is displayed and then it starts over at the first digit.

Flashing Colon:

There is a special case when displaying the colon. It flashes when in time setting mode. It took a few tries to get the flashing to look good and steady in the three states of the time setting mode; slow forward, fast forward and idle. To achieve a steady flash rate we used another timer. This timer simply toggles the colon on or off ever time that it times out, then when it is time to display the colon it is simply lit or not.

Sleep Mode:

For the Solder : Time’s sleep mode we use a manual counter variable. This variable is incremented every time the program goes through a loop, and when it over flows (gets too big for the size of the variables holder) a sleep flag is set and the watch goes to sleep. If the button is pressed before the watch goes into sleep mode, the sleep counter is reset to zero and counting starts again. This way, the watch will go to sleep consistently after about 5 seconds from the last time you pressed the button.

Before the watch goes to sleep it turns off the LEDs. The watch button is set to wake the watch up if it is pressed. Nothing is done to the RTC since it goes into stand-by mode when no data is being transfered and it simply keeps the time.

http://www.spikenzielabs.com/SpikenzieLabs/SolderTime.html

 

Connector Basics

Introduction

Connectors are used to join subsections of circuits together. Usually, a connector is used where it may be desirable to disconnect the subsections at some future time: power inputs, peripheral connections, or boards which may need to be replaced.

Covered in This Tutorial

In this tutorial we will go over:

  • Basic connector terminology
  • Categorize connectors into distinguishable categories
  • Talk about the differences between connectors within those categories.
  • Show how to identify polarized connectors
  • Talk about which connectors are best suited for certain applications

Suggested Reading

You may find these concepts useful before starting on this tutorial:

Connector Terminology

Before we get started discussing some commonly used connectors, let’s explore the terminology used to describe connectors.

Gender - The gender of a connector refers to whether it plugs in or is plugged into and is typically male or female, respectively (kids, ask your parents for a more thorough explanation). Unfortunately, there are cases where a connector may be referred to as “male” when it would appear to be female; in the examples section, we’ll point a few of those out as we discuss individual component types and explain why that’s the case.

Male and female 2.0mm PH series JST connectors

Male (left) and female 2.0mm PH series JST connectors. In this case, gender is determined by the individual conductor.

Polarity - Most connectors can only be connected in one orientation. This trait is called polarity, and connectors which have some means to prevent them being connected wrong are said to be polarized, or sometimes keyed.

North America wall plug

A polarized North American wall plug. By having two different widths for the plug blades, the plug will only go into the outlet one way.

Contact - Contacts are the business portion of the connector. They are the metal parts which touch each other, forming an electrical connection. This is also where problems occur: the contacts can become soiled or oxidized, or the springiness required to hold the contacts together may fade with time.

ADH8066 mating connector

The contacts on this connector are clearly visible.

Pitch - Many connectors consist of an array of contacts in a repeated pattern. The pitch of the connector is the distance from the center of one contact to the center of the next. This is important, because there are many families of contacts which look very similar but may differ in pitch, making it difficult to know that you are purchasing the right mating connector.

.1" pin header connector examples

The pitch of the pins on the headers on a standard Arduino is .1".

Mating cycles - Connectors have a finite life, and connecting and disconnecting them is what wears them out. Datasheets usually present that information in terms of mating cycles, and it varies widely from one technology to another. A USB connector may have a lifetime in the thousands or tens of thousands of cycles, while a board-to-board connector designed for use inside of consumer electronics may be limited to tens of cycles. It’s important that you select a connector with a suitable life for the application.

Connector for GS406 GPS module

Mating connector for the GS406 GPS module. The connector’s datasheet indicates a maximum of 50 insertion cycles for this part.

Mount - This one has the potential for being confusing. The term “mount” can refer to several things: how the connector is mounted in use (panel mount, free-hanging, board mount), what the angle of the connector is relative to its attachment (straight or right-angle), or how it is mechanically attached (solder tab, surface mount, through hole). We’ll discuss this more in the examples section for each individual connector.

Comparison of different mounting methods for barrel-type connectors

A comparison of three different methods of mounting the same barrel connector: (left to right) board mount, inline cable mount, and panel mount.

Strain relief - When a connector mounts to a board or cable, the electrical connections tend to be somewhat fragile. It is typical to provide some kind of strain relief to transfer any forces acting on that connector to a more mechanically sound object than the fragile electrical connections. Again, there will be some good examples of this later on.

1/8" Headphone jack showing strain relief

This 1/8" headphone jack comes with a strain relief “boot” slid over the cable to prevent forces on the cable from being transmitted directly to the electrical joints.

USB Connectors

USB connectors come in two flavors: host and peripheral. In the USB standard, there is a difference between the two, and the connectors on cables and devices reflect this. However, all USB connectors will have some things in common:

  • Polarization - A USB connector can only nominally be inserted one way. It may be possible to force a connector in wrong, but that will result in damage to the device.
  • Four contacts - All USB connectors have at least four contacts (although some may have five, and USB 3.0connectors have even more). These are for power, ground, and two data lines (D+ and D-). USB connectors are designed to transmit 5V, up to 500mA.
  • Shielding - USB connectors are shielded, such that a metal shell which is not part of the electrical circuit is provided. This is important to keep the signal intact in environments with a lot of electrical “noise”.
  • Robust power connection - It’s important for the power pins to make connection before the data lines, to avoid trying to power the device over the data lines. All USB connectors are designed with this in mind.
  • Molded strain relief - All USB cables have plastic overmolding at the connector to prevent strain on the cable that could potentially damage the electrical connections.

Labeled image of USB extension cable

USB extension cable, with some of the common features of USB connectors labeled.

USB-A Connectors

USB-A female is the standard “host” connector type. This is found on computers, hubs, or any device intended to have peripherals plugged into it. It is also possible to find extension cables with a female A connector and a male A connector on the other end.

USB-A ports on a laptop computer.

Female USB-A ports on the side of a laptop. The blue connector is USB 3.0 compliant.

USB-A male is the standard “peripheral” connector type. Most USB cables will have one end terminating in a USB-A male connector, and many devices (such as keyboards and mice) will have a built-in cable terminated with a USB-A male connector. It’s also possible to find USB-A male connectors that are board mountable, for devices like USB memory sticks.

USB-A male connector examples

Two types of Male USB-A connectors, on a SparkFun Cerberus cable and an AVR Stick development board.

USB-B Connectors

USB-B female is a standard for peripheral devices. It’s bulky, but robust, so in applications where size is not an issue, it’s the preferred means for providing a removable connector for USB connectivity. It is usually a through-hole board mount connector, for maximum reliability, but there are panel-mount options for it as well.

USB-B connector on an Arduino Uno

Arduino boards, including this Uno, have long used the female USB-B connector, due to its low cost and durability.

USB-B male is almost exclusively found at the end of a cable. USB-B cables are ubiquitous and inexpensive, which also contributes to the popularity of the USB-B connection.

Male USB-B connector

USB-B male connector on the end of a SparkFun Cerberus cable.

USB-Mini Connectors

The USB-Mini connection was the first standard attempt to reduce the size of the USB connector for smaller devices. USB-Mini female is typically found on smaller peripherals (MP3 players, older cellphones, small external hard drives), and is usually a surface mount connector, trading robustness for size. USB-Mini is slowly being phased out in favor of the USB-Micro connector.

USB-Mini female connector

USB-Mini female connector on a Protosnap Pro Mini.

USB-Mini male is another cable-only connector. As with USB-B, it’s extremely common, and cables can be found cheaply almost anywhere.

USB-Mini male connector

USB-Mini male connector on the end of a SparkFun Cerberus cable.

USB-Micro Connectors

USB-Micro is a fairly recent addition to the USB connector family. As with USB-Mini, the primary concern is size reduction, but USB-Micro adds a fifth pin for low-speed signalling, allowing it to be used in USB-OTG (On-the-go) applications where a device may want to operate as either a host or a peripheral depending on circumstances.

USB-Micro female is found on many newer peripherals, such as digital cameras and MP3 players. The adoption of USB-micro as a standard charge port for all new cellular phones and tablet computers means that chargers and data cables are becoming increasingly common, and USB-Micro is likely to supplant USB-Mini in the coming years as the small-factor USB connector of choice.

USB-Micro female connector

USB-Micro female connector on a LilyPad Arduino USB board.

USB-Micro male is also a cable-only connector. There are generally two types of cables with USB-Micro male ends: one for connecting a device with a USB-Micro port as a peripheral to a USB host device and one for adapting the USB-Micro female port to a USB-A female port, to be used in USB-OTG capable devices.

USB-Micro male connector

USB-Micro male connector on the SparkFun Cerberus cable.

USB-A female to USB-Micro adapter

Adapter pigtail for using USB-OTG capable devices having only a USB-Micro port with standard USB peripherals. Note that not all devices supporting USB-OTG will work with this pigtail.

Audio Connectors

Another familiar connector group are those used for audio-visual applications–RCA and phono. While these can’t truly be considered to be of the same family, as the various USB connectors are, we’ll consider both of them to be in the same vein.

“Phone” Type Connectors

You’ll probably immediately recognize the 1/8" version of this connector as a the plug on the end of a pair of headphones. These connectors actually come in three common sizes: ¼" (6.35mm), 1/8" (3.5mm), and 2.5mm. ¼" size connectors find a lot of use in the professional audio and music community- most electric guitars and amplifiers have ¼" tip-sleeve (TS) jacks on them. 1/8" tip-ring-sleeve (TRS) is very common as the connector for headphones or audio output signals on MP3 players or computers. Some cell phones will provide a 2.5mm tip-ring-ring-sleeve (TRRS) jack for connecting to headphones that also include a microphone for hands-free communications.

The common availability of these connectors and cables makes them a good candidate for general purpose connectivity applications–for instance, long before USB, Texas Instruments graphing calculators used a 2.5mm TRS connector for a serial programming connector. It should be remembered that tip-sleeve connector types are not designed for carrying power; during insertion, the tip and the sleeve can be momentarily shorted together, which may damage the power supply. The lack of shielding makes them poor candidates for high-speed data, but low speed serial data can be passed through these connectors.

1/8" TRS phone plug

Headphone-type TRS phone plug, 1/8". Typically, tip and ring will carry the stereo audio signals while sleeve will be connected to ground.

1/8" TS phone plug

1/8" phone plug. Note the lack of a ring contact on this connector.

1/8" board mount headphone jack

1/8" board mount headphone jack with pins corresponding pin connections labeled. When no jack is inserted, an internal switch connects the tip and ring pins to the adjacent unmarked pins, allowing insertion detection.

RCA Connectors

Familiar as the home-stereo connector of choice for many decades, the RCA connector was introduced in the 1940s by RCA for home phonographs. It is slowly being supplanted by connections like HDMI in the audio-visual realm, but the ubiquity of the connectors and cables makes it a good candidate for home-built systems. It will be a long time before it is obsolete.

Female RCA connectors are usually found on devices, although it is possible to find extension or conversion cables with female jacks on them. Most RCA connectors are connected to one of four types of signals: component video (PAL or NTSC, depending on where the equipment was sold), composite video, stereo audio, or S/PDIF audio.

Female RCA plug, for video signals.

Female RCA connector, for video signals. Typically, NTSC or PAL video signal connectors will be yellow.

Male RCA connectors are usually found on cables.

Male RCA plugs

Male RCA plugs. Red and white are usually for audio applications, with red denoting the “right” audio channel.

Power Connectors

While many connectors carry power in addition to data, some connectors are used specifically to provide power connections to devices. These vary widely by application and size, but we will only focus on some of the most common ones here.

Barrel Connectors

Barrel connectors are typically found on low-cost consumer electronics which can be plugged into wall power via bulky AC wall adaptors. Wall adaptors are widely available, in a variety of power ratings and voltages, making barrel connectors a common means for connecting power to small projects.

The female barrel connector, or “jack”, can be purchased in several varieties: PCB mounted (surface mount or through hole), cable mount, or panel mount. Some of these connectors will have an additional contact that allows the application to detect whether a power supply is plugged into the barrel jack or not, thus allowing the device to bypass batteries and save battery life when running on external power.

Female barrel connector

Female barrel connector. When no plug is inserted, the “insertion detection” pin will be shorted to the “sleeve” pin.

The male barrel connector, or “plug”, is usually only found in a wire termination variety, although there are multiple methods of attaching the plug to the end of the wire. It’s also possible to get plugs that come pre-attached to a cable.

Male barrel plug

Unattached male barrel plug, for attachment to any power supply. Note that the sleeve connection is designed to be crimped onto the wire for extra strain relief.

Barrel connectors provide only two connections, frequently referred to as “pin” or “tip” and “sleeve”. When ordering, there are three differentiating characteristics of a barrel connection- inner diameter (the diameter of the pin inside the jack), outer diameter (the diameter of the sleeve on the outside of the plug), and polarity (whether the sleeve voltage is higher or lower than the tip voltage).

Sleeve diameter is most commonly either 5.5mm or 3.5mm.

Pin diameter is contingent upon sleeve diameter; a 5.5mm sleeve will have either a 2.5mm or 2.1mm pin. Unfortunately, this means that a plug designed for a 2.5mm pin will fit in a 2.1mm jack, but that the connection will be, at best, intermittent. 3.5mm sleeve plugs usually mate to a jack with a 1.3mm pin.

Polarity is the final aspect to consider; most often, the sleeve will be considered 0V and the tip will be a positive voltage relative to the sleeve. Many devices will have a small diagram indicating the polarity expected by the device; care should be taken to adhere to this, as an improper power supply may damage the device.

Plugs of both sleeve sizes are usually 9.5mm long, but longer and shorter ones do exist. All SparkFun products use a positive polarity 5.5mm sleeve and a 2.1mm pin; we recommend sticking to that standard where possible, as it seems to be the most common flavor found in the wild.

Barrel connector polarity label

Common polarity diagrams for AC adaptors with barrel plugs. Positive polarity (tip positive, sleeve 0V) is most common. Diagram courtesy Wikipedia user Three-quarter-ten.

“Molex” Connectors

Most computer hard drives, optical drives, and other internal peripherals get power through what is typically called a “Molex” connector. To be more accurate, it’s a Molex series 8981 connector–Molex is actually the name of the company which initially designed this connector back in the 1950s–but common usage has denuded that fact somewhat.

Molex connectors are designed to carry a lot of current: up to 11A per pin. For projects where a lot of power may be needed–a CNC machine, for instance, or a 3D printer- a very common method for powering the project is to use a desktop PC power supply and connecting the various system circuits through Molex connectors.

The Molex connector is one where the male/female terminology is a bit odd. The female connector is usually found on the end of a cable, and it slips inside of a plastic shell which surrounds the male pins on the male connector. Usually, the connectors are press-fit only, and very, very tight–they are intended to be connected and disconnected only a few times and, as such, are a bad choice for systems where connections will frequently be changed.

Male Molex connector

Male Molex connector. The gender of the pins inside the connector is what signifies the gender of the connector as a whole.

Female Molex connector

Female Molex connector on a project power supply.

IEC Connector

As with the Molex connector, this is a case where a generalized component name has come to be synonymous with a single, particular item. IEC connector usually refers to the power supply inlet which is commonly seen on desktop PC power supplies. Strictly speaking, that’s an IEC 60320-1 C13 (female) and C14 (male) connector.

IEC 60320-1 C14 male connector

C14 male IEC power inlet, on a DC project power supply. Note that, as with the Molex connector, the gender of the connector is defined by the pins within the hood.

C13 female IEC power connector

C13 female IEC power connector, on a fairly standard AC power supply cable. Cables with this end can be found all around the world, usually with the dominant local AC connector at the other end.

IEC connectors are used almost exclusively for AC power input. The nice thing about using one on a project is that IEC-to-wall cables are extremely common and available with localized wall plugs for most international locations!

JST Connector

At SparkFun, we frequently refer to “2.0mm JST Connectors”. This is yet another generalization of a specific product- JST is a Japanese company which makes high-quality connectors, and our 2.0mm JST connector of choice is the PH series two-position polarized connector.

All of SparkFun’s single-cell lithium-polymer ion batteries come standard with this type of JST connector, and many of our boards include this connector (or a footprint for it) as a power supply input. It has the advantage of being compact, durable, and difficult to connect backwards. Another feature, which can be an advantage or a disadvantage, depending on how you look at it, is that the JST connector is wicked hard to disconnect (although a carefully applied diagonal cuttercan be helpful!) once it’s mated. While this makes it unlikely to fail during use, it also means that disconnecting the battery for charging can damage the battery connector.

2-Pin JST male connector on a LilyPad Arduino USB board

2-Pin JST male connector on a LilyPad Arduino USB board. Again, as with the Molex, the pins inside the hood determine the gender of the connector.

Male and female 2-pin JST connectors

Male and female 2-pin JST connectors.

There are PH series connectors with more than two positions; SparkFun even sells them. However, our most frequent application is for the 2-position battery connection.

Pin Header Connectors

Pin header connectors comprise several different means of connection. Generally, one side is a series of pins which are soldered to a PCB, and they can either be at a right-angle to the PCB surface (usually called “straight”) or parallel to the board’s surface (confusingly referred to as “right-angle” pins). Such connectors come in a variety of pitches, and may have any number of individual rows of pins.

Right angle female header pin connector

Right-angle female header pin connection on an FTDI basic board.

The most commonly seen pin headers are .1" single or double row connectors. These come in male and femaleversions, and are the connectors used to connect Arduino boards and shields together. Other pitches are not uncommon; for instance, the XBee wireless module uses a 2.0mm pitch version of the same connector.

.1" pin header connector examples

.1" pin header connectors, male and female, on an Arduino Uno board.

A common variation on this part is a “machine pin” version. While the normal version is formed out of stamped and folded sheet metal, machine pin connectors are formed by tooling the metal into the desired shape. The result is a more robust connector, with a better joint and longer life, making it somewhat more expensive.

Female machine pin headers

Female machine pin headers. Note that these are designed to be snapped apart into smaller sections, while standard .1" female header pin connectors are not. It’s also important to note that not all non-machine pin header connectors will mate with the machine pin variety.

Cables made to connect to these pin headers are usually one of two types: individual wires with crimp connectors on them or ribbon cables with insulation displacement connectors. These can simply be clamped onto the end of a ribbon cable, which creates a connection to each one of the conductors in the ribbon cable. Generally, cables are only available as female gender and expect a male pin to mate with.

Crimp connected header cable

Six-position crimp-type cable. Each wire is individually stripped, a connector crimped to it, and then the connectors are inserted into the plastic frame.

2x5 insulation displacement connectors on a ribbon cable

2x5 insulation displacement connectors (IDC) on a ribbon cable. This type of cable can be quickly assembled because it does not require stripping of individual connectors. It also has polarizing tabs on each end, to prevent incorrect insertion in the mating board-side connector.

Temporary connectors

Screw Terminals

In some cases, it may be desirable to be able to connect bare, unterminated wire to a circuit. Screw terminals provide a good solution for this. They are also good for situations in which a connection should be capable of supporting multiple different connecting devices.

The downside of screw terminals is that they can come undone fairly easily, leaving a bare wire waving around in your circuit. A small dab of hot glue can address this without being too difficult to remove later.

Screw terminals are typically designed for a narrow range of wire gauges, and wires that are too small can be as big a problem as wires that are too big. SparkFun carries two types of screw terminal–a .1" pitch version and a 3.5mm version. Most screw terminals are highly modular, and they can easily be extended at the same pitch by simply connecting two or more smaller sections together.

3.5mm screw terminals


-> 3.5mm pitch screw terminals, showing the insertion point of the wire to be connected, the retention screw which holds the wire in place, and the modular connectors on the sides of the individual units allowing multiple pieces to be ganged together. <-

Banana Connector

Most pieces of power test equipment (multimeters, power supplies) have a very simple connector called a “banana jack” on it. These mate to “banana plugs”, crimped, sprung metal plugs, meant to make a single power connection. They are frequently available in a stackable configuration and can be easily connected to any type of wire. They are capable of carrying several amps of current and are inexpensive.

Banana plug

Stackable banana plug. Note that there are two different ways to plug in an additional banana plug.

Variable power supply with banana plugs

Extech variable bench supply with banana jacks on the front.

Alligator Clip

Named for obvious reasons, alligator clips are good for test connections to posts or bare wires. They tend to be bulky, easily cause shorts to nearby bare metal, and have a reasonably poor grip that can be easily compromised. They are primarily used for low-cost connections during debugging.

Alligator clips

“third hand” tool, which uses alligator clips to hold work pieces, holding a wire terminated with an alligator clip for electrical test. Note the plastic boot surrounding the alligator clip, to make it less likely to short to other connections.

IC Clip (or IC Hook)

For more delicate probing operations, there are a variety of IC clips on the market. These are sized to allow a user to clip them onto the pins of an IC without contacting adjacent pins; some of them are delicate enough to be clipped onto even fine-pitched SMD component legs. These smaller clips can be found on logic analyzers as well as test leads, which are great for prototyping or troubleshooting circuits.

Large IC clip

large IC clip on the end of a wire. This clip is still small enough to be connected to a single leg on a through-hole chip without causing a problem for adjacent pins.

Other Connectors

RJ-type Modular Connectors

Registered jack connectors are standard for telecommunications equipment into a local exchange. The names one normally hears associated with them (RJ45, RJ12, etc) are not necessarily correct, as the RJ designator is a based on a combination of the number of positions, the number of conductors actually present, and the wiring pattern. For example, while the ends of a standard ethernet cable are usually referred to as “RJ45”, RJ45 actually implies not only an 8 position, 8 conductor modular jack, it also implies that it is wired for ethernet.

These modular connectors can be very useful, since they combine ready availability, multiple conductors, moderate flexibility, low cost, and moderate current carrying capacity. While not originally intended to deliver a great deal of power, these cables can be used to deliver data and a couple of hundred milliamps from one device to another. Care should be taken to ensure that jacks provided for applications like this are not connected to conventional ethernet ports, as damage will result.

8p8c "RJ45" style modular jack

A standard 8p8c (8-position, 8-conductor) “RJ45” modular jack. Be aware that if you intend to use this type of jack to pass DC signals and power, you must avoid using connectors with built-in signal transformers.

D-sub Type Connectors

Named for the shape of their shell, D-subminiature connectors are a classic standard in the computing world. There are four very common varieties of this connector: DA-15, DB-25, DE-15, and DE-9. The pin number indicates the number of connections provided, and the letter combination indicates the size of the shell. Thus, DE-15 and DE-9 have the same shell size, but a different number of connections.

Female board-mount DE9 connector

Female DE-9 board-mount connector. Gender is defined by the pins or sockets associated with each signal, not the connector as a whole, making this connector female despite the fact that it effectively inserts into the shell of the mating connector.

DB-25 and DE-9 are the most useful to the hardware hacker; many desktop computers still include at least one DE-9 serial port, and often one DB-25 parallel port. Cables terminated with DE-9 and DB-25 connectors are widely available, too. As with the modular connector above, these can be used to provide power and point-to-point communications between two devices. Again, since the common usage of these cables does not include power transmission, it is very important that any repurposing of the cables be done cautiously, as a non-standard device plugged into a standard port can easily cause damage.

Resources and Going Further

You should now have a good idea which connectors are suited best for certain applications and which connectors will be useful to you in your next project. Please check out these other links to lean more about connectors.

  • Giant database of connectors and pinouts - Everything you never wanted to know about pretty much any connector, ever. A good site for basic info about connectors, but often quite shy on interface details.
  • Wikipedia article on registered jack connectors - More on the confusing world of the registered jack (RJ) connector, which is often misunderstood and misused.
  • Wikipedia article on D-subminiature connectors - As with the registered jack connector, misinformation abounds on the D-subminiature standard. Wikipedia has a great article about it.
  • Mouser electronics catalog - Browsing an electronics supplier catalog is often a great place to start looking for the name of an unidentified connector; Mouser’s enhanced online catalog is just as good as the print version, with fewer papercuts!

If you’d like top explore more SparkFun tutorials, check out these other offerings:

 


cc

 Creative Commonstutorials are CC BY-SA 4.0

Original From:

https://learn.sparkfun.com/tutorials/connector-basics

Analog vs. Digital

Overview

We live in an analog world. There are an infinite amount of colors to paint an object (even if the difference is indiscernible to our eye), there are an infinite number of tones we can hear, and there are an infinite number of smells we can smell. The common theme among all of these analog signals is their infinite possibilities.

Digital signals and objects deal in the realm of the discrete or finite, meaning there is a limited set of values they can be. That could mean just two total possible values, 255, 4,294,967,296, or anything as long as it’s not ∞ (infinity).

Analog and digital real-life items

Real-world objects can display data, gather inputs by either analog or digital means. (From left to right): Clocks, multimeters, and joysticks can all take either form (analog above, digital below).

Working with electronics means dealing with both analog and digital signals, inputs and outputs. Our electronics projects have to interact with the real, analog world in some way, but most of our microprocessors, computers, and logic units are purely digital components. These two types of signals are like different electronic languages; some electronics components are bi-lingual, others can only understand and speak one of the two.

In this tutorial, we’ll cover the basics of both digital and analog signals, including examples of each. We’ll also talk about analog and digital circuits, and components.

Suggested Reading

The concepts of analog and digital stand on their own, and don’t require a lot of previous electronics knowledge. That said, if you haven’t already, you should peek through some of these tutorials:

Analog Signals

Define: Signals

Before going too much further, we should talk a bit about what a signal actually is, electronic signals specifically (as opposed to traffic signals, albums by the ultimate power-trio, or a general means for communication). The signals we’re talking about are time-varying “quantities” which convey some sort of information. In electrical engineering the quantitythat’s time-varying is usually voltage (if not that, then usually current). So when we talk about signals, just think of them as a voltage that’s changing over time.

Signals are passed between devices in order to send and receive information, which might be video, audio, or some sort of encoded data. Usually the signals are transmitted through wires, but they could also pass through the air via radio frequency (RF) waves. Audio signals, for example might be transferred between your computer’s audio card and speakers, while data signals might be passed through the air between a tablet and a WiFi router.

Analog Signal Graphs

Because a signal varies over time, it’s helpful to plot it on a graph where time is plotted on the horizontal, x-axis, and voltage on the vertical, y-axis. Looking at a graph of a signal is usually the easiest way to identify if it’s analog or digital; a time-versus-voltage graph of an analog signal should be smooth and continuous.

Analog Sine Wave

While these signals may be limited to a range of maximum and minimum values, there are still an infinite number of possible values within that range. For example, the analog voltage coming out of your wall socket might be clamped between -120V and +120V, but, as you increase the resolution more and more, you discover an infinite number of values that the signal can actually be (like 64.4V, 64.42V, 64.424V, and infinite, increasingly precise values).

Example Analog Signals

Video and audio transmissions are often transferred or recorded using analog signals. The composite video coming out of an old RCA jack, for example, is a coded analog signal usually ranging between 0 and 1.073V. Tiny changes in the signal have a huge effect on the color or location of the video.

Composite video signal

An analog signal representing one line of composite video data.

Pure audio signals are also analog. The signal that comes out of a microphone is full of analog frequencies and harmonics, which combine to make beautiful music.

Digital Signals

Digital signals must have a finite set of possible values. The number of values in the set can be anywhere between two and a-very-large-number-that’s-not-infinity. Most commonly digital signals will be one of two values – like either 0V or 5V. Timing graphs of these signals look like square waves.

Square wave signal. Two values, either 0V or 5V.

Or a digital signal might be a discrete representation of an analog waveform. Viewed from afar, the wave function below may seem smooth and analog, but when you look closely there are tiny discrete steps as the signal tries to approximate values:

Digital Sine Wave

That’s the big difference between analog and digital waves. Analog waves are smooth and continuous, digital waves are stepping, square, and discrete.

Example Digital Signals

Not all audio and video signals are analog. Standardized signals like HDMI for video (and audio) and MIDII2S, or AC'97for audio are all digitally transmitted.

Most communication between integrated circuits is digital. Interfaces like serialI2C, and SPI all transmit data via a coded sequence of square waves.

SPI square wave signals

Serial peripheral interface (SPI) uses many digital signals to transmit data between devices.

Analog and Digital Circuits

Analog Electronics

Most of the fundamental electronic components – resistorscapacitors, inductors, diodes, transistors, and operational amplifiers – are all inherently analog. Circuits built with a combination of solely these components are usually analog.

Example analog circuit

Analog circuits are usually complex combinations of op amps, resistors, caps, and other foundational electronic components. This is an example of a class B analog audio amplifier.

Analog circuits can be very elegant designs with many components, or they can be very simple, like two resistors combining to make a voltage divider. In general, though, analog circuits are much more difficult to design than those which accomplish the same task digitally. It takes a special kind of analog circuit wizard to design an analog radio receiver, or an analog battery charger; digital components exist to make those designs much simpler.

Analog circuits are usually much more susceptible to noise (small, undesired variations in voltage). Small changes in the voltage level of an analog signal may produce significant errors when being processed.

Digital Electronics

Digital circuits operate using digital, discrete signals. These circuits are usually made of a combination of transistors and logic gates and, at higher levels, microcontrollers or other computing chips. Most processors, whether they’re big beefy processors in your computer, or tiny little microcontrollers, operate in the digital realm.

Example digital circuit

Digital circuits make use of components like logic gates, or more complicated digital ICs (usually represented by rectangles with labeled pins extending from them).

Digital circuits usually use a binary scheme for digital signaling. These systems assign two different voltages as two different logic levels – a high voltage (usually 5V, 3.3V, or 1.8V) represents one value and a low voltage (usually 0V) represents the other.

Although digital circuits are generally easier to design, they do tend to be a bit more expensive than an equally tasked analog circuit.

Analog and Digital Combined

It’s not rare to see a mixture of analog and digital components in a circuit. Although microcontrollers are usually digital beasts, they often have internal circuitry which enables them to interface with analog circuitry (analog-to-digital converterspulse-width modulation, and digital-to-analog converters. An analog-to-digital converter (ADC) allows a microcontroller to connect to an analog sensor (like photocells or temperature sensors), to read in an analog voltage. The less common digital-to-analog converter allows a microcontroller to produce analog voltages, which is handy when it needs to make sound.

Resources and Going Further

Now that you know the difference between analog and digital signals, we’d suggest checking out the Analog to Digital Conversion tutorial. Working with microcontrollers, or really any logic-based electronics, means working in the digital realm most of the time. If you want to sense light, temperature, or interface a microcontroller with a variety of other analog sensors, you’ll need to know how to convert the analog voltage they produce into a digital value.

Also, consider reading our Pulse Width Modulation (PWM) tutorial. PWM is a trick microcontrollers can use to make a digital signal appear to be analog.

Here are some other subjects which deal heavily with digital interfaces:

Or, if you’d like to delve further into the analog realm, consider checking out these tutorials:

 


cc

 Creative Commonstutorials are CC BY-SA 4.0

Original From:

https://learn.sparkfun.com/tutorials/analog-vs-digital?_ga=2.115872645.205432072.1519278474-2127327188.1495905514

PCB Basics

Overview

One of the key concepts in electronics is the printed circuit board or PCB. It’s so fundamental that people often forget to explain what a PCB is. This tutorial will breakdown what makes up a PCB and some of the common terms used in the PCB world.

Blank PCB from the ClockIt Kit

Over the next few pages, we’ll discuss the composition of a printed circuit board, cover some terminology, a look at methods of assembly, and discuss briefly the design process behind creating a new PCB.

Suggested Reading

Before you get started you may want to read up on some concepts we build upon in this tutorial:


Translations

Minh Tuấn was kind enough to translate this tutorial to Vietnamese. You can view the translation here.

What's a PCB?

Printed circuit board is the most common name but may also be called “printed wiring boards” or “printed wiring cards”. Before the advent of the PCB circuits were constructed through a laborious process of point-to-point wiring. This led to frequent failures at wire junctions and short circuits when wire insulation began to age and crack.

Mass of wire wrap
courtesy Wikipedia user Wikinaut

A significant advance was the development of wire wrapping, where a small gauge wire is literally wrapped around a post at each connection point, creating a gas-tight connection which is highly durable and easily changeable.

As electronics moved from vacuum tubes and relays to silicon and integrated circuits, the size and cost of electronic components began to decrease. Electronics became more prevalent in consumer goods, and the pressure to reduce the size and manufacturing costs of electronic products drove manufacturers to look for better solutions. Thus was born the PCB.

LilyPad PCB

PCB is an acronym for printed circuit board. It is a board that has lines and pads that connect various points together. In the picture above, there are traces that electrically connect the various connectors and components to each other. A PCB allows signals and power to be routed between physical devices. Solder is the metal that makes the electrical connections between the surface of the PCB and the electronic components. Being metal, solder also serves as a strong mechanical adhesive.

Composition

A PCB is sort of like a layer cake or lasagna- there are alternating layers of different materials which are laminated together with heat and adhesive such that the result is a single object.

alt text

Let’s start in the middle and work our way out.

FR4

The base material, or substrate, is usually fiberglass. Historically, the most common designator for this fiberglass is “FR4”. This solid core gives the PCB its rigidity and thickness. There are also flexible PCBs built on flexible high-temperature plastic (Kapton or the equivalent).

You will find many different thickness PCBs; the most common thickness for SparkFun products is 1.6mm (0.063"). Some of our products- LilyPad boards and Arudino Pro Micro boards- use a 0.8mm thick board.

Perf board

Cheaper PCBs and perf boards (shown above) will be made with other materials such as epoxies or phenolics which lack the durability of FR4 but are much less expensive. You will know you are working with this type of PCB when you solder to it - they have a very distictive bad smell. These types of substrates are also typically found in low-end consumer electronics. Phenolics have a low thermal decomposition temperature which causes them to delaminate, smoke and char when the soldering iron is held too long on the board.

Copper

The next layer is a thin copper foil, which is laminated to the board with heat and adhesive. On common, double sided PCBs, copper is applied to both sides of the substrate. In lower cost electronic gadgets the PCB may have copper on only one side. When we refer to a double sided or 2-layer board we are referring to the number of copper layers (2) in our lasagna. This can be as few as 1 layer or as many as 16 layers or more.

Exposed Copper on PCB

PCB with copper exposed, no solder mask or silkscreen.

The copper thickness can vary and is specified by weight, in ounces per square foot. The vast majority of PCBs have 1 ounce of copper per square foot but some PCBs that handle very high power may use 2 or 3 ounce copper. Each ounce per square translates to about 35 micrometers or 1.4 thousandths of an inch of thickness of copper.

Soldermask

The layer on top of the copper foil is called the soldermask layer. This layer gives the PCB its green (or, at SparkFun, red) color. It is overlaid onto the copper layer to insulate the copper traces from accidental contact with other metal, solder, or conductive bits. This layer helps the user to solder to the correct places and prevent solder jumpers.

In the example below, the green solder mask is applied to the majority of the PCB, covering up the small traces but leaving the silver rings and SMD pads exposed so they can be soldered to.

Green Solder Mask

Soldermask is most commonly green in color but nearly any color is possible. We use red for almost all the SparkFun boards, white for the IOIO board, and purple for the LilyPad boards.

Silkscreen

The white silkscreen layer is applied on top of the soldermask layer. The silkscreen adds letters, numbers, and symbols to the PCB that allow for easier assembly and indicators for humans to better understand the board. We often use silkscreen labels to indicate what the function of each pin or LED.

PCB with silkscreen

Silkscreen is most commonly white but any ink color can be used. Black, gray, red, and even yellow silkscreen colors are widely available; it is, however, uncommon to see more than one color on a single board.

Terminology

Now that you’ve got an idea of what a PCB structure is, let’s define some terms that you may hear when dealing with PCBs:

  • Annular ring - the ring of copper around a plated through hole in a PCB.

Annular ring on resistor Annular ring on vias

Examples of annular rings.

  • DRC - design rule check. A software check of your design to make sure the design does not contain errors such as traces that incorrectly touch, traces too skinny, or drill holes that are too small.
  • Drill hit - places on a design where a hole should be drilled, or where they actually were drilled on the board. Inaccurate drill hits caused by dull bits are a common manufacturing issue.

Bad drill hits

Not so accurate, but functional drill hits.

  • Finger - exposed metal pads along the edge of a board, used to create a connection between two circuit boards. Common examples are along the edges of computer expansion or memory boards and older cartridge-based video games.
  • Mouse bites - an alternative to v-score for separating boards from panels. A number of drill hits are clustered close together, creating a weak spot where the board can be broken easily after the fact. See the SparkFun Protosnap boards for a good example.

LilyPad Protosnap with mouse bites

Mouse bites on the LilyPad ProtoSnap allow the PCB to be snapped apart easily.

  • Pad - a portion of exposed metal on the surface of a board to which a component is soldered.

PTH Pads SMD Pads

PTH (plated through-hole) pads on the left, SMD (surface mount device) pads on the right.

  • Panel - a larger circuit board composed of many smaller boards which will be broken apart before use. Automated circuit board handling equipment frequently has trouble with smaller boards, and by aggregating several boards together at once, the process can be sped up significantly.
  • Paste stencil - a thin, metal (or sometimes plastic) stencil which lies over the board, allowing solder paste to be deposited in specific areas during assembly.

Abe does a quick demonstration of how to line up a paste stencil and apply solder paste.

  • Pick-and-place - the machine or process by which components are placed on a circuit board.

Bob shows us the SparkFun MyData Pick and Place machine. It’s pretty awesome.

  • Plane - a continuous block of copper on a circuit board, define by borders rather than by a path. Also commonly called a “pour”.

PCB ground pour

Various portions of the PCB that have no traces but has a ground pour instead.

  • Plated through hole - a hole on a board which has an annular ring and which is plated all the way through the board. May be a connection point for a through hole component, a via to pass a signal through, or a mounting hole.

Plated through hole resistor

A PTH resistor inserted into the FabFM PCB, ready to be soldered. The legs of the resistor go through the holes. The plated holes can have traces connected to them on the front of the PCB and the rear of the PCB.

  • Pogo pin - spring-loaded contact used to make a temporary connection for test or programming purposes.

Pogo Pin

The popular pogo pin with pointed tip. We use tons of these on our test beds.

  • Reflow - melting the solder to create joints between pads and component leads.
  • Silkscreen - the letters, number, symbols, and imagery on a circuit board. Usually only one color is available, and resolution is usually fairly low.

Silkscreen

Silkscreen identifying this LED as the power LED.

  • Slot - any hole in a board which is not round. Slots may or may not be plated. Slots sometimes add to add cost to the board because they require extra cut-out time.

slot

Complex slots cut into the ProtoSnap - Pro Mini. There are also many mouse bites shown. Note: the corners of the slots cannot be made completely square because they are cut with a circular routing bit.

  • Solder paste - small balls of solder suspended in a gel medium which, with the aid of a paste stencil, are applied to the surface mount pads on a PCB before the components are placed. During reflow, the solder in the paste melts, creating electrical and mechanical joints between the pads and the component.

alt text

Solder paste on a PCB shortly before the components are placed. Be sure to read about paste stencil above as well.

  • Solder pot - a pot used to quickly hand solder boards with through hole components. Usually contains a small amount of molten solder into which the board is quickly dipped, leaving solder joints on all exposed pads.
  • Soldermask - a layer of protective material laid over the metal to prevent short circuits, corrosion, and other problems. Frequently green, although other colors (SparkFun red, Arduino blue, or Apple black) are possible. Occasionally referred to as “resist”.

alt text

Solder mask covers up the signal traces but leaves the pads to solder to.

  • Solder jumper - a small, blob of solder connecting two adjacent pins on a component on a circuit board. Depending on the design, a solder jumper can be used to connect two pads or pins together. It can also cause unwanted shorts.
  • Surface mount - construction method which allows components to be simply set on a board, not requiring that leads pass through holes in the board. This is the dominant method of assembly in use today, and allows boards to be populated quickly and easily.
  • Thermal - a small trace used to connect a pad to a plane. If a pad is not thermally relieved, it becomes difficult to get the pad to a high enough temperature to create a good solder joint. An improperly thermally relieved pad will feel “sticky” when you attempt to solder to it, and will take an abnormally long time to reflow.

thermal

On the left, a solder pad with two small traces (thermals) connecting the pin to the ground plane. On the right, a via with no thermals connecting it completely to the ground plane.

  • Thieving - hatching, gridlines, or dots of copper left in areas of a board where no plane or traces exist. Reduces difficulty of etching because less time in the bath is required to remove unneeded copper.
  • Trace - a continuous path of copper on a circuit board.

Traces on PCB

A small trace connecting the Reset pad to elsewhere on the board. A larger, thicker trace connects to the 5V power pin.

  • V-score- a partial cut through a board, allowing the board to be easily snapped along a line.
  • Via - a hole in a board used to pass a signal from one layer to another. Tented vias are covered by soldermask to protect them from being soldered to. Vias where connectors and components are to be attached are often untented (uncovered) so that they can be easily soldered.

alt text alt text

Front and back of the same PCB showing a tented via. This via brings the signal from the front side of the PCB, through the middle of the board, to the back side.

  • Wave solder - a method of soldering used on boards with through-hole components where the board is passed over a standing wave of molten solder, which adheres to exposed pads and component leads.

Designing Your Own!

How do you go about designing your own PCB? The ins and outs of PCB design are way too in depth to get into here, but if you really want to get started, here are some pointers:

  1. Find a CAD package: there are a lot of low-cost or free options out there on the market for PCB design. Things to consider when choosing a package:
    • Community support: are there a lot of people using the package? The more people using it, the more likely you are to find ready-made libraries with the parts you need.
    • Ease-of-use: if it’s painful to use it, you won’t.
    • Capability: some programs place limitations on your design- number of layers, number of components, size of board, etc. Most of them allow you to pay for a license to upgrade their capability.
    • Portability: some free programs do not allow you to export or convert your designs, locking you in to one supplier only. Maybe that’s a fair price to pay for convenience and price, maybe not.
  2. Look at other people’s layouts to see what they have done. Open Source Hardware makes this easier than ever.
  3. Practice, practice, practice.
  4. Maintain low expectations. Your first board design will have lots of problems. Your 20th board design will have fewer, but will still have some. You’ll never get rid of them all.
  5. Schematics are important. Trying to design a board without a good schematic in place first is an exercise in futility.

Finally, a few words on the utility of designing your own circuit boards. If you plan on making more than one or two of a given project, the payback on designing a board is pretty good- point-to-point wiring circuits on a protoboard is a hassle, and they tend to be less robust than purpose-designed boards. It also allows you to sell your design if it turns out to be popular.

(中文) PIR传感器相关知识

How PIRs Work

PIR sensors are more complicated than many of the other sensors explained in these tutorials (like photocells, FSRs and tilt switches) because there are multiple variables that affect the sensors input and output. To begin explaining how a basic sensor works, we'll use this rather nice diagram

The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR. The lens used here is not really doing much and so we see that the two slots can 'see' out past some distance (basically the sensitivity of the sensor). When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.

The PIR Sensor

The IR sensor itself is housed in a hermetically sealed metal can to improve noise/temperature/humidity immunity. There is a window made of IR-transmissive material (typically coated silicon since that is very easy to come by) that protects the sensing element. Behind the window are the two balanced sensors.

Image from RE200B datasheet

You can see above the diagram showing the element window, the two pieces of sensing material

Image from RE200B datasheet

This image shows the internal schematic. There is actually a JFET inside (a type of transistor) which is very low-noise and buffers the extremely high impedence of the sensors into something a low-cost chip (like the BIS0001) can sense.

Lenses

PIR sensors are rather generic and for the most part vary only in price and sensitivity. Most of the real magic happens with the optics. This is a pretty good idea for manufacturing: the PIR sensor and circuitry is fixed and costs a few dollars. The lens costs only a few cents and can change the breadth, range, sensing pattern, very easily.In the diagram up top, the lens is just a piece of plastic, but that means that the detection area is just two rectangles. Usually we'd like to have a detection area that is much larger. To do that, we use a simple lens such as those found in a camera: they condenses a large area (such as a landscape) into a small one (on film or a CCD sensor). For reasons that will be apparent soon, we would like to make the PIR lenses small and thin and moldable from cheap plastic, even though it may add distortion. For this reason the sensors are actually Fresnel lenses:

Image from Sensors Magazine

The Fresnel lens condenses light, providing a larger range of IR to the sensor.

Image from Cypress appnote 2105

OK, so now we have a much larger range. However, remember that we actually have two sensors, and more importantly we dont want two really big sensing-area rectangles, but rather a scattering of multiple small areas. So what we do is split up the lens into multiple section, each section of which is a fresnel lens.

Here you can see the multiple facet-sections

This macro shot shows the different Frenel lenses in each facet!

The different faceting and sub-lenses create a range of detection areas, interleaved with each other. Thats why the lens centers in the facets above are 'inconsistant' - every other one points to a different half of the PIR sensing element

Connecting to a PIR

Most PIR modules have a 3-pin connection at the side or bottom. The pinout may vary between modules so triple-check the pinout! It's often silkscreened on right next to the connection (at least, ours is!) One pin will be ground, another will be signal and the final one will be power. Power is usually 3-5VDC input but may be as high as 12V. Sometimes larger modules don't have direct output and instead just operate a relay in which case there is ground, power and the two switch connections.

The output of some relays may be 'open collector' - that means it requires a pullup resistor. If you're not getting a variable output be sure to try attaching a 10K pullup between the signal and power pins.

An easy way of prototyping with PIR sensors is to connect it to a breadboard since the connection port is 0.1" spacing. Some PIRs come with header on them already, the one's from adafruit have a straight 3-pin header on them for connecting a cable

For our PIR's the red cable is + voltage power, black cable is - ground power and yellow is the signal out. Just make sure you plug the cable in as shown above! If you get it backwards you won't damage the PIR but it won't work.

Testing a PIR

Now when the PIR detects motion, the output pin will go "high" to 3.3V and light up the LED!

Once you have the breadboard wired up, insert batteries and wait 30-60 seconds for the PIR to 'stabilize'. During that time the LED may blink a little. Wait until the LED is off and then move around in front of it, waving a hand, etc, to see the LED light up!

Retriggering

There's a couple options you may have with your PIR. First up we'll explore the 'Retriggering' option.

Once you have the LED blinking, look on the back of the PIR sensor and make sure that the jumper is placed in the L position as shown below.

Now set up the testing board again. You may notice that when connecting up the PIR sensor as above, the LED does not stay on when moving in front of it but actually turns on and off every second or so. That is called "non-retriggering".
Now change the jumper so that it is in the H position. If you set up the test, you will notice that now the LED does stay on the entire time that something is moving. That is called "retriggering".

(The graphs above are from the BISS0001 datasheet, they kinda suck)

For most applications, "retriggering" (jumper in H position as shown below) mode is a little nicer.

If you need to connect the sensor to something edge-triggered, you'll want to set it to "non-retriggering" (jumper in L position).

Changing sensitivity

The Adafruit PIR has a trimpot on the back for adjusting sensitivity. You can adjust this if your PIR is too sensitive or not sensitive enough - clockwise makes it more sensitive.

Changing Pulse Time and Timeout Length

There are two 'timeouts' associated with the PIR sensor. One is the "Tx" timeout: how long the LED is lit after it detects movement - this is easy to adjust on Adafruit PIR's because there's a potentiometer.

The second is the "Ti" timeout which is how long the LED is guaranteed to be off when there is no movement. This one is not easily changed but if you're handy with a soldering iron it is within reason.First, lets take a look at the BISS datasheet again

On Adafruit PIR sensors, there's a little trim potentiometer labeled TIME. This is a 1 Megaohm adjustable resistor which is added to a 10K series resistor. And C6 is 0.01uF so

Tx = 24576 x (10K + Rtime) x 0.01uF

If the Rtime potentiometer is turned all the way down counter-clockwise (to 0 ohms) then

Tx = 24576 x (10K) x 0.01uF = 2.5 seconds (approx)

If the Rtime potentiometer is turned all the way up clockwise to 1 Megaohm then

Tx = 24576 x (1010K) x 0.01uF = 250 seconds (approx)

If RTime is in the middle, that'd be about 120 seconds (two minutes) so you can tweak it as necessary. For example if you want motion from someone to turn on a fan for a minimum of 1 minute, set the Rtime potentiometer to about 1/4 the way around.

For older/other PIR sensors

If you have a PIR sensor from somewhere else that does not have a potentiometer adjust, you can trace out the adjustment resistors this way:

Determining R10 and R9 isnt too tough. Unfortunately this PIR sensor is mislabeled (it looks like they swapped R9 R17). You can trace the pins by looking at the BISS001 datasheet and figuring out what pins they are - R10 connects to pin 3 and R9 connects to pin 7. the capacitors are a little tougher to determine, but you can 'reverse engineer' them from timing the sensor and solving!

For example:

Tx is = 24576 * R10 * C6 = ~1.2 seconds
R10 = 4.7K and C6 = 10nF

Likewise,

Ti = 24 * R9 * C7 = ~1.2 seconds
R9 = 470K and C7 = 0.1uF

Using a PIR

Reading PIR Sensors

Connecting PIR sensors to a microcontroller is really simple. The PIR acts as a digital output so all you need to do is listen for the pin to flip high (detected) or low (not detected).Its likely that you'll want reriggering, so be sure to put the jumper in the H position!

Power the PIR with 5V and connect ground to ground. Then connect the output to a digital pin. In this example we'll use pin 2.

The code is very simple, and is basically just keeps track of whether the input to pin 2 is high or low. It also tracks the state of the pin, so that it prints out a message when motion has started and stopped.
  1. /*
  2. * PIR sensor tester
  3. */
  4. int ledPin = 13; // choose the pin for the LED
  5. int inputPin = 2; // choose the input pin (for PIR sensor)
  6. int pirState = LOW; // we start, assuming no motion detected
  7. int val = 0; // variable for reading the pin status
  8. void setup() {
  9. pinMode(ledPin, OUTPUT); // declare LED as output
  10. pinMode(inputPin, INPUT); // declare sensor as input
  11. Serial.begin(9600);
  12. }
  13. void loop(){
  14. val = digitalRead(inputPin); // read input value
  15. if (val == HIGH) { // check if the input is HIGH
  16. digitalWrite(ledPin, HIGH); // turn LED ON
  17. if (pirState == LOW) {
  18. // we have just turned on
  19. Serial.println("Motion detected!");
  20. // We only want to print on the output change, not state
  21. pirState = HIGH;
  22. }
  23. } else {
  24. digitalWrite(ledPin, LOW); // turn LED OFF
  25. if (pirState == HIGH){
  26. // we have just turned of
  27. Serial.println("Motion ended!");
  28. // We only want to print on the output change, not state
  29. pirState = LOW;
  30. }
  31. }
  32. }
Don't forget that there are some times when you don't need a microcontroller. A PIR sensor can be connected to a relay (perhaps with a transistor buffer) without a micro!

Make Your Own Fritzing Parts 

What is Fritzing?

Fritzing Logo

Fritzing is a great open source tool for anyone to teach, share, and prototype their electronic projects! It allows you to design a schematic, and thus a part, which can then be added to very professional-looking wiring diagrams. You can even design your own PCBs and have them fabricated from the files you design. Here at SparkFun, we use Fritzing in the classrooms, our hook-up guides, and any other place we need to show how to hook-up our boards to other hardware.

Fritzing Hookup Example

Fritzing example of the INA169 connected to an Arduino

The awesome thing about Fritzing is that you can make your own Fritzing parts for your project and share with the community! This tutorial is going to go over how to make a custom Fritzing part in the Fritzing (New) Parts Editor, starting from the beginning.

Do You Need to Make a Custom Fritzing Part?

Fritzing comes with tons of electronic parts already installed with the software. SparkFun also has a Fritzing Github repofor housing parts we’ve created not already in Fritzing. Before creating your own part, double check to see if it exists in those two locations or if another Fritzing user already made the part you need on the Fritzing forum. It will save you a lot of time if the part is already made! However, if you’re certain that the part you need doesn’t live in Fritzing land already, read on!

Suggested Reading

This tutorial assumes that you are already familiar with Adobe Illustrator, Inscape, or both. Using these programs is beyond the scope of this tutorial. If you need more info on how to use eithwer of these programs, their respective websites should have lots of tutorials and guides on how to get started with vector graphics. If that fails, there’s always Google.

Here are other related tutorials you may want to check out before reading this one:

Download and Install

You will need to download and install the following software in order to follow along and make your own custom Fritzing part.

Please Note: If you only need to make a basic IC, Fritzing (New) Parts Editor allows you to make custom ICs easily, and you won’t need to download a vector graphic editor. You can still follow along, since this tutorial will be building off a custom IC in the Fritzing (New) Parts Editor.

Fritzing

Go to the download page on the Fritzing site to download the latest Fritzing version for your OS. Find where you want to put the Fritzing application on your hard drive, and unzip the Fritzing folder in that location.

Vector Graphics Editor

There is a lot of different types of vector graphics editors out there. The vector graphics editors we use here at SparkFun are Adobe Illustrator and Inkscape. Choose the one you are the most familiar and comfortable with. If you don’t have a vector graphics editor, Inkscape is a great open source choice, and it is free.

Inkscape

Inkscape Logo

Go to the Inkscape download page and download the appropriate Official Release Package for your computer.

Windows Users: Double click on the executable. Follow along the Inkscape Setup Wizard.

Mac OS X Users: Follow along the newest instructions on the Inkscape site.

Adobe Illustrator

Adobe Illustrator Logo

Adobe Illustrator is not free, but if you already have the Adobe Creative Cloud you can download it. You can also purchase an Illustrator monthly membership.

Please Note: We have no affiliation with Adobe and are only promoting Illustrator because it is a great piece of software that works well for what we need in this tutorial.

Other Downloads

Fritzing Fonts and Templates

Fritzing uses the OCR-A font for ICs. For all the other parts you can use OCR-A and Droid Sans fonts. Fritzing has fonts and templates available for download on their site. You will need to download Fritzing's Graphic Standards to follow this tutorial. Go to their template download page, and download the Fritzing's Graphic Standards folder. After you download their zip file, you will need to make sure to unzip the folder, and place anywhere on your computer. You will want to install the fonts on your computer.

SparkFun Fritzing Example Templates

This tutorial will reference the SparkFun Fritzing Example Templates a lot. If you are making a Fritzing part for a SparkFun board or want a starting point, download this set of example templates from the SparkFun Fritzing Parts Github repo. The SparkFun Fritzing templates will have this tutorial's example, SparkFun T5403 Barometer Breakout SVG, files to compare and work with.

Breadboard View

When the Fritzing starts up, you should be in the Welcome view. You will want to go to Breadboard view.

breadboard view

There is two main steps you will need to do in Breadboard view. First, create your breadboard SVG, and upload it. Fritzing prefers using SVG format, so your images look great when you are zoomed in and out! Second, you’ll need to change the connector pins.

Please note: If you are only making a basic IC you can skip to Editing Breadboard View section of this tutorial.

Fritzing Graphic Standards

On the Fritzing website, there are a lot of graphic standards to follow. It is a great idea to follow the graphic standards that way your parts match other Fritzing parts.

Templates

When making you part, it is recommended to start from a template. Have an image of the part to refer to, so, when making your SVG files, the process will go faster.

Tip: If you are making a custom Fritzing part for a board you made in EAGLE, you can download an ULP that converts boards to SVG. This way you can have an accurate SVG of your EAGLE board for a reference. You can find EAGLE ULPs on the Cadsoft site.

It is time to make your graphic for the Breadboard view!

Create a New Part

For this tutorial, we are going to create a Fritzing part for the SparkFun T5403 Barometer Breakout.

T5403 Breakout Image

EAGLE image of the SparkFun T5403 Barometer Breakout

Open the Fritzing application. You should see tabs for Welcome, Breadboard, Schematic, and PCB towards the top of the program. Click on Breadboard button to make sure you are in the Breadboard view.

Breadboard Button

Check for Pre-made Parts

If you are just updating a board in Fritzing, first check to see if there is a part that is closely related to the Fritzing part you are trying to create. You can type the part's name into the search bar.

Search for Part

The search bar can be found at the top of the Parts window

You can also look in the different sections of the Fritzing's Parts window for a similar part.

Parts Window

Look for the SparkFun flame to see a huge section of SparkFun Fritzing parts

Using an IC as a Starting Point

If there is not a part like the one you are trying to make, using an IC as a base is a great place to start. Click on the CORE tab in the Part Window. Scroll down until you see the ICs. Under the ICs section, click and drag the IC icon onto the Breadboard window.

Core Tab

Custom ICs are simple, since Fritzing lets you change the number of pins and the IC package

Dragging IC on breadboard window

Changing the Name of the IC

Look for the IC properties in the Inspector window on the right. Change the name of the IC to your part's name. Then, change the number of pins needed for the board or part in the pins section. For the SparkFun T5403 Barometer Breakout, we need 8 pins. You will see the IC, in the Breadboard view, change to your part’s name.

Changing name

Fritzing (New) Parts Editor

Right-click the IC in the Breadboard window, and select Edit (new parts editor). The Fritzing (New) Parts Editor should pop up.

Go to Parts Editor

There are 6 main sections of the Fritzing (New) Parts Editor in which you will need to make changes. Those are:

  • Breadboard
  • Schematic
  • PCB
  • Icon
  • Metadata
  • Connectors

There really isn't an order you need to follow. After making a couple different custom parts you will probably end up starting in one view before the others. In this tutorial, we’re just going to go down the list.

Author note: I found, for boards with a large number of pins, that starting off in the Connectors view saves a little bit more time, since you can go down the list to name the connector pins faster.

Before you continue on, it is a good idea to save as a new part first. If you need to stop anytime when making the custom part, you can come back to it in the future. Go to File. Then, select Save as new part.

Save as new Part

You can choose to name the prefix if you want.


Let's continue on to Breadboard view!

Custom Breadboard SVG

Create a File

Open up your vector graphics editor and create a new file. The image size of the file should be the same size of your board. The SparkFun T5403 Barometer Breakout size is 1" x 0.650". You are going to want to save the file with a good naming convention, since you are going to end up needing 3 different svg files when creating your Fritzing part.

Illustrator Users: You can save by going to File->Save As, saving as a SVG, and hitting Save.

For this example the Breadboard SVG is named: SFE_T5403_Barometer_Breakout_breadboard.svg

Use Templates as References

To compare the different layers and groups, you can open up the Fritzing BreadboardViewGraphic_Template.svg file found in the Fritzing Fonts and Template folder you downloaded earlier. You can also open the example SparkFun T5403 Barometer Breakout breadboard SVG template file from the SparkFun Fritzing Parts Github repo.

You can see with the example templates how you can kept the layers organized. For the SparkFun T5403 Barometer Breakout, there is a “breadboard” group. Inside that breadboard group it will have the group of parts, copper layers, silkscreen group, and the board path.

Tips for Making Your Custom Breadboard Graphic

You are now able to create your custom part’s breadboard graphic. Here are some helpful tips!

Follow the Fritzing Graphic Standards

Here are some main color standards for Breadboard images:

To keep with the Fritzing graphics standards, you are going to want to make the copper contacts the copper/tinned color.

Copper Green

HEX: 9A916C, RGB: 154 145 108

If you have legs on any of your parts on your board, the color to use is grey.

Leg Grey

HEX: 8C8C8C, RGB: 140 140 140

SparkFun Red is: HEX: E62C2E, RGB: 230 44 46

Keep It Simple

The great thing with Fritzing is you can make your board as simple or as complex as you want. Since SparkFun is always trying to make our products better with revisions and have a lot of boards, it is easier and faster for us to not included certain details, like traces or every component, on our boards. That way if there is a new change with the board, like a resistor value change, we don't have to go in and change that resistor in the Fritzing part. Focusing more on the important components, like ICs, might be a better way to spend your tine. It will still look nice, but less work!

Use Components That Already Exist

If you need an SMD LED on your board that is already in Fritzing, go ahead and use it! This will save you time and keep the all the Fritzing parts having the same look and feel. If you create a custom board with components that others can use, you can share them on the Fritzing site, so others can use too! Make sure to organize the component graphics nicely in the vector graphics editor you are using, so the parts are easy to find when using on future boards.

Name Connector Pins in Copper Groups

Naming your connectors will be a huge time saver. For the SparkFun T5403 Barometer Breakout example, under the copper group, each connector is named connector#pad.

Copper Layers

Example in Illustrator. If you are using Inkscape, you will still want to make sure the connectors are appropriately named.

Use the ORC-A or Droid Sans Fonts.

Stick with the Fritzing fonts to kept all Fritzing parts looking alike. It is suggested that the standard font size is 5pt. However, there will be times you won't have space for smaller boards. You won't want to go lower then 3pt, because it starts to become harder to see without zooming in. On the Fritzing site they mention using black as the font color. Whatever your silkscreen color is tends to look better. For this example we are using white, since that is the breakout board's silkscreen color and it is easier to read against a red background.

Create a Compound Path to Make Board Openings See-through

Illustrator Users: Create a path in the size of your PCB. For the SparkFun T5403 Barometer Breakout, you can use the rectangle tool to make a 1" x 0.650" rectangle. Then, make paths where you have openings in your board. For example, you can use the ellipse tool, under the rectangle tool, to make perfect circles where there are openings for stand-offs and connector pins. Select all the hole opening layers and the bottom PCB layer.

Select All

Make sure the bottom PCB layer is selected

Next go to Object->Compound Path->Make. You should now have a compound path, and you will be able to see through the openings in Fritzing.

Final Breadboard Image

Final breadboard graphic

Save

Make sure to Save as SVG again once you are done creating your custom board! Now, you can continue on to Editing Breadboard View.

Breadboard View - Parts Editor

Load Image

After you created your custom breadboard image, you will want to load the breadboard SVG in the Fritzing (New) Parts Editor. First, go back to the Fritzing (New) Parts Editor and click the Breadboard button to get into the Breadboard view. Go to File->Load image for view.

Load graphic

Next, you will select the breadboard SVG you just created and hit Open. The graphic should be now in the Fritzing (New) Parts Editor.

Connectors

When working in the main Fritzing application, you connect different Fritzing parts with colored wires to show how the parts connect to one and another. In order for Fritzing to know where connector pins are on a board or part, you will need to tell Fritzing where those connectors are.

Name and Description for Connector Pins

For the Breadboard view, the Connectors window will be on the right side of the Fritzing (New) Parts Editor. Select a pin to change the name of the pin and to add a description.

Select Pin

Choose any of the connector pins to edit

Change Connector Pin Name

Select the Connector Pin's Graphic

Click on the Select graphic button on the right of your connector pin's name. Then, click on the connector pin's graphic. This will set the Anchor point. The Anchor point is the location where the wire connects to that connector. By default the Terminal point will show up in the middle of the selected graphic. If you want to move the Terminal point, you are able to click on the Terminal point and hold to move. You can also change the Terminal point by clicking on either “Center”, “W”, “N”, “S”, or “E” in the Connectors window.

Example Terminal Placement

You can see the difference in the placement of the wire when you change the Terminal point

Change Connector Type

Change the type of connector in the Connectors window. You can choose from male, female, or pad. For the SparkFun T5403 Barometer Breakout, all the connector pins are female.

Set Connector Type

In the image below, you can see the differences between setting the connector type as male vs female.

Different Connector Type

Top board has the connector type set at male. Bottom board has the connector type correctly set at female.

Repeat for All Connector Pins

Name, select the appropriate graphic, and change the connector type for all your connector pins. You can also set Internal Connections in the Connectors window.

Schematic View

Custom Schematic SVG

Go back to either Illustrator, Inkscape, or the vector graphic editor you are using. Open up the Fritzing's SchematicViewGraphic_Template.svg in the downloaded Fonts and Templates folder. You can also open the example SparkFun T5403 Barometer Breakout schematic SVG template file from the SparkFun Fritzing Parts Github repo.

When editing the schematic to match your board, you will want to make sure each connector pin is shown. You will want to change the pin labels to match the connector pin names. Depending on your part, you might have to resize the template schematic. Make sure there is 0.1” space between the main part symbol square and the edge of the outer pins.

Schematic Example

Make sure to delete the 0.1" dimension helper box, so it doesn’t show up in the final Fritzing schematic graphic

Save SVG

You will want make sure to save as a new SVG. Remember to have a naming convention that will be easy to tell the difference between the other SVG files you are creating for your Fritzing part.

Editing Schematic View in Parts Editor

Load SVG

Go back to the Parts Editor, and click on the Schematic button to go to the Schematic view. Go to File->Load image for view. Next, you will select the schematic SVG you just created, and click Open. The part should be now in the Fritzing (New) Parts Editor.

Set Connector Pins

If you look at the Connectors window on the right side, you will notice that your pin names are already there. When you make a change to the connector pin's name and description in either Breadboard, Schematic, PCB, or Connectors view, the Parts Editor will automatically change the connector pin's name and description for the other views. Also, the connector type (male, female, or pad) will still be the same.

Just like you did in Breadboard view, you will still need to select a graphic for each pin. Click on the ‘Select graphic’ button, and choose the appropriate graphic for that pin. For the Schematic view, you are going to want to change the Terminal point, so the connecting wires are connecting at the furthest point.

The easiest way to do this is make sure the connector pin’s graphic is still selected, and change the Terminal point in the Connectors window. For the GND graphic, the Terminal point is moved to the south end by clicking on “S”.

Terminal Point

Repeat for All Connectors

After you update all your connector pins you can move on to Editing in PCB view.

PCB View

Making custom PCB SVG

Go back to either Illustrator, Inkscape, or the vector graphic editor you are using. When making a custom PCB SVG, the main image groups you will need are copper (which will have all your connector pads) and silkscreen.

Create the PCB Graphic

You can either start fresh when creating a PCB SVG, modify your custom breadboard SVG, or edit the Fritzing's PCBViewGraphic_Template.svg in the downloaded Fonts and Templates folder. For this example, the custom breadboard SVG was modified, and the file was saved as a new SVG called SFE_T5403_Barometer_Breakout_PCB.svg.

Make Sure to have Two Copper Groups

When setting up your layers, make sure to have two copper groups. All of your connector layers should be in the copper groups. When you do this, Fritzing will know that the component has the copper connectors on both sides of the PCB.

Example of PCB Layers

Illustrator example of having two copper groups

Make Sure the Connector Pins' Spacing is Accurate

It is important to have the PCB connector pins match accurately with your board and to have the appropriate spacing between pins. Fritzing offers a PCB Fab services. If you or other Fritzing users want to use that service with your custom part, you will want to make sure your PCB view is accurate.

Graphic Standards

Instead of the connector pins being a copper/tinned green color, the PCB view connector pins are the “copper” color:

Copper Color

Hex: F7BD13 RGB: 247 189 19

The main changes made from the custom breadboard SVG is that the main groups are copper and silkscreen. The silkscreen will still be white.

Final PCB Graphic

Final PCB Graphic

Editing PCB View in Parts Editor

Go back to the Parts Editor, and click on the PCB button to get to PCB view. Go to File->Load image for view. Next, you will select the PCB SVG you just created, and click Open. The part should be now in the Fritzing (New) Parts Editor.

Update Connector Pins

Select the appropriate graphics for each connector pin, just like you did in Breadboard and Schematic view.

Icon View

Reuse a Past Graphic

Go to the Fritzing (New) Parts Editor, and click on the Icon button to get to Icon view. The great thing about Icon view is that you can reuse your breadboard, schematic, or PCB SVG for the icon image, so there is no need to make a new image! All you need to do is go to File and select what image you want to reuse. For the SparkFun T5403 Barometer Breakout, the Icon view reuses the breadboard image. The breadboard image should show up.

Reuse Past Graphic

Great Scott! You are now done with Icon view!

Metadata

Go to Metadata View

Go to the Parts Editor, and click the Metadata button to go into Metadata view. The Metadata is where you will add all the important information about your part!

Different Sections in the Metadata View

Title: Pretty self-explanatory. This is going to be the name of your part.

Date: The date entry is locked in Fritzing. The date should show the date you are creating the part. If you update the part later down the road, the date will be changed to the current date of the last update.

Author: You will want to put your name in here, so, if you share your part with the Fritzing community, they know who made the part.

Description: Description should included anything that is important about the board, such as operating voltage.

Label: The Label is shown in Schematic view and makes it easier to tell which part you have selected. For the SparkFun T5403 Barometer Breakout, the Label is changed to Part. The reason for that is, because Part is fairly small and the SparkFun T5403 Barometer Breakout name is already on the schematic graphic itself. It is up to you what you want to label your part!

URL: Consider posting the url of the part, so anyone can get more information about your part.

Family: If you have a part that comes in different colors, chip packages, etc, you will want them to be in the same Family. For example if you have a through-hole LED that comes in different colors, all the different colors of the same LED will be in the same family.

Variant: When creating a brand new part, you want to make sure the Variant is 1. When you do revisions in the future, it will change the next revision to Variant 2 if it is in the same family.

Properties: A place to put important details like part numbers, pin spacing, and etc.

Tags: Use tags that can be found easier and best describe your part in as few words as possible.

Metadata

Feel that the info is a little lacking? You can update this content again later when you have more to write.

Connectors View

Go to Connectors view

Go to the Parts Editor, and click the Connectors button to go into Connectors view. In the Connectors view you are able to do the following:

  • Change the number of connectors
  • Set connector type
  • Set the connector pins as Through-hole or SMD
  • Name connector pins
  • Add connector pin descriptions

Connectors view

You shouldn't need to change anything in the Connectors view, since you already filled out all the information in the other views. If you need to make any last minute changes, now you can. Keep in mind, if you change the number of connectors here, you will need to go back and update Breadboard, Schematic, and PCB views.

Save

Now you can save your part! Go to File>Save

Continue on to exporting part!

Exporting New Part

Quality Check in Fritzing Application

It is time to check out your new Fritzing part in the main Fritzing application. When you Saved As new part in the Fritzing (New) Parts Editor earlier, the part automatically shows under the My Parts label in the MINE tab in the main Fritzing application.

Before exporting your new custom part, you will want to check if each view looks good. Make sure you are in the main Fritzing application and not the Fritzing (New) Parts Editor. Go to Breadboard view by clicking on the Breadboard button at the top. In the Parts window, on the right side, make sure you are in the MINE tab. You should see your new part. Click and drag the board on the Breadboard view.

MINE Tab

Double check if the pins are named correctly and are working properly. Do the same in the Schematic and PCB view. Once you have done a quality check, you can export the part.

Export part

Right click on the new part’s icon in the My Parts window and select Export Part. Save out your Fritzing part.

Export Part

Congratulations, you made your own Fritzing Part!

Resources and Going Further

Contribute to Fritzing

Now that you have your part done, you are able to connect with other Fritzing parts. You can share your part or a project tutorial on the Fritzing site. There are many more ways to contribute to the Fritzing community! Check out the Fritzing Support Us page for even more ways to support Fritzing.

Large Batches of Fritzing Parts?

If you are a developer that uses EAGLE or someone who is investing a lot of time in making Fritzing parts, the Fritzing team has open sourced a toolkit to make the SVG files from EAGLE .brd files. It is highly recommended that you check out if you are creating batches of SVG board files ready for Fritzing. They have the source code on the Fritzing Google code page.

Further Reading

At SparkFun, we use Fritzing at a lot in our Learn tutorials. Check out how we use Fritzing in different tutorials to show how to connect different parts together.

Here are some tutorials that uses Fritzing in the Hook-up section:

If you want to learn more about designing your own PCBs with other software, visit these tutorials:

Serial Peripheral Interface (SPI)

Introduction

Serial Peripheral Interface (SPI) is an interface bus commonly used to send data between microcontrollers and small peripherals such as shift registers, sensors, and SD cards. It uses separate clock and data lines, along with a select line to choose the device you wish to talk to.

Suggested Reading

Stuff that would be helpful to know before reading this tutorial:

What's Wrong with Serial Ports?

A common serial port, the kind with TX and RX lines, is called “asynchronous” (not synchronous) because there is no control over when data is sent or any guarantee that both sides are running at precisely the same rate. Since computers normally rely on everything being synchronized to a single “clock” (the main crystal attached to a computer that drives everything), this can be a problem when two systems with slightly different clocks try to communicate with each other.

To work around this problem, asynchronous serial connections add extra start and stop bits to each byte help the receiver sync up to data as it arrives. Both sides must also agree on the transmission speed (such as 9600 bits per second) in advance. Slight differences in the transmission rate aren’t a problem because the receiver re-syncs at the start of each byte.

Asynchronous serial waveform

(By the way, if you noticed that “11001010” does not equal 0x53 in the above diagram, kudos to your attention to detail. Serial protocols will often send the least significant bits first, so the smallest bit is on the far left. The lower nybble is actually 0011 = 0x3, and the upper nybble is 0101 = 0x5.)

Asynchronous serial works just fine, but has a lot of overhead in both the extra start and stop bits sent with every byte, and the complex hardware required to send and receive data. And as you’ve probably noticed in your own projects, if both sides aren’t set to the same speed, the received data will be garbage. This is because the receiver is sampling the bits at very specific times (the arrows in the above diagram). If the receiver is looking at the wrong times, it will see the wrong bits.

A Synchronous Solution

SPI works in a slightly different manner. It’s a “synchronous” data bus, which means that it uses separate lines for data and a “clock” that keeps both sides in perfect sync. The clock is an oscillating signal that tells the receiver exactly when to sample the bits on the data line. This could be the rising (low to high) or falling (high to low) edge of the clock signal; the datasheet will specify which one to use. When the receiver detects that edge, it will immediately look at the data line to read the next bit (see the arrows in the below diagram). Because the clock is sent along with the data, specifying the speed isn’t important, although devices will have a top speed at which they can operate (We’ll discuss choosing the proper clock edge and speed in a bit).

alt text

One reason that SPI is so popular is that the receiving hardware can be a simple shift register. This is a much simpler (and cheaper!) piece of hardware than the full-up UART (Universal Asynchronous Receiver / Transmitter) that asynchronous serial requires.

Receiving Data

You might be thinking to yourself, self, that sounds great for one-way communications, but how do you send data back in the opposite direction? Here’s where things get slightly more complicated.

In SPI, only one side generates the clock signal (usually called CLK or SCK for Serial ClocK). The side that generates the clock is called the “master”, and the other side is called the “slave”. There is always only one master (which is almost always your microcontroller), but there can be multiple slaves (more on this in a bit).

When data is sent from the master to a slave, it’s sent on a data line called MOSI, for “Master Out / Slave In”. If the slave needs to send a response back to the master, the master will continue to generate a prearranged number of clock cycles, and the slave will put the data onto a third data line called MISO, for “Master In / Slave Out”.

alt text

Notice we said “prearranged” in the above description. Because the master always generates the clock signal, it must know in advance when a slave needs to return data and how much data will be returned. This is very different than asynchronous serial, where random amounts of data can be sent in either direction at any time. In practice this isn’t a problem, as SPI is generally used to talk to sensors that have a very specific command structure. For example, if you send the command for “read data” to a device, you know that the device will always send you, for example, two bytes in return. (In cases where you might want to return a variable amount of data, you could always return one or two bytes specifying the length of the data and then have the master retrieve the full amount.)

Note that SPI is “full duplex” (has separate send and receive lines), and, thus, in certain situations, you can transmit and receive data at the same time (for example, requesting a new sensor reading while retrieving the data from the previous one). Your device’s datasheet will tell you if this is possible.

Slave Select (SS)

There’s one last line you should be aware of, called SS for Slave Select. This tells the slave that it should wake up and receive / send data and is also used when multiple slaves are present to select the one you’d like to talk to.

alt text

The SS line is normally held high, which disconnects the slave from the SPI bus. (This type of logic is known as “active low,” and you’ll often see used it for enable and reset lines.) Just before data is sent to the slave, the line is brought low, which activates the slave. When you’re done using the slave, the line is made high again. In a shift register, this corresponds to the “latch” input, which transfers the received data to the output lines.

Multiple slaves

There are two ways of connecting multiple slaves to an SPI bus:

  1. In general, each slave will need a separate SS line. To talk to a particular slave, you’ll make that slave’s SS line low and keep the rest of them high (you don’t want two slaves activated at the same time, or they may both try to talk on the same MISO line resulting in garbled data). Lots of slaves will require lots of SS lines; if you’re running low on outputs, there are binary decoder chips that can multiply your SS outputs.

alt text

  1. On the other hand, some parts prefer to be daisy-chained together, with the MISO (output) of one going to the MOSI (input) of the next. In this case, a single SS line goes to all the slaves. Once all the data is sent, the SS line is raised, which causes all the chips to be activated simultaneously. This is often used for daisy-chained shift registers and addressable LED drivers.

alt text

Note that, for this layout, data overflows from one slave to the next, so to send data to any one slave, you’ll need to transmit enough data to reach all of them. Also, keep in mind that the first piece of data you transmit will end up in the last slave.

This type of layout is typically used in output-only situations, such as driving LEDs where you don’t need to receive any data back. In these cases you can leave the master’s MISO line disconnected. However, if data does need to be returned to the master, you can do this by closing the daisy-chain loop (blue wire in the above diagram). Note that if you do this, the return data from slave 1 will need to pass through all the slaves before getting back to the master, so be sure to send enough receive commands to get the data you need.

Programming for SPI

Many microcontrollers have built-in SPI peripherals that handle all the details of sending and receiving data, and can do so at very high speeds. The SPI protocol is also simple enough that you (yes, you!) can write your own routines to manipulate the I/O lines in the proper sequence to transfer data. (A good example is on the Wikipedia SPI page.)

If you’re using an Arduino, there are two ways you can communicate with SPI devices:

  1. You can use the shiftIn() and shiftOut() commands. These are software-based commands that will work on any group of pins, but will be somewhat slow.
  2. Or you can use the SPI Library, which takes advantage of the SPI hardware built into the microcontroller. This is vastly faster than the above commands, but it will only work on certain pins.

You will need to select some options when setting up your interface. These options must match those of the device you’re talking to; check the device’s datasheet to see what it requires.

  • The interface can send data with the most-significant bit (MSB) first, or least-significant bit (LSB) first. In the Arduino SPI library, this is controlled by the setBitOrder() function.
  • The slave will read the data on either the rising edge or the falling edge of the clock pulse. Additionally, the clock can be considered “idle” when it is high or low. In the Arduino SPI library, both of these options are controlled by the setDataMode() function.
  • SPI can operate at extremely high speeds (millions of bytes per second), which may be too fast for some devices. To accommodate such devices, you can adjust the data rate. In the Arduino SPI library, the speed is set by the setClockDivider() function, which divides the master clock (16MHz on most Arduinos) down to a frequency between 8MHz (/2) and 125kHz (/128).
  • If you’re using the SPI Library, you must use the provided SCK, MOSI and MISO pins, as the hardware is hardwired to those pins. There is also a dedicated SS pin that you can use (which must, at least, be set to an output in order for the SPI hardware to function), but note that you can use any other available output pin(s) for SS to your slave device(s) as well.
  • On older Arduinos, you’ll need to control the SS pin(s) yourself, making one of them low before your data transfer and high afterward. Newer Arduinos such as the Due can control each SS pin automatically as part of the data transfer; see the Due SPI documentation page for more information.

Resources and Going Further

Tips and Tricks

  • Because of the high speed signals, SPI should only be used to send data over short distances (up to a few feet). If you need to send data further than that, lower the clock speed, and consider using specialized driver chips.
  • If things aren’t working the way you think they should, a logic analyzer is a very helpful tool. Smart analyzers like the Saleae USB Logic Analyzer can even decode the data bytes for a display or logging.

alt text

Advantages of SPI:

  • It’s faster than asynchronous serial
  • The receive hardware can be a simple shift register
  • It supports multiple slaves

Disadvantages of SPI:

  • It requires more signal lines (wires) than other communications methods
  • The communications must be well-defined in advance (you can’t send random amounts of data whenever you want)
  • The master must control all communications (slaves can’t talk directly to each other)
  • It usually requires separate SS lines to each slave, which can be problematic if numerous slaves are needed.

Further Reading

Check out the Wikipedia page on SPI, which includes lots of good information on SPI and other synchronous interfaces.

This blog post presents a more correct way to set up an SPI network amongst your embedded devices, particularly for use with an Arduino microcontroller.

A number of SparkFun products have SPI interfaces. For example, the Bar Graph Breakout kit has an easy-to-use SPI interface that you can use to turn any of 30 LEDs on or off.

Other communication options:

Now that you’re a pro on SPI, here are some other tutorials to practice your new skills:

Series and Parallel Circuits

Series and Parallel Circuits

Simple circuits (ones with only a few components) are usually fairly straightforward for beginners to understand. But, things can get sticky when other components come to the party. Where’s the current going? What’s the voltage doing? Can this be simplified for easier understanding? Fear not, intrepid reader. Valuable information follows.

In this tutorial, we’ll first discuss the difference between series circuits and parallel circuits, using circuits containing the most basic of components – resistors and batteries – to show the difference between the two configurations. We’ll then explore what happens in series and parallel circuits when you combine different types of components, such as capacitors and inductors.

Covered in this Tutorial

  • What series and parallel circuit configurations look like
  • How passive components act in these configurations
  • How a voltage source will act upon passive components in these configurations

Suggested Reading

You may want to visit these tutorials on the basic components before diving into building the circuits in this tutorial.

Series Circuits

Nodes and Current Flow

Before we get too deep into this, we need to mention what a node is. It’s nothing fancy, just the electrical junction between two or more components. When a circuit is modeled on a schematic, the nodes are the wires between components.

Node example schematic

Example schematic with four uniquely colored nodes.

That’s half the battle towards understanding the difference between series and parallel. We also need to understand how current flows through a circuit. Current flows from a high voltage to a lower voltage in a circuit. Some amount of current will flow through every path it can take to get to the point of lowest voltage (usually called ground). Using the above circuit as an example, here’s how current would flow as it runs from the battery’s positive terminal to the negative:

Example of current flow through circuit

Current (indicated by the blue, orange, and pink lines) flowing through the same example circuit as above. Different currents are indicated by different colors.

Notice that in some nodes (like between R1 and R2) the current is the same going in as at is coming out. At other nodes (specifically the three-way junction between R2, R3, and R4) the main (blue) current splits into two different ones. That’s the key difference between series and parallel!

Series Circuits Defined

Two components are in series if they share a common node and if the same current flows through them. Here’s an example circuit with three series resistors:

Schematic: Three resistors in series

There’s only one way for the current to flow in the above circuit. Starting from the positive terminal of the battery, current flow will first encounter R1. From there the current will flow straight to R2, then to R3, and finally back to the negative terminal of the battery. Note that there is only one path for current to follow. These components are in series.

Parallel Circuits

Parallel Circuits Defined

If components share two common nodes, they are in parallel. Here’s an example schematic of three resistors in parallel with a battery:

Schematic: Three resistors in parallel

From the positive battery terminal, current flows to R1… and R2, and R3. The node that connects the battery to R1 is also connected to the other resistors. The other ends of these resistors are similarly tied together, and then tied back to the negative terminal of the battery. There are three distinct paths that current can take before returning to the battery, and the associated resistors are said to be in parallel.

Where series components all have equal currents running through them, parallel components all have the same voltage drop across them – series:current::parallel:voltage.

Series and Parallel Circuits Working Together

From there we can mix and match. In the next picture, we again see three resistors and a battery. From the positive battery terminal, current first encounters R1. But, at the other side of R1 the node splits, and current can go to both R2and R3. The current paths through R2 and R3 are then tied together again, and current goes back to the negative terminal of the battery.

Schematic: Series and Parallel Resistors

In this example, R2 and R3 are in parallel with each other, and R1 is in series with the parallel combination of R2 and R3.

Calculating Equivalent Resistances in Series Circuits

Here’s some information that may be of some more practical use to you. When we put resistors together like this, in series and parallel, we change the way current flows through them. For example, if we have a 10V supply across a 10kΩ resistor, Ohm’s law says we’ve got 1mA of current flowing.

Schematic: Single Resistor in series with battery

If we then put another 10kΩ resistor in series with the first and leave the supply unchanged, we’ve cut the current in half because the resistance is doubled.

Schematic: Two series resistors in series with a battery

In other words, there’s still only one path for current to take and we just made it even harder for current to flow. How much harder? 10kΩ + 10kΩ = 20kΩ. And, that’s how we calculate resistors in series – just add their values.

To put this equation more generally: the total resistance of N – some arbitrary number of – resistors is their total sum.

Schematic snippet: N resistors in series

Equation: Rtot = R1+R2+...+R(N-1)+RN

Calculating Equivalent Resistances in Parallel Circuits

What about parallel resistors? That’s a bit more complicated, but not by much. Consider the last example where we started with a 10V supply and a 10kΩ resistor, but this time we add another 10kΩ in parallel instead of series. Now there are two paths for current to take. Since the supply voltage didn’t change, Ohm’s Law says the first resistor is still going to draw 1mA. But, so is the second resistor, and we now have a total of 2mA coming from the supply, doubling the original 1mA. This implies that we’ve cut the total resistance in half.

Schematic: Two parallel resistors in parallel with a battery

While we can say that 10kΩ || 10kΩ = 5kΩ (“||” roughly translates to “in parallel with”), we’re not always going to have 2 identical resistors. What then?

The equation for adding an arbitrary number of resistors in parallel is:

1/Rtot = 1/R1 + 1/R2 + ... + 1/R(N-1) + 1/RN

If reciprocals aren’t your thing, we can also use a method called “product over sum” when we have two resistors in parallel:

R1||R2 = R1*R2/(R1+R2)

However, this method is only good for two resistors in one calculation. We can combine more than 2 resistors with this method by taking the result of R1 || R2 and calculating that value in parallel with a third resistor (again as product over sum), but the reciprocal method may be less work.

Experiment Time - Part 1

What you’ll need:

Let’s try a simple experiment just to prove that these things work the way we’re saying they do.

First, we’re going to hook up some 10kΩ resistors in series and watch them add in a most un-mysterious way. Using a breadboard, place one 10kΩ resistor as indicated in the figure and measure with a multimeter. Yes, we already know it’s going to say it’s 10kΩ, but this is what we in the biz call a “sanity check”. Once we’ve convinced ourselves that the world hasn’t changed significantly since we last looked at it, place another one in similar fashion but with a lead from each resistor connecting electrically through the breadboard and measure again. The meter should now say something close to 20kΩ.

You may notice that the resistance you measure might not be exactly what the resistor says it should be. Resistors have a certain amount of tolerance, which means they can be off by a certain percentage in either direction. Thus, you may read 9.99kΩ or 10.01kΩ. As long as it’s close to the correct value, everything should work fine.

Multimeter Fritzing Diagram

The reader should continue this exercise until convincing themselves that they know what the outcome will be before doing it again, or they run out of resistors to stick in the breadboard, whichever comes first.

Experiment Time - Part 2

Now let’s try it with resistors in a parallel configuration. Place one 10kΩ resistor in the breadboard as before (we’ll trust that the reader already believes that a single 10kΩ resistor is going to measure something close to 10kΩ on the multimeter). Now place a second 10kΩ resistor next to the first, taking care that the leads of each resistor are in electrically connected rows. But before measuring the combination, calculate by either product-over-sum or reciprocal methods what the new value should be (hint: it’s going to be 5kΩ). Then measure. Is it something close to 5kΩ? If it’s not, double check the holes into which the resistors are plugged.

Experiment: Measure parallel resistors with a multimeter

Repeat the exercise now with 3, 4 and 5 resistors. The calculated/measured values should be 3.33kΩ, 2.5kΩ and 2kΩ, respectively. Did everything come out as planned? If not, go back and check your connections. If it did, EXCELSIOR! Go have a milkshake before we continue. You’ve earned it.

Rules of Thumb for Series and Parallel Resistors

There are a few situations that may call for some creative resistor combinations. For example, if we’re trying to set up a very specific reference voltage you’ll almost always need a very specific ratio of resistors whose values are unlikely to be “standard” values. And while we can get a very high degree of precision in resistor values, we may not want to wait the X number of days it takes to ship something, or pay the price for non-stocked, non-standard values. So in a pinch, we can always build our own resistor values.

Tip #1: Equal Resistors in Parallel

Adding N like-valued resistors R in parallel gives us R/N ohms. Let’s say we need a 2.5kΩ resistor, but all we’ve got is a drawer full of 10kΩ’s. Combining four of them in parallel gives us 10kΩ/4 = 2.5kΩ.

Four 10kΩ Resistors in parallel can be used to create a 2.5kΩ one!

Tip #2: Tolerance

Know what kind of tolerance you can tolerate. For example, if you needed a 3.2kΩ resistor, you could put 3 10kΩ resistors in parallel. That would give you 3.3kΩ, which is about a 4% tolerance from the value you need. But, if the circuit you’re building needs to be closer than 4% tolerance, we can measure our stash of 10kΩ’s to see which are lowest values because they have a tolerance, too. In theory, if the stash of 10kΩ resistors are all 1% tolerance, we can only get to 3.3kΩ. But part manufacturers are known to make just these sorts of mistakes, so it pays to poke around a bit.

Tip #3: Power Ratings in Series/Parallel

This sort of series and parallel combination of resistors works for power ratings, too. Let’s say that we need a 100Ω resistor rated for 2 watts (W), but all we’ve got is a bunch of 1kΩ quarter-watt (¼W) resistors (and it’s 3am, all the Mountain Dew is gone, and the coffee’s cold). You can combine 10 of the 1kΩ’s to get 100Ω (1kΩ/10 = 100Ω), and the power rating will be 10x0.25W, or 2.5W. Not pretty, but it will get us through a final project, and might even get us extra points for being able to think on our feet.

We need to be a little more careful when we combine resistors of dissimilar values in parallel where total equivalent resistance and power ratings are concerned. It should be completely obvious to the reader, but…

Tip #4: Different Resistors in Parallel

The combined resistance of two resistors of different values is always less than the smallest value resistor. The reader would be amazed at how many times someone combines values in their head and arrives at a value that’s halfway between the two resistors (1kΩ || 10kΩ does NOT equal anything around 5kΩ!). The total parallel resistance will always be dragged closer to the lowest value resistor. Do yourself a favor and read tip #4 10 times over.

Tip #5: Power Dissipation in Parallel

The power dissipated in a parallel combination of dissimilar resistor values is not split evenly between the resistors because the currents are not equal. Using the previous example of (1kΩ || 10kΩ), we can see that the 1kΩ will be drawing 10X the current of the 10kΩ. Since Ohm’s Law says power = voltage x current, it follows that the 1kΩ resistor will dissipate 10X the power of the 10kΩ.

Ultimately, the lessons of tips 4 and 5 are that we have to pay closer attention to what we’re doing when combining resistors of dissimilar values in parallel. But tips 1 and 3 offer some handy shortcuts when the values are the same.

Series and Parallel Capacitors

Combining capacitors is just like combining resistors…only the opposite. As odd as that sounds, it’s absolutely true. Why would this be?

A capacitor is just two plates spaced very close together, and it’s basic function is to hold a whole bunch of electrons. The greater the value of capacitance, the more electrons it can hold. If the size of the plates is increased, the capacitance goes up because there’s physically more space for electrons to hang out. And if the plates are moved farther apart, the capacitance goes down, because the electric field strength between them goes down as the distance goes up.

Now let’s say we’ve got two 10µF capacitors wired together in series, and let’s say they’re both charged up and ready discharge into the friend sitting next to you.

Capacitors in series

Remember that in a series circuit there’s only one path for current to flow. It follows that the number of electrons that are discharging from the cap on the bottom is going to be the same number of electrons coming out of the cap on the top. So the capacitance hasn’t increased, has it?

In fact, it’s even worse than that. By placing the capacitors in series, we’ve effectively spaced the plates farther apart because the spacing between the plates of the two capacitors adds together. So we don’t have 20µF, or even 10µF. We’ve got 5µF. The upshot of this is that we add series capacitor values the same way we add parallel resistor values. Both the product-over-sum and reciprocal methods are valid for adding capacitors in series.

Capacitors in series schematic/equation

It may seem that there’s no point to adding capacitors in series. But it should be pointed out that one thing we did get is twice as much voltage (or voltage ratings). Just like batteries, when we put capacitors together in series the voltages add up.

Adding capacitors in parallel is like adding resistors in series: the values just add up, no tricks. Why is this? Putting them in parallel effectively increases the size of the plates without increasing the distance between them. More area equals more capacitance. Simple.

Capacitors in parallel schematic/equation

Experiment Time - Part 3

What you’ll need:

Let’s see some series and parallel connected capacitors in action. This will be a little trickier than the resistor examples, because it’s harder to measure capacitance directly with a multimeter.

Let’s first talk about what happens when a capacitor charges up from zero volts. When current starts to go in one of the leads, an equal amount of current comes out the other. And if there’s no resistance in series with the capacitor, it can be quite a lot of current. In any case, the current flows until the capacitor starts to charge up to the value of the applied voltage, more slowly trickling off until the voltages are equal, when the current flow stops entirely.

As stated above, the current draw can be quite large if there’s no resistance in series with the capacitor, and the time to charge can be very short (like milliseconds or less). For this experiment, we want to be able to watch a capacitor charge up, so we’re going to use a 10kΩ resistor in series to slow the action down to a point where we can see it easily. But first we need to talk about what an RC time constant is.

Tau = R*C

What the above equation says is that one time constant in seconds (called tau) is equal to the resistance in ohms times the capacitance in farads. Simple? No? We shall demonstrate on the next page.

Experiment Time - Part 3, Continued...

For the first part of this experiment, we’re going to use one 10K resistor and one 100µF (which equals 0.0001 farads). These two parts create a time constant of 1 second:

Tau = 10kOhm * 100uF = 1 second

When charging our 100µF capacitor through a 10kΩ resistor, we can expect the voltage on the cap to rise to about 63% of the supply voltage in 1 time constant, which is 1 second. After 5 time constants (5 seconds in this case) the cap is about 99% charged up to the supply voltage, and it will follow a charge curve something like the plot below.

Capacitor charge time graph

Now that we know that stuff, we’re going to connect the circuit in the diagram (make sure to get the polarity right on that capacitor!).

Fritzing diagram, power off, cap in series with resistor, battery

With our multimeter set to measure volts, check the output voltage of the pack with the switch turned on. That’s our supply voltage, and it should be something around 4.5V (it’ll be a bit more if the batteries are new). Now connect the circuit, taking care that the switch on the battery pack is in the “OFF” position before plugging it into the breadboard. Also, take care that the red and black leads are going to the right places. If it’s more convenient, you can use alligator clips to attach the meter probes to the legs of the capacitor for measurement (you can also spread those legs out a bit to make it easier).

Once we’re satisfied that the circuit looks right and our meter’s on and set to read volts, flip the switch on the battery pack to “ON”. After about 5 seconds, the meter should read pretty close to the battery pack voltage, which demonstrates that the equation is right and we know what we’re doing. Now turn the switch off. It’s still holding that voltage pretty well, isn’t it? That’s because there’s no path for current to discharge the capacitor; we’ve got an open circuit. To discharge the cap, you can use another 10K resistor in parallel. After about 5 seconds, it will be back to pretty close to zero.

Experiment Time - Part 3, Even More...

Now we’re on to the interesting parts, starting with connecting two capacitors in series. Remember that we said the result of which would be similar to connecting two resistors in parallel. If this is true, we can expect (using product-over-sum)

C = 100uF*100uF/(100uF+100uF) = 50uF

What’s that going to do to our time constant?

Tau = 0.5 seconds

Experiment 3.2 fritzing diagram

With that in mind, plug in another capacitor in series with the first, make sure the meter is reading zero volts (or there-abouts) and flip the switch to “ON”. Did it take about half as much time to charge up to the battery pack voltage? That’s because there’s half as much capacitance. The electron gas tank got smaller, so it takes less time to charge it up. A third capacitor is suggested for this experiment just to prove the point, but we’re betting the reader can see the writing on the wall.

Now we’ll try capacitors in parallel, remembering that we said earlier that this would be like adding resistors in series. If that’s true, then we can expect 200µF, right? Then our time constant becomes

Tau = 2 seconds

This means that it will now take about 10 seconds to see the parallel capacitors charge up to the supply voltage of 4.5V.

Frizing diagram: caps in parallel

For the proof, start with our original circuit of one 10kΩ resistor and one 100µF capacitor in series, as hooked up in the first diagram for this experiment. We already know that the capacitor is going to charge up in about 5 seconds. Now add a second capacitor in parallel. Make sure the meter is reading close to zero volts (discharge through a resistor if it isn’t reading zero), and flip the switch on the battery pack to “ON”. Takes a long time, doesn’t it? Sure enough, we made the electron gas tank bigger and now it takes longer to fill it up. To prove it to yourself, try adding the third 100µF capacitor, and watch it charge for a good, long time.

Series and Parallel Inductors

Series and Parallel Inductors

Cases where inductors need to be added either in series or in parallel are rather rare, but not unheard of. In any case, let’s address them just to be complete.

In a nutshell they add just like resistors do, which is to say they add with a plus sign when in series, and with product-over-sum when in parallel. The tricky part comes when they are placed close together so as to have interacting magnetic fields, whether intentionally or not. For this reason, it is preferable to have a single component rather than two or more, though most inductors are shielded to prevent interacting magnetic fields.

In any case, suffice it to say that they add like resistors do. More information than that regarding inductors is well beyond the scope of this tutorial.

Resources and Going Further

Now that you’re familiar with the basics of serial and parallel circuits, why not check out some of these tutorials?

  • Voltage Dividers - One of the most basic, and recurring circuits is the voltage divider. This is a circuit which really builds upon the concepts explored in this tutorial.
  • What is an Arduino? - Now that you’ve got the basics of circuits under your belt, you could head directly to learning about microcontrollers with one of the most popular platforms out there: Arduino.
  • Switch Basics - We’ve talked about some of the more basic circuit elements in this tutorial, but this wasn’t one of them. Switches are a critical component in just about every electronics project out there. Learn all about switches in this tutorial
  • Sewing with Conductive Thread - Circuits don’t have to be all breadboards and wire. E-textiles uses conductive thread to sew lights and other electronics into clothing or other fabric.