Archive | hardware hacking

Book – “Arduino Workshop – A Hands-On Introduction with 65 Projects”

Over the last few years I’ve been writing a few Arduino tutorials, and during this time many people have mentioned that I should write a book. And now thanks to the team from No Starch Press this recommendation has morphed into my new book – “Arduino Workshop“:

shot11

Although there are seemingly endless Arduino tutorials and articles on the Internet, Arduino Workshop offers a nicely edited and curated path for the beginner to learn from and have fun. It’s a hands-on introduction to Arduino with 65 projects – from simple LED use right through to RFID, Internet connection, working with cellular communications, and much more.

Each project is explained in detail, explaining how the hardware an Arduino code works together. The reader doesn’t need any expensive tools or workspaces, and all the parts used are available from almost any electronics retailer. Furthermore all of the projects can be finished without soldering, so it’s safe for readers of all ages.

The editing team and myself have worked hard to make the book perfect for those without any electronics or Arduino experience at all, and it makes a great gift for someone to get them started. After working through the 65 projects the reader will have gained enough knowledge and confidence to create many things – and to continue researching on their own. Or if you’ve been enjoying the results of my thousands of hours of work here at tronixstuff, you can show your appreciation by ordering a copy for yourself or as a gift :)

You can review the table of contents, index and download a sample chapter from the Arduino Workshop website.

Arduino Workshop is available from No Starch Press in printed or ebook (PDF, Mobi, and ePub) formats. Ebooks are also included with the printed orders so you can get started immediately.

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, Arduino Workshop, book, books, cellular, clocks, display, distance, ds1307, DS3232, education, EEPROM, freetronics, GPS, graphic, GSM, hardware hacking, I2C, internet, LCD, learning electronics, lesson, no starch press, numeric keypad, part review, product review, projects, RDM630, RDM6300, relay, review, sensor, servo, SMS, time clock, timing, tronixstuff, tutorial, twitter, wireless, xbee13 Comments

SMD Soldering made easier

Hooray – we’re back…

SMD (surface mount device) soldering to some people can seem scary and dangerous. And if done incorrectly, or in the wrong state of mind, and/or with the wrong equipment – it can be. Or like myself, you could be pretty bad at it. To make things easier, I’d like to point you in a few directions to find help and guidance if this technique is new to you. Furthermore, if you find any more resources, leave a comment below and we will investigate them further.

First up we have a new comic from Greg Peek and Dave Roberts from siliconfarmers.com, (written in a similar vein to the “Soldering is Easy” comic that was released in 2010) that is easy to read and makes sense. Here is the cover:

smtcomic

As you can see from the CC logo on the title page, the comic is in the public domain, so please print it out, email it, and generally distribute it far and wide. For more information about the authors see their website at siliconfarmers.com. I have also placed the file here at tronixstuff for you to download.

Next we have a detailed and nicely illustrated tutorial by Jon Oxer from freetronics.

Jon runs through the process of soldering with a toaster over, with great success. So head over and have a read.

For the first video tutorial we have the SMD episide of the series by David L. Jones at eevblog, well worth the time:

Next, the people from Sparky’s Widgets doing some drag soldering:

That’s all we have for now, so if you find any more that are worthwhile leave a comment below.

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, hardware hacking, SMD, soldering, tutorial4 Comments

Hewlett-Packard 5082-7415 LED Display from 1976

In this article we examine a five digit, seven-segment LED display from Hewlett-Packard, the 5082-7415:

According to the data sheet (HP 5082-series.pdf) and other research this was available for a period of time around 1976 and used with other 5082-series modules in other HP products. Such as the Hewlett-Packard 3x series of calculators, for example:

Using the display is very easy – kudos to the engineers at HP for making a simple design that could be reusable in many applications. The 5082-7415 is a common-cathode unit and wiring is very simple – there are the usual eight anodes for segments a~f and the decimal point, and the five cathodes.

As this module isn’t too easily replaceable, I was very conservative with the power supply – feeding just under 1.6V at 10mA to each of the anode pins. A quick test proved very promising:

Excellent – it worked! But now to get it displaying some sort of interesting way. Using the following hardware…

  • Freetronics Eleven Arduino-compatible board
  • Two 74HC595 shift registers
  • Eight 560 ohm resistors
  • Five 1k ohm resistors
  • Five BC548 transistors
  • A large solderless breadboard and plenty of wires

… it was connected in the same method as a four-digit display (except for the extra digit) as described in my tutorial. Don’t forget to use the data sheet (HP 5082-series.pdf). You don’t have to use Arduino – any microcontroller with the appropriate I/O can take care of this.

Here is a simple Arduino sketch that scrolls through the digits with and then without the decimal point:

And the results:

Now for something more useful. Here is a function that sends a single digit to a position on the display with the option of turning the decimal point on or off:

So if you wanted to display the number three in the fourth digit, with the decimal point – use

with the following result:

We make use of the displayDigit() function in our next sketch. We introduce a new function:

It accepts a long integer between zero and 99999 (number) and displays it on the module for cycles times:

For demonstration purposes the sketch displays random numbers, as shown in the video below:

Update – 01/10/2014

You can purchase the four-digit version (QDSP6064) from Tronixlabs:

They worked very nicely and can be driven in the same method as the 5082-7415s descibed earlier. In the following video we have run the same sketches with the new displays:

In the meanwhile, I hope you found this article of interest. Thanks to the Vintage Technology Association website and the Museum of HP Calculators for background information. And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

visit tronixlabs.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 forum – dedicated to the projects and related items on this website.

Posted in 5082-7415, arduino, hardware hacking, HP, LED, lesson, part review, tronixlabs, tutorial, vintage

Project: Clock Three – A pillow clock with LilyPad Arduino

A pillow clock? How? Read on…

Updated 18/03/2013

Time for another instalment in my irregular series of irregular clock projects. In contrast with the minimalism of Clock Two, in this article we describe how to build a different type of clock – using the “lilypad” style of Arduino-compatible board and components designed for use in e-textiles and wearable electronics. As the LilyPad system is new territory for us, the results have been somewhat agricultural. But first we will examine how LilyPad can be implemented, and then move on to the clock itself.

The LilyPad system

By now you should have a grasp of what the whole Arduino system is all about. If not, don’t panic – see my series of tutorials available here. The LilyPad Arduino boards are small versions that are designed to be used with sewable electronics – in order to add circuitry to clothing, haberdashery items, plush toys, backpacks, etc. There are a few versions out there but for the purpose of our exercise we use the Protosnap Lilypad parts which come in one PCB unit for practice, and then can be ‘snapped out’ for individual use. Here is an example in the following video:

The main circular board in the Arduino-type board which contains an ATmega328 microcontroller, some I/O pins, a header for an FTDI-USB converter and a Li-Ion battery charger/connector. As an aside, this package is  good start – as well as the main board you receive the FTDI USB converter, five white LEDs, a buzzer, vibration module, RGB LED, a switch, temperature sensor and light sensor. If you don’t want to invest fully in the LilyPad system until you are confident, there is a smaller E-Sewing kit available with some LEDs, a battery, switch, needle and thread to get started with.

Moving forward – how will the parts be connected? Using thread – conductive thread. For example:

This looks and feels like normal thread, and is used as such. However it is conductive – so it doubles as wire. However the main caveat is the resistance – conductive thread has a much higher resistance than normal hook-up wire. For example, measuring a length of around eleven centimetres has a resistance of around 11Ω:

So don’t go too long with your wire runs otherwise Ohm’s Law will come into play and reduce the available voltage. It is wise to try and minimise the distance between parts otherwise the voltage potential drop may be too much or your digital signals may have issues. Before moving on to the main project it doesn’t hurt to practice sewing a few items together to get the hang of things. For example, run a single LED from a digital output – here I was testing an LED by holding it under the threads:

