Diodes

diode

Today we will look at the last component in our 3 part series on basic electronic components, the diode.

Diodes only allows electricity to flow through them in a single direction, this is achieved by the diode having a low resistance, ideally zero, in one direction and a high resistance, ideally infinite, in the other direction. This does mean that diodes are polarized (they have 2 terminal, an anode and a cathode) and the direction in which they are placed in a circuit is of great importance.

Diodes are extremely important in converting AC to DC though their use in a bridge-rectifier, but that is a topic for another post.

Diodes usually have 2 markings on them, a band to indicate the side of the cathode and secondly the diode type code (for example 1N4148) this can be used to look up the maximum voltage and current the diode allows.

Here is the schematic symbol used to represent a diode:

diodesymbol

Diodes

Capacitors

Today we will cover the next in our series of the basic electronic component, the capacitor.

caps

A capacitor is used to store and release electrical charge in a circuit. When the voltage in the circuit is higher than what is stored in the capacitor, the capacitor will allow current to flow in and the capacitor will be given a charge. When the voltage in the circuit drops lower than what is stored in the capacitor it will dis-charge, releasing its stored charge into the circuit. This will cause the voltage in the circuit to temporarily raise.

This is extremely useful as some components, such as electric motors, use more power when they are first activated then when they are already active which can cause a voltage drop in the circuit that can have negative effects on other components in the circuit.

Capacitors help level out these fluctuations in voltage.

There are 2 main types of capacitors, Polarized and Non-Polarized. I will not go into a great deal of detail regarding the differences, but in a nut shell non-polarized capacitors have no implicit polarity and can thus be connected to the circuit either way, whereas polarized capacitors have a defined + and – terminal and must be connected to the circuit corresponding to its terminal polarity. This also means that non-polarized capacitors are suited for use with AC, but polarized capacitors are strictly only suited for DC as they experience large leakage if the voltage is inverted across its terminals as is the case with AC, which can cause the capacitor to overheat.

The capacitance of a capacitor is measured in Farad(F). For most circuits you will likely work on microFarad(µF) and picoFarad(pF) sized capacitors will be utilised.

Here are the schematics used to represent both polarized and non-polarized capacitors:

Polarized Capacitor

polarized cap            Non-Polarized Capacitornon polarized cap

Capacitors

Resistors

In a previous post we had a look at transistors, in the next few posts we will look at 3 other basic electronic components; resistors, capacitors and diodes.

Let us start with the most basic of the 3 today, the resistor. As their name suggest, they resist the flow of electrical current through a circuit. The change in current can be determined using Ohm’s Law, which states that the current flowing through a conductor equals the Voltage across the conductor divided by the resistance present in the conductor, or  I = V/R, where I represents current (measured in Amps), V represents Voltage (measured in Volts) and R represents the resistance (measured in Ohms Ω).

Resistors have coloured stripes along their sides which are used to indicate their values, here is the table used for value lookup:

Colour Value
Black 0
Brown 1
Red 2
Orange 3
Yellow 4
Green 5
Blue 6
Violet 7
Grey 8
White 9

A simple way to remember the sequence of the colours is with the rhyme:
Better Be Right Or Your Great Big Venture Goes Wrong.

The last stripe indicates the tolerance of the resistor:

Colour Value
Brown ±1%
Red ±2%
Gold ±5%
Silver ±10%

Here is an example of how to utilise the table:

resistor 220

The resistor above has 3 colour stripes and a tolerance stripe.

Red Red Brown with a Gold tolerance stripe.

This translates to:

2 2 x 10¹ ± 5% = 220Ω ±5%

Now for an example with a Resistor with 5 stripes:

resistor 10k

The resistor above has 4 colour stripes and a tolerance stripe.

Brown Black Black Red and a Gold tolerance stripe.

This Translates to:

1 0 0 x 10²± 5% = 10,000Ω ±5% = 10kΩ ±5%

Here is the schematic used to represent Resistors in a circuit diagram:

Resistor Symbol

Resistors

Book Review – Build Your Own Humanoid Robots

Book Cover

The first thing to note is that this book does not cover any Arduino-based robots. All the robots are based on PIC micro-controllers. Also note that this book goes into very low-level detail, even covering the fabrication of your own Printed Circuit Boards.

But even considering the above-mentioned I found this book extremely useful, not because of the electronic sections, but because of the mechanical build sections. 

The book shows exactly what raw materials to buy, what tools you will require and how to assemble the robots chassis and mechanical parts. And all these can easily be incorporated into an Arduino-based robot.

All six projects in the book can also be made to work with an Arduino without too much difficulty, all it will require is a bit of creativity and understanding of Arduino. 

For someone interested in Arduino based robots this book might not be the complete package, but the mechanical sections are some of the best I have ever seen in a book. If you are however interested in PIC-based robotics this book is a must buy.

Book Review – Build Your Own Humanoid Robots

Pololu Zumo 32U4 Robot

zumo32u4

In a previous post I looked at the Pololu Robot shield for Arduino, which was a robot shield on top of which a Arduino UNO R3 plugged into to form a great little autonomous robot.

Today we will be looking at the Pololu Zumo 32U4 Robot, a robot similar in size to the Zumo Robot shield for Arduino, but with quite a few changes. Firstly it no longer requires a separate Arduino board as it has an Arduino compatible micro-controller directly integrated into its main-board. It also has a LCD screen and IR proximity sensors which the previously mentioned robot did not have.

The Zumo Robot shield for Arduino came with 75:1 HP motors which produce average speed and torque. In the new Zumo I am installing 100:1 HP motors which are slower that the 75:1 HP motors but produce a lot more torque (which will be great for pushing in Robot Sumo matches).

Similarly to the Zumo Robot shield for Arduino the robot also has an expansion area that can be used to connect additional sensors and actuators. As with the Zumo Robot shield for Arduino various different operating source code can be downloaded from Pololu website, that changes the robot into anything from a sumo fighter to a line follower or even an auto-balancing robot, to name a few.

I bought the Zumo 32U4 Robot kit, which required assembly (unlike the Zumo Robot shield for Arduino that only required an Arduino to be plugged in). 

Here is a time Lapse of the robots assembly. 

I really like the Pololu Zumo series of robots and find them reliable, easy to develop for and a great deal of fun. There are various options available, from fully assembled to kit form depending what you are interested in.

zumos

And now that I have two, I can finally have some Robot Sumo fights, so expect some videos of that soon.

Pololu Zumo 32U4 Robot

IoT

I am starting an IoT project and wanted to share a little bit.  IoT or the Internet of Things is defined on Wikipedia as “the network of physical objects—devices, vehicles, buildings and other items embedded with electronics, software, sensors and network connectivity—that enables these objects to collect and exchange data. The Internet of Things allows objects to be sensed and controlled remotely across existing network infrastructure, creating opportunities for more direct integration of the physical world into computer-based systems, and resulting in improved efficiency, accuracy and economic benefit;”.  

To learn more I would recommend the book The Internet of Things Do-It-Yourself at Home Projects for Arduino, Raspberry Pi, and BeagleBone Black by Donald Norris. It provides an in-depth technical overview of concepts as well as some projects that can be built. The projects in the book are not particularly exciting but they do a good job at illustrating concepts and methods utilised.

Book

So I am going to be using a Raspberry Pi2 running Windows 10 IoT core, which will be communicating with some Arduino boards.

I am also looking at integrating with Azure Machine Learning to do some interesting things. 

I have not decided on many elements of the final project, but it will involve a robot.

rasp

On a side note, do not try to deploy Windows 10 IoT Core on a SD card using a Mac, it is a huge pain. My main computer I use at home (and for most of my development, blogging, video editing, etc.) is a MacBook Pro and in the end I gave up trying to get the deploy working and used my windows laptop which worked almost instantaneously.

Once I have decided exactly what I want to achieve and made some progress I will post more on this topic.

IoT

Insectbot Mini DIY Kit

InsectMain

I have previously built an Insectbot using instructions from the Internet, but subsequently DFRobot have created a kit that conveniently contains everything you need to build one without the need of finding and buying all the components individually.

InsectBoxOpen

This is a very easy little robot to assemble and is great for beginners, with one exception, the piece of plastic used for the robots head needs to be cut and holes made through, which sounds easy enough…. However do not be fooled, as it is the most brittle and fragile piece of plastic I have ever seen. Not breaking it is nearly impossible. Luckily it can easily be replaced with any other piece of flat plastic, such as a plastic container lid, etc.  

The robot uses a rechargeable battery, which is very convenient and comes with an adapter to charge via USB. 

InsectContent2

Here is a time-lapse video of the robots assembly.

The kit is relatively inexpensive and is a great little kit (with the exception of the plastic used for the robots head) and I would recommend it for anyone interested in getting started. The Beetle board used in the robot is fully Arduino compatible and can be developed for using the Arduino IDE.

A basic version of operating code can be downloaded from the products web page (http://www.dfrobot.com/index.php?route=product/product&product_id=1055#.Vtke2JN97fZ). This can be modified as much as you like to truly make the little robot your own.

Here is a video of the little guy in action. Just take note of one shortcoming, and that is that they really struggle to get traction when walking, so some custom shoes will help (I used some cork from a wine bottle, which I cut into little feet.) 

Insectbot Mini DIY Kit

BITE SIZE ARDUINO – PIEZO BUZZER

Today we will have a look at how to connect a piezo buzzer to an Arduino and how to generate different audio signals with it. A piezo buzzer is a audio signalling device, it is the most basic electronic component by which to generate sounds at different frequencies.

A piezo buzzer has 2 connection terminals, one is connected to GND and the other to a PWM digital pin, for this example we will use pin 3.

piezo_bb

We will use the tone() function to generate tones at different frequencies, for an Arduino Uno the frequency rage is between 31 and 65535 Hz. Please note that the possible min and max frequencies differ between different models of Arduino boards. The tone() function takes 3 parameters, firstly the pin to use, then the frequency to use and lastly the duration to generate the tone in milliseconds.

Here is the code used:

#define PIEZO_PIN 3

void setup()
{
}

void loop()
{
     tone(PIEZO_PIN, 31, 1000);
     delay(500); // Pause between Tones 
     tone(PIEZO_PIN, 15000, 1000);
     delay(500); // Pause between Tones 
     tone(PIEZO_PIN, 30000, 1000);
     delay(500); // Pause between Tones 
     tone(PIEZO_PIN, 45000, 1000);
     delay(500); // Pause between Tones 
     tone(PIEZO_PIN, 65535, 1000);
     delay(500); // Pause between Tones 
     noTone(PIEZO_PIN); // Silence Tones
     delay(500);
}
BITE SIZE ARDUINO – PIEZO BUZZER

BITE SIZE ARDUINO – RGB LED

A RGB LED is a LED that can change the colour of the light it produces depending on which of the LEDs’ Connectors have current flowing through them. The LED has 4 connectors, one connector for red, one for green, one for blue and then finally an anode or a cathode, depending if the RGB is a common anode or cathode LED.

So what is the difference between common anode and common cathode?

Well a RGB LED is actually a combination of 3 LEDs, a red LED, a green LED and a blue LED. All LEDs have 2 connectors, an anode and a cathode. So depending how these LEDs are connected together determines if they share an anode or a cathode, thus common anode RGB LED or common cathode RGB LED. The Anode\Cathode leg can be identified as it is the longest leg on the LED. Below are 2 diagrams that illustrates the difference discussed.

Common Cathode:

Common Cathode_schemCommon Anode:

Common Anode_schem

How these 2 different RGB LEDs are connected to a circuit also differs, let us first have a look at a circuit that contains a common cathode RGB LED:

common cathode arduino_bb

Here is the code used with this circuit:

int redPin = 9;
int greenPin = 10;
int bluePin = 11;
 
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}
 
void loop()
{
  setLEDColour(255, 0, 0);  // red
  delay(2000);
  setLEDColour(0, 255, 0);  // green
  delay(2000);
  setLEDColour(0, 0, 255);  // blue
  delay(2000);
  setLEDColour(255, 255, 0);  // yellow
  delay(2000);  
  setLEDColour(80, 0, 80);  // purple
  delay(2000);
}
 
void setLEDColour(int red, int green, int blue)
{
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}

Now let us have a look at a circuit that contains a common anode RGB LED:

common anode arduino_bb

Code used with this circuit:

int redPin = 11;
int greenPin = 10;
int bluePin = 9;
 
void setup()
{
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);  
}
 
void loop()
{
  setLEDColour(255, 0, 0);  // red
  delay(2000);
  setLEDColour(0, 255, 0);  // green
  delay(2000);
  setLEDColour(0, 0, 255);  // blue
  delay(2000);
  setLEDColour(255, 255, 0);  // yellow
  delay(2000);  
  setLEDColour(80, 0, 80);  // purple
  delay(2000);
}
 
void setLEDColour(int red, int green, int blue)
{
  red = 255 - red;
  green = 255 - green;
  blue = 255 - blue;

  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);  
}

Although the circuits and code differ between the 2 types of RGB LEDs, the end results are exactly the same.

Try changing the values passed into the setLEDColour function to see what different colours can be created.

BITE SIZE ARDUINO – RGB LED