Tag Archive | "learning electronics"

Kit Review – Snootlab Rotoshield

Hello Readers

[Update: 11/12/11 - Added example code and video]

In this article we will examine yet another product from a bundle sent for review by Snootlab, a Toulouse, France-based company that in their own words:

… designs and develops electronic products with an Open Hardware and Open Source approach. We are particularly specialized in the design of new shields for Arduino. The products we create are licensed under CC BY-SA v3.0 (as shown in documents associated with each of our creations). In accordance with the principles of the definition of Open Source Hardware (OSHW), we have signed it the 10th February 2011. We wish to contribute to the development of the ecosystem of “do it yourself” through original designs of products, uses and events.

Furthermore, all of their products are RoHS compliant and as part of the Open Hardware commitment, all the design files are available from the Snootlab website.

The subject of the review is the Snootlab Rotoshield – a motor-driver shield for our Arduino systems. Using a pair of L293 half-bridge motor driver ICs, you can control four DC motors with 256 levels of speed, or two stepper motors. However this is more than just a simple motor-driver shield… The PCB has four bi-colour LEDs, used to indicate the direction of each DC motor; there is a MAX7313 IC which offers another eight PWM output lines; and the board can accept external power up to 18V, or (like other Snootlab shields) draw power from a PC ATX power supply line.

However as this is a kit, let’s follow construction, then explore how the Rotoshield could possibly be used. [You can also purchase the shield fully assembled - but what fun would that be?] Assembly was relatively easy, and you can download instructions and the schematic files in English. As always, the kit arrives in a reusable ESD bag:

There are some SMD components, and thankfully they are pre-soldered to the board. These include the SMD LEDs, some random passives and the MAX7313:

Thankfully the silk-screen is well noted with component numbers and so on:

All the required parts are included, including stackable headers and IC sockets:

It is nice to not see any of the old-style ceramic capacitors. The people at Snootlab share my enthusiasm for quality components. The assembly process is pretty simple, just start with the smaller parts such as capacitors:

… then work outwards with the sockets and terminals:

… then continue on with the larger, bulkier components. My favourite flexible hand was used to hold the electrolytics in place:

… followed with the rest, leaving us with one Rotoshield:

If you want to use the 12V power line from the ATX socket, don’t forget to bridge the PCB pads between R7 and the AREF pin. The next thing to do is download and install the snooter library to allow control of the Rotoshield in your sketches. There are many examples included with the library that you can examine, just select File > Examples > snootor in the Arduino IDE to select an example. Function definitions are available in the readme.txt file included in the library download.

[Update]

After acquiring a tank chassis with two DC motors, it was time to fire up the Rotoshield and get it to work. From a hardware perspective is was quite simple – the two motors were connected to the M1 and M2 terminal blocks, and a 6V battery pack to the external power terminal block on the shield. The Arduino underneath is powered by a separate PP3 9V battery.

In the following sketch I have created four functions – goForward(), goBackward(), rotateLeft() and rotateRight(). The parameter is the amount of time in milliseconds to operate for. The speed of the motore is set using the Mx.setSpeed() function in void Setup(). Although the speed range is from zero to 255, this is PWM so the motors don’t respond that well until around 128. So have just set them to full speed. Here is the demonstration sketch:

… and the resulting video:

For support, visit the Snootlab website and customer forum in French (use Google Translate). However as noted previously the team at Snootlab converse in excellent English and have been easy to contact via email if you have any questions. Snootlab products including the Snootlab Rotoshield are available directly from their website. High-resolution images available on flickr.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, follow on twitterfacebook, or join our Google Group.

[Disclaimer - the products reviewed in this article are promotional considerations made available by Snootlab]

Posted in arduino, I2C, kit review, L293, MAX7313, microcontrollers, motor shield, product review, rotoshield, snootlabComments (5)

Introduction to the Inductor

Hello everyone!

Today we are going to explore the use of the Inductor. This is a continuation from the series of articles on alternating current. An inductor is a component that can resist changes in AC current, and store energy in a magnetic field from a current that passes through it. A changing current (AC) causes a changing magnetic field which induces a voltage that opposes the current produced by the magnetic field. This is known as the inductance.  One could think of an inductor as an AC resistor. But first of all, what is an inductor comprised of?

In simple terms an inductor is a coil of wire, wrapped around a core. The core forms a support for the coil of wire – such as ceramic cores, or in some cases can affect the properties of the magnetic field depending on the chemical composition of the core. These may include cores formed from ferrite (usually zinc and manganese, or zinc and nickel) or powdered iron (which has a tiny air gap allowing the core to store a higher level of magnetic flux (the measure of magnetic field strength)- allowing a higher level of DC current to flow through before becoming saturated.

So, the amount of inductance is influenced by several factors – the core material (as above), the size and shape of the core, as well as the number of turns of wire in the coil and its shape. The unit of inductance is the henry (H), however common values are usually in the millihenry (mH) or microhenry (uH) range.

Furthermore, there is an amount of DC resistance due to the properties of the coil wire, however this is usually negligible and kept to a minimum. For example, looking at a data sheet for a typical line of inductors – inductors.pdf – the DC resistance of a 10uH inductor is a maximum of 0.05 ohms. With inductors of higher values, the DC resistance will need to be taken account of. But more about that later.

This is the usual symbol for an inductor in a schematic:

However this may also be used:

And here is a variety of inductors in the flesh:

10microhenryss

radial ferrite core, generally for PCB use, handles around 1.5 amperes

radial leaded, very low resistance, handles around 2.5 amperes

ferrite core, convenient for through-hole PCB

phenolic core

toroidal – handles large currents ~10 amperes depending on model

surface-mount, can still handle around 500 mA

All of the pictured inductors have an inductance of 10 uH. Now let’s examine how inductors work with alternating current. Consider the following circuit:

1

 

Just like capacitors in AC circuits, an inductor has a calculable reactance. The formula for the reactance (X, in ohms) of an inductor is:


where f is the frequency of the AC and L is the value of the inductor in Henries (remember that 1uH is 10 to the power of -6). The formula to calculate the impedance of the above circuit is:

where Z is in ohms. And finally, the formula for AC Vout is

The formula for DC Vout is the usual voltage dividing formula. In this case, as we consider the inductor to not have any resistance, DC Vout = DC Vin.

So, let’s work through an example. Our DC Vin is 12 volts, with a 2V peak to peak AC signal, at a frequency of 20 kHz. The resistor R has a value of 1 kilo ohm, and the inductor L is 10 millihenries (0.01 H). A quick check of the data sheet shows that the 10 mH inductor has a resistance that cannot be ignored – 37.4 ohms. So this must be taken into account when calculating the DC Vout. Therefore we can consider the inductor to be a 37.4 ohm resistor when calculating the DC Vout, which gives us a result of 11.56 volts DC. Substituting the other values gives us a reduced AC signal voltage of 1.24 volts peak to peak.

Another interesting fact is that there is a relationship between AC Vout and the frequency of the AC signal. In the video below, I have used a 10k ohm resistor and a 10 uH inductor in the circuit described above. The frequency counter is measuring the frequency of AC Vin, and the multimeter is measuring the AC Vout:

This is an interesting relationship and demonstrates how an inductor can resist alternating current, depending on the frequency.

Thus ends our introduction to the inductor. We will continue with the inductor in the near future. I hope you understood and can apply what we have discussed today. As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement, you can either leave a comment below or email me – john at tronixstuff dot com.

Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our Google Group and post your questions there.

Posted in education, inductor, learning electronics, lesson, test equipment, tutorialComments (0)

Education – Introduction to Alternating Current – part two

Hello everyone

Today we are going to continue exploring alternating current, with regards to how resistors and capacitors deal with AC. This chapter is part two, chapter one is here. Once you have read this article, continue on with learning about inductors. To help with the explanations, remember this diagram:

sin2

That is, note that there are three possible voltage values, Vpp, Vp and Vrms. Moving on. Alternating current flows through various components just like direct current. Let’s examine some components and see.

First, the resistor. It operates in the same way with AC as it does DC, and the usual calculations apply with regards to Ohm’s law, dividing voltage and so on. However you must keep in mind the type of voltage value. For example, 10Vrms + 20Vpp does NOT equal 30 of anything. But we can work it out. 20Vpp is 10Vp,  which is 7.07Vrms… plus 10Vrms = 17.07Vrms. Therefore, 10Vrms + 20Vpp = 17.07Vrms.

Furthermore, when using Ohm’s law, or calculating power, the result of your equation must always reflect the type of voltage used in the calculations. For example:

scan1

Next, the capacitor. Capacitors oppose the flow of alternating current in an interesting way – in simple terms, the greater the frequency of the current, the less opposition to the current. However, we call this opposition reactance, which is measured in ohms. Here is the formula to calculate reactance:


the result Xc is measured in Ohms, f is frequency is Hertz, and C is capacitance in Farads. Here are two examples – note to convert the value of the capacitor back to Farads

 

scan3

scan4

Also consider if you have identical frequencies, a smaller capacitor will offer a higher resistance than a larger capacitor. Why is this so? A smaller capacitor will reach the peak voltages quicker as it charges in less time (as it has less capacitance); wheras a larger capacitor will take longer to charge and reach the peak voltage, therefore slowing down the current flow which in turn offers a higher reactance.

Resistors and capacitors can also work together as an AC voltage divider. Consider the following schematic:

As opposed to a DC voltage divider, R2 has been replaced with C1, the 0.1 uF capacitor. In order to calculate Vout, we will need the reactance of C1 – and subsitute that value for R2:

scan61

 

However, once the voltage has been divided, Vout has been transformed slightly – it is now out of phase. This means that Vout oscillates at the same frequency, but at different time intervals than Vin. The easiest way to visualise this is with an oscilloscope, which you can view below:

Please note that my CRO is not in the best condition. In the clip it was set to a time base of 2 milliseconds/division horizontal and 5 volts/division vertical.

Thus ends chapter two of our introduction to alternating current. I hope you understood and can apply what we have discussed today. As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement, you can either leave a comment below or email me – john at tronixstuff dot com.

Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our Google Group and post your questions there.

Posted in AC, alternating current, education, learning electronics, lesson, tutorialComments (1)

Getting Started with Arduino – Chapter Twelve

This is part of a series titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Welcome back

This chapter we will spend some more time with the rotary encoder by using it to control a clock, look at ways of driving a common-anode LED display with Arduino, and make a usable alarm clock with which we can start to move from the prototype stage to an actual finished product – something you would be proud to give to someone.

So off we go…

In chapter eleven, we looked at getting some values from the rotary encoder. Not the easiest way of receiving user input, but certainly interesting. This week I have an example for you where the encoder is used for setting the time of a digital clock. This example is basically two previous projects mashed together. It consists of the LED digital clock from exercise 7.1, and the rotary encoder sketch from example 11.2. The sketch was quite simple in theory, but somewhat complex in execution. The idea was to read the decoder, and after every read, display the time. However, if the encoder’s button was pressed, the time set function would be activated. At this point, you turn the encoder in one direction to set the hours, and the other direction to set the minutes. Then press the button again to set that time and return to normal operations.

To recreate it you will need:

  • Your standard Arduino setup (computer, cable, Uno or 100% compatible)
  • Seven 560 ohm 1/4 watt resistors
  • Four 1 kilo ohm 1/4 resistors
  • Four BC548 NPN transistors (if you cannot find these, you can use 2N3904)
  • Two 74HC595 shift registers
  • DS1307 timer IC circuit components (see this schematic from chapter seven) or a pre-built module
  • Solderless breadboard and connecting wires

Here is the sketch for your perusal, and the matching schematic (sorry, I forgot to add the DS1307 module – see example 12.2 schematic below for how to do this):

example12p1small

… in real life:

example12p1boardsmall

and a video clip:

After watching that clip you can soon see that there is an issue with the encoder. As a normal switch can bounce (turn on and off very very quickly in the latter part of operation), so can a rotary encoder. That is why it would sometimes return a result of clockwise, instead of anti-clockwise. Furthermore, they are right little pains when trying to use in a breadboard, so if you were going to use one in greater lengths, it would pay to make up your own little breakout board for it. Therefore at this stage we will leave the encoder for a while.

You may also have noticed the extra shield between the real time clock shield (yellow) and the arduino board. It is the Screwshield for Arduino – reviewed here. It is very useful to making a stronger connection to the I/O pins, or using normal multi-core wires.

pinsborder

Next on the agenda is the common-anode LED display. Normally the LED display we have demonstrated in the past has been common-cathode, and very easy to use. Current would flow from the power supply, through the shift register’s outputs (for example the 74HC595), through current-limiting resistors, into the LED segment, then off to earth via the cathode. Current flows through a diode from the anode to the cathode, and finally back to earth/ground. For a refresher on diodes, please read this article. The other month I found this style of useful LED display:

clockdisplaysmall

Absolutely perfect for our clock experimentations. A nice colon in the middle, and another LED between the third and fourth digit which could make a good indicator of some sort. However the one catch (always a catch…) is that is was common-anode. This means that current starts from the power supply, through the common anode pin for the particular digit, then the LED segment, the LED’s individual cathode pin, through the current-limiting resistor and then to ground. With the current flowing in the opposite direction via a common anode, we can’t just hook the display up to our 74HC595 shift register.

Therefore, we will need the shift register to control switches to allow the current to flow through each segment, just like we have done previously controlling the cathodes of a common cathode display (see example 12.1). So to control the digits of this new display, we will need twelve switches (eight for the segments of the digit, and four to control the anodes). That would mean twelve BC548  transistors and 10k ohm resistors, and a lot of mess.

Instead we will now use the 74HC4066 quad bilateral switch IC. I have reviewed this chip being used with Arduinos in a separate article here. The 74HC4066 is quite a common chip, available from many suppliers including: element14/Newark (part number 380957), Digikey (part number 568-1463-5-ND) or Mouser (771-74HC4066N). If you cannot find them, email me and I can sell you some at cost plus postage. Once you have a understanding of this IC, please consider the following circuit:

example12p2schematic

Most of this should be easily understood. One shift register is controlling the anodes, turning them on and off via a 74HC4066. In past examples this shift register would have turned off common cathodes via a 10k resistor and an NPN transistor. The other shift register is controlling the individual LEDs for each digit via a pair of 74HC4066s (as they only have four switches per IC).

Here is the sketch, it should be quite a familiar piece of code for you by now.

To recreate it you will need:

  • Your standard Arduino setup (computer, cable, Uno or 100% compatible)
  • Seven 560 ohm 1/4 watt resistors
  • DS1307 timer IC circuit components (see this schematic from chapter seven) or a pre-built module
  • Two 74HC595 shift registers
  • Three 74HC4066 quad bilateral switch ICs
  • Solderless breadboard and connecting wires
  • LED clock display module

And here is the result, with red and a blue display.

And the usual board layout:

example12p2boardsmall

The blue looks really good in a dark background. You can also get them in yellow and green.

LEDborder

Moving along. Now and again, you often want to have a few buttons in use for user input, however the cheap ones don’t really like to sit in a breadboard. Naturally, you could make your own “button shield”, which would be very admirable, but then it would be preset to certain pins, which could interfere with your project. I had the same problem in writing this chapter, so came up with this example of an external “button panel” to make life easier. Here is the schematic, nothing complex at all – just four buttons and the required 10k ohm pull-down resistors:

example12p3schematic

and the finished product:

example12p3small

This was a quick job, as I will need to use a few buttons in the near future. Have also put some rubber feet on the bottom to stop the solder joints scratching the surface of the bench. Originally I was going to chop off the excess board at the top, but instead will add some LEDs to it after finishing this article. However using this button board will save a lot of frustration by not trying to jam the buttons into a breadboard.

pinsborder

Exercise 12.1

Now it is time for you to do some work. From this chapter onwards, we will be working on making a small alarm clock – something you could use. Just like the six million dollar man, we have the capability, the technology, and so on … except for Steve Austin. So this chapter, your task is to create and breadboard the  circuit and the underlying sketch. Using the LED display from example 12.1, your clock will have a menu option to set the time, alarm time, turn on and off the alarm, a snooze button – and also switch the display on and off (so you don’t stare at it when you should be trying to sleep).

You could either use a DS1307 module, or the raw parts. For an explanation of the circuitry, please see this post about making a RTC shield. You can always change it when we get to making a real prototype. The same with the Arduino – but for this exercise just stick with the normal board. Later on we will use a bare circuit the same as in chapter ten. With regards to user input, it’s up to you. A rotary encoder could be a real PITA, my example below just uses buttons. Anyhow, off you go!

Parts you will need:

  • Your standard Arduino setup (computer, cable, Uno or 100% compatible)
  • Seven 560 ohm 1/4 watt resistors
  • DS1307 timer IC circuit components (see this schematic from chapter seven) or a pre-built module
  • Two 74HC595 shift registers
  • Three 74HC4066 quad bilateral switch ICs
  • Four normally open buttons or a board as described in example 12.3
  • Solderless breadboard and connecting wires
  • LED clock display module

Here is my interpretation of the answer to the exercise. Although this is a particularly long sketch for our examples, it is broken up into many functions which are quite modular, so you can easily follow the flow of the sketch if you start at void loop(). All of the types of functions used have been covered in the past tutorials. In then next chapters we will add more functions, such an an adjustable snooze, selectable blinking colon, and so on. If you have any questions, please ask.

The buttons have several functions. In normal clock display mode, button one is for menu, two turns the alarm on, three turns it off, and four turns the display on and off. If you press menu, button two is to select time set, three for alarm set, and four is like an enter button. When in the time/alarm set modes, button one increases the hour, button two increases minutes in units of ten, and button three increases minutes in ones, and four is enter. When the alarm activates, button four turns it off.

The schematic is just example 12.2 and example 12.3 connected together, however the first button on the external board is connected to digital pin 8 instead of 1.

So here is a photo of our work in progress:

exercise12p1boardsmall

And a video clip showing the various functions of the clock in operation:

I hope you found success and inspiration in this chapter. Now to Chapter Thirteen.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in 4066, 74HC4066, arduino, COM-09117, COM-09481, COM-09483, education, learning electronics, lesson, microcontrollers, tutorialComments (11)

Education – Introduction to Alternating Current

Hello everyone!

Today we are going to introduce the basics of AC – alternating current. This is necessary in order to understand future articles, and also to explain in layperson’s terms what AC is all about. So let’s go!

AC – Alternating Current. We see those two letters all around us. But what is alternating current? How does current alternate? We know that DC (direct current) is the result of a chemical reaction of some sort – for example in a battery, or from a solar cell. We know that it can travel in either direction, and we have made use of it in our experimenting. DC voltage does not alter (unless we want it to).

Therein lies the basic difference – and why alternating current is what is is – it alternates! :) This is due to the way AC current is created, usually by a generator of some sort. In simple terms a generator can be thought of as containing a rotating coil of wire between two magnets. When a coil passes a magnet, a current is induced by the magnetic field. So when the coil rotates, a current is induced, and the resulting voltage is relative to the coil’s positioning with the magnets.