Be careful with loose live threads – it’s easy to short out a circuit when they unexpectedly touch. Finally for more information about sewing LilyPad circuits, you can watch some talent from Sparkfun in this short lesson video:

And now to the Clock!

It will be assumed that the reader has a working knowledge of Arduino programming and using the DS1307 real-time clock IC. The clock will display the time using four LEDs – one for each digit of the time. Each LED will blink out a value which would normally be represented by the digit of a digital clock (similar to blinky the clock). For example, to display 1456h the following will happen:

  • LED 1 blinks once
  • LED 2 blinks four times
  • LED 3 blinks five times
  • LED 4 blinks six times

If a value of zero is required (for example midnight, or 1000h) the relevant LED will be solidly on for a short duration. The time will be set when uploading the sketch to the LilyPad, as having two or more buttons adds complexity and increases the margin for error. The only other hardware required will be the DS1307 real-time clock IC. Thankfully there is a handy little breakout board available which works nicely. Due to the sensitivity of the I2C bus, the lines from SDA and SCL to the LilyPad will be soldered. Finally for power, we’re using a lithium-ion battery that plugs into the LilyPad. You could also use a separate 3~3.3 V DC power supply and feed this into the power pins of the FTDI header on the LilyPad.

Now to start the hardware assembly. First – the RTC board to the LilyPad. The wiring is as follows:

  • LilyPad + to RTC 5V
  • LilyPad – to RTC GND
  • LilyPad A4 to RTC SDA
  • LilyPad A5 to RTC SCL
Here is an our example with the RTC board soldered in:

At this stage it is a good idea to test the real-time clock. Using this sketch, you can display the time data on the serial monitor as such:

Sewing it together…

Once you have the RTC running the next step is to do some actual sewing. Real men know how to sew, so if you don’t – now is the time to learn. For our example I bought a small cushion cover from Ikea. It is quite dark and strong – which reduces the contrast between the conductive thread and the material, for example:

However some people like to see the wires – so the choice of slip is up to you. Next, plan where you want to place the components. The following will be my rough layout, however the LilyPad and the battery will be sewn inside the cover:

The LilyPad LEDs have the current-limiting resistor on the board, so you can connect them directly to digital outputs. And the anode side is noted by the ‘+':

For our example we connect one LED each to digital pins six, nine, ten and eleven. These are also PWM pins so a variety of lighting effects are available. The cathode/negative side of the LED modules are connected together and then return to the ‘-‘ pad on the LilyPad. The actual process of sewing can be quite fiddly – so take your time and check your work. Always make note to not allow wires (threads) to touch unless necessary. It can help to hold the LilyPad up and let the cloth fall around it to determine the location of the LilyPad on the other side, for example:

As this was a first attempt – a few different methods of sewing the parts to the cloth were demonstrated. This becomes evident when looking on the inside of the slip:

… however the end product looked fair enough:

After sewing in each LED, you could always upload the ‘blink’ sketch and adapt it to the LEDs – a simple way to test your sewing/wiring before moving forward.

The sketch…

As usual with my clock projects the sketch is based around the boilerplate “get time from DS1307″ functions. There is also the function blinkLED which is used to control the LEDs, and the time-to-blinking conversion is done in the function displayTime. For those interested, download and examine the sketch.

The results!

Finally in the video clip below our pillow clock is telling the time – currently 1144h:

So there you have it, the third of many clocks we plan to describe in the future. Once again, this project is just a demonstration – so feel free to modify the sketch or come up with your own ideas.

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, BOB-00099, clocks, DEV-11032, DEV-11262, ds1307, DS3232, etextile, hardware hacking, I2C, Ikea, lilypad, microcontrollers, tronixstuff, tutorial2 Comments

Project: Clock Two – Single digit clock

Let’s hack an Ikea lamp into a single-digit clock! How? Read on…

Updated 18/03/2013

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:

from www.ikea.com.au

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.

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.

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, clocks, ds1307, DS3232, hardware hacking, Ikea, kvart, tutorial15 Comments

Review: Mayhew Labs “Go Between” Arduino Shield

Hello readers

In this article we examine one of those products that are really simple yet can solve some really annoying problems. It is the “Go Between” Arduino shield from Mayhew Labs. What does the GBS do? You use it to solve a common problem that some prolific Arduino users can often face – how do I use two shields that require the same pins?

Using a clever matrix of solder pads, you can change the wiring between the analogue and digital pins. For example, here is the bare shield:

gbsss

Now for an example problem. You have two shields that need access to digital pins 3, 4 and 5 as also analogue pins 4 and 5. We call one shield the “top shield” which will sit above the GBS, and the second shield the “bottom” shield which will sit between the Arduino and the GBS. To solve the problem we will redirect the top shield’s D3~5 to D6~8, and A4~5 to A0~1.

To redirect a pin (for example D3 to D6), we first locate the number along the “top digital pins” horizontal of the matrix (3). Then find the destination “bottom” pin row (6). Finally, bridge that pad on the matrix with solder. Our D3 to D6 conversion is shown with the green dot in the following:

gbsss2

Now for the rest, diverting D4 and D5 to D7 and D8 respectively, as well as analogue pins 4 and 5 to 0 and 1:

gbsss3

The next task is to connect the rest of the non-redirected pins. For example, D13 to D13. We do this by again bridging the matching pads:

gbsss4

Finally the sketch needs to be rewritten to understand that the top shield now uses D6~8 and A0~1. And we’re done!

Try not to use too much solder, as you could accidentally bridge more pads than necessary. And you can always use some solder wick to remove the solder and reuse the shield again (and again…). Now the genius of the shield becomes more apparent.

The only downside to this shield is the PCB design – the days of square corners should be over now:
gbscornersss1

It is a small problem, but one nonetheless. Hopefully this is rectified in the next build run. Otherwise the “Go Between” Shield is a solution to a problem you may have one day, so perhaps keep one tucked away for “just in case”.

While we’re on the subject of Arduino shield pinouts, don’t forget to check out Jon Oxer’s shieldlist.org when researching your next Arduino shield – it is the largest and most comprehensive catalogue of submitted Arduino shields in existence.

[Note - the "Go Between" Shield was purchased by myself personally 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.

Posted in arduino, go between, hardware hacking, mayhew labs, product review, review0 Comments

Project – Ultrasonic Combination Switch

In this project you learn how to make an ultrasonic distance-sensing combination switch.

Updated 18/03/2013

Time for a follow-up to the Single Button Combination Lock by creating another oddball type of switch/lock. To activate this switch we make use of a Parallax Ping))) Ultrasonic sensor, an Arduino-style board and some other hardware – to make a device that receives a four-number code which is made up of the distance between a hand and the sensor. If Arduino and ultrasonic sensors are new to you, please read this tutorial before moving on.

The required hardware for this project is minimal and shown below – a Freetronics Arduino-compatible board, the Ping))) sensor, and for display purposes we have an I2C-interface LCD module:

The combination for our ‘lock’ will consist of four integers. Each integer is the distance measured between the sensor and the user’s hand (etc.). For example, a combination may be 20, 15, 20, 15. So for the switch to be activated the user must place their hand 20cm away, then 15, then 20, then 15cm away. Our switch will have a delay between each measurement which can be modified in the sketch.

To keep things simple the overlord of the switch must insert the PIN into the switch sketch. Therefore we need a way to take measurements to generate a PIN. We do this with the following sketch, it simply displays the distance on the LCD):

And here is a demonstration of the sketch in action:

Now for the switch itself. For our example the process of “unlocking” will be started by the user placing their hand at a distance of 10cm or less in front of the sensor. Doing so will trigger the function checkPIN(), where the display prompts the user for four “numbers” which are returned by placing their hand a certain distance away from the sensor four times, with a delay between each reading which is set by the variable adel. The values of the user’s distances are stored in the array attempt[4].

Once the four readings have been taken, they are compared against the values in the array PIN[]. Some tolerance has been built into the checking process, where the value entered can vary +/- a certain distance. This tolerance distance is stored in the variable t in this function. Each of the user’s entries are compared and the tolerance taken into account. If each entry is successful, one is added to the variable accept. If all entries are correct, accept will equal four – at which point the sketch will either “unlock” or display “*** DENIED ***” on the LCD.

Again, this is an example and you can modify the display or checking procedure yourself. Moving forward, here is our lock sketch:

To finish the switch, we housed it in the lovely enclosure from adafruit:

And for the final demonstration of the switch in action. Note that the delays between actions have been added for visual effect – you can always change them to suit yourself:

So there you have it – the base example for a different type of combination switch. I hope someone out there found this interesting or slightly useful.

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 adafruit, arduino, combination lock, DFR0063, enclosure, hardware hacking, parallax, ping, projects, ultrasonic2 Comments

Repurposing Cat5E Network Cable

Hello readers

Just some random notes from my Saturday afternoon. While cleaning up the garage I found a rather long Cat5E network cable hiding from a long-forgotten project in the past:

However after trying to use it between my EtherTen and the router, the cable turned out to have a break in it somewhere. So what to do? Twentieth-century me would have just thrown it out, but that would be irresponsible. But inside that blue insulation are four twisted-pairs of 24AWG wire – perfect for prototyping and general low-voltage use:

So time to strip back the outer insulation and give the twisted-pairs their freedom:

They are a little thinner than first imagined, but how thin are they? Not being one to memorise the American Wire Gauge data I took a few quick measurements:

A quick measurement of the wire diameter without insulation. AWG specification is 0.511mm. Those digital vernier calipers were pretty sensitive so that will do. Excellent – now I have almost 120 metres of perfectly good hook-up wire. Just have to remember to test each piece before using it – that break was in there somewhere! What would that have cost me new? Local retailers (ugh) can charge over 25 centre per metre. So that’s a free lunch.

Next time you have some broken network cable… don’t throw it out – reuse it. What else can we do with the cable? Leave your suggestions in the comments below.

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.

Posted in hardware hacking, recycling, repurposing20 Comments

Learn to solder with eevblog’s David L. Jones!

Hello Readers

How is your soldering? Have you always wanted to improve your soldering skills, or never heated an iron in your life and didn’t know where to start? No matter your level of skill you could do a lot worse than review the following video blogs in this article by David L. Jones.

Who? 

[David] shares some of his 20 years experience in the electronics design industry in his unique non-scripted naturally overly enthusiastic and passionate style.
Bullsh!t and political correctness don’t get a look-in.

Dave started out in hobby electronics over 30 years ago and since then has worked in such diverse areas as design engineering, production engineering, test engineering, electro-mechanical engineering, that wacky ISO quality stuff, field service, concept design, underwater acoustics, ceramic sensors, military sonar systems, red tape, endless paperwork trails, environmental testing, embedded firmware and software application design, PCB design (he’s CID certified), power distribution systems, ultra low noise and low power design, high speed digital design, telemetry systems, and too much other stuff he usually doesn’t talk about.

He has been published in various magazines including: Electronic Today International, Electronics Australia, Silicon Chip, Elektor, Everyday Practical Electronics (EPE), Make, and ReNew.

Few people know Dave is also a world renowned expert and author on Internet Dating, a qualified fitness instructor, geocacher, canyoner, and environmentalist.

Regular readers of this website would know that I rarely publish outside material – however the depth and quality of the tutorials make them a must-see for beginners and experienced people alike. Furthermore, if you have the bandwidth they can be viewed in 1080p. And as a fellow Australian I’m proud to support Dave and his efforts. So I hope you can view, enjoy and possibly learn from the following videos:

The first covers the variety of tools you would use:

And the second covers through-hole PCB soldering:

The third covers surface-mount soldering:

Finally, watch the procedure for soldering a tiny SMD IC using the ‘dead bug’ method:

And for something completely different:

If you enjoyed those videos then don’t forget to check out what’s new on Dave’s eevblog website and forum. Videos shown are (C) David L. Jones 2011 and embedded with permission.

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.

Posted in education, eevblog, hardware hacking, learning electronics, soldering2 Comments

Discovering Arduino’s internal EEPROM lifespan

How long does the internal EEPROM of an Atmel ATmega328 last for? Let’s find out…

Updated 18/03/2013

Some time ago I published a short tutorial concerning the use of the internal EEPROM  belonging to the Atmel ATmega328 (etc.) microcontroller in our various Arduino boards. Although making use of the EEPROM is certainly useful, it has a theoretical finite lifespan – according to the Atmel data sheet (download .pdf) it is 100,000 write/erase cycles.

One of my twitter followers asked me “is that 100,000 uses per address, or the entire EEPROM?” – a very good question. So in the name of wanton destruction I have devised a simple way to answer the question of EEPROM lifespan. Inspired by the Dangerous Prototypes’ Flash Destroyer, we will write the number 170 (10101010 in binary) to each EEPROM address, then read each EEPROM address to check the stored number. The process is then repeated by writing the number 85 (01010101 in binary) to each address and then checking it again. The two binary numbers were chosen to ensure each bit in an address has an equal number of state changes.

After both of the processes listed above has completed, then the whole lot repeats. The process is halted when an incorrectly stored number is read from the EEPROM – the first failure. At this point the number of cycles, start and end time data are shown on the LCD.

In this example one cycle is 1024 sequential writes then reads. One would consider the entire EEPROM to be unusable after one false read, as it would be almost impossible to keep track of  individual damaged EEPROM addresses. (Then again, a sketch could run a write/read check before attempting to allocate data to the EEPROM…)

If for some reason you would like to run this process yourself, please do not do so using an Arduino Mega, or another board that has a fixed microcontroller. (Unless for some reason you are the paranoid type and need to delete some data permanently). Once again, please note that the purpose of this sketch is to basically destroy your Arduino’s EEPROM. Here is the sketch:

If you are unfamiliar with the time-keeping section, please see part one of my Arduino+I2C tutorial. The LCD used was my quickie LCD shield – more information about that here. Or you could always just send the data to the serial monitor box – however you would need to leave the PC on for a loooooong time… So instead the example sat on top of an AC adaptor (wall wart) behind a couch (sofa)  for a couple of months:

The only catch with running it from AC was the risk of possible power outages. We had one planned outage when our house PV system was installed, so I took a count reading before the mains was turned off, and corrected the sketch before starting it up again after the power cut. Nevertheless, here is a short video – showing the start and the final results of the test:


So there we have it, 1230163 cycles with each cycle writing and reading each individual EEPROM address. If repeating this odd experiment, your result will vary.

Well I hope someone out there found this interesting. Please refrain from sending emails or comments criticising the waste of a microcontroller – this was a one off.

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, atmega328, atmel, EEPROM, hardware hacking, lesson, microcontrollers, projects, tutorial8 Comments

Tutorial: Control AC outlets via SMS

Learn how to control AC outlets via SMS text message. This is chapter thirty-three 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.

Updated 02/03/2013

Assumed understanding for this article is found in part one. If you have not already done so, please read and understand it.

In this chapter we will continue with the use of the SM5100 cellular shield to turn digital outputs on and off via SMS. However please read chapters twenty-six and twenty-seven first if you are unfamiliar with using the GSM shield with Arduino. As an extension of chapter twenty-seven, we will use our Arduino to turn on or off AC outlets via a common remote-control AC outlet pack. Please note this is more of a commentary of my own experience, and not an exact tutorial. In other words, by reading this I hope you will gain some ideas into doing the necessary modifications yourself and in your own way.

Firstly, we need some remote-control AC outlets. Most electrical stores or giant retail warehouses may have something like this:

originaloutletsss

Nothing too original, just a wireless remote control that can switch on or off receiver outlets on a choice of four radio frequencies. Before moving forward I would like to acknowledge that this article was inspired by the wonderful book Practical Arduino – Cool Projects for Open Source Hardware by Jon Oxer and Hugh Blemings. In chapter two an appliance remote-control system is devised using a similar system.

At first glance the theory behind this project is quite simple – using the hardware in example 27.2, instead of controlling LEDs, activate the buttons on the wireless remote control for the AC outlets – leaving us with AC outlets controlled via SMS. However there are a few things to keep in mind and as discovered during the process, various pitfalls as well.

Before voiding the warranty on your remote control, it would be wise to test the range of the remote control to ensure it will actually work in your situation. I found this was made a lot easier by connecting a radio to the remote outlet – then you can hear when the outlet is on or off. If this is successful, make a note of the amount of time required to press the on and off buttons – as we need to control the delay in our Arduino sketch.

The next step is to crack open the remote control:

originalremotess

… and see what we have to work with:

remotepcbss

Straight away there are two very annoying things – the first being the required power supply – 12 volts; and the second being the type of button contacts on the PCB. As you can see above we only have some minute PCB tracks to solder our wires to. It would be infinitely preferable to have a remote control that uses actual buttons soldered into a PCB, as you can easily desolder and replace them with wires to our Arduino system. However unless you can casually tear open the remote control packaging in the store before purchase, it can be difficult to determine the type of buttons in the remote.

As you can see in the photo above, there is an off and on pad/button each for four channels of receiver. In my example we will only use two of them to save time and space. The next question to solve is how to interface the Arduino digital outputs with the remote control. In Practical Arduino, the authors have used relays, but I don’t have any of those in stock. However I do have a quantity of common 4N25 optocouplers, so will use those instead. An optocoupler can be thought of as an electronic switch that is isolated from what is it controlling – see my article on optocouplers for more information.

Four optocouplers will be required, two for each radio channel. To mount them and the associated circuitry, we will use a blank protoshield and build the Arduino-remote control interface onto the shield. The circuitry for the optocoupler for each switch is very simple, we just need four of the following:

As the LED inside the optocoupler has a forward voltage of 1.2 volts at 10mA, the 390 ohm resistor is required as our Arduino digital out is 5 volts. Dout is connected to the particular digital out pin from the Arduino board. Pins 4 and 5 on the optocoupler are connected to each side of the button contact on our remote control.

The next consideration is the power supply. The remote control theoretically needs 12 volts, however the included battery only measured just over nine. However for the optimum range, the full 12 should be supplied. To save worrying about the battery, our example will provide 12V to the remote control. Furthermore, we also need to supply 5 volts at a higher current rating that can be supplied by our Arduino. In the previous GSM chapters, I have emphasised that the GSM shield can possibly draw up to two amps in current. So once again, please ensure your power supply can deliver the required amount of current. From experience in my location, I know that the GSM shield draws around 400~600 milliamps of current – which makes things smaller and less complex.

The project will be supplied 12 volts via a small TO-92 style 78L12 regulator, and 5 volts via a standard TO-220 style 7805 regulator. You could always use a 7812, the 78L12 was used as the current demand is lower and the casing is smaller. The power for the whole project will come from a 15V DC 1.5A power supply. So our project’s power supply schematic will be as follows:

Now to mount the optocouplers and the power circuitry on the blank protoshield. Like most things in life it helps to make a plan before moving forward. I like to use graph paper, each square representing a hole on the protoshield, to plan the component layout. For example:

It isn’t much, but it can really help. Don’t use mine – create your own, doing so is good practice. After checking the plan over, it is a simple task to get the shield together. Here is my prototype example:

shieldss

It isn’t neat, but it works. The header pins are used to make connecting the wires a little easier, and the pins on the right hand side are used to import the 15V and export 12V for the remote. While the soldering iron is hot, the wires need to be soldered to the remote control. Due to the unfortunate size of the PCB tracks, there wasn’t much space to work with:

txsolder1ss

But with time and patience, the wiring was attached:

txsolder2ss

Again, as this is a prototype the aesthetics of the modification are not that relevant. Be careful when handling the remote, as any force on the wiring can force the soldered wire up and break the PCB track. After soldering each pair of wires to the button pads, use the continuity function of a multimeter to check for shorts and adjust your work if necessary.

At this stage the AC remote control shield prototype is complete. It can be tested with a simple sketch to turn on and off the related digital outputs. For example, the following sketch will turn on and off each outlet in sequence:

Now to get connected with our GSM shield. It is a simple task to insert the remote shield over the GSM shield combination, and to connect the appropriate power supply and (for example) GSM aerial. The control sketch is a slight modification of example 27.2, and is shown below

The variable pressdelay stores the amount of time in milliseconds to ‘press’ a remote control button. To control our outlets, we send a text message using the following syntax:

Where a/b are remote channels one and two, and x is replaced with 0 for off and 1 for on.

So there you have it – controlling almost any AC powered device via text message from a cellular phone. Imagine trying to do that ten, or even five years ago. As always, now it is up to you and your imagination to find something to control or get up to other shenanigans.

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 AC power, arduino, CEL-00675, CEL-09607, cellphone hacking, cellular, GSM, hardware hacking, lesson, SM5100, SMS, tutorial

Project – Simple RFID access system

In this tutorial you can make an RFID access system. It’s very simple and can be used with a wide variety of end-uses.

Updated 18/03/2013

The purpose of this project is to prototype a basic RFID access system. Although it is not that complicated, this article is my response to a kit reviewed in the Australian “Silicon Chip” (November 2010) electronics magazine. Their article describes the kit in detail – operation, schematic, use and installation. However the code for the microcontroller (PIC16F628A)  is not published due to the kit manufacturer holding copyright over the design.

This is a shame, as many organisations have been quite successful selling open-source kits. So instead of moaning about it, I have created my own design that matches the operation of the original, instead using the ATmega328 MCU with Arduino bootloader. Consider this a basic framework that you can modify for your own access system, or the start of something more involved.

articless

There are pros and cons with the original vs. my version. The biggest pro is that you can buy the whole kit for around Au$40 including a nice PCB, solder it together, and it works. However if you want to do it yourself, you can modify it to no end, and have some fun learning and experimenting along the way. So let’s go!

The feature requirements are few. The system must be able to learn and remember up to eight RFID access tags/cards, etc – which must be able to be altered by a non-technical user. Upon reading a card, the system will activate a relay for a period of time (say 1 second) to allow operation of a door strike or electric lock. Finally, the RFID tag serial numbers are to be stored in an EEPROM in case of a power outage. When a tag is read, a matching LED (1~8) will show which tag was read. There are also two LEDs, called “Go” and “Stop” which show the activation status. The original kit has some more LEDs, which I have made superfluous by blinking existing LEDs.

This is a simple thing to make, and the transition from a solderless breadboard to strip board will be easy for those who decide to make a permanent example. But for now, you can follow with the prototype. First is the parts list:

  • Atmel ATmega328 with Arduino bootloader;
  • 16 MHz resonator (X1 in schematic);
  • ten LEDs of your choice;
  • two normally-open push buttons;
  • two 560 ohm resistors (all resistors 1/4 watt);
  • one 1k ohm resistor;
  • three 10k ohm resistors;
  • one BC548 transistor;
  • three 0.01 uF monolithic capacitors;
  • one 100 uF electrolytic capacitor;
  • one 1N4004 diode;
  • Microchip 24LC256 EEPROM;
  • 125 kHZ RFID module;
  • 125 kHz RFID tags/cards;
  • connecting wire;
  • large solderless breadboard;
  • LM7805 power regulator;
  • relay of your choice with 5V coil (example).

When selecting a relay, make sure it can handle the required load current and voltage – and that the coil current is less than 100mA.

If attempting to switch mains voltage/current – contact a licensed electrician. Your life is worth more than the money saved by not consulting an expert.

And here is the schematic (large version):

simplerfidschematic

Here is the prototype on the solderless breadboard. For demonstration purposes an LED has been substituted for the transistor/relay section of the circuit, the power regulator circuitry has not been shown, and there are superfluous 4.7k resistors on the I2C bus. To program the software (Arduino sketch) the easiest way is by inserting the target IC into an Arduino-compatible board, or via a 5V FTDI cable and a basic circuit as described here.

rfidbboardss

The Arduino sketch is also quite simple. The main loop calls the procedure readTags() to process any RFID tag read attempts, and then monitors button A – if pressed, the function learnTags() is called to allow memorisation of new RFID tags. Each tag serial number consists of 14 decimal numbers, and these are stored in the EEPROM sequentially. That is, the first tag’s serial number occupies memory positions 0~13, the second tag’s serial number occupies memory position 14~28, and so on. Two functions are used to read and write tag serial numbers to the EEPROM – readEEPROMtag() and writeEEPROMtag().

The EEPROM is controlled via the I2C bus. For a tutorial about Arduino, I2C bus and the EEPROM please read this article. For a tutorial about Arduino and RFID, please read this article. The rest of the sketch is pretty self-explanatory. Just follow it along and you can see how it works. You can download the sketch from hereAnd finally, a quick video demonstration:

So there you have it. I hope you enjoyed reading about this small project and perhaps gained some use for it of your own or sparked some other ideas in your imagination that you can turn into reality.

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 hardware hacking, learning electronics, microcontrollers, projects, RDM630, RDM6300, rfid12 Comments

Tutorial: Arduino and GSM Cellular – Part Two

Continue to learn about connecting your Arduino to the cellular network with the SM5100 GSM module shield. This is chapter twenty-seven 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.

Updated 02/03/2013

Assumed understanding for this article is found in part one. If you have not already done so, please read and understand it. In this instalment we continue with bare projects which you can use as a framework for your own creations.

Reach out and control something

First we will discuss how to make something happen by a simple telephone call. And the best thing is that we don’t need the the GSM module to answer the telephone call (thereby saving money) – just let the module ring a few times. How is this possible? Very easily. Recall example 26.1 – we monitored the activity of the GSM module by using our terminal software. In this case what we need to do is have our Arduino examine the text coming in from the serial output of the GSM module, and look for a particular string of characters.

When we telephone the GSM module from another number, the module returns the text as shown in the image below:

term2

We want to look for the text “RING”, as (obviously) this means that the GSM shield has recognised the ring signal from the exchange. Therefore need our Arduino to count the number of rings for the particular telephone call being made to the module. (Memories – Many years ago we would use public telephones to send messages to each other. For example, after arriving at a foreign destination we would call home and let the phone ring five times then hang up – which meant we had arrived safely). Finally, once the GSM shield has received a set number of rings, we want the Arduino to do something.

From a software perspective, we need to examine each character as it is returned from the GSM shield. Once an “R” is received, we examine the next character. If it is an “I”, we examine the next character. If it is an “N”, we examine the next character. If it is a “G”, we know an inbound call is being attempted, and one ring has occurred. We can set the number of rings to wait until out desired function is called. In the following example, when the shield is called, it will call the function doSomething() after three rings.

The function doSomething() controls two LEDs, one red, one green. Every time the GSM module is called for 3 rings, the Arduino alternately turns on or off the LEDs. Using this sketch as an example, you now have the ability to turn basically anything on or off, or call your own particular function. Another example would be to return some type of data, for example you could dial in and have the Arduino send you a text message containing temperature data.

And now for a quick video demonstration. The first call is made, and the LEDs go from red (off) to green (on). A second call is made, and the LEDs go from green (on) to red (off). Although this may seem like an over-simplified example, with your existing Ardiuno knowledge you now have the ability to run any function by calling your GSM shield.

Control Digital I/O via SMS

Now although turning one thing on or off is convenient, how can we send more control information to our GSM module? For example, control four or more digital outputs at once? These sorts of commands can be achieved by the reception and analysis of text messages.

Doing so is similar to the method we used in example 27.1. Once again, we will analyse the characters being sent from the GSM module via its serial out. However, there are two AT commands we need to send to the GSM module before we can receive SMSs, and one afterwards. The first one you already know:

Which sets the SMS mode to text. The second command is:

This command tells the GSM module to immediately send any new SMS data to the serial out. An example of this is shown in the terminal capture below:

smsrxdemo

Two text messages have been received since the module was turned on. You can see how the data is laid out. The blacked out number is the sender of the SMS. The number +61418706700 is the number for my carrier’s SMSC (short message service centre). Then we have the date and time. The next line is the contents of the text message – what we need to examine in our sketch.

The second text message in the example above is how we will structure our control SMS. Our sketch will wait for a # to come from the serial line, then consider the values after a, b, c and d – 0 for off, 1 for on. Finally, we need to send one more command to the GSM module after we have interpreted our SMS:

This deletes all the text messages from the SIM card. As there is a finite amount of storage space on the SIM, it is prudent to delete the incoming message after we have followed the instructions within. But now for our example. We will control four digital outputs, D9~12. For the sake of the exercise we are controlling an LED on each digital output, however you could do anything you like. Although the sketch may seem long and complex, it is not – just follow it through and you will see what is happening:

And now for a video demonstration:

So there you have it – controlling your Arduino digital outputs via a normal telephone or SMS. Now it is up to you and your imagination to find something to control, sensor data to return, or get up to other shenanigans.

If you enjoyed this article, you may find this of interest – controlling AC power outlets via SMS.

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, CEL-00675, CEL-09607, cellphone hacking, cellular, GSM, hardware hacking, lesson, microcontrollers, SM5100, SMS, tutorial

Tutorial: Arduino and the DS touch screen

Use inexpensive touch-screens with Arduino in chapter twenty-three 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.

[Updated 19/01/2013]

Today we are going to spend some time with a touch screen very similar to the ones found in a Nintendo DS gaming unit. In doing so, we can take advantage of a more interesting and somewhat futuristic way of gathering user input. Please note that in order to use the screen without going completely insane, you will need the matching breakout board, as shown in the following image:

screenbbss

The flimsy flexible PCB runner is inserted into the plastic socket on the breakout board – be careful not to crease the PCB nor damage it as it can be rather easy to do so. (The screen can be easy to break as well…) However don’t let that put you off. You will most likely want to solder in some header pins for breadboard use, or sockets to insert wires. For this article it is being used with pins for a breadboard.

Before we start to use the screen, let’s have a quick investigation into how they actually work. Instead of me trying to paraphrase something else, there is a very good explanation in the manufacturer’s data sheet. So please read the data sheet then return. Theoretically we can consider the X and Y axes to be two potentiometers (variable resistors) that can be read with the analogRead() function. So all we need to do is use two analog inputs, one to read the X-axis value and one for the Y-axis value.

However, as always, life isn’t that simple. Although there are only four wires to the screen, the wires’ purpose alters depending on whether we are measuring the X- or Y-axis. Which sounds complex but is not. Using the following example, we can see how it all works.

Example 23.1

In this example, we will read the X- and Y-axis values returned from the touch screen and display them on an LCD module. (Or you could easily send the values to the serial monitor window instead). From a hardware perspective, you will need:

  • Arduino Uno or 100% compatible board
  • DS touch screen and breakout board ready for use
  • Solderless breadboard and some jumper wires
  • Arduino-ready LCD setup. If you are unsure about using LCDs, please revisit chapter 24 of my tutorials.

Connection of the touch screen to the Arduino board is simple, Arduino analog (yes, analog - more on this later) pins A0 to Y1, A1 to X2, A2 to Y2 and A3 to X1 – as below:

exam23p1linkss

Mounting the rest for demonstration purposes is also a simple job. Hopefully by now you have a test LCD module for easy mounting :)

exam23p1ss

I have mounted  the touch screen onto the breadboard with some spare header pins, they hold it in nicely for testing purposes. Also notice that the touch screen has been flipped over, the sensitive side is now facing up. Furthermore, don’t forget to remove the protective plastic coating from the screen before use.

From a software (sketch) perspective we have to do three things – read the X-axis value, the Y-axis value, then display them on the LCD. As we (should) know from the data sheet, to read the X-axis value, we need to set X1 as 5V, X2 as 0V (that is, GND) and read the value from Y2. As described above, we use the analog pins to do this. (You can use analog pins as input/output lines in a similar method to digital pins – more information here. Pin numbering continues from 13, so analog 0 is considered to be pin 14, and so on). In our sketch (below) we have created a function to do this and then return the X-axis value.

The Y-axis reading is generated in the same method, and is quite self-explanatory. The delay in each function is necessary to allow time for the analog I/O pins to adjust to their new roles as inputs or outputs or analog to digital converters. Here is our sketch:

Next, let’s have a look at this example in action. The numbers on the LCD may be not what you expected…

The accuracy of the screen is not all that great – however first take into account the price of the hardware before being too critical. Note that there are values returned even when the screen is not being pressed, we could perhaps call these “idle values”. Later on you will learn tell your sketch to ignore these values if waiting for user input, as they will note that nothing has been pressed. Furthermore, the extremities of the screen will return odd values, so remember to take this into account when designing bezels or mounting hardware for your screen.

Each touch screen will have different values for each X and Y position, and that is why most consumer hardware with touch screens has calibration functions to improve accuracy. We can now use the X and Y values in sketches to determine which part of the screen is being touched, and act on that touch.

In order to program our sketches to understand which part of the screen is being touched, it will help to create a “map” of the possible values available. You can determine the values using the sketch from example 23.1, then use the returned values as a reference for designing the layout of your touch interface. For example, the following is a map of my touch screen:

rangess

Example 23.2

For the next example, I would like to have four “zones” on my touch screen, to use as virtual buttons for various things. The first thing to do is draw a numerical “map” of my touch screen, in order to know the minimum and maximum values for both axes for each zone on the screen:

zonallayoutss

At this point in the article I must admit to breaking the screen. Upon receiving the new one I remeasured the X and Y points for this example and followed the  process for defining the numerical boundaries for each zone is completed by finding average mid-points along the axes and allowing some tolerance for zone boundaries.

Now that the values are known, it is a simple matter of using mathematical comparison and Boolean operators (such as >, <, &&, etc)  in a sketch to determine which zone a touch falls into, and to act accordingly. So for this example, we will monitor the screen and display on the LCD screen which area has been pressed. The hardware is identical to example 23.1, and our touch screen map will be the one above. So now we just have to create the sketch.

After reading the values of the touch screen and storing them into variables x and y, a long if…then…else if loop occurs to determine the location of the touch. Upon determining the zone, the sketch calls a function to display the zone type on the LCD. Or if the screen is returning the idle values, the display is cleared. So have a look for yourself with the example sketch:

And see it in operation:

So there you have it, I hope you enjoyed reading this as much as I did writing it. Now you should have the ability to use a touch screen in many situations – you just need to decide how to work with the resulting values from the screen and go from there.

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, BOB-09170, education, hardware hacking, LCD-08977, lesson, microcontrollers, nintendo ds, touch screen, tutorial16 Comments

Breaking up an automatic room deodoriser – round two

Again we attempt to break down an automatic room deodoriser.

Updated 18/03/2013

Today we are going to tear down another automatic room deodoriser. Why? Well the first attempt beat me, so it was time to even the score and try again with another type. The supermarket had the following units for $7.99, which seemed a little too cheap:

brandnewss1

The “satisfaction guarantee” gave me a chuckle, the thought of writing to SC Johnson complaining that their products were not that hackable would be interesting. But would it be hackable at all? Let’s find out. The packaging promises a squirt of scent when the unit detects motion, then holds out for 30 minutes until the next release. The word motion hints that there would be a PIR inside the unit. However the instructions mention that the unit does not work that well in dark or bright rooms – which is odd, as PIRs usually work in the dark. Hmm. This unit is somewhat smaller than the previous attempt, yet still offers us a pair of alkaline AA cells:

insidess

Moving on, time to start the disassembly process. The rear shows four screws, easily removed:

backss

revealing the fun things:

gearsss

The motor drive is reduced twice, which then has a geared arm which causes the vertical motion to pressure the cylinder to release the scent. The whole mess of gears was lubricated generously, the whole lot literally came out with the touch of a finger. Removing the gears and goop reveals the motor and control boards, which clipped out easily:

motorpcbss

Interesting – a labelled motor. Very good, what looks like to be a 3V DC motor. The control board is made up of two PCBs, a smaller module that holds a control IC of some sort, and the larger, lesser-densely populated board with the button, status LED and “motion detector”. Let’s have a close-up of that PCB:

pcbaloness

So we have the button, which causes the motor to run; a yellow LED which blinks once every five seconds; and out motion detector in the black casing. The motion detector seemed rather familiar, so I removed the black housing around it with some pliers, which revealed this:

lightsensorss

Huh – that looks just like an LED. The metal object inside the clear casing was even identical to what you would see inside an LED. However, foolishly I broke it off the PCB when removing the housing, so could not get any voltage to it. From reading the instructions earlier on – that mention the light/dark issue, causes me to ponder if this is some sort of light-dependent sensor?

No – it is a photodiode! However the motor looked quite worthwhile. Curious to see what is driving it, I hooked up Mr Fluke to see what happens:

No surprises there, almost three volts DC forward voltage. After applying forward current the circuit applies a quick reverse current to release, thereby causing the gears and arm to ‘squeeze’ down on the scent cylinder. So now we have a circuit board that runs on 3V, which can output 3V for a few seconds every 30 minutes – or at the press of a button.

With regards to current, another measurement was taken:


When free-running, the motor draws around 45 milliamps – and the stall current (that is, the current drawn when I force the spindle to stop) is around 675 milliamps. That is quite a strong little motor, and worth the effort. In general, this has been a good tear down, we scored some AA cells, a good motor and gears, some stink spray, and a timing circuit that could have uses elsewhere. So overall a win – the score has evened with the deodoriser world! High resolution photos 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.

Posted in electronics, hardware hacking, room deoderiser, tutorial5 Comments

Add a real-time clock to the Freetronics Eleven

Let’s add a DS1307 real-time clock to our Freetronics Arduino-compatible board.

Updated 18/03/2013 – this is also perfect for the Freetronics Eleven board.

Now and again I find myself making another kind of clock or timing device using the Arduino system, and each one has been making use of the Maxim DS1307 real-time clock IC. However every time another clock is being worked on, my DS1307 real-time clock shield needs to come out to play. Although in itself it is a nice shield, at the end of the day – the less you have the better. Originally I used a Freetronics TwentyTen board – which has now been superseded by their Eleven board, however they’re both identical for the purposes of this tutorial.

So what to do? As regular readers will know, my preferred board is the Freetronics Eleven, and within this we have a solution to the following problem:

problemss

The Freetronics team have thoughtfully provided a prototyping area in their board – and that will be a perfect home for the real time clock system. Being a cheapskate and a masochist – instead of  following others by using a smaller RTC module I will instead use parts already in stock (except for the battery) and install my own circuit. So, as always – we need a plan. The circuit itself is quite simple, the DS1307 data sheet has a fine example on page thirteen, and here is my interpretation:

schematicss

So the parts required for our clock circuit will be:

  • IC1 – Maxim DS1307 I2C real-time clock IC
  • 8-pin IC socket
  • R1~R3 – 10k ohm 1% metal film resistors
  • X1 – 32.768 kHz crystal
  • B1 – Panasonic CR1220 3v battery with solder pins (Farnell part number 1298944) [data sheet one and two]
  • One header pin (from those 40-way strips)
  • some thin black single-core wire

The CR1220 battery was chosen over the usual CR2032 due to the smaller diameter. According to the DS1307 data sheet, the battery should last around ten years if it has a capacity of 48 mAh. Our CR1220 is 35 mAh – which will do nicely, perhaps seven years or so. That will have to do. Don’t forget to check the voltage of the battery before installation – it should be just over three volts.

Now to get everything arranged in the prototyping area. When doing this it pays to always have the schematic in front of you as well so you can refer to it when necessary. Planning to use protoboard of any size requires a good plan as well. After spending some time considering component placement, the final layout was as follows:

layoutsss

Each square on the grid represents one hole on the board. After you see the images below, everything will make sense. Before soldering away, it will pay to give the prototyping area a quick clean with some PCB cleaner.

Now it is finally time to get soldering. The first items were the battery, crystal and the resistors. Although the battery was designed to be soldered, I am always a little wary when applying heat to them. Two seconds with the hot iron was enough.

When soldering in the crystal (or anything else), try to keep in mind what the leads will be connecting to. For example, the crystal legs will need to connect to pins 1 and 2 of the IC socket. So bend the crystal leads in the direction of the respective IC socket pins. Doing so will make creating solder joins between them much easier:

The resistors were simple enough. Keep the excess clippings to make jumpers with later. Also notice how the right hand leg of R3 was bent around and brought back up to the top row – this is to help make connections with the 5V rail link:

resisleadsss

The next item was the IC socket. Nothing to worry about there, just drop it in and solder away. Don’t forget to bridge the crystal pins to socket pins one and two, and the battery positive pin to IC socket pin three.

Next for the SQW pin. The DS1307 can also output a nice square wave at either 1Hz, 4.096 kHz, 8.192 kHz or 32.768 kHz, with the resulting signal being found on pin 7. It isn’t something really used that often, but you never know. So I soldered in one of these pins, which should make it easy enough to use later on:

Note that if you are using the SQW function, the DS1307 will merrily pulse away once it is set, until the power is cut – the square-wave generator is autonomous to the I2C bus once it has been set. And it remembers (as long as the backup battery is fine). For example, you can upload a sketch to set the SQW to 4.096 kHz, remove power, yank out the ATmega328, power up – and the SQW is still active.

Next we turn the board over, and solder in our jumper wires:

backlinkss

The lead on the top runs from the right-hand side of the pull-up resistors R1~R3 (when facing the top of the board) to the 5V pad. The bottom lead runs from pin four of the IC socket to the GND pad. The negative pin of the battery is also bent over and soldered to the GND pad. Also, connect all the resistors together as shown in the above image (below the TX pin). The next step is turn the board back over and make some more wired connections, the first being pin eight of the IC socket to the resistors and then to the 5V link on the rear:

toplinksss

The next are somewhat longer, they are the leads for the I2C bus. Run a wire from next to IC socket pin six all the way to (and through) the bottom-right hole of the TwentyTen (when facing the top); this will be the SCL line and soldered to analogue 5. Repeat again from IC socket pin five, this is the SDA line (as above) for analogue 4. The joints you have to solder them onto are not that large, however it can be done. Before soldering the wires in, heat up the existing joint to melting point then let it cool again – this makes actually soldering the wire in a lot easier:

i2css

And there we have it. At this stage, don’t plug the board in. Do some quality control: check that the soldered joints are complete; check that solder has bridged where you need it, and not where you don’t; use the continuity function (‘beeper’) of a multimeter to spot-check for shorts, and also follow the new 5V and GND lines to ensure they are connected correctly. And finally, insert the DS1307 IC into the socket.

finishedss

OK – now for some test timing. If you have not worked with the DS1307 IC before, there is a full explanation of how it works within our Arduino tutorials. Here’s a sketch you can use to test the real-time clock. Once you have uploaded that sketch, open the serial monitor box at 9600 bps, and you should have something like this:


Now let’s check the 1 Hz output from the SQW pin:

Recall that you can generate four frequencies with your DS1307, here is an example sketch that does just that:

and here is the result – measured on a freqency counter:

My frequency counter is around twenty-two years old, please be patient with it as the sampling rate is not the best.

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, clocks, ds1307, freetronics, hardware hacking, learning electronics, microcontrollers, tutorial4 Comments

Breaking up an automatic room deodoriser – part one

In this article we attempt to break down an automatic room deodoriser and have some fun.

Updated 18/03/2013

[Update - we won round two]

Today we are going to tear down an automatic room deodoriser. Why? Why not! After walking around the supermarket as one does, pontificating over the need for doughnuts – I noticed this package on sale for eight dollars:

unopenedss

What grabbed my attention was the words “movement sensor” and the price tag. A sensor by itself can cost more. Where’s the catch? I am sure the company makes their money back from selling the refills, in a similar method to ink cartridges and razor blades. Good for them. However, perhaps this can be good for us! So into the basket and home it came. My flatmates thought it was a lovely gesture to have one in the hallway. Hah! As Dave Jones would say, “don’t turn it on – take it apart!” So let’s go…

The can of spray went straight into the WC, nothing of interest there. Three alkaline AA cells were included:

alkalinesss

Well that’s a good start, you can always use these in a camera or something else. Armed with a philips-head screwdriver and a pair of needle-nosed pliers, the entire assembly came apart very easily and without force. I must congratulate the designers, you almost get the feeling that this is designed to be repaired if broken, and not replaced. The process of disassembly was quite easy:

1ss1

The front cover came off quite easily. The switch on the right enables/disables the movement sensor; the LED indicates the repeat mode for the spray; and the black switch controls the duration between sprays – off, 9, 18 or 36 minutes.

2ss1

After removing the rear panel with four screws, we can see the motor and one of the two PCBs. Two more screws, and we can remove the electronics and mechanical sections:

3ss2

This is the front-facing part of the motor board. The motor turns one direction then another to have the plastic ‘finger’ push down and release on the aerosol can nozzle. The gear ratios are quite large, allowing the motor to exert quite an amount of torque. The metal base board has some convenient mounting holes as well, so this could be reused easily. If you had a pair of these you could drive something that is quite heavy at a sedate speed.

4ss

Here is the main controller board, with nicely colour-coded JST connectors for leads to the motor, power source (those 3 x AA cells, 4.5V) and to the switch that turns the sensor on and off. The underside is very professional, all SMD:

6ss

The motion detector’s board plugs nicely into the main board, thanks to the 2×9 pin header and socket arrangement:

5ss

Now it is time to see how things work. The first step will be the motor – how much voltage and current does it use? I ran the motor without a load for thirty minutes at 4.5 volts DC – the  motor body did not warm up at all, a good sign that this voltage was suitable. With regards to current, there are two measurements to take – current while free-running, and under maximum load (i.e. feeding the motor 4.5 volts while holding the gears still). While free running, the current drawn was 34 milliamps:

freerunss

… and when I held down the gears so the motor could not turn, the current drawn was 305 milliamps:

maxloadss

So now we have a nice strong motor that can run at 4.5 DC, and draws between 34 and 305 milliamps. That’s a good start. Furthermore, being able to stick the meter display to the desk lamp really makes life easy. Now it is time to investigate the detector. It had a few codes on the PCBs, such as KT-7964, Smart Motion A-06 and RB-S04 which I searched for on the Internet without any luck.

So the next thought was to feed it 4.5 volts DC, and use the Scanalogic2 to analyse any signals or voltages around the PIR sensor module to see what happens. However, the entire system was dead, it would not do a thing. The same problem occurred at four volts DC. No luck either. After the initial power up, the unit should light the LED for one second, then activate the motor for a “first spray” – but nothing. Hmmm.

So at this point we are at a brick wall, however this is not the end. Research will continue to look for details of the PIR unit, and once it is working independently a new post will be published.

This article also shows to me and others that not everything is a success first time. It can be disappointing, however it’s not the end of the world. With every failure comes knowledge which can be used the next time around. So subscribe to the web page updates, and keep an eye out in the future. High resolution images are available from 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.

Posted in hardware hacking, room deoderiser, tutorial11 Comments

Getting Started with Arduino! – Chapter Five

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

Welcome back fellow arduidans!

Hello once again to our weekly Arduino instalment. This week are up to all sorts of things, including: more shiftiness with shift registers, more maths, 7-segment displays, arduinise a remote control car, and finally make our own electronic game! Wow – let’s get cracking…

In the last chapter we started using a 74HC595 shift register to control eight output pins with only three pins on the Arduino. That was all very interesting and useful – but there is more! You can link two or more shift registers together to control more pins! How? First of all, there is pin we haven’t looked at yet – pin 9 on the ‘595. This is “data out”. If we connect this to the data in pin (14) on another ‘595, the the first shift register can shift a byte of data to the next shift register, and so on.

Recall from our exercise 4.1, this part of the sketch:

If we add another shiftOut(); command after the first one, we are sending two bytes of data to the registers. In this situation the first byte is accepted by the first shift register (the one with its data in pin [14] connected to the Arduino), and when the next byte is sent down the data line, it “pushes” the byte in the first shift register into the second shift register, leaving the second byte in the first shift register.

So now we are controlling SIXTEEN output pins with only three Arduino output pins. And yes – you can have a third, fourth … if anyone sends me a link to a Youtube clip showing this in action with 8 x 74HC595s, I will send them a prize. So, how do we do it? The code is easy, here is the sketch. On the hardware side, it is also quite simple. If you love blinking LEDs this will make your day. It is the same as exercise 4.1, but you have another 74HC595 connected to another 8 LEDS. The clock and latch pins of both ‘595s are linked together, and there is a link between pin 9 of the first register and pin 14 of the second. Below is a photo of my layout:

example5p1small

and a video:

Can you think of anything that has seven or eight LEDs? Hopefully this photo will refresh your memory:

ch57seg_small

Quickie – if you want to find out the remainder from a quotient, use modulo – “%”. For example:

a = 10 % 3;

returns a value of 1; as 10 divided by 3 is 3 remainder 1.

and

If you need to convert a floating-point number to an integer, it is easy. Use int();. It does not round up or down, only removes the fraction and leaves the integer.

Anyhow, now we can consider controlling these numeric displays with our arduino via the 74HC595. It is tempting to always use an LCD, but if you only need to display a few digits, or need a very high visibility, LED displays are the best option. Furthermore, they use a lot less current than a backlit LCD, and can be read from quite a distance away. A 7-segment display consists of eight LEDs arrange to form the digit eight, with a decimal point. Here is an example pinout digram:

7segpinout

Note that pinouts can vary, always get the data sheet if possible.

Displays can either be conmmon-anode, or common-cathode. That is, either all the LED segment anodes are common, or all the cathodes are common. Normally we will use common-cathode, as we are “sourcing” current from our shift register through a resistor (560 ohm), through the LED then to ground. If you use a common-anode, you need to “sink” current from +5v, through the resistor and LED, then into the controller IC. Now you can imagine how to display digits using this type of display – we just need to shiftout(); a byte to our shift register that is equavalent to the binary representation of the number you want to display.

Huh?

Let’s say we want to display the number ‘8’ on the display. You will need to light up all the pins except for the decimal point. Unfortunately not all 7-segment displays are the same, so you need to work out which pinout is for each segment (see your data sheet) and then find the appropriate binary number to represent the pins needed, then convert that to a base-10 number to send to the display. I have created a table to make this easier:

example5p2pintable

And here is a blank one for you to print out and use: blank pin table.pdf.

Now let’s wire up one 7-segment display to our Arduino and see it work. Instead of the eight LEDs used in exercise 4.1 there is the display module. For reference the pinouts for my module were (7,6,4,2,1,9,10,5,3,8) = (a,b,c,d,e,f,g,DP, C, C) where DP is the decimal point and C is a cathode (which goes to GND). The sketch: example 5.2. Note in the sketch that the decimal point is also used; it’s byte value in this example is 128. If you add 128 to the value of loopy[] in the sketch, the decimal point will be used with the numbers.

example5p2small

and the video:

There you go – easily done. Now it is time for you to do some work!

Exercise 5.1

Produce a circuit to count from 0 to 99 and back, using two displays and shift-registers. It isn’t that difficult, the hardware is basically the same as example 5.1 but using 7-segment displays.

You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • Two 7-segment, common-cathode displays
  • Two 74HC595 shift registers
  • 16 x 560 ohm 0.25 W resistors. For use as current limiters between the LED display segments and ground
  • a breadboard and some connecting wire
  • some water

You are probably wondering how on earth to separate the digits once the count hits 10… a hint: 34 modulo 10 = 4. 34 divided by 10 = 3.4 … but 3.4 isn’t an integer. While you are thinking, here is the shot of my layout:

exercise5p1small

and the ubiquitous video:

And here is the sketch for my interpretation of the answer.

I hope you have gained more of an understanding of the possibilities available with shift registers. We will continue with more in the next tutorial.
Exercise 5.2

Once again it is your turn to create something. We have discussed binary numbers, shift registers, analogue and digital inputs and outputs, creating our own functions, how to use various displays, and much more. So our task now is to build a binary quiz game. This is a device that will:

  • display a number between 0 and 255 in binary (using 8 LEDs)
  • you will turn a potentiometer (variable resistor) to select a number between 0 and 255, and this number is displayed using three 7-segment displays
  • You then press a button to lock in your answer. The game will tell you if you are correct or incorrect
  • Basically a “Binary quiz” machine of some sort!

I realise this could be a lot easier using an LCD, but that is not part of the exercise. Try and use some imagination with regards to the user interface and the difficulty of the game. At first it does sound difficult, but can be done if you think about it. At first you should make a plan, or algorithm, of how it should behave. Just write in concise instructions what you want it to do and when. Then try and break your plan down into tasks that you can offload into their own functions. Some functions may even be broken down into small functions – there is nothing wrong with that – it helps with planning and keeps everything neat and tidy. You may even find yourself writing a few test sketches, to see how a sensor works and how to integrate it into your main sketch. Then put it all together and see!

You will need: (to recreate my example below)

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • Three 7-segment, common-cathode displays
  • eight LEDs (for binary number display)
  • Four 74HC595 shift registers
  • 32 x 560 ohm 0.25 W resistors. For use as current limiters between the LED display segments and ground
  • a breadboard and some connecting wire
  • 10k linear potentiometer (variable resistor)
  • some water

For inspiration here is a photo of my layout:

exercise5p2small

and a video of the game in operation. Upon turning on the power, the game says hello. You press the button to start the game. It will show a number in binary using the LEDs, and you select the base-10 equivalent using the potentiometer as a dial. When you select your answer, press the button  – the quiz will tell you if you are correct and show your score; or if you are incorrect, it will show you the right answer and then your score.

I have set it to only ask a few questions per game for the sake of the demonstration:

And yes – here is the sketch for my answer to the exercise. Now this chapter is over. Hope you had fun! Now move on to Chapter Six.

 

Posted in 74hc595, arduino, education, hardware hacking, lesson, microcontrollers, tutorial25 Comments


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: