Wednesday, February 29, 2012

Tutorial: Analog input for multiple buttons – Part Two

This is chapter forty-six of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Welcome back fellow arduidans!

while back I described how to read multiple buttons using only one analog input pin. However we could only read one button at a time. In this instalment we revisit this topic and examine an improved method of doing so which allows for detecting more than one button being pressed at the same time. This method is being demonstrated as it is inexpensive and very easy to configure.

(For a more exact and expensive method please consider the use of the Microchip MCP23017 which allows for sixteen inputs via the I2C bus).

As you know the analogue input pins of the Arduino can read a voltage of between zero and five volts DC and return this measurement as an integer between zero and 1023. Using a small external circuit called a “R-2R ladder”, we can alter the voltage being measured by the analogue pin by diverting the current through one or more resistors by our multiple buttons. Each combination of buttons theoretically will cause a unique voltage to be measured, which we can then interpret in our Arduino sketch and make decisions based on the button(s) pressed.

First the circuit containing four buttons:

Can you see why this is called an R-2R circuit? When building your circuit – use 1% tolerance resistors – and check them with a multimeter to be sure. As always, test and experiment before committing to anything permanent.

Now to determine a method for detecting each button pressed, and also combinations. When each button is closed, the voltage applied to analogue pin zero will be different. And if two buttons are pressed at once, the voltage again will be different. Therefore the value returned by the function analogRead() will vary for each button-press combination. To determine these, I connected a numeric display to my Arduino-compatible board, then simply sent the analogRead() value to the display. You can see some of the results of this in the following video:

The analogRead() results of pressing every combination of button can be found in the following table:

After this experiment we now have the values returned by analogRead() and can use them in a switch… case function or other decision-making functions in our sketches to read button(s) and make decisions based on the user input. Unfortunately there was some overlap with the returned values and therefore in some cases not every possible combination of press will be available.

However, we’re still doing well and you can get at least eleven or twelve combinations still with only one analog input pin. You can add delay() functions in your sketch if necessary to take care of switch debouncing or do it with hardware if you feel it is necessary.

So now you have a more useful method for receiving input via buttons without wasting many digital input pins. I hope you found this article useful or at least interesting. This series of tutorials has been going for almost two years now, and may soon start to wind down – it’s time to move forward to the next series of tutorials :)

So if you have any suggestions for further articles (and not thinly-veiled methods of asking me to do your work for you…) – email them to john at tronixstuff dot com.

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.

 

Tuesday, February 28, 2012

Tutorial: Analog input for multiple buttons – Part Two

This is chapter forty-six of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Welcome back fellow arduidans!

while back I described how to read multiple buttons using only one analog input pin. However we could only read one button at a time. In this instalment we revisit this topic and examine an improved method of doing so which allows for detecting more than one button being pressed at the same time.

As you know the analogue input pins of the Arduino can read a voltage of between zero and five volts DC and return this measurement as an integer between zero and 1023. Using a small external circuit called a “R-2R ladder”, we can alter the voltage being measured by the analogue pin by diverting the current through one or more resistors by our multiple buttons. Each combination of buttons theoretically will cause a unique voltage to be measured, which we can then interpret in our Arduino sketch and make decisions based on the button(s) pressed.

First the circuit containing four buttons:

Can you see why this is called an R-2R circuit? When building your circuit – use 1% tolerance resistors – and check them with a multimeter to be sure. As always, test and experiment before committing to anything permanent.

Now to determine a method for detecting each button pressed, and also combinations. When each button is closed, the voltage applied to analogue pin zero will be different. And if two buttons are pressed at once, the voltage again will be different. Therefore the value returned by the function analogRead() will vary for each button-press combination. To determine these, I connected a numeric display to my Arduino-compatible board, then simply sent the analogRead() value to the display. You can see some of the results of this in the following video:

The analogRead() results of pressing every combination of button can be found in the following table:

It looks good except for the combinations five and seven – an anomaly which seems odd. Nevertheless your experience may vary as well. But after this experiment we now have the values returned by analogRead() and can use them in a switch… case function or other decision-making functions in our sketches to read button(s) and make decisions based on the user input.

Question - Who came up with the name for the device known as the ‘transistor’?

So now you have a more useful method for receiving input via buttons without wasting many digital input pins. I hope you found this article useful or at least interesting. This series of tutorials has been going for almost two years now, and may soon start to wind down – it’s time to move forward to the next series of tutorials :)

So if you have any suggestions for further articles (and not thinly-veiled methods of asking me to do your work for you…) – email them to john at tronixstuff dot com.

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.

Thursday, February 23, 2012

Initial review: Hakko FX-888 Soldering Station

Introduction

During many years of orbiting around the world of electronics and related fields, soldering was not really one of my strong points. After moving more seriously into this field it occurred to me that my choice of soldering weapons played a part in the end results. So a few days ago I pulled the trigger and ordered my first “real” station – the Hakko FX-888.

Opening…

After waving goodbye to the courier and opening the delivery carton, the following was presented:

Frankly it’s only a box and shouldn’t matter, but you can appreciate the effort involved from a retail perspective. Opening up we find a neatly and safely packaged station with the multilingual instructions on top:

Everything is included to get going without any surprises. The station itself:

This is quite solid and weighty – at 1.3kg, so will not be moved by accident. The colours are quite snazzy and in some markets you can choose different colour schemes. According to Hakko – this is a “High-performance soldering iron that, in the pursuit both “usability” and “appearance”, has evolved beyond being a mere working tool”…

As you can see the temperature can be adjusted between 200 and 480 degrees Celsius. There is a calibration adjustment below the temperature knob, and the tool for calibration (“thermal correction”) is hidden away underneath the station:

You can also see the power switch on the right-hand side of the unit (when positioned normally). A tiny Allen key is included which is used to lock the temperature control to a desired position, however there isn’t a spot to keep it – so for now I have used (once again) some blu-tac to stick it under the base (not shown in photograph). Finally there is one red LED above the Hakko logo which lights when the heater is on – however it turns off once at the required temperature.

Next we have the soldering iron with fixed lead to the station:

This is a very light iron – for me the lightest so far, with a weight of 44 grams excluding the cord. The iron ships with a 0.5mm conical tip (type T18-B) that is fine for normal through-hole work, however there are sixteen different tips available from Hakko. What took me by surprise is the flexibility of the cord bushing, no matter which direction you turned the iron in your hand – there was hardly if any at all resistance from the cord. When changing tips be careful when unscrewing the nut, it is easy to unscrew the handle instead.

Finally we have the iron holder and parts:

The holder is made from metal, although it may not look so in the image. There is space for the included sponge and brass cleaning wire. You can also use the rubber cleaner (the grey/green lip) for cleaning as well. You can fit a large cleaning wire in the holder, however only small amount is presented at any one time, so you will need to rotate it now and again by opening the bottom of the holder which reveals the wire space.

Specifications

For those who like the numbers, here they are:

  • Station power consumption - 70W
  • Temperature range – 200~480 degrees Celsius
  • Temperature stability – +/- 1 degree Celsius at idle temperature
  • Iron power consumption – 65W at 26V AC
  • Cord length – 1.2m
  • Tip to ground resistance – 2Ω

The system is designed to protect against anti-static discharge, and the handle and other parts are conductors – not insulators. For more details please see the Hakko website.

Question - What nationality is the Hakko company?

Australian pricing – WTF?!

There is one thing that I am not too happy about – the price. In Australia the FX-888 can be found for between $160 and $175+GST – and delivery should be free. However the exact same product in the US market works out to be around … Au$89+sales tax. Ugh. I don’t mind paying an extra 25% due to the distances between sunny Melbourne and the rest of the world – but the local price is just too high. Sure, I could import one – but then there isn’t any warranty. Not that I expect the Hakko to break anytime soon, but who knows? So one pays more and deals with it.

Other observations

The reheating speed is excellent, the iron can reach any selected temperature in less than sixty seconds. This also helps avoid cold joints by recovering from temperature loss at a rapid rate. Furthermore having such a light iron without the burden of an AC lead at the back allows much more tip control and reduces wrist and muscle fatigue over long sessions.

Finally, the user manual includes exploded diagrams for all parts and the matching part numbers, which tells me Hakko want this station to last and are happy for you to maintain it yourself. Unlike using my older iron, I am sure with extended use the FX-888 will be less of a physical drain and also help improve my confidence in soldering.

Conclusion

Although the FX-888 is not inexpensive, it is very easy to use and light-years ahead of using a normal hand-held soldering iron. If you are finding yourself doing more soldering than the occasional hobbyist or are looking to work with a wide variety or components and soldering joints then you could do a lot worse than considering the FX-888. At this juncture it was not the cheapest, however I feel it was a solid investment and will last me a long time.

The Hakko FX-888 Soldering Station is available worldwide. Residing in Australia I purchased mine from element14.

Disclaimer – The items in this review were purchased by myself and reviewed without notifying the manufacturer or retailer. 

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.

Monday, February 20, 2012

Project: Clock Two – Single digit clock

Introduction

Time for another instalment in my irregular series of clock projects. (Or should that be “Time for another instalment in the series of irregular clock projects”?) In contrast with the extreme “blinkiness” of Clock One, in this article we describe how to build this single-digit digital clock:

Once again the electronics of the clock will be based from an Arduino-compatible board with a DS1307 real-time clock IC added to the board. On top of this we add a shield with some extra circuitry and two buttons – but more on this later.

The inspiration for this clock came from a product that was recently acquired at Ikea – the “Kvart” work lamp, for example:

If you are shopping for one, here are the Ikea stock details:

The goal is to place the electronics of the clock in the base, and have one single-digit LED display at the top of the neck which will blink out the digits. There will be two buttons under the base that are used to set the time. It will be powered by a 9V battery or an AC adaptor which is suitable for a typical Arduino board.

Construction

This article is a diary of my construction, and you can always use your own knowledge and initiative. It is assumed that you have a solid knowledge of the basics of the Arduino system.  If not, review my series of tutorials available from here. Furthermore, feel free to modify the design to work with what you have available – I hope this article can be of some inspiration to you.

Software

It is much easier to prototype the clock and get the Arduino sketch working how you like it before breaking down the lamp and building up the clock. To do this involves some jumper wires and a solderless breadboard, for example:

Although there are four buttons on the board we only use two. They are connected to digital pins eight and nine (with 10k pull-down resistors). The LED display segments a~g are connected to Arduino digital pins 0~6 respectively. The decimal point is connected to the pulse output pin of the DS1307 – which will be set to a 1Hz output to have a nice constant blinking to show the clock is alive and well.

If you are unfamiliar with operating the DS1307 real-time clock IC please review this tutorial. Operation of the clock has been made as simple for the user as possible. To set the time, they press button A (on digital eight) while the current time is being displayed, after which point the user can select the first digit (0~2) of the time by pressing button A. Then they press button B (on digital nine) to lock it in and move to the second digit (0~9) which is again chosen with button A and selected with button B. Then they move onto the digits in the same manner.

After this process the new time is checked for validity (so the user cannot enter invalid times such as 2534h) – and is ok, the clock will blink the hyphen twice and then carry on with the new time. If the entered time is invalid, the clock reverts back to the current time. This process is demonstrated in the following video clip:

You can download the Arduino sketch from here. Note that it is written for Arduino v23 – not v1.0.

Question - In what year was Ikea founded?

Hardware

The parts required to replicate the Clock Two in this article are:

  • One Arduino-compatible board with DS1307 real-time clock IC as described in this article
  • One Arduino protoshield and header pins
  • One common-cathode 7-segment LED display of your choosing
  • Seven current-limiting resistors to reduce the output current from Arduino digital outputs going to the LED segments. In our example we use a 560 ohm resistor network to save time
  • Two buttons and two 10k ohm pull-down resistors
  • One meter of nine-core wire that will fit inside the neck and stand of the Kvart lamp – an external diameter of less than 6mm will be fine
  • And of course – the lamp

The protoshield is used to hold the buttons, resistor network and the terminus for the wires between the LED display and the Arduino digital outputs, for example:

At this stage you will need to do some heavy deconstruction on the lamp. Cut off the mains lead at the base and remove the plastic grommet from the stand that surrounded the AC lead. Next,  with some elbow grease you can twist off the lamp-shade unit from the end of the flexible neck. You could always reuse the lamp head and AC lead if wired by a licensed electrician.

Now you need to feed the multicore wire through the neck and down to the base of the lamp. You can pull it through the hole near the base, and then will need to drill a hole in the base to feed it through to the electronics as such:

Take care when feeding the cable though so you don’t nick the insulation as shown above. Leave yourself a fair bit of slack at the top which will make life easier when soldering on the LED display, for example:

The next step is to solder the wires at the top to the LED display. Make notes to help recall which wires are soldered to the pins of the display. If your soldering skills (like mine) aren’t so good, use heatshrink to cover the soldering:

Most displays will have two GND pins, so bridge them so you only need to use one wire in the multicore back to base:

At this point use the continuity function of a multimeter or a low-voltage power source to test each LED segment using the other end of the cable protruding from the base. Once you are satisfied the segments have been soldered correctly, carefully draw the cable back through the neck and base in order to reduce the slack between the display and the top of the lamp neck. Then solder the individual LED segment wires to the protoshield.

Now if you have not already done so, upload the sketch into the Arduino board – especially if you are going to permanently mount the circuitry into the base. A simple method of mounting would be using  a hot glue gun, but for the purpose of demonstration we have just used blu-tac:

 Although this does look a little rough, we are using existing stock which kept the cost down. If you are going to power the clock with an AC adaptor, you will also need to cut out small opening to allow the lead to protrude from the side of the base. And now for the resulting clock – our Clock Two:

So there you have it, the second of many clocks we plan to describe in the future. If you have any comments or suggestions, please leave them below or in our Google Group.

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.

Monday, February 13, 2012

Is this the world’s smallest Arduino-compatible board?

Introducing the Freetronics LeoStick – one very small Arduino Leonardo-compatible board, in the format of a typical USB memory stick – the board for integration into smaller projects, on-the-go fun when travelling, or minimalism-enthusiasts:

Whether or not the LeoStick is the world’s smallest Arduino-compatible board – it’s pretty darn tiny – for example:

Note that the length includes the USB plug extrusion on the PCB. A lot of small boards on the market may consider themselves to be fully Arduino-compatible, but with a few minor or major caveats – such as not having full USB interface, or using a cut-down MCU such as an ATtiny, or offer less current handling ability. After comparing their specifications with the LeoStickyou can see how much has gone into such a small board:

  • Native USB port built-in, no need for any USB or FTDI cables
  • Two Full Color RGB LEDs on-board! Drive different colored outputs and fun feedback from your sketch right away. One RGB LED is completely programmable, the other does Power, USB RX and TX indication, the RX and TX LEDs can also be controlled.
  • On-board Piezo speaker element, play sounds, tunes and beeps. Can also be used as a knock/vibration sensor
  • Same I/O pins. The LeoStick provides all the same header connections as larger boards, you can connect all the same sensors, actuators, and other inputs and outputs as typical Arduino models.
  • Breadboard compatible, has 0.1″ pitch pads and header pins can be fitted underneath
  • 500mA polyfuse and protection on the USB port
  • ATmega32U4 microcontroller, Arduino compatible with on-board USB, 32K Flash, 2.5K RAM, 1K EEPROM at 16MHz
  • ISP 6-pin connector for advanced programming of the ATmega32U4 MCU

Here is the underside of the LeoStick , showing the piezo speaker:

And here is a quick video of the LeoStick in action:

Although this is a newly-released product, it does rely on a modified beta version of the upcoming Arduino Leonardo bootloader. There are some known issues with Windows 7 64-bit drivers and some library functions don’t work perfectly yet. Any firmware or Arduino Leonardo compatible support should not be considered to be final release firmware or in any way an official Arduino. At Freetronics’ request, please don’t hassle the Arduino team with support or requests related to this board – they’re solely the responsibility of Freetronics.

Nevertheless there is a growing and vibrant support forum where you can see examples of the LeoStick in action and discuss other subjects and issues. The LeoStick is also a very complete ATmega32U4 breakout and USB board by itself and the LeoStick can be programmed directly from the supplied standard ISP header by AVR Studio, Mac OSX-AVR, avrdude, WinAVR etc.

The LeoStick  is also new to us here as well, and we look forward to integrating it into projects in the near future, as well as having a board to experiment with when travelling. As we always say – if it meets your needs or you want to try something new, you could do a lot worse than getting yourself a LeoStickIf you are interested in learning how to use Arduino in general – check out our tutorial here. For more discussion and support information for the LeoStick consult the forum or product web page.

Disclaimer – The LeoStick board reviewed in this article was a promotional consideration made available by Freetronics

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.

Saturday, February 11, 2012

Experimenting with Surface-Mount Component Prototyping

Now and again I have looked at SMT (surface-mount technology) components and thought to myself “I should try that one day”. But not wanting to fork out for a toaster oven and a bunch of special tools I did it on the cheap – so in this article you can follow along and see the results. Recently I ordered some ElecFreaks SOIC Arduino Mega-style protoshields which apart from being a normal double-sided protoshield, also have a SOIC SMT pad as shown below:

First up I soldered in two SOIC format ICs – a 555 and a 4017:

These were not that difficult – you need a steady hand, a clean soldering iron tip and some blu-tac. To start, stick down the IC as such:

… then you can … very carefully … hand-solder in a few legs, remove the blu tac and take care of the rest …

The 4017 went in easily as well…

…however it can be easier to flood the pins with solder, then use solder-wick to soak up the excess – which in theory will remove the bridges between pins caused by the excess solder. And some PCB cleaner to get rid of the excess flux is a good idea as well.

Now to some smaller components – some LEDs and a resistor. These were 0805 package types, which measure 2.0 × 1.3 mm – for example a resistor:

The LEDs were also the same size. Unlike normal LEDs, determining the anode and cathode can be difficult – however my examples had a small arrow determining current flow (anode to cathode) on the bottom:

Another way is to use the continuity function of a multimeter – if their output voltage is less than the rating of the LED, you can probe it to determine the pins. When it glows, the positive lead is the anode. Handling such small components requires the use of anti-magnetic tweezers – highly recommended…

… and make holding down the components with one hand whilst soldering with the other much, much easier.

Unlike normal veroboard, protoshield or other prototyping PCBs the protoshield’s holes are surrounded with a “clover” style of solder pad, for example:

These solder pads can make hand-soldering SMT parts a little easier. After some experimenting, I found the easiest way was to first flood the hold with solder:

… then hold down the component with the tweezers with one hand while heating the solder with the other – then moving and holding one end of the component into the molten solder:

Question - What are the dimensions (length x width) of an 0805 SMT component in mm?

The first time (above) was a little messy, but one improves with practice. The clover-style of the solder pads makes it easy to connect two components, for example:

With some practice the procedure can become quite manageable:

As the protoshields are double-sided you can make connections between components on the other side to keep things neat for observers. To complete the experiment the six LEDs were wired underneath (except for one) to matching Arduino Mega digital output pins, and a simple demonstration sketch used to illuminate the LEDs, as shown below:

For one-off or very low-volume SMD work these shields from elecfreaks are quite useful. You will need a steady hand and quite a lot of patience, but if the need calls it would be handy to have some of these boards around just in case. For a more involved and professional method of working with SMT, check out this guide by Jon Oxer.

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, 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.

Friday, February 10, 2012

February 2012 Competition

It’s that time of the month again so we are running another competition. This month we have two prizes. Let’s check those out then follow up with the rules of entry.

Prize One is a brand new Freetronics EtherMega board – the mother of all Arduino-compatible boards. As reviewed recently, the EtherMegacombines the power and versatility of the Arduino Mega2560, a microSD card shield, a full Ethernet shield and power over Ethernet support:

From the Freetronics website:

The EtherMega is a 100% Arduino Mega 2560 compatible board that can talk to the world. Do Twitter updates automatically, serve web pages, connect to web services, display sensor data online, and control devices using a web browser. The Freetronics EtherMega uses the same ATmega2560 as the Arduino Mega 2560 so it has masses of RAM, flash memory, and I/O pins, and also includes the same Wiznet W5100 chip used by the official Arduino Ethernet Shield, so it’s 100% compatible with the Ethernet library and sketches.

Any project you would previously have built with an Arduino Mega 2560 and an Ethernet shield stacked together, you can now do all in a single, integrated board. We’ve even added a micro SD card slot so you can store web content on the card, or log data to it. But it gets even better: we found space to squeeze in a small prototyping area, so now it’s possible to build a complete, Internet-enabled Arduino device including your own custom parts all on a single board! You don’t even need to use a prototyping shield for many projects.

Prize Two is awesome – it has to be one of the most amazing developments in the Arduino world I have seen for a long time. However it’s so new it hasn’t been released for sale – yet. But we have one to give away, and when this product is released to the open market we’ll give you the full rundown on it:

The most annoying thing is that I have one of these right here in front of me, but can’t tell you anything about it. So stay tuned using the methods at the end of this post for more information when it becomes available.

How to enter!

There will be six questions for you to answer spread across articles published between the 1st and 29th of February. So you will need to review older posts. At the end of February and once you have answers to all six questions, email the answers along with your full name, email address and postal address to competition at tronixstuff dot com with the subject heading February.

During the second week of March, all the correct entries will be collated and two randomly chosen. The first correct entry drawn will win first prize, and the second entry the second prize. Entries will be accepted until 03/03/2012 0005h GMT.

As with any other competition, there needs to be some rules:

  • Incomplete entries will be rejected, so follow the instructions!
  • The winners’ first name and country will be announced publicly;
  • The winners’ name and mailing address will be passed to the prize supplier only for the purpose of prize delivery and not for any form of marketing.
  • Entries that contain text not suitable for minors or insulting to the competition will be rejected (seriously – it happens);
  • Prizes will be delivered via Australia Post domestic or regular international air mail. We take absolutely no responsibility for packages that go missing or do not arrive. If you live in an area with a “less than reliable” domestic postage system, you can pay for registered mail or other delivery service at your expense.
  • Winners outside of Australia will be responsible for any taxes, fees or levies imposed by your local Governments (such as import levies, excise, VAT, etc.) upon importation of purchased goods;
  • Prizes may take up to 45 days to be received;
  • No disputes will be entered in to;
  • Prizes carry no warranty nor guarantee – and are to be used or abused at entirely your own risk;
  • Entries will be accepted until 03/03/2012 0005h GMT.
Thanks to Freetronics for the EtherMega first prize!

So have fun and keep an eye out for the four competition questions spread through the February posts… In the meanwhile, 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.