For example, consider the diagram below (exploded view, it is normally more compact):

generator

This is a very basic generator. A rotating coil of wire is between two magnets. The spacing of the magnets in real life is much closer. So as the coil rotates, the magnetic fields induce a current through the coil, which is our alternating current. But as the coil rotates around and around, the level of voltage is relative to the distance between the coil and the magnet. The voltage increases from zero, then decreases, then increases… as the coil constantly rotates. If you were to graph the voltage level (y-axis) against time (x-axis), it would look something like below:

sin1

That graph is a sine wave… and is a representation of perfect AC current. If you were to graph DC voltage against time, it would be a straight horizontal line. For example, compare the two images below, 2 volts DC and AC, shown on an oscilloscope:

2v-dc-cro-small

2 volts DC

The following clip is 2 volts AC, as shown on the oscilloscope:

So as you can see, AC is not a negative and positive current like DC, it swings between negative and positive very quickly. So how do you take the voltage measurement? Consider the following:

sin2

The zero-axis is the point of reference with regards to voltage. That is, it is the point of zero volts. In the oscilloscope video above, the maximum and minimum was 2 volts. Therefore we would say it was 2 volts peak, or 2Vp. It could also be referred to as 4 volts peak to peak, or 4Vpp – as there is a four volt spread between the maximum and minimum values of the sine wave.

There is another measurement in the diagram above – Vrms, or volts root mean squared. The Vrms value is the amount of AC that can do the same amount of work as the equivalent DC voltage. Vrms = 0.707 x Vp; and Vp = 1.41 * Vrms. Voltages of power outlets are rated at Vrms instead of peak as this is relative to calculations. For example, in Australia we have 240 volts:

241vacs

Well, close enough. In fact, our electricity distributor says we can have a tolerance of +/- 10%… some rural households can have around 260 volts. Moving on…

The final parameter of AC is the frequency, or how many times per second the voltage changes from zero to each peak then back to zero. That is the time for one complete cycle. The number of times this happens per second is the frequency, and is measured in Hertz (Hz). The most common frequency you will hear about is your domestic supply frequency. Australia is 50 Hz:

50-hzss

… the US is 60 Hz, etc. In areas that have a frequency of 60 Hz, accurate mains-powered time pieces can be used, as the seconds hand or counter can be driven from the frequency of the AC current.

The higher the frequency, the shorter the period of time taken by one cycle. The frequency and time are inversely proportional, so frequency = 1/time; and time – 1/frequency. For example, if your domestic supply is 50 Hz, the time for each cycle is 1/50 = 0.02 seconds. This change can be demonstrated quite well on an oscilloscope, for example:

In the video above there is 2 volts AC, and the frequency starts from 100 Hz, then moves around the range of 10 to 200 Hz. As you can see, the amplitude of the sine wave does not change (the height, which indicates the voltage) but the time period does alter, indicating the frequency is changing. And here is the opposite:

This video is a demonstration of changing the voltage, whilst maintaining a fixed frequency. Thus ends the introduction to alternating current. In the next instalment about AC we will look at how AC works in electronic circuits, and how it is handled by various components.

I hope you understood and can apply what we have discussed today. As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement.

Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our Google Group and post your questions there.

Posted in AC, alternating current, education, learning electronics, lesson, safety, tutorialComments (0)

Getting Started with Arduino – Chapter Eleven

This is part of a series titled “Getting Started with Arduino!” – A tutorial on the Arduino universe. The first chapter is here, the index is here.

Welcome back

In this instalment we will start to investigate radio data transmission; then introduce rotary encoders.

As technology has marched along and generally improved on the past, things have been getting small and relatively cheaper. What was once jaw-droppingly amazing is now just meh. But as you are reading this, you know differently. We can now take control of this technology for our own devices. What has been in the past quite unapproachable is now relatively – the concept of wireless data transmission. But no just sending a signal, like a remote-control garage door opener – but sending actual,  useful data – numbers and characters and so on.

How is it so? With this pair of tiny devices:

txrxmodule

Quite small indeed – the pins are spaced 2.54mm apart, and the graph paper is 5mm square. The transmitter is on the right. This pair operates at 315 kHz, over up to a theoretical 150 metres. The data transmission speed is 2400 bps (bits per second). These units are serial passthrough, that is they can replace a link of wire between the serial TX (pin 1) from one Arduino, and the RX of another Arduino (pin 0). They don’t need aerials for very short distances, but the use of one will extend the range towards the maximum. And finally, the transmitter needs between 2 and 10 volts; the receiver 5. Here is the data sheet for these modules: 315MHz.pdf. Normally they are sold individually, for example the transmitter and receiver. You can also find faster (data speed) modules, however we will use these ones today.

In preparation to use these modules, another library needs to be installed – the VirtualWire library. Download the latest revision from the following location: http://www.open.com.au/mikem/arduino/.

There is also a guide to using the library in .pdf format as well. Please note the library author’s instructions with regards to licensing on the last page of the guide. For a refresher on how to install a library, please head back to chapter two. This library will save us a lot of time, it takes care of checking for errors, and only allows complete, correct data (i.e. what is received matches what is sent) to be used in the receiver’s sketch.

However, as wireless is not 100% reliable, you need to take into account that transmissions may not be received, or erroneous ones will be ignored by the receiver’s sketch. You can reduce the data speed to improve reliability and range. Furthermore, you cannot use PWM on D9 and D10 if you are using VirtualWire.

Therefore if you are using this for some important communications, have the transmitter repeatedly sent the message. Later on in this series we will investigate more powerful solutions. Anyhow, moving along …

First of all, we will demonstrate the use of these modules with a basic sketch. It sends some text from one Arduino to another. The receiving Arduino sends the data to the serial monitor box. Of course you could always use an LCD module instead. In my own inimitable style the sketches are very simple, yet allow you to use their contents in your own work. Here is the sketch for the transmitter – tx.pdf and the receiver – rx.pdf.

When working with two sketches at the same time, you can have two Arduinos connected to your PC simultaneously,  just remember to select the correct USB port for the correct Arduino. Do this with the tools > serial port menu option in the IDE. Otherwise you will become very frustrated if you upload the rx sketch to the tx Arduino.

Furthermore, you will need to remove the wire from digital 0 to the data pin on the receiving units before uploading the sketch. And finally, remember to set the serial monitor window at 9600 baud.

Here are my two boards in action:

example11p1small

Although having both boards connected to the one computer is only useful for demonstration purposes, in real life this is obviously useless. Remember that once you upload your sketch the Arduino doesn’t need a computer, only a power supply. You can feed yours between 7 and 12 volts DC through the socket. A nice switchmode power pack will do nicely, or if you are a cheapskate like me, a PP3 battery and clip soldered to a DC plug:

pp3small

You may find that when you use a battery powered Arduino that it basically does not work. Arduino genius Jon Oxer (co-author of Practical Arduino) has found a solution for this issue – place a 10k resistor between GND and digital 0 (RX), or between digital pins 0 and 1. The next thing to consider it improving the reception range. This can be done using two methods – the first by connecting an external antenna, either a length of wire, or perhaps a purpose-built aerial. The second method is to increase the supply voltage of the transmitter up to 12 volts.

Now it is your time to do some work:

Exercise 11.1

You now are able to send characters using the radio link from one Arduino to another. Now it is time to control things remotely. For the purpose of the exercise, we will just control three LEDs, turning them on and off. You already know how to control other things with digital output pins, so we just need to focus on getting the switching on and off. Hint – you can send characters via the wireless link, so create your own codes.

You will need:

  • Two standard Arduino setups (computer, cable, Uno or compatible)
  • two breadboards and some connecting wire
  • One transmitter and one receiver unit
  • three LEDs
  • 3 x 560 ohm 0.25 W resistors. They are to reduce the current to protect the LEDs

Here is the schematic of my interpretation:

exerc11p1sch

… the transmitter:

exer11p1txsmall

… the receiver:

exer11p1rxsmall

and the video:

So how did you go? Hopefully this exercise was easier than you had first expected. If not, here are the example sketches: exercise 11.1 tx and exercise 11.1 rx. A basic transmit/receive system like this would also be handy for testing the range that wireless modules can operate over, or testing a particular site to see if you could implement such wireless modules. It’s always better to test before agreeing to make something for someone.

That concludes our work with radio wireless links – for now.

LEDborder

Next on the agenda is the rotary encoder. Recall how we used a potentiometer in the previous chapters as a dial, to select menu options using the readdial() function. It was simple, cheap and it worked, but some may say it was a kludge. There must be a better way! And there is, with the rotary encoder. A rotary encoder looks like a potentiometer, but it is a knob that can be rotated in either direction infinitely. Furthermore, the knob is also a normally-open button. The encoder we will be using in this chapter is a 12-step encoder, in that you can feel it physically resist rotation slightly twelve times over the 360 degrees of rotation.

Here is our example:

encoder11

On one side there are three pins, and two on the opposing side. On the perpendicular sides are legs for strength, that is they are meant to be soldered into a PCB to lock it in nicely. The problem for us is that those legs interfere when trying to use the encoder in a breadboard, so I have bent them up and cut them off:

encoder2

The pins are easy to understand. The two pins on one side are the button contacts, just like any simple button. The other side with the three pins – the centre goes to ground, and the outside pins are the forwards and backwards output pins. The data sheet for our encoder is here. After fooling about with this all afternoon, the quickest way to get a feel for how it works is with a simple demonstration. So first we will test it out, then see how we can use it in our user-interfaces.

This example is very easy to assemble. You only need an encoder, and the usual Arduino setup. Here is the sketch, and the schematic:

example11p2schem

and in real life:

example11p2boardsmall

and finally a snapshot of the output. Don’t forget to set the speed in your serial monitor box to 115200 baud:

example11p2screen

So as you can see, this is a much better solution that then potentiometer that we used in the past. Plus having the button integrated in the encoder is very convenient, you can really create a user interface with only one control. In the next instalment of this series we will implement the encoder in an existing design. So on to Chapter Twelve.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, COM-09117, learning electronics, lesson, microcontrollers, rotary encoder, tutorial, WRL-10532, WRL-10534Comments (25)

Electronic components – the Resistor (Part Two)

Hello readers

Today we continue with the series of articles on basic electronics with this continuation of the article about the resistor. Part one can be found hereWith regards to this article, it is only concerned with direct current (DC) circuits. In this chapter we will examine how two or more resistors alter the flow of current in various ways. First of all, let’s recap what we learned in the previous chapter.

Ohm’s Law – the relationship between voltage, current and resistance:

ohmslaw

Resistors in series:

series

Resistors in parallel:

parallel

 

Dividing voltage with resistors:

divider

However the fun doesn’t stop there. As there is a relationship between voltage, current and resistance, we can also divide current with resistors. For now we will see how this works with two resistors. Please consider the following:

There is a balance between the two resistors with regards to the amount of current each can handle. The sum of the current through both resistors is the total current flowing through the circuit (It). The greater the resistance the less current will flow, and vice versa. That is, they are inversely proportional. And if R1 = R2, I1 = I2. Therefore, I1/I2=R2/R1 – or you can re-arrange the formula to find the other variables.

Here is an example of doing just that:

currdivex2

Our problem here – there is 6 volts DC at half an amp running from left to right, and we want to use an indicator LED in line with the current. However the LED only needs 2 volts at 20mA. What value should the resistors be?

First of all, let’s look at R1. It needs to change 6V to 2V, and only allow 20 mA to pass. R=E/A or R= 4 volts /0.2 amps = 200 ohms.

So R1 is 200 ohms. I1 is .02 A. Now we know that the total current is equal to I1+I2, so I2 will be 0.48A. That leaves us with the known unknown R2 :)  We can re-arrange the formula R2/R1=I1/I2 to get R2 = (R1 x I1)/I2 – which gives us R2 of 8.3 ohms. Naturally this is a hypothetical, but I hope you now understand the relationship between the current through the resistors, and their actual resistance.

What we have just demonstrated in the problem above is an example of Kirchhoff’s current law (KCL). Gustav Kirchhoff was another amazing German physicist who worked on the understandings of electrical circuits amongst other things. More on GK here. His current law states that the amount of current entering a junction in a circuit must be equal to the sum of the currents leaving that junction. And not-coincidentally, there is also Kirchhoff’s voltage law (KVL) – the amount of voltage supplied to a circuit must equal the sum of the voltage drops in the circuit. These two laws also confirm one of the basic rules of physics – energy can not be created nor destroyed, only changed into different forms.

Here is a final way of wrapping up both KCL and KVL in one example:

The current through R3 is equal to I1 + I2

Therefore, using Ohm’s law, V1 = R1I1 + (R3 x (I1+I2)) and V2 = R2I2 + (R3 x (I1+I2))

So with some basic algebra you can determine various unknowns. If algebra is your unknown, here is a page of links to free mathematics books, or have a poke around BetterWorldBooks.

There is also another way of finding the currents and voltages in a circuit with two or more sources of supply – the Superposition Theorem.

This involves removing all the sources of power (except for one) at a time, then using the rules of series and parallel resistors to calculate the current and voltage drops across the other components in the circuit. Then once you have all the values calculated with respect to each power source, you superimpose them (by adding them together algebraically) to find the voltages and currents when all the power sources are active. It sounds complex, but when you follow this example below, you will find it is quite simple. And a lot easier the th.. fourth time.  Just be methodical and take care with your notes and calculations. So let’s go!

Consider this circuit:

scan1

With the Superposition theorem we can determine the current flowing through the resistors, the voltage drops across them, and the direction in which the current flows. With our example circuit, the first thing to do is replace the 7V power source with a link:

Next, we can determine the current values. We can use Ohm’s law for this. What we have is one power source, and R1 which is in series with R2/R3 (two parallel resistors). The total current in the circuit runs through R1, so calculate this first. It may help to think of the resistors in this way:

Then the formula for Rt is simple (above), and Rt is And now that we have a value for Rt, and the voltage (28V) the current is simple:

scan3

Which gives us a value of 6 amps for It. This current flows through R1, so the current for R1 is also 6 amps. Next, the current through R2:

Using Kirchhoff’s Current Law, the current flowing through R2 and R3 will equal It. So, this is 4 amps.

At this point, note down what we know so far:

For source voltage 28V, Ir1 = 6A, Ir2 = 2A and Ir3 = 4A; R1=4 ohms, R2 = 2 ohms, R3 = 1 ohm.

Now – repeat the process by removing the 28V source and returning the 7V source, that is:

The total resistance Rt:

Gives us Rt = 2.3333 ohms (or 2 1/3);

Total current It will be 7 volts/Rt = 3 amps, so Ir3 = 3;

So Ir2 = 2A – therefore using KCL Ir1 = 3-2 = 1A.

So, with 7V source: Ir1 = 1A, Ir2 = 2A and Ir3 = 3A.

Next, we calculate the voltage drop across each resistor, again by using only one voltage source at a time. Using Ohm’s law, voltage = current x resistance.

For 28V:

Vr1 = 4 x 6 = 24V; Vr2 = 2 x 2 = 4V; Vr3 = 4 x 1 = 4V. Recall that R2 and R3 are in parallel, so the total voltage drop (24 + 4V) = 28 V which is the supply voltage.

Now, for 7V:

Vr1 = 4V, Vr2 = 4V, Vr3 = 3V.

Phew – almost there. Now time to superimpose all the data onto the schematic to map out the current flow and voltage drops when both power sources are in use:

scan11

Finally, we combine the voltage values together, and the current values together. If the arrow is on the left, it is positive; on the right – negative. So:

Current – Ir1 = 6 – 1 = 5A; Ir2 = 2 +2 = 4A; Ir3 = 4-3 = 1A;
Voltage – Vr1 = 24 – 4 = 20V; Vr2 = 4 + 4 = 8V; Vr3 = 4 – 3 = 1V.

And with a deep breath we can proudly show the results of the investigation:

So that is how you use the Superposition theorem. However, there are some things you must take note of:

  • the theorem only works for circuits that can be reduced to series and parallel combinations for each of the power sources
  • only works when the equations are linear (i.e. straight line results, no powers, complex numbers, etc)
  • will not work when resistance changes with temperature, current and so on
  • all components must behave the same way regardless to polarity
  • you cannot calculate power (watts) with this theorem, as it is non-linear.

Well that is enough for today. I hope you understood and can apply what we have discussed today. The final chapter on resistors can be found here. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in education, kirchoff, learning electronics, resistorComments (6)

Seriously – don’t buy a cheap plugpack…

Hello readers

Instead of a normal day involving fun and learning with electronics, I got the scare of my life and a very sore back. You’re probably thinking it was something to do with the bedroom, but (un)fortunately no. It was revenge of the cheap plug pack. (In Australia we call wall warts plug packs).

In the recent past I wrote about a couple of cheap plug packs from eBay – here. Foolishly I kept using the other working plug pack. Not any more!

Consider this photo:

crap2s

Notice how there is the adaptor with the Australia pins – this slides on and off relatively easily. Today I went to unplug the whole thing, by gripping the small adaptor which would pull the lot out at once. However my grip was not strong enough and my fingers slipped, pushed down and pulled at the plugpack itself – just enough to leave a gap and the pins exposed. (see below) At which point my fingers slipped and grabbed the live pins.

crap2as

Although I consider myself to be a large physical specimen (185cm tall, 120kg) the shock was amazing (in a bad way). I fell arse over and ended up flat on the floor, and some strange feelings in my chest. After a few moments I sat up and had a walk around. Luckily my doctor is only ten minutes walk away so she gave me a once-over and told me to relax for the rest of the day.

So – the morals of today’s story:

One – don’t cut corners on safety by using substandard equipment

Two – no matter how familiar you are with electronics or electrical work – ELECTRICITY CAN KILL YOU!

Three – always see a doctor, even for the slightest shock.

If you have a tale of woe to share, please leave a comment below or in our Google Group. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in education, learning electronics, safetyComments (8)

Let’s make a cheap +5V power supply

In this tutorial we make a simple 5V DC power supply from initial idea to finished product. This is not an exercise in making a flash power supply, just solving a problem with the parts at hand.

Updated 18/03/2013

When writing my Arduino tutorials, or generally experimenting with the breadboards – and more often both – I have needed 5V DC to power something, or in the case of working with two Arduinos at once, having to run USB cables all around the place just to power them. Some may say “Oh, just get another couple of wall warts/plug packs”. True, but good ones are over Au$20 here… and buying cheap ones have not been so successful in the past. However, I do have a collection of odd-voltage plug packs from old cordless phones and so on.. 12V AC, 15V DC etc.

So while at my desk I thought “How can I combine my need for 5V, my cheapness and use one of these plugpacks?”. Easy!

After perusing my stock database it turned out that all the parts were already around me to make a simple 5V supply using an LM7805 voltage regulator. It is quite versatile, can accept voltages up to 35V, and I have some in the drawer. Here is the data sheet: LM7805.pdf.

One should keep in mind the possible current draw from the device this is powering. The LM7805 is good for one amp, so if you’re going to milk it to the limit, your power supply should be good for around 1.5A.

Following this it occurred to me that it would be nice to not have to worry about the type of current from the plug pack – AC or DC. So my circuit needs a bridge rectifier. That can be made with four 1N4004 diodes. And it would be nice to have a power-on indicator that isn’t a tiny speck of light. Thankfully I bought some 20 mm red LEDs when element14 had a crazy sale. Perfect.

And finally, a nice enclosure. Or anything really, to hold it all together. A small semi-opaque jiffy box was hiding in the cupboard with some veroboard, so they will be used. How? Here is my schematic:

schematicsmall

Oh – the resistor is 560 ohms. And here are the participants in this project:

partssmall1

The black stuff at the top-right is heatshrink. The next though was how to mount the board in the box – I don’t have any standoffs, but the box does have some slots to hold the board. So this tells me how much space there is to use on the board, as I will trim it down to fit the space available:

boxsmall

But before hacking things up with the tinsnips, it pays to see if your circuit will actually fit in the board space available. (However my circuit was quite small, so I knew it would fit). This can be done by laying out your parts on a sheet of paper that has a grid of dots at 2.54mm intervals. Next was to measure the internal dimensions of the box in order to cut the veroboard. Then out with the tinsnips and chop chop chop. When using tinsnips or a saw of some sort, try and cut a little outside of the line – as the PCB material does flex a little .This means that you may lose 2~3 mm at the edges, so make allowances for that.

Moving on, I now have the board sized for the box and can start component placement:

pcbinboxsmall

The parts just fit in together nicely. I will have to drill the holes for the 7805 regulator so it can fit, however it doesn’t really leave room for the 0.1uF capacitor. However it is not really necessary, the output will be ok without it. The leads from the power socket, and to the switch and output lead will feed from the bottom of the PCB:

layout1

Now for one final visual check, and then to solder in the components. After doing so, then it was time to put the link in and cut the tracks. I use a sanding bit on the drill to cut the tracks, completely removing the copper:

lay2small

After cutting the tracks on the solder side, it was a good time to use the continuity function of the multimeter to check for shorts between tracks and other errors. The soldering proved to be fine, and the track cuts worked. Now it was time to position the DC socket and switch in order to wire them in, then drill their holes. The output wire is to come out of the top:

almostsmall

Now all there is to do is solder the connecting wires from the DC socket to the rear of the circuit board, and the output wire via the switch. At this point the unit was also tested. Naturally my eyesight had failed me and a short had appeared. However it was sorted out with the solder sucker:

smallaalmost

Notice how I tied a knot in the output lead before it passes through the lid – this is to stop accidental damage to the board caused by someone pulling the wire out. Here is the finished product, with a nice red glow for a power-available indicator:

finishedssss

Hooray – finished. What else was there to do on a Tuesday night? The LED indicates power is supplied to the box, and the switch just controls the load. Not too happy about that 5.05V reading… but then again, that meter was somewhat inexpensive. Now let’s have a look at the CRO and look for any ripple from the supply:

crosmall

The display was set to 50 millivolts per vertical division – and still a nice solid line. Considering the cost of the power supply, that’s not too bad. And we didn’t need the extra smoothing capacitor after all.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, LM7805, power supply, projects, tutorialComments (8)

Part review – NXP 74HC4066 Quad bilateral switch IC

Hello readers!

Today we are going to examine the 74HC4066 quad bilateral switch IC. My reason for writing this comes from a comment left by a reader on chapter nine of the Arduino tutorial. They suggested using a 4066 IC to control the cathodes of the LED matrix instead of resistors and NPN transistors. This was a good suggestion, however the 4066 can only switch a current of 10mA per pin. Luckily the 74HC4066 can handle up to 25mA per switch – so we’ll look into this instead.

First of all, let’s say hello:

74hc4066

This is the 14-pin DIP package. It is also available in surface mount, and other newer package styles. Although we are looking at an example from NXP, according to my main component supplier (element-14/Newark) this IC is also manufactured by Texas Instruments, ON Semi, ST Microelectronics and Fairchild. So, what is a quad-bilateral switch? Four switches in one IC. Here is a diagram:

Imagine a simple normally-open push button. You press the button, and current can flow through the switch. Using the 74HC4066, when current is applied to the E pin, current can pass through from the matching Y pin to the Z pin. As you can see above, there are four of these switches in the IC. This is where the benefit of the IC comes to mind, normally one might use a 1k ohm resistor and an NPN switching transistor as an electronic switch, and I have done so myself. But when you need a few of them, it can be easier to start using these 74HC4066s as long as the current requirements are met.

With regards to the current the IC can switch, Is, the maximum is 25mA per switch. This is more than enough to run a typical LED, TTL logic gate, etc. The other interesting parameter is the turn-on and turn off times – at 6 volts it can turn on in around 10 nanoseconds and turn off at around 13 nanoseconds (so a rough calculation – say it takes 30 nanoseconds to switch on and then switch off, that’s 33.3 million times per seconds (33.3 MHz). All these parameters and more are available from the data sheet (pdf). Someone correct me if I’m wrong!

That’s enough theory – let’s put it to work now. Our first demonstration is quite simple – just switch on and off some LEDs via a 74HC595 shift register and an Arduino. We send a number (0, 1, 2, 4, 8 ) to the shift register, which stays off, then sets pins Q0, Q1, Q2, Q3 high in order, which in turn activate the switches 1~4 on the 74HC4066. The 74HC4066 sends a current to each LED connected to the switch outputs.

Here is the schematic:

demo1schematicsmall1

Laid out on the breadboard:

demo1small

And the ubiquitous video:

And here is the Arduino sketch: demo1.pdf. Well that was interesting. I know these simple demonstrations may be… well a little simple, but after taking the time to build them from scratch you get a better understanding of the part and how they work. Practice makes perfect and all that. Anyhow, let’s have a look at something much more interesting – a very basic (!) digital to analogue converter. Consider the circuit below:

demo2schematic

The 74HC4066 switches creates a final voltage through the sum of various currents being switched into the final output. First of all, here is a video of the switches being turned on and off one at a time:

and the corresponding Arduino sketch:demo2.pdf. The next video shows the results of sending decimal numbers 0~15 to the shift register – in effect continually adding the outputs of the pins until all pins are on, then in reverse:

and the corresponding Ardiono sketch:demo3.pdf.

Well I hope you found this part review interesting, and helped you think of something new to make. In conclusion I would consider the 74HC4066 easier and quicker for end user to use in projects (less pins to solder, etc) however using it could cost more depending on the volume required. Furthermore, this would only apply if the current restrictions of the IC are met.

So have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Notes: In writing this post, I used information from NXP, plus information and circuit inspiration from various books by Forrest Mims III.

Posted in 4066, 74HC4066, lesson, part review, tutorialComments (24)

Getting Started with Arduino – Chapter Ten

This is part of a series titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the index is here.

In this tutorial we’ll minimise an Arduino Uno board, use time to control – and then find some synergy between the two.

As time goes by, you will want to build projects to use away from the bench, or that are permanent. Although doing so is infinitely fun, it can become expensive if you keep buying Arduino boards for each project or proof-of-concept prototype, or even finished products. However, as always, the Arduino team have solved this problem for us as well. The actual microcontroller integrated circuit (e.g. ATmega328P-PU) can operate with a lot less circuitry than that is contained on your Uno or compatible board. In fact, you can have a functioning Arduino system with three components and a 5V power supply.

How?

To start, please download the Uno schematic from here. Upon glancing at it for the first time, there seems to be a lot of things required. However if you just want to use the digital and analogue pins, you can cut that schematic down to a lot less, however you need to make a couple of changes to how you upload the sketch. Here is what you can get away with:

example10p1schematicsmall

X1 is the 16 MHz resonator. Using only the main circuit on the left, to upload your sketch you need to place the ATmega chip in your Arduino board, upload the sketch, then very carefully remove the chip and place it into your circuit, breadboard, etc. Please make sure to observe anti-static precautions, and always use a chip puller (below):

pullersmall

Furthermore, if you only have one chip, it would be very wise to have a second or third as a backup. A programmed ATmega with the Arduino bootloader can be had for less than US$6. Below is a shot of my barebones Arduino system at work. It is setup to run this basic example:

worksbarebonessmall

The blue and yellow wires run off to a 5 volt power supply. And here is it working:

To recreate this at home, you will need:

  • One ATmega328P-PU microcontroller with Arduino bootrom
  • solderless breadboard
  • 10k ohm resistor
  • 16 MHz resonator
  • (optional – for USB cable) 6-pin header pin
  • (optional – for USB cable) 0.1 uF ceramic capacitor
  • (optional – for USB cable) FTDI cable (the 5 volt version!)

A note about the resonator. Your Arduino board will most likely have a metal crystal, however a resonator is a little cheaper and easier to use, as it has the capacitors in built. If you look at the Arduino schematic, they use a crystal and two 22 picofarad capacitors. So if you use the resonator, pins 1 and 3 go to chip pins 9 and 10, and resonator pin 2 goes to GND. Here is the data sheet for the resonator. They should be easily available, for example from here. The USB cable option will make life a lot easier. The cable is called an FTDI cable, and contains the electronics within to interface between the USB port on your computer and the TX/RX pins on the microcontroller. The wiring details are in the schematic above.

The cable also supplies power whilst programming, or leaving the cable plugged in. Here is my board with the extra wiring connected:

worksftdismall

So if you have this kind of setup, you can just plug the cable into the computer USB port and upload sketches as normal. However there are some modifications that may need to be done with your computer’s operating system to make it work. If you are running Linux or MacOS, please visit here; if you are running windows of some sort, go to device manager, right click the USB serial port you are using, select properties, port-settings tab, advanced, and turn on set RTS on Close.

When purchasing an FTDI cable – make sure you get the 5 volt version!

So now you can integrate the Arduino chip into your prototypes much easier and cheaper. However, if you are going to use SPI or I2C devices, more circuitry will be required. We will examine creating these interfaces in more detail later. A good compromise in this situation is a miniature Arduino-compatible board such as the Freetronics LeoStick.

If you are interested in a project using such a barebones setup, please have a look at blinky the clock.

ic-border

Next on the agenda is a small project to consolidate some previous learning. At the end of chapter nine, we made a (relatively) user friendly clock with an alarm. And in chapter three, we controlled a relay with our arduino. So now we have the ability to create our own on/off timer of which possible uses could be limitless.

In doing so, we can start by modifying the sketch from exercise 9.3. It has the ability to set an alarm time (let’s call it a start time from now on), so we can add the ability to set an end time – it just requires some more variable to store the end time data, and another menu function to set these. Finally, another function is required to check if it is time to turn off (basically identical to the checkalarm() function.

The hardware side of things for the example will be quite simple as well, below is my schematic, and the basic board:

example10p2

example10p2boardsmall

 

 

I am using 12v relays as currently that is all I have in stock. The 12V power supply is just an LM7812 regulator from a 20V DC plugpack. For demonstration purposes any low-voltage relay would be fine. A 5V relay would be perfect as you could run it from the Arduino’s 5V rail.

Note: From here on you understand that one can use an Arduino to switch a very high current and/or voltage with some relays. Please exercise care and consult a qualified, licensed person if you are working with mains voltage (100~250V AC… the stuff that comes out of power points/outlets). They can KILL you!

So for this example, I have modified the sketch as described earlier to accept a start time, end time, and display relevant data on the screen. It will switch on and off the relay, which controls a light globe drawing 100mA – 5 times the current an Arduino digital out pin can deliver. It only operates using 24-hour time, to save user confusion. You could control anything as long as you do not exceed the current and voltage maximums for your particular relay.

So here it is in action. The time has already been set previously, so you can watch the setting of the on/off time, and watch it in action. You can skip ahead from 01:03s to 01:48s to save time.

and here is the sketch for your perusal.

As as example the user interface wasn’t that flash, but naturally it can be worked on to be more intuitive. So now it is your chance to do so, with…

Exercise 10.1

Create a timing system for a hypothetical lighting system that controls two independent circuits. Each timer can turn on or off at a specified time, either daily, only on weekdays, only on a certain day of the week (e.g. only Fridays) or only on weekends. The menu system should be easy and quick to use.

For the purpose of the exercise, you can switch on or off an LED to represent each lighting circuit – you already know how to use the relays.

You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • Two usual LEDs of your choice
  • 2 x 560 ohm 0.25 W resistors. For use as current limiters between the LEDs and ground
  • 1 x 10k resistor
  • one push button
  • a breadboard and some connecting wire
  • some water
  • DS1307 timer IC circuit components (see this schematic from chapter seven) or a pre-built module
  • one 10k linear potentiometer
  • LCD module as per chapter two

Here are some videos of my interpretation. To save time I have not connected the LEDs, however timer running status is indicated on the second line of the display – an “!” is shown when a circuit has been activated. The first video shows setting the real time, timer data and displaying the results:

and the sketch.

How did you go? With a little more hardware this exercise could become a real product – you could control sprinkler systems instead of lights, thermostats, anything is really possible. Having a larger LCD screen would help with the user interface, perhaps a 20 character by 4 line unit. As long as such a screen has the standard HD44780 interface, you would be fine. Now on to Chapter Eleven

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, barebones, breadboard, education, microcontrollers, relayComments (17)

Education – the RC circuit

Hello readers

Today we continue down the path of analog electronics theory by stopping by for an introductory look at the RC circuit. That’s R for resistor, and C for capacitor. As we know from previous articles, resistors can resist or limit the flow of current in a circuit, and a capacitor stores electric current for use in the future. And – when used together – these two simple components can be used for many interesting applications such as timing and creating oscillators of various frequencies.

How is this so? Please consider the following simple circuit:

rccircuit

 

When the switch is in position A, current flows through R1 and into the capacitor C1 until it is fully charged. During this charging process, the voltage across the capacitor will change, starting from zero until fully charged, at which point the voltage will be the same as if the capacitor had been replaced by a break in the circuit – in this case 6V. Fair enough. But how long will the capacitor take to reach this state? Well the time taken is a function of several things – including the value of the resistor (R1) as it limits the flow of current; and the size of the capacitor – which determines how much charge can be stored.

If we know these two values, we can calculate the time constant of the circuit. The time constant is denoted by the character zeta (lower-case Greek Z).

The time constant is the time taken (in seconds) by the capacitor C that is fed from a resistor R to charge to a certain level. The capacitor will charge to 63% of the final voltage in one time constant, 85% in two time constants, and 100% in five time constants. If you graphed the % charge against time constant, the result is exponential. That is:

Now enough theory – let’s put this RC circuit to practice to see the voltage change across the capacitor as it charges. The resistor R1 will be 20k ohm, the capacitor 1000 uF.

Our time constant will be R x C which will be 20000 ohms x 0.001 farads, which equals 20 (seconds).  Notice the unit conversion – you need to go back to ohms and farads not micro-, pico- or nanofarads. So our example will take 20 seconds to reach 63% of final voltage, and 100 seconds to reach almost full voltage. This is assuming the values of the resistor and capacitor are accurate. The capacitor will have to be taken on face value as I can’t measure it with my equipment, and don’t have the data sheet to know the tolerance. The resistor measured at 19.84 k ohms, and the battery measured 6.27 volts. Therefore our real time constant should be around 19.84 seconds, give or take.

First of all, here is a shot of the little oscilloscope measuring the change in voltage over the capacitor with respect to time. The vertical scale is 1v/division:

And here is the multimeter measuring the voltage next to a stopwatch. (crude yet effective, no?)

The two videos were not the most accurate, as it was difficult to synchronise the stopwatch and start the circuit, but I hope you could see the exponential relationship between time and voltage.

What about discharging? Using the circuit above, if we moved the switch to B after charging the capacitor –  and R2 was also 20k ohm – how long would it take to discharge the capacitor? Exactly the same as charging it! So one time constant to discharge 63% and so on. So you can take the graph from above and invert it as such:

How can we make use of an RC circuit?

I’m glad you asked. Consider the following circuit:

pic23

When power is applied, the capacitor starts to charge, and in doing so allows current to flow to the emitter of the transistor, which turns on the LED. However as the capacitor charges, less current passes to the base of the transistor, eventually turning it off. Therefore you can calculate time constants and experiment to create an off timer. However, a preferable way would be to make use of a 555 timer. For example, an RC combination is used to set the pulse length used in astable timing applications, for example using R1, R2 and C1:

555astable

(For more information on the 555 timer, please read this article)

Another use of the RC circuit is oscillating. Due to varying capacitor values due to tolerance, you most likely cannot make precision frequency generators, but you can still have some fun and make useful things. Here is a classic oscillator example – an astable multivibrator:

multivib1

What is going on here? Here it is in action:

and here is one side being measured on the little scope:

We have two RC circuits, each controlling a transistor. When power is applied, there is no way to determine which side will start first, as this depends on the latent charge in the capacitors and the exact values of the resistors and capacitors. So to start let’s assume the left transistor (Q1) and LED are on; and the right transistor (Q2) and LED are off. The voltage at collector of Q1 will be close to zero as it is on. And the voltage at the base of Q2 will also be close to zero as C2 will initially be discharged. But C2 will now start charging via R4 and base of Q1 to around 5.4V (remember the 0.6v loss over the base-emitter junction of a transistor). While this is happening, C1 starts charging through R2. Once the voltage difference reaches 0.6V over the capacitor, Q2 is turned on.

But when Q2 is on, the voltage at the collector drops to zero, and C2 is charged, so it pulls the voltage at the base of Q1 to -5.4v, turning it off and the left LED. C1 starts charging via R1, and C2 starts charging via R3 until it reaches 0.6v. Then Q1 turns on, bringing the base of Q2 down to -5.4V – switching it off. And the whole process repeats itself. Argh. Now you can see why Arduino is so popular.

Time for a laugh – here is the result of too much current through a trimpot:

So there you have it – the RC circuit. Part of the magic of analogue electronics! And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in education, learning electronics, lesson, multivibrator, RC circuit, tutorialComments (11)

Part review – Sparkfun Arduino protoshield kit

Hello readers

Today we are going to look at another Arduino protoshield kit, this time one manufactured for Sparkfun. The reason to use such a thing is to enable extra hardware of your choice to be connected easily to your Arduino board. In the past I have detailed other shields, for example an LCD module, a real-time clock, and a microSD shield. However now I have another brand of shield, so let’s take it for a drive and see what happens.

Once again, this shield is a product of the minimalist-packaging school – arriving in just a plastic bag:

bagsmall

These days that is perfectly acceptable, as long as something is safe there’s no need for overpackaging. Not a slip of instructions were to be found, and a quick look at the website only had a link to a third-party tutorial and the shield schematic (pdf). The circuitry is quite simple so nothing more is necessary for construction. So with the schematic on the screen it was time to solder. First thing is to match the included parts with the schematic:

partssmall

Considering the price of this kit, I would have expected some pins as well as header sockets – not everyone wants to stack another shield on top. However the PCB is the thickest I have ever seen. The first thing to solder in were the buttons:

buttonsinsmall

Next were the three resistors. There are two 330 ohm to reduce the current to the LEDs and one 10k ohm for the button. The silk-screening has the values on the board, so you can place them effortlessly:

solderresistorssmall

Next are the two 0.1uF ceramic capacitors – they act to smooth the power supply. They are not marked on the board, only little rectangles. So here is a photo of where they should be:

capsinsmall

And finally the LEDs. Make sure to line up the flat edge of the LED (the cathode) with the image of the LED on the board. Try and get the LED flush with the PCB, and bend the legs in alternate directions to keep the LED flush while you are soldering it:

solderledssmall

The included LEDs are 5mm yellow, so you have the opportunity to change the colour if need be. If you are going to add your own circuitry, you might want to do that before soldering in the header sockets. You could also drop in a micro-breadboard instead. When it comes time to solder in the stacking headers  - insert them into your shield, put another shield on top to keep the sockets aligned, then solder them in:

testsocketsmall1

However at the end of the day it works:

finishedsmall

There you have it – one Arduino protoshield ready for action. If you look at the top-right of the board, you will notice pinouts that are custom-made for the Bluesmirf wireless serial bluetooth devices.

In general this shield is adequate. There is room for a few improvements, for example nothing on the bottom is labelled, which can be an issue if your eyesight or memory is poor. And considering the price of the board (US$16.95++) it should have included both header pins and sockets, and perhaps even have been assembled except for the headers. But thankfully there are other options to select from. Compared to my personal preference (the Freetronics protoshield), this protoshield from Sparkfun could use some improvement. Perhaps version three ? Only time will tell. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

[Note - this kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Posted in arduino, DEV-07914, part reviewComments (0)

Education – the Bipolar Transistor

Hello readers

Today we continue with the series of articles on basic electronics with this introductory article about the bipolar transistor, and using it as a switch.

What is a transistor?  It is a semiconductor with three leads, with which a small voltage or current applied to one lead can control a much larger current flowing through the other two leads. A transistor can be used as either a switch or an amplifier. Furthermore, there are two main types of transistor – the bipolar and the field-effect transistor. This article will examine and refer to bipolar transistors as transistors. Let’s go!

A transistor consists of three layers of silicon, P- and N-type in fact. Do you recall the diode article? A transistor is basically two diodes connected together in a Y-formation, in one of two ways as shown below:

pic11

Also notice the circuit symbols for NPN and PNP-type transistors. Transistors can be found in many shapes and sizes, the size usually being directly proportional to the amount of current the particular transistor is designed to handle. Thankfully the physical shape or package design has been standardised, and each casing type has a designation. Let’s look at some of the more common ones now:

TO-92 casing. When the flat-side is facing you, the pin numbering is 1-2-3. This casing style is for transistors that usually handle up to 100 mA. Unfortunately there are three varieties with regards to which pin is the base, collector and emitter – so always check your data sheet if in doubt.

TO-220 casing. When the metal tab is at the rear (above), the pin numbering is 1-2-3. The metal tab acts as a heatsink, and the hole enables one to bolt it to a larger heatsink, metal chassis, etc. This casing style is for transistors that usually handle up to around 8 amps.

TO-3 casing. These are all metal in order to dissipate heat – as they can handle up to around 75 amps of current. The entire metal case and ends are pin 2; pins 1 and 3 are the usual leads. Check your data sheet for pins 1 and 3! There are many other types of casing, but the three above are usually the most common.

How do transistors work?

For current to flow from the base of a transistor to the emitter, it needs to be forward-biased by at least 0.6 volts. In other words, there must be a potential difference between the base and emitter by 0.6V. If the base is connected to ground, the transistor will not let current pass from the collector to the emitter:

pic21

The transistors in the circuits above are NPN transistors. The current that flows from the base to the emitter is known as base current or Ib. The current that flows from the collector to the emitter is known as the collector current, or Ic. An interesting property of the transistor is this: the ratio of Ic to Ib is constant, and Ic is always larger than Ib. The ratio of Ic/Ib is known as the gain of the transistor. When reading a data sheet, gain is usually defined as hFE. This formula also proves that if there is no base current, there will be no collector current – you can’t divide by zero.

Using the transistor as a switch

To use a transistor as a switch, we need to know several things to be successful. For example:

To use the transistor to turn on the “load” we need to:

  • know the current drawn by the load. This is also the transistor’s Ic (collector current). Or the load’s resistance, as Ohm’s law can be used to calculate the current
  • know the transistor gain (hFE)
  • calculate Ib (base current)
  • use the above data to find a value for that lonely resistor

Let’s do that now with a contemporary problem… we have an Arduino that needs to turn a relay on and off at certain times. However you can only source up to 20 mA from a digital output on the Arduino, so we want to use it instead to switch a transistor which can control the relay coil. The problem is, what value resistor to use to control the base current?

pic41

First of all, let’s note what we do know. The relay (data sheet) coil requires 60 mA of current to activate, it is a 5 volt relay, and the coil has a resistance of 83 ohms. The transistor (data sheet) is a BC548 NPN transistor, very cheap and easy to find. It can handle a collector/load current of 100 mA, and the hFE (gain) is 110.  That diode is there to loop back pulse current when the relay is switched off. The supply voltage is 5 volts, and the digital output from the arduino is also 5 volts when active. There is also one more thing to take note of – the base-emitter junction is a diode, and therefore has a voltage drop of 0.7 volts. When you are switching large voltages, this is not an issue – however as we are working with a small voltage, the drop needs to be taken into account.

So, let’s calculate Ib, the base current. If hFE = Ic/Ib then 110 = 0.06 A/Ib; which translates to Ib = 0.06/110 = 0.0005 A. Which is basically nothing, so we’ll round it up to 1 milliamp.

Next, the resistor value. Using Ohm’s law (voltage = current x resistance):

Voltage = (5-0.7) = 4.3 volts (we need to take into account the voltage drop over the base-emitter junction of the transistor)

Current = 0.005 A (Will use a slightly higher current just to be on the safe side)

So, resistance = 4.3/0.005 = 860 ohms. For such a tiny current and small voltage, a 1/4-watt resistor is fine. (power = volts x current; = 4.3 * 0.005 = 0.0215 < 0.25)

If we didn’t have an 860 ohm resistor, a little higher is OK. I have used a 1k ohm resistor and it has worked nicely.

And there you have it – a transistor used as a switch. As stated at the beginning, this is only an introduction. There are literally hundreds of thousands of pages of material written about the use of transistors, so don’t stop here – experiment and do your own research and learning! In the next few weeks we will look at using transistors as amplifiers.

As always, thank you for reading and I look forward to your comments and so on. Furthermore, don’t be shy in pointing out errors or places that could use improvement. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts. Or join our new Google Group.

Some information for this post is from: historical info from Wikipedia; various technical information and inspiration from books by Forrest Mims III;  TO-3 package photo from Farnell Australia.

Posted in education, learning electronics, lesson, transistor, tutorialComments (4)

Getting Started with Arduino! – Chapter Nine

This is part of a series titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino microcontrollers. The first chapter is here, the index is here.

Welcome back fellow arduidans!

In this chapter we will start looking at LED matrix displays, designing user interfaces, implementing a user interface for  a clock, and finish up making an alarm clock.

Firstly, let’s have plenty of fun with 64 LEDs! Using an 8×8 LED display module:

ledmatrixsmall

Previously we have used 74HC595 shift registers to drive strips of LEDs, single and four-digit LED displays. An LED matrix seems complex at first, but after further investigation quite simple. With sixteen pins you can control 64 LEDs. It works by having 8 row pins, each pin connected to all the anodes on one row; and 8 pins each connected to the cathodes on one column:

matrixschematic

It does look like a mess, but we can work it out. As we did with the 4-digit 7-segment display module, we just need one shift register for the anodes, and one for the cathodes. Moving along from exercise 6.2, it will be easy to drive the an LED matrix display – one shift register (the left hand side) will apply current to the rows (anodes) and the other shift register will apply current to NPN transistors to allow current to flow from the cathodes (columns) to ground. So we can make an example quite easily. You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • One 8×8 LED matrix. Try to find one that has LEDs with a forward voltage of 2 volts and a current of less than 20mA. If it is bicolour, that’s ok – just use one colour for now
  • Eight 560 ohm 1/4 watt resistors
  • Eight 1 kilo ohm 1/4 resistors
  • Eight BC548 NPN transistors
  • Two 74HC595 shift registers
  • Solderless breadboard and connecting wires

Here is a circuit diagram for our example (click on it to enlarge):

example9p1schematicsmall

Please note that there are eight transistor/resistor combinations from the second shift register – I just have not drawn them in to save my sanity. They’re on the bottom right of my board:

example9p1boardsmall

Now how are we going to light up those LEDs? We need to send two bytes of data to the shift registers, one byte for the row, and one for the column. For this example we will work with individual pixels. For example, say you want to turn on the pixel at 8 across, 8 down – the bottom right. You need to send the following bytes of data to the shift registers: b00000001 and b00000001. In decimal those two numbers are 128 and 128. Or the top-left LED, at 1 across, 1 down – it would be b10000000, b10000000 or decimal 1,1. Once again we can use the functions:

… to send the data to the shift registers. This example sketch for the above circuit should be pretty well self-explanatory if you have been following my tutorials.

Here is is in action:

Once again, quite mesmerising. Did you notice that the horizontal solid rows were dimmer than the solid vertical columns? This is because when you light up one row, all eight LEDs are drawing current from one pin of the shift register – so there is less current for each LED; whereas in the column, each LED has its own source of current, so can therefore operate at full brightness. So a hint – when you are creating images or characters for your display, use scrolling columns to display the image.

Experiment with the example 9.1 sketch, if you display only vertical columns, and make the delay zero – you can give the illusion that the entire display is on, but it is not. Which leads us into the first exercise for this chapter.

Exercise 9.1

We can display entire columns with our matrix display. We can position these columns on demand. And without a delay, fill up the entire matrix. Now you can create images, or characters and display them on the matrix, one column at a time. For example, the little yellow dude from that popular arcade game many years ago might look like this:

Using the circuit described for example 9.1, create a character, shape, or whatever tickles your fancy, and animate it to move across the screen.

Hint – To animate an image, you will need to map the matrix every time the image changes – just like a normal animation or cartoon. However, store all the values for the entire animation in one array, otherwise you will go bonkers. When you need to read the array, each matrix image can be read as they are multiples of eight (then add the reference to the value you want).

For inspiration, here is what I came up with:

and the corresponding sketch.

How did you go? If you have an interesting animation, and you can do so – please email a link to Youtube, Vimeo, etc showing your creation – you could win a prize.

Time to get a little more serious now. :(

Over time you have been making things, some useful, some more experimental than anything. Hopefully you will reach the stage of designing something that has a real-world use and could be used by people other than yourself or your immediate circle of friends. In the next few weeks we will look at methods of transitioning projects from prototypes to standalone products you can develop!

A major part of your design should be the user interface, or how your project responds to user input and displays data, results and so on. If something is difficult to use, or understand, it will not be a good product. So what can we do about this? This week we will examine the clock made in example 7.4 and change it to be independent of a computer, and easy for the user to operate. But now for some design inspiration…

The humble alarm clock (it has been staring at me every morning). Here is my late grandfather’s clock from the 1960s:

frontclocksmall

rearclocksmall

Simple, yet functional. It does what it is supposed to do with the minimum of fuss. (It’s German). And that is how our project user interfaces should be. As technical people it is very easy to get carried away and put buttons, lights, and all sorts of things together, but at the end of the day, less is more. How can we emulate this with Arduino – but in a simple method?

Looking at the face of the clock, it displays the time (hours, minutes, seconds) and the alarm time. We can use an LCD for that. On the top is the alarm off button. We can use a button for that. On the rear there are winders for the time and alarm spring – we have electricity for that. There are two knobs, one to adjust the time, and one to adjust the alarm – here we have several options. We could use up/down buttons… perhaps we could use a knob as well? And finally there is the gain control – we don’t need this as our DS1307 is infinitely more accurate.

A rough map of how you want things to work is always a good start, for example my mess below:

uidraftsmall

How can this be implemented? Let’s see. The clock will normally display the date, time, etc. If a button is pressed, it will switch to menu mode (on the right). A knob will be used to select one of the options listed on the right, when the required option is displayed, the user presses the button to select the option. Then the user can use the knob to adjust the variable for that option, and press the button to return to the menu. The last menu option is to return to the clock display. So we can control the whole lot with only one button and one knob.

The button is easy with Arduino, and to save money we can use a potentiometer as a knob. Remember we did this in in exercise 6.2. Normally it can return a value between 0 and 1023, but with our clock we need it to return a value that falls within a variety of ranges – from 0 to 6 for day of the week, to 0 to 59 for the minute adjustment.

Exercise 9.2

Create a function to use a potentiometer to return an integer between zero and a maximum range value. The function will accept the maximum range value, and return an integer which represents the position of the knob. For example:

Here is a short video of my interpretation in action.

And the resulting sketch. The value rangemax that is fed into the function is the number of positions in the range you want to work with. For example, if I want the knob to return a value between zero and fifty-nine (sixty values in the range) I would set rangemax to 60. The value dialpin is the number of the analogue pin the potentiometer is connected to. You should use a linear potentiometer to ensure a nice smooth adjustment.

Great – now we have a way of reading our knob and customising the result for our range requirements. Our clock example’s menu will require eight options, each with their own function (e.g. set hours, set minutes, set year, return to clock, etc). We have one button, so you could use that to trigger an interrupt to start the menu display (interrupts were covered in chapter three). However if you have made an LCD shield use the interrupt pins, you will need to check the button status while displaying the time. We will make the display of the menu a separate function as well.

For now we will make our clock respond to the ‘menu’ button, and display the eight options when the knob is rotated. We will build on the sketch from example 7.4. Here is the result of doing this:

Now it is time (ha!) to make those menu options actually do something. First we need our displaymenu() function to call the selected option. This can be done with a switch…case function. For example, I will put this code after the while loop:

There is no need for a seventh option (return to clock display) as this will default if the knob is in the ’7′ range. Notice I have already declared the name of the functions to call. All we have to do is create the individual functions. However there is one catch to work around, when it comes to setting time and date data, this is all done with the one function:

So inside the function that (for example) sets the hour, immediately before setting the hour, read the rest of the values from the clock, and reset them back in with the setDateDS1307() function.

Once again the basic work has been done for you, please see this video:

… and the sketch. Although the contents of the LCD during the menus may be brief, the framework of the user interface has been created and can now be easily modified. For example, if you had a 20 x 4 character LCD, you could offer more help to the user. But returning to the original task – emulating Grandfather’s alarm clock. We need an alarm!

Exercise 9.3

You guessed it – modify the clock in example 9.3 to have an alarm as well. User can set the alarm, and turn it on or off with the menu system. When the alarm sounds, the user should be able to turn off the alarm, Have fun!

How did you go? Here is a video demonstration of my work:

… and the sketch. That was really fun – I have a lot more clock ideas now.

I hope you enjoyed the change of pace this article and have a greater understanding on why we should create simpler human-machine interfaces wherever possible. Now to move on to Chapter Ten.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, education, LED matrix, lesson, microcontrollers, tutorialComments (41)

Electronic components – the Capacitor

Hello readers

Today we continue with the series of articles on basic electronics with this introductory article about the capacitor.

What is a capacitor? A very simple answer to that question is a part that stores electric current for use in the future. How is this so? A capacitor is made up of two conductive plates, separated by a dielectric. The plates can be made from conductive material such as aluminium, and the dielectric is between these conductive plates. Dielectrics can be made from nothing (i.e. be a tiny gap between the plates or a vacuum), paper, plastic film, glass, a special kind of fluid, or ceramic material:

pic1

When a difference in potential exists across the plates (a change in voltage) an electric field is created between the plates, which stores electrical energy – charging the capacitor. When the potential difference is removed, the energy will leak through the dielectric until the potential no longer exists – in other words discharging the capacitor. The amount of energy that a capacitor can hold – its capacitance, is a unit of measure called the Farad.

The term farad is named after an Englishman by the name of Michael Faraday, a genius chemist and physicist that discovered (amongst many other things) the concept of electromagnetic fields. Anyhow, one farad (F) is quite a lot of energy, so capacitors usually store much less. The most common units of measurement are the following:

  • picofarads – pF – 10^-12 – 0.000 000 000 001 F
  • nanofarads – nF – 10^-9 – 0.000 000 001 F
  • microfarads – uF – 10^-6 – 0.000 001 F

As well as the capacitance value, the other common parameters of a capacitor are:

  • the voltage (never exceed your voltage!)
  • leakage current – capacitors are not perfect and do leak a very tiny amount of current, usually in the micro-ampere range
  • tolerance – similar to resistors, actual versus manufactured values can vary – sometimes up to 20% either way
  • working temperature – always check this if your project involves extreme temperatures

It is always interesting to read component data sheets, and this is no exception for capacitors. You can learn a lot about the individual parameters and design your project accordingly. Here is a typical example of a data sheet for an electrolytic capacitor from Vishay. And here are the schematic symbols for non-polarised and then polarised capacitors:


At this point let’s have a look at the various types of popular capacitors:

Electrolytic Capacitors

electrolyticsmall

These are used when very high values of capacitance are required, for power smoothing, spike suppression and so on. They consist of two sheets of aluminium foil, one sheet covered with an oxide coating, separated by paper soaked in electrolye – this is rolled up and inserted into a cylinder, with two wires inserted. As the electrolyte is a liquid, it is affected by ambient temperature. Therefore as temperature increases, the capacitance increases – and vice versa. Therefore temperature extremes need to be taken into account, and perhaps other types of capacitors used. The capacitors in the photo above are radial capacitors; you can also find axial capacitors with one lead at each end. Note that electrolytics are polarised! They have a positive and negative lead – the negative is normally indicated by the striped-arrow line (see above).

V-chip capacitors

These are surface-mount electrolytic capacitors, for example these two on my Arduino (below):

smtelectrosmall

Ceramic capacitors

These are very small, constructed from layers of aluminium and ceramic material:

ceramicsmall

tinypolyestersmall

Their capacitance is also very low, the lowest I have seen is 0.015 picofarads. Typically used in situations that have high frequencies, such as spike protection for integrated circuits. Reading the value is quite simple, the first two digits are the significant figures, and the third is the multiplier. The result is always picofarads. For example. 121 is 120 picofarads, 8.2 is 8.2 picofarads, 12 is 12 picofarads. If there is a letter suffix, this indicates the tolerance:

  • C = +/1 0.25pF
  • D = +/- 0.5 pF
  • J = 5%
  • K = 10%
  • M = 20%
  • P = +100%/-0%
  • Y = -20%/+50%
  • Z = -20%/+80%

If there are numbers after the tolerance, they normally state the maximum working voltage. If your capacitor does not have a tolerance printed on it, assume it is between 10 and 20%. Or better yet, replace it with a better capacitor that states the tolerance.

Polyester capacitors

 

greencapsmall

newpolyestersmall

These are also very popular for high-frequency circuits, as they can discharge very quickly and have a very low leakage. The older styles (green/brown above) – read their values is the same as the ceramic capacitors (above), with a slight difference – sometimes (!) the voltage rating is before/above/below the value code. So using the green example above which reads “2A683J”, this breaks down to the voltage rating 2A, and the value 683, then the tolerance J. Voltage ratings are:

  • 2A – 100V DC
  • 2E – 250V DC
  • 2G – 400 V DC
  • 2J = 630V DC

So the 2A683J will have a voltage rating of 100V, a tolerance of 5%, and a capacitance of 68000 picofarads (0.068 uF or 68 nF).

Please note – this coding does seem to vary by manufacturer. Some will actually have (e.g.) 630V printed on them, and some even have their own coding. If you are unsure of the voltage rating, one has to really examine the circuit the capacitor is located in, or hunt down the data sheet. When buying new parts, it pays to get the data sheet from the distributor, then file it away indexed with your stock control database.

The newer styles (blue above) are different again. This one is 0.47 uF 63 volts 10% tolerance.

Variable capacitors

variablesmall

There are two main types – trimmer capacitors (above right) used for fine-tuning; and normal variable (or mini-tuning) capacitors (above left) used for applications such as radio tuning. Usually have a set range, for example the tuning capacitor’s range is 60 to 160 picofarads. The schematic symbol for trimmer capacitors is:

and for variable capacitors is:

Tantalum capacitors

Can be used as a replacement for electrolytic capacitors where space is at a premium, and a more accurate and less leaky (electrically that is) solution is required. Tantalums are also polarised (see the tiny ‘+’ in the photo above).

Surface-mount capacitors

There are many types of capacitor in surface-mount packaging. Hover over the images below for descriptions:

Mathematics of capacitors

Working with capacitors is easy, however some mathematics may be required. If you recall the formulae associated with resistors, you will find this quite easy.

Capacitors in parallel

This is simple – the total capacitance of parallel capacitors is the sum of the lot. However – the voltage parameter of the group is the minimum value used. Furthermore, do not mix capacitor types.

For example – C1 is 10 uF, 63V; C2 is 470 uF 25V; C3 is 1000 uF 16V. With these three in parallel, the capacitance is 1480 uF; and the maximum voltage is 16 volts.

{Thank you readers for checking my maths! – John :)}

Capacitors in series

This is somewhat complex, but can be done!

pic8

Again, always use the same type of capacitor, and the lowest voltage rating applies to the entire group.

Smoothing DC current with a capacitor

When AC current is converted to DC current using a bridge rectifier (four diodes) the resulting DC current is not very smooth… that is the actual voltage changes between zero and the maximum over very short periods of time. A capacitor can be placed between the positive and negative rails immediately after the bridge rectifier to solve this problem. It does this by charging to capacity when the DC current is above zero, then when the voltage from the rectifier drops the capacitor supplies current, acting as a reservoir. This in turn maintains the supply voltage:

beforeafter

Using the circuit above, we will demonstrate the smoothing process in the video clip below. The first part shows the AC current on the oscilloscope; the second part shows the noisy DC current at the points 4 and 8 on the circuit above. Then a 470 uF electrolytic capacitor is inserted across points 4 and 8 – you can see the difference and how smooth the current has become. There is still a slight ripple, but I cannot show this due to the low resolution of my oscilloscope. When building a power supply, one would place the linear regulator after the capacitor in our example.

Some information for this post is from Wikipedia; various technical information and inspiration from books by Forrest Mims III;  tantalum and SMD capacitor photos from element14 Australia.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in capacitor, education, learning electronics, lesson, tutorialComments (12)

Electronic components – the Resistor

Hello readers

Today we continue with the series of articles on basic electronics with this introductory article about the resistorWith regards to this article, it is only concerned with direct current (DC) circuits.

What is a resistor? It is a component that can resist or limit the flow of current. Apart from resistors, other electronic components also exhibit an amount of resistance, however the precise amount can vary. The unit of measure of resistance is the Ohm (Ω), and named after the clever German physicist Georg Simon Ohm. He discovered that there was a relationship between voltage (the amount force that would drive a current between two points), current (the rate of flow of an electric charge) and resistance (the measure of opposition to a current) – what we know as Ohm’s law – which states that the current between two points in a conductor is directly proportional to the potential difference (voltage) between the two points, and inversely proportional to the resistance between them.

Or, current = voltage / resistance. You should remember that formula, it can be useful now and again.

But I digress.

There are many types of resistors, each with a different application – but all with the same purpose. Let’s have a look at some now…

Fixed-value leaded resistors

These are the most common type that you will come across. The larger they are, the great amount of watts (the amount of power dissipated by the resistance) they can handle. More common varieties can vary from 0.125 watt to 5 watts. For example, here is a 0.125W resistor, the  length of the body is 3.25 mm.:

The body colour of these smaller resistors usually indicates the type of resistor. For example, those with a beige body are carbon resistors. They are usually the cheapest, and have a tolerance of 5%. This means that the indicated value can vary 5% either way – so if your resistor read 100 ohms, the actual value could be between 95 and 105 ohms. Resistors with a blue-ish body are metal-film resistors. They are usually a little bit more expensive, but have a 1% tolerance. Unless you are really trying to save a few cents, use metal-films. Another example is this one watt resistor:

They are much larger, this example is 25mm long and 8mm in thickness. The size of a resistor is generally proportional to its power handling ability.

Do you see the coloured bands around the resistor? They are colour codes, a way of indicating the resistance and tolerance values. And for colour-challenged electronics enthusiasts, a royal PITA. Resistor values can vary, from zero ohms (technically not a resistor… but they do exist for a good reason) up to thousands of millions (giga-) of ohms.

Let’s learn how to read the resistor colour codes. First of all, have a look at this chart:

resistor-colour-codes-small

Some resistors will have four bands, some will have five. From personal experience, new resistors are generally five band now. So you just match up the first three bands from left to right, then the fourth band is your multiplier, and the last band is the tolerance. For example, the three resistors below are labelled as 560 ohm resistors:

560rsmall

So the bands are: green, blue, black, black, tolerance – 5, 6, 0 = 560, then 1 for multipler = 560 ohms. The carbon-film resistor (top) has a gold tolerance band – 5%, the others being metal film are brown for 1%. This is why it is much easier to have a nice auto-ranging multimeter. Now if you need a resistor that can handle more than one watt, you move into ceramic territory. Thankfully these are large enough to have their values printed on them. For example:

There are literally scores of varieties of resistors in this physical category. If you don’t have the time or penchant to visit an electronics store, browse around online catalogues with images such as Digikey, element14/Newark (USA), Mouser, etc.

Surface-mount resistors

These are the becoming the norm as technology marches on. Even electronics hobbyists are starting to work with them. They consist of two metal ends which make contact with the circuit board, and a middle section which determines the resistance. They are tiny! The smallest being 0.6 x 0.3 mm in size. The smaller sizes may not have markings, so you need to carefully keep track of them.

As an aside, here is a interesting article on how to solder SMD parts at home. Moving on…

Resistor Arrays

You may find yourself in the situation where you need multiple values of the same resistor in a row, for example to limit current to a bank of LEDs or an LED display module. This is where a resistor array can be convenient. You can usually find arrays with between four and sixteen resistors in a variety of casings which speeds up prototyping greatly – however they do cost more than the individual resistors. For example: (hover over image for description)

Variable resistors

As expected there are many types of variable resistors, from the tiny to the large. Just like fixed-value resistors you need to ensure the power-handling (watts value) is sufficient for your project.

Variable resistors normally consist of a surface track that has resistive properties, and a tiny arm or contact that moves along the track. There are three terminals, one at each end of the track, and one to the arm or wiper. You would normally use the wiper contact and one of the others, depending on which way you want the variable resistor to operate (either increasing or decreasing in resistance). For example:

So as the wiper moves clockwise, the resistance increases…

Starting with the small – a variety of trimpots, used more for refining settings and not general everyday user input. Here is a small range of PCB-mount trimpots:

trimpotssmall

The two on the left are not sealed, exposed to dust and other impurities that can interfere with them. The two on the right are enclosed, and have a smoother feel when adjusting, and are generally preferable. These trimpots are single-turn, which can make getting finite adjustments in high-value resistances rather difficult. However you can purchase multi-turn trimpots allowing you greater detail in adjustment. Trimpots are usually labelled very well, depending on the manufacturer. For example, the black one above is 10k ohm, easy. Some will have a numerically coded version. Such as the one on the right. It is labelled 501, which means 50 ohms with 1 zero after it, so it is 500 ohms. Another example is 254, that is 25 with four zeros, i.e. 250000 ohms or 25 kilo ohm.

Next up are potentiometers – the garden variety variable resistor:

potssmall1

Apart form the resistance and wattage value, there are two major types to choose from: linear and logarithmic. The resistance of linear ‘pots’ is equally proportional to the angle of adjustment. That is, if you turn it half-way, its value is (around) 50% of the total resistance. Ideal for adjusting voltage, brightness, etc. Logarithmic are usually for volume controls. Here is a very crude example of the logarithmic VR’s resistance value relative to wiper position:

loggraph

When identifying your variable resistor, units marked with ‘A’ next to the value are logarithmic, and ‘B’ are linear. For example, B10k is a 10 kilo ohm linear potentiometer. These types are also available as doubles, so you can adjust two resistances at the same time – ideal for stereo volume controls. If you are going to build a project with these and mount them into a case, be sure to check that the knobs you want to use match the shaft diameter of the potentiometer before you finalise your design.

Light-dependent resistors

These can be a lot of fun. In total darkness their resistance value is quite high, around 1 mega ohm, but in normal light drops to around 17 kilo ohm (check your data sheet). They are quite small, the head being around 8mm in diameter.

Great for determing day or night time, logging sunrise and sunset durations, or making something that buzzes only in the dark like a cricket.

Digital potentiometers

Imagine a tiny integrated circuit that contained hundreds of resistors in series, and could have the resistance selected by serial digital control. These are usually classified by the total resistance, the number of potentiometers in the chip, the number of divisions of the total resistance offered, and the volatility of the wiper. That is, when the power is turned off, does it remember where the wiper was upon reboot, or reset to a default position. For example, Maxim IC have a range of these here.

Thermistors

Think of a thermistor as a resistor that changes its resistance relative to the ambient temperature. Here is a thermistor as found in the Electronic Bricks:

thermistorsmall

And the circuit symbol:

There are positive and negative thermistors, which increase or decrease their resistance relative to the temperature. Within the scope of this website, thermistors are not an idea solution to measure temperature with our microcontrollers, it is easier to use something like an Analog Devices TMP36. However, in general analogue situations thermistors are used widely.

Mathematics of resistors

Working with resistors is easy, however some planning is required. One of the most popular uses is to reduce current to protect another component. For example, an LED. Say you have an LED that has a forward voltage of 2 volts, draws 20 mA of current, and you have a 5V supply. What resistor value will you use?

First of all, note down what we know: Vs (supply voltage) = 5V, Vl (LED voltage) = 2V, Il (LED current = 0.02A). Using Ohm’s law (voltage = current x resistance) we can rearrange it so:

resistance = voltage / current

So, resistance = (5-2)/0.02 = 150 ohms.

So in the circuit above, R1 would be 150 ohms

Resistors in series

pic2

If you have resistors in series, the total resistance is just the sum of the individual values. So R = R1 + R2 + R3 …Rx

Resistors in parallel

Using resistors in parallel is a little trickier. You might do this to share the power across several resistors, or to make a value that you can’t have with a single resistor.

Voltage division with resistors

If you cannot reduce your voltage with a zener diode, another method is voltage division with resistors. Simple, yet effective:

pic41

Always check that the resistors you are using are of a suitable power handling type. Remember that W = V x A (power in watts = volts x current in amps)!

Update – “The resistor – part two” has now been published, with more information on how resistors divide and control current, and much more. Please visit here.

Well that wraps up my introduction to resistors. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in education, learning electronics, lesson, resistor, tutorialComments (12)

Electronic components – the Diode

Hello readers

Although my posts have generally been about microcontrollers, kits and related items, I have been rather lax in writing about electronics in general, and that magical world of wonder known as analogue electronics… i.e “Before Arduino” :) So let’s go back to some of the basics. Starting with the diode

What is a diode? It is an electronic component that allows current to only flow in one direction. Before the advent of semiconductors, vacuum tube diodes were used. Thankfully no more…

A diode is comprised of two types of semiconductor crystal (usually made from silicon or germanium) that are highly refined then doped with an impurity. Depending on the impurity, the crystal can either be called an “N-type” or “P-type”. When you put an N-doped region next to a P-doped region, a diode or PN junction is formed. In our diodes, the P-region is called the anode, and the N-region is called the cathode. As you can imagine, these properties are useful, allowing current to flow only in one direction.


The basic symbol for a diode in a circuit diagram or schematic is this:


So in a circuit, the current only flows in one direction, for example:


When a diode is connected in this way, it is said to be forward-biased, that is the anode is connected to a higher voltage than the cathode. If the diode was reversed, with the cathode connected to the higher voltage, it would not allow current to flow, and therefore would break the circuit. A forward-biased diode is considered to be a closed switch, as the voltage does not drop as the current passes through the diode. However that is assuming the diode is perfect. And like many other things in life, it is not perfect.

All diodes are not perfect, and have what is called a forward voltage drop, this is the amount by which the voltage decreases as the current passes through the diode from anode to cathode. For silicon diodes, this is ~0.7 volts; for germanium diodes ~0.3 volts.

Diodes are also manufactured to handle a certain amount of power. Recall that:

power (watts) = current (amps) x voltage (volts)

As the voltage drop with our normal diode is 0.7V, the power dissipated by the diode can be calculated by simply multiplying the current by 0.7.

For example, if we have a 1 watt diode, how much current can it handle?

1 = current x 0.7; current = 1/0.7

Current = 1.42

So the 1 watt diode can theoretically handle 1.42 amps of current.

What happens if you use a diode the other way, that is attempt to allow current to flow from the cathode through to the anode. Ideally nothing will happen – to a point. Diodes have a breakdown voltage, when a reverse-biased (backwards) diode starts to allow current to flow through it. The breakdown voltage of each type of diode is different, it depends on the manufacturer. The best way to find out what the breakdown voltage of your diode is to check the data sheet. For example, a popular diode is the 1N4001. From page two of the data sheet (pdf), comes the following table:

pic4

So for the 1N4001 diode, the breakdown voltage is 50V. Peak repetitive means that the diode can sustain doing this more than once. Excessive voltage will not usually destroy a diode. Excessive current will destroy a diode. This is interesting, as you can use a diode as a voltage regulator, provided that you don’t exceed the maximum current it can handle. Refresh your memory about voltage division with resistors. The disadvantage of using two resistors is that it can be difficult to purchase precise values.

So let’s use a zener diode instead. They are manufactured with a much more precise (and lower) voltage; and handle less power. Zener diodes have a slightly different symbol:


Zener diodes will usually (hopefully) have their breakdown voltage within their part number. For example, an NXP 4.7V zener diode’s part number is: BZX79-B4V7. The 4V7 is the breakdown voltage, with a V for the decimal point. It can handle 500 mW, but this is not obvious – once again, you will need the data sheet (pdf). Below is a photo of a typical zener diode. It is very small, the grid paper beneath it is 5mm square. The ring or dark band around one end of the diode always indicates the cathode end:

1n750a

And now for an example. We have a tiny Zilog ePIR that requires a nice smooth 3.3v DC, and only draws 10mA, however the power rail on our prototype is 5V. This is a job for a 3.3V zener diode. Here is our schematic:

pic6

We need to calculate the appropriate resistance to limit the current through our zener diode. We are using a Fairchild BZX55C3v3 (data sheet pdf). Maximum power is 500mW or 1 watt. To calculate the value of the resistor, we will need the maximum current for the diode, calculated by

current = power / voltage

current = 0.5 watts / 3.3 volts

current = 0.150 A or 150 mA.

Using Ohm’s law, resistance = voltage /current

resistance = 1.7 volts / .15 A

resistance = 11.333333 = 12 ohms

So we would use a nice metal film 1% tolerance 12 ohm resistor, rated at 500 mW. Easy, 1.2 cents from RS or element-14.

Another type of diode is the signal diode. They handle much less current, usually around 100 mA, but are more suited for high-frequency signals, or semiconductor protection.Signal diodes can have a high breakdown voltage, but low power handling ability. A very popular signal diode used is the 1N4148 (data sheet), an example of which is below:

1n4148

For example, a signal diode may be places across the coil of a relay that is being controlled by a transistor – as it allows the current produced by the change in magnetic field when the coil is deactivated to head through the coil instead of the transistor. For example, when using an Arduino to control a relay coil:

 

pic7

Our next diode type is the germanium diode. They have a very small voltage drop of 0.2V, and are mostly used in crystal radio sets. They are very fragile, but are ideal for putting across a radio wave signal to convert it from AC to DC, which can then be amplified. If you are interested, here are some guides to making a crystal radio.

Another type of diode is the Schottky diode (named after the German physicist Walter Schottky). The symbol for a schottky diode is this:

There are two main differences between a schottky diode and a normal diode. One – a schottky diode does not have a discernible recovery time between conducting and not conducting a current. For example, a normal diode may take around a few hundred nanoseconds; whereas a schottky does not. This makes them useful in situations that involve very very high speed switching of current (for example, DC-DC converters such as Limor Fried’s mintyboost). Two – a schottky diode has a smaller forward voltage, a typical example (data sheet) is 0.55v.

Finally we come to rectifier diodes. Their main feature is the ability to handle large amounts of current, from 1 amp upwards; and higher breakdown voltages. For example the 1N4001 (data sheet) diode is 50V at 1 amp; the 1N5401 (data sheet) is 100V at 3 amps. The main purpose of these diodes is to protect against incorrect polarity from power supplies, and to convert AC to DC. For example, if you were designing a childrens’ toy that used a 9V battery, you would use reverse-bias a rectifier diode between 9V and GND in case the child forced the battery in the wrong way.

But how can rectifier diodes convert AC to DC power? Very easily – through the use of a bridge rectifier. A bridge rectifier is basically four rectifier diodes connected together, for example:

pic8

 

 

When the AC power is between 0 and maximum wave, the positive DC rail is fed by the path: 1,2,3,4; the negative DC rail is 8,7,6,5. When the AC power is between 0 and minimum wave, the positive DC rail is fed by the path: 5,6,3,4; the negative DC rail is: 8,7,2,1.

Bridge rectifiers come in various shapes and sizes, for example DIP packaging for 1A 100V models:

right through to 300A 1600V models…


Last but not least is the light emitting diode (LED). An LED is a special kind of diode, when it is forward-biased and a current applied, it releases energy in the form of light instead of heat. Here is the common schematic symbol for an LED:

When using an LED it is critical to ensure you have the correct voltage, otherwise your LED will overheat, burn your fingers when you touch it then eventually break. Always consult your data sheet. Calculating the correct voltage is quite simple. Using a bog-standard 5mm RED LED as an example (data sheet), you can use the following formula:

R = (Vs-Vled) / A

where:

  • R = value of resistor to use in ohms
  • Vs is your supply voltage in volts DS
  • Vled is the forward voltage of the LED at the recommended current
  • A is the recommended operation current of the LED

So for our example, we will use a 9V battery, and the LED from the data sheet above, Vled is 2V and A is 20 mA or 0.02 A

That gives us R = (9-2)/0.02 = 7/0.02 = 350 ohms.

Therefore, place a 350 ohm resistor between the positive of the battery and the anode of the LED. The most popular value of resistor to use would be a 390 ohm, 1/4 watt.

You can find LEDs in many different colours, and also units with two or more LEDs in the one housing, example red, green and blue. Some LEDs also create light in non-visible wavelengths, such as infra-red – these are used in remote-control applications and night-vision equipment. However if you are reading this, you would know by now where to find LEDs.

Well that wraps up my introduction to diodes. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

 

 

Posted in bridge rectifier, diode, education, learning electronics, schottky, twitter, zenerComments (6)

Getting Started with Arduino! – Chapter Eight

This is part of a series titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino microcontrollers. The first chapter is here, the complete index is here.

In this chapter we will continue to examine the features of the DS1307 real time clock, receive user input in a new way, use that input to control some physical movement, then build a strange analogue clock. So let’s go!

Recall from chapter seven, that the DS1307 is also has an inbuilt square wave generator, which can operate at a frequency of 1Hz. This is an ideal driver for a “seconds” indicator LED. To activate this you only need to send the hexidecimal value 0×10 after setting the date and time parameters when setting the time. Note this in line 70 of the solution for exercise 7.1. This also means you can create 1Hz pulses for timing purposes, an over-engineered blinking LED, or even an old-school countdown timer in conjunction with some CMOS 4017 ICs.

For now, let’s add a “seconds” LED to our clock from Exercise 7.1. The hardware is very simple, just connect a 560 ohm resistor to pin 7 of our DS1307, thence to a normal LED of your choice, thence to ground. Here is the result:

Not that exciting, but it is nice to have a bit more “blinkiness”.

Finally, there is also a need to work with 12-hour time. From the DS1307 data sheet we can see that it can be programmed to operate in this way, however it is easier to just work in 24-hour time, then use mathematics to convert the display to 12-hour time if necessary. The only hardware modification required is the addition of an LED (for example) to indicate whether it is AM or PM. In my example the LED indicates that it is AM.

Exercise 8.1

So now that is your task, convert the results of exercise 7.1 to display 12-hour time, using an LED to indicate AM or PM (or two LEDs, etc…)

Here is my result in video form:

and the sketch.

OK then, that’s enough about time for a while. Let’s learn about another way of accepting user input…

Your computer!

Previously we have used functions like Serial.print() to display data on the serial monitor box in the Arduino IDE. However, we can also use the serial monitor box to give our sketch data. At first this may seem rather pointless, as you would not use an Arduino just to do some maths for you, etc. However – if you are controlling some physical hardware, you now have a very simple way to feed it values, control movements, and so on. So let’s see how this works.

The first thing to know is that the serial input has one of two sources, either the USB port (so we can use the serial monitor in the Arduino IDE) or the serial in/out pins on our Arduino board. These are digital pins 0 and 1. You cannot use these pins for non-serial I/O functions in the same sketch. If you are using an Arduino Mega the pins are different, please see here.  For this chapter, we will use the USB port for our demonstrations.

Next, data is accepted in bytes (remember – 8 bits make a byte!). This is good, as a character (e.g. the letter A) is one byte. Our serial  input has a receiving buffer of 128 bytes. This means a project can receive up to 128 bytes whilst executing a portion of a sketch that does not wait for input. Then when the sketch is ready, it can allow the data to serially flow in from the buffer. You can also flush out the buffer, ready for more input. Just like a … well let’s keep it clean.

Ok, let’s have a look. Here is a sketch that accepts user input from your computer keyboard via the serial monitor box. So once you upload the sketch, open the serial monitor box and type something, then press return or enter. Enter and upload this sketch:

 

Here is a quick video clip of it in operation:

So now we can have something we already know displayed in front of us. Not so useful. However, what would be useful is converting the keyboard input into values that our Arduino can work with.

Consider this example. It accepts a single integer from the input of serial monitor box, converts it to a number you can use mathematically, and performs an operation on that number. Here is a shot of it in action:

example8p2

If you are unsure about how it works, follow the sketch using a pen and paper, that is write down a sample number for input, then run through the sketch manually, doing the computations yourself. I often find doing so is a good way of deciphering a complex sketch. Once you have completed that, it is time for…

Exercise 8.2

Create a sketch that accept an angle between 0 and 180, and a time in seconds between 0 and (say) 60. Then it will rotate a servo to that angle and hold it there for the duration, then return it to 0 degrees. For a refresher on servo operation, visit chapter three before you start.

Here is a video clip of my interpretation at work:

So now you have the ability to generate user input with a normal keyboard and a PC. In the future we will examine doing so without the need for a personal computer…

Finally, let’s have some fun by combining two projects from the past into one new exercise.

Exercise 8.3

Create an analogue clock using two servos, in a similar method to our analogue thermometer from chapter three. The user will set the time (hours and minutes) using the serial monitor box.

Here is a photo of my example. I spared no expense on this one…

exercise8p3small

Here is a video demonstration. First we see the clock being set to 12:59, then the hands moving into position, finally the transition from 12:59 to 1:00.

If you had more servos and some earplugs, a giant day/date/clock display could be made… Nevertheless, we have had another hopefully interesting and educational lecture. Or at least had a laugh. Now onto chapter nine.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, education, LCD, lesson, microcontrollers, serial monitor, servo, tutorialComments (17)

Getting Started with Arduino! – Chapter Seven

This is part of a series titled “Getting Started with Arduino!” – A tutorial on the Arduino microcontrollers. The first chapter is here, the complete index is here.

Welcome back fellow arduidans!

This week is going to focus around the concept of real time, and how we can work with time to our advantage. (Perhaps working with time to our disadvantage is an oxymoron…) Once we have the ability to use time in our sketches, a whole new world of ideas and projects become possible. From a simple alarm clock, to complex timing automation systems, it can all be done with our Arduino and some brainpower. There is no time to waste, so let’s go!

First of all, there are a few mathematical and variable-type concepts to grasp in order to be able to understand the sketch requirements. It is a bit dry, but I will try and minimise it.

The first of these is binary-coded decimal.

Can you recall from chapter four how binary numbers worked? If not, have a look then come back. Binary coded decimal (or BCD) numbers are similar, but different… each digit is stored in a nibble of data. Remember when working with the 74HC595 shift registers, we sent bytes of data – a nibble is half of a byte. For example:

bcdtable

Below is a short clip of BCD in action – counting from 0 to 9 using LEDs:

However, remember each digit is one nibble, so to express larger numbers, you need more bits. For example, 12 would be 0001 0010; 256 is 0010 0101 0110, etc. Note that two BCD digits make up a byte. For example, the number 56 in BCD is 0101 0110,  which is 2 x 4 bits = 1 byte.

Next, we will need to work with variables that are bytes. Like any other variable, they can be declared easily, for example:

byte seconds = B11111;

B11111 is 31 in base 10, (that is, 2^4+2^3+2^2+2^1+2^0     or    16+8+4+2+1)

However, you can equate an integer into a byte variable. Here is a small sketch demonstrating this. And the result:

example7p1

If you printed off the results of the sketch in example 7.1, it would make a good cheat sheet for the Binary Quiz program in Chapter Five.

Anyhow, moving forward we now take a look at hexadecimal numbers. ‘Hex’ numbers are base-16, in that 16 digits/characters are used to represent numbers. Can you detect a pattern with the base-x numbers? Binary numbers are base-2, as they use 0 and 1; decimal numbers are base-10, as they use 0 to 9 – and hexadecimal numbers use 0 to 9 then A to F. Run the following sketch to see how they compare with binary and decimal.

Below is a screenshot of the result: the left column is binary, the centre decimal, and the right hexadecimal:

example7p1

Unfortunately the IC we use for timing uses BCD, so we need to be able to convert to and from BCD to make sense of the timing data. So now we have an understanding of BCD, binary, base-10 decimal, bytes, hexadecimal and nibbles. What a mouthful that was!

Coffee break.

Before we head back to timing, let’s look at a new function: switch… case. Say you needed to examine a variable, and make a decision based on the value of that variable, but there were more than two possible options. You could always use multiple if…then…else if functions, but that can be hard on the eyes. That is where switch… case comes in. It is quite self-explanatory, look at this example:

OK, we’re back. It would seem that this chapter is all numbers and what not, but we are scaffolding our learning to be able to work with an integrated circuit that deals with the time for us. There is one last thing to look at then we can get on with timing things. And that thing is…

The I2C bus.

(There are two ways one could explain this, the simple way, and the detailed way. As this is “Getting Started with Arduino”, I will use the simple method. If you would like more detailed technical information, please read this document: NXP I2C Bus.pdf, or read the detailed website by NXP here)

The I2C bus (also known as “two wire interface”) is the name of a type of interface between devices (integrated circuits) that allows them to communicate, control and share data with each other. (It was invented by Philips in the late 1970s. [Philips spun off their semiconductor division into NXP]).  This interchange of data occurs serially, using only  two wires (ergo two wire interface), one called SDA (serial data) and the other SCL (serial clock).

nxpi2cbussmall

I2C bus – image from NXP documentation

A device can be a master, or a slave. In our situation, the Arduino is the master, and our time chip is the slave. Each chip on the bus has their own unique “address”, just like your home address, but in binary or in hexadecimal. You use the address in your sketch before communicating with the desired device on the I2C bus. There are many different types of devices that work with the I2C bus, from lighting controllers, analogue<> digital converters, LED drivers, the list is quite large. But the chip of interest to us, is the Maxim DS1307 Serial I2C real-time clock. Let’s have a look:

ds1307small

This amazing little chip, with only a few external components, can keep track of the time in 12-and 24-hour formats, day of week, calendar day, month and year, leap years, and the number of days in a month. Interestingly, it can also generate a square wave at 1Hz, 4kHz, 8kHz, or 32 kHz. For further technical information, here is the DS1307 data sheet.pdf. Note – the DS1307 does not work below 0 degrees Celsius/32 degrees Fahrenheit, if you need to go below freezing, use a DS1307N.

Using the DS1307 with our Arduino board is quite simple, either you can purchase a board with the chip and external circuitry ready to use, or make the circuit yourself. If you are going to do it yourself, here is the circuit diagram for you to follow:

  ds1307exampleuse
 

The 3V battery is for backup purposes, a good example to use would be a CR2032 coin cell – however any 3V, long-life source should be fine. If you purchase a DS1307 board, check the battery voltage before using it…. my board kept forgetting the time, until I realised it shipped with a flat battery. The backup battery will not allow the chip to communicate when Vcc has dropped, it only allows the chip to keep time so it is accurate when the supply voltage is restored. Fair enough. The crystal is 32.768 kHz, and easily available. The capacitor is just a standard 0.1uF ceramic.

Now to the software, or working with the DS1307 in our sketches. To enable the I2C bus on Arduino there is the wire library which contains the functions required to communicate with devices connected to our I2C bus. The Arduino pins to use are analogue 4 (data) and analogue 5 (clock). If you are using a Mega, they are 20 (data) and 21 (clock). There are only three things that we need to accomplish: initially setting the time data to the chip; reading the time data back from the chip; and enabling that 1Hz square-wave function (very useful – if you were making an LED clock, you could have a nice blinking LED).

First of all, we need to know the I2C address for our DS1307. It is 0×68 in hexadecimal. Addresses are unique to the device type, not each individual device of the same type.

Next, the DS1307 accepts or returns the timing data in a specific order…

  • seconds (always set seconds to zero, otherwise the oscillator in the DS1307 will stay off)
  • minutes
  • hours
  • day of week (You can set this number to any value between 1 and 7, e.g. 1 is Sunday, then 2 is Monday…)
  • day of month
  • month
  • year
  • control register (optional – used to control the square-wave function frequency and logic level)

… but it only accepts and returns this data in BCD. So – we’re going to need some functions to convert decimal numbers to BCD and vice-versa (unless you want to make a BCD clock …)

However, once again in the interests of trying to keep this simple, I will present you with a boilerplate sketch, with which you can copy and paste the code into your own creations. Please examine this file. Note that this sketch also activates the 1Hz square wave, available on pin 7. Below is a quick video of this square wave on my little oscilloscope:

This week we will look at only using 24-hour time; in the near future we will examine how to use 12-hour (AM/PM) time with the DS1307. Here is a screen capture of the serial output box:

example7p3

Now that you have the ability to send this time data to the serial output box, you can send it to other devices. For example, let’s make a simple LCD clock. It is very easy to modify our example 7.3 sketch, the only thing to take into account is the available space on the LCD module. To save time I am using the Electronic Brick kit to assemble this example. Below is a short clip of our LCD clock operating:

and here is the sketch. After seeing that clock fire up and work correctly, I felt really great – I hope you did too.

Update – for more information on the DS1307 real-time clock IC, visit this page

Now let’s head back in time, to when digital clocks were all the rage…

Exercise 7.1

Using our Arduino, DS1307 clock chip, and the exact hardware from exercise 6.2 (except for the variable resistor, no need for that) – make a nice simple digital clock. It will only need to show the hours and minutes, unless you wish to add more display hardware. Have fun!

Here is my result, in video form:

and the sketch. Just an interesting note – after you upload your sketch to set the time; comment out the line to set the time, then upload the sketch a second time. Otherwise every time your clock loses power and reboots, it will start from the time defined in the sketch!

As mentioned earlier, the DS1307 has a square-wave output that we can use for various applications. This can be used from pin 7. To control the SQW is very easy – we just set the pointer to the SQW register then a value for the frequency. This is explained in the following sketch:

And here it is in action – we have connected a very old frequency counter to pin 7 of the DS1307:

And there we have it – another useful chapter. Now to move on to Chapter Eight.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, BCD, ds1307, education, hexadecimal, I2C, LCD, lesson, microcontrollers, tutorialComments (36)

Getting Started with Arduino! – Chapter Six addendum

Welcome back fellow arduidans!

After reviewing Chapter Six of our tutorials, I felt that there was some important information missing about the section regarding driving 4-digit 7-segment LED display modules. Although we have discussed displaying numbers using the module, and hopefully you have done this yourself with exercise 6.2, those numbers were constantly being written to the display as the sensor was being repeatedly read.

But how do we send a number to the display – and hold it there? We need a function that can accept the number to display – and the length of time (in cycles) to hold it there. I have rewritten the function displaynumber() from the solution to exercise 6.2 – now it accepts another value, “cycles”. This is the number of times the number will be shown on the display.

Here is a sketch to demonstrate this function, the hardware is the same as exercise 6.2, except there is no need for the variable resistor.

And my day wouldn’t be complete without another video demonstration. This example has cycles set to 500.

So there you have it! Now you have the knowledge to use these multi-digit displays effectively. And now that we have mastered them, we can move onto more interesting and useful display types. In the meanwhile, off to Chapter Seven.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, education, lesson, microcontrollers, tutorialComments (0)

We now have a Google Group!

Hello readers

I would like to announce the opening of our own tronixstuff discussion email list via Google Groups: http://groups.google.com/group/tronixstuff

Through this group we can discuss posts, projects, products and anything else mentioned on the tronixstuff or related websites. For the time being it will be moderated until we get going and see what the level of conversation is like. However, please feel free to ask questions, offer suggestions, or make constructive criticism about anything in the tronixstuff world.

It is also meant for support with any of the Arduino tutorials or products mentioned in the blog. I will do my best to help you, so don’t be afraid to ask!

However it is not for spam, discrimination, attacking others, or blatantly selling things.

screenshot

So sign up now!

http://groups.google.com/group/tronixstuff

Posted in about, education, learning electronics, projects, tutorialComments (0)

Getting Started with Arduino! – Chapter Six

This is part of a series titled “Getting Started with Arduino!” – A tutorial on the Arduino microcontrollers. The first chapter is here, and the complete index is here.

Welcome back fellow arduidans!

Hello once again to our regular Arduino tutorial instalment. In this chapter we are up to all sorts of things, including: distance sensing, using prototyping shields, even more shiftiness with shift registers and 4-digit 7-segment displays, and some exercises to refresh and expand your knowledge. Wow – let’s get cracking…

Do you know how to keep your distance? Some people do, some do not. The same goes for mechatronical things (i.e. robots, those little autonomous vacuum cleaners, etc). So to solve that problem you can integrate a distance sensor into your design. Hopefully by following this section you will gain an understanding of such sensors, and be able to make use of them later on in your own projects. Anyhow, today we are looking at the Sharp GP2Y0A21YK0F infra-red distance sensor. What a mouthful… The funny thing is that it looks like a robot head:

sharpsensorsmall

That white JST connector is for three leads, +5V, GND, and analogue out. When purchasing it you should also get a matching lead to save time and mucking about.

How it works is quite simple (I must stop writing that, some things are not as simple as they seem…) – the sensor contains an infra-red transmitter and a receiver. It returns a voltage that is relative to the distance between itself and the object in front of it. This output voltage is inversely proportional to the distance; which is explained better with this graph from the data sheet:

voltagedistance

However it is always fun to test these things out yourself. So I placed a sensor up over my desk, measured out 80cm, and attached the multimeter to the analogue output of the sensor:

sensorchecksmall

A crude setup but effective. I held a white piece of cardboard in front of the sensor, starting from more than one metre away, then moved closer to the minimum, then back out again. As shown in this video clip:

Although watching that multimeter may not have been too interesting, hopefully the next task will be!

Exercise 6.1

Using the values from the graph from the Sharp data sheet (above), make yourself a distance-measuring device. Use an LCD module to display the measurements. Metric and imperial! This shouldn’t be too hard at all, you’re just using one analogue input from the sensor, some basic maths, and displaying some data on an LCD. Furthermore, to make it truly portable, you could wire up a 9v PP3 battery to a DC plug and use it for power. A hint – before calculating distances, run a sketch to just return the analogRead() value from the sensor. Then you can make your own judgement on voltage-distance calculations. To save time I used the Electronic Bricks to rapidly construct this prototype.

You will need:
  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • One parallel LCD display module
  • One Sharp infra-red distance sensor and sensor cable
  • a breadboard and some connecting wire

Anyhow, here is a photo of what I came up with:

exercise6p1small

and the ubiquitous video clip

Finally, my sketch for the solution. You may have to adjust the values in the decision tree for more accuracy. After spending some time with this sensor, I wouldn’t rely on it for exact distance calculations, however it would be very useful for general item detection, air switches and so on. In the next week or two we will examine another type of distance sensor.

What else could this be used for? Robotics sensors, burglar alarms, switching things on and off. Hopefully you have gained some knowledge about this sensor and have some ideas for implementation.

LEDborder

Now that we have spent a few weeks constructing our prototypes on breadboards and electronic bricks, it is now time to look at how we can do this in a more compact, and/or permanent method. As you already know, the Arduino system allows for “shields”, PCBs that plug on top of your Arduino board to add some sort of extra functionality. One of these was the Electronic Brick chassis, another popular shield is the Ethernet shield.

Moving on…

In previous instalments we have worked with 7-segment LED displays, using up to three at once, being controlled by 74HC595 shift registers. As you may have realised by now that involved a lot of wiring, resistors, time and effort. But what if you need four or more digits? Use an LCD… Maybe. Sometimes you need to use LED displays for aesthetic reasons, price, clarity, or just because you love that LED look. Thankfully you can find four digit displays, instead of having to use 2 x 2 or 4 x 1 digit displays. Let’s have a look at one now:

4dig7segsmall

For the newcomer there would be a surprising lack of pins on this display module. That is a good thing, and a slightly tricky thing – but we can overcome the obstacles and use it very easily. How? Again, with two 74HC595 shift registers and some brainpower. Firstly, let’s have a look at the pins – from left to right they are: E, D, C, G, F, B, A, C1, C2, C3, C4, decimal point, unused, unused. This display is common cathode, so to display (for example) the number 1 on digit 3, you would apply ~+2 volts to pins 6 and 7, and attach ground to pin 10. Very much the same as using a single-digit display, except you need to choose the cathode that corresponds with the digit you wish to use. In this tutorial we are using a Common Cathode unit. Out of curiosity’s sake, here is the data sheet for the module used in this chapter: data sheet.pdf.

Secondly, how are we going to control the cathodes with out Arduino? Current comes out of a cathode, so it would not accept a signal from our digital out pins. What we need to do is have a simple switch on each cathode between the display pin and ground, so we can control which digit we want to use. How can we do this with our Arduino? Easy… we can use a simple NPN transistor as a switch. Remember we did this with a relay in chapter three!

But using 4 digital out pins for cathode control is a waste of pins, we can use our trusty shift register again to control the cathodes. So that means we need two shift registers in total, the first to control the digit (0~9), and the second to switch on the cathode of the position we wish to display our digit in. Time to do it!

The first (left-hand) shift register from the Arduino controls the segments on the display, via 560 ohm resistors. Just like last time. The second (right-hand) shift register controls the cathodes. Pins Q0~Q3 connect to the base of a BC548 transistor via a 1k ohm resistor. The collector of the transistor is connected to the cathode on the display, and the emitter to ground. For example:

example6p1schematicsmall

Note that the schematic above is a guide only. But here it is in real life, below:

example6p1small

After a few projects, wiring up displays and shift registers should be a lot quicker for you now. Here is the matching sketch I came up with for the demonstration video below.

You’d have to admit, even in the year 2010, LED displays still look mesmerising. Or maybe that’s just me! Here is the data sheet display.pdf for the LED display I used. You can use other ones,as long as they are common cathode; just match the LED element pins with your first shift register, and the cathode pins with the second shift register.

But on to making something useful…

Exercise 6.2

Using the hardware from example 6.1 above, create a device that displays the value of an analogue sensor. For example, if we connect a 10k variable resistor to an analogue input, the Arduino will return a reading of between 0 and 1023. From a hardware perspective, all you need to do is add an analogue sensor (e.g. LDR, 10k variable resistor, the infra-red sensor from earlier on, etc.). The software will be a little tricky, but if you completed exercise 5.1, or 5.2 you shouldn’t have a problem at all. As you will be displaying one digit at a time, but very quickly, try to minimise the number of times you clear the display – in doing so you will keep the brightness at a maximum.

You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • One 4-digit, 7-segment LED display, common cathode
  • Two 74HC595 shift registers
  • Four BC548 or equivalent NPN transistors
  • 8 x 560 ohm 0.25 W resistors. For use as current limiters between the LED display segments and ground
  • One 10k variable resistor
  • a breadboard and some connecting wire

For motivation, here is a video clip of my result. There are two examples, one with leading zeroes, and one without:

And the sketch as well.

That wasn’t too hard was it? Now that you can use such a display, it will become easier to display output from your various projects. Now on to Chapter 6A.

LEDborder

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, distance sensor, education, gp2y0a21yk0f, infrared, IR, lesson, microcontrollers, sharp, tutorialComments (33)

Kit Review – adafruit industries SIM reader (part two)

[Updated 18/03/2013]

Hello readers

Now for the second instalment of my kit review of the adafruit industries SIM card reader. In part one the kit was successfully assembled and the software installed. After some research and some very useful advice from the amazing people at adafruit, we can now move forward to the conclusion of this review.

First of all, a big thanks to adafruit support who pointed me in the direction of something very simple yet crucial: the kit FAQ. Once again I have exhibited the stereotypical behaviour of a male and not read all the instructions first! (Slow clapping from the females in the audience…)  The most crucial point being:

The reader and software looks in the default locations that cell phones use to store SMS and phonebook data – just like the professional forensics software. Some phones do not store any data on SIM cards, instead using their internal memory, and some do a good job of overwriting the data when it is erased. Thus it is not guaranteed that a particular message or phonebook entry will be accessable – it depends a lot on the phone used!

D’Oh.

To cut a long story short another SIM card was acquired that had not been near my handsets, and this worked perfectly. Again, that wonderful feeling of something working filled me with warmth and happiness.

Now for the moment of truth! Insert the SIM card, plug in the cable, connect the PP3 battery if you’re using RS232, and execute:

python pySimReader.py

which after starting up, and you clicking “connect reader” should result with this:

dump2

That’s more like it. Time to examine what the SIM holds… first – the phone book:

dump3

You can double-click on a listing (above left) and the edit entry box appears (above right) allowing you to … edit an entry!

Next we look at the SMS messages function. Unfortunately the SIM card I tested was deactivated and therefore couldn’t be used to receive SMSs. However an excellent demonstration is found in the video at Citizen Engineer (volume one). Finally, we can examine the details of the SIM card itself:

dump4

What are all those acronyms?

  • MSISDN – the phone number attached to that SIM card;
  • Serial number – the SIM serial number, usually printed on the SIM card;
  • IMSI number – a unique number sent by the phone to the network to identify the user;
  • SIM phase – SIM cards were originally ‘Phase 1′, and the phase number increased as the GSM standard was developed over time.

So there you have it. In conclusion, this is an easy to assemble kit which is fun and educational. This is the type of kit that would be good for those who are being introduced to the fascinating world of electronics (etc) as it is quick to build, and does something with the “real world” (i.e. mobile phones) that young people love so much. Or anyone else for that matter. High resolution photos are available on flickr.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

[Note - this kit was purchased by myself personally and reviewed without notifying the manufacturer or retailer]

Posted in adafruit, cellphone hacking, kit review, learning electronics, tutorial

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: