t r o n i x s t u f f

fun and learning with electronics

Project: Clock Four – Scrolling text clock

Introduction

Time for another instalment in my highly-irregular series of irregular clock projects.  In this we have “Clock Four” – a scrolling text clock. After examining some Freetronics Dot Matrix Displays in the stock, it occurred to me that it would be neat to display the time as it was spoken (or close to it) – and thus this the clock was born. It is a quick project – we give you enough to get going with the hardware and sketch, and then you can take it further to suit your needs.

Hardware

You’ll need three major items – An Arduino Uno-compatible board, a real-time clock circuit or module using either a DS1307 or DS3232 IC, and a Freetronics DMD. You might want an external power supply, but we’ll get to that later on.

The first stage is to fit your real-time clock. If you are unfamiliar with the operation of real-time clock circuits, check out the last section of this tutorial. You can build a RTC circuit onto a protoshield or if you have a Freetronics Eleven, it can all fit in the prototyping space as such:

If you have an RTC module, it will also fit in the same space, then you simply run some wires to the 5V, GND, A4 (for SDA) and A5 (for SCL):

By now I hope you’re thinking “how do you set the time?”. There’s two answers to that question. If you’re using the DS3232 just set it in the sketch (see below) as the accuracy is very good, you only need to upload the sketch with the new time twice a year to cover daylight savings (unless you live in Queensland). Otherwise add a simple user-interface – a couple of buttons could do it, just as we did with Clock Two. Finally you just need to put the hardware on the back of the DMD. There’s plenty of scope to meet your own needs, a simple solution might be to align the control board so you can access the USB socket with ease – and then stick it down with some Sugru:

With regards to powering the clock – you can run ONE DMD from the Arduino, and it runs at a good brightness for indoor use. If you want the DMD to run at full, retina-burning brightness you need to use a separate 5 V 4 A power supply. If you’re using two DMDs – that goes to 8 A, and so on. Simply connect the external power to one DMD’s terminals (connect the second or more DMDs to these terminals):

The Arduino Sketch

You can download the sketch from here. It was written only for Arduino v1.0.1. The sketch has the usual functions to set and retrieve the time from DS1307/3232 real-time clock ICs, and as usual with all our clocks you can enter the time information into the variables in void setup(), then uncomment setDateDs1307(), upload the sketch, re-comment setDateDs1307, then upload the sketch once more. Repeat that process to re-set the time if you didn’t add any hardware-based user interface.

Once the time is retrieved in void loop(), it is passed to the function createTextTime(). This function creates the text string to display by starting with “It’s “, and then determines which words to follow depending on the current time. Finally the function drawText() converts the string holding the text to display into a character variable which can be passed to the DMD.

And here it is in action:

Conclusion

This was a quick project, however I hope you found it either entertaining or useful – and another random type of clock that’s easy to reproduce or modify yourself. We’re already working on another one which is completely different, so stay tuned.

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.

March 15, 2013 Posted by | arduino, clocks, dmd, ds1307, DS3232, freetronics, learning electronics, microcontrollers, projects, scrolling, time clock, timing, tutorial | , , , , , , , , , , , , , | 2 Comments

Results – February 2012 Competition

Now that February is over it’s time to announce the lucky winners of our February competition…

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

Winner of the first prize is Rosemary H from the United Kingdom.

Prize Two is awesome – and a mystery no more. It is the new Freetronics LeoStick:

From the Freetronics website:

The LeoStick is just like the upcoming Arduino Leonardo, but given the “honey, I shrunk the kids” treatment!
Just pop it into your USB port (no cable required!) and upload straight from the Arduino IDE. We’ve even included on-board RGB LED lights and a speaker in this handy sized board. All the usual Arduino pins are present and each LeoStick comes with low profile header sockets for plugging in modules, shields and wires.

Winner of the second prize is Andrian from Moldova. Congratulations to the winners and thanks to everyone for entering.

For the curious, the questions and answers were:

  1. What frequency crystal would you use with the DS1307 RTC? – 32.768kHz
  2. How many LEDs are on an EtherMega board? Now I have two answers as the question should have been more specific. There are ten LEDs on the actual PCB, plus two more on the ethernet socket. So we accepted ten or twelve for the answer
  3. What are the dimensions (length x width) of an 0805 SMT component in mm? – 2.0 x 1.3 mm
  4. In what year was Ikea founded? – 1943
  5. What nationality is the Hakko company? Japanese
  6. Who came up with the name for the device known as the ‘transistor‘? - John R. Pierce
Finally, thank you for your competition entries – I really appreciate it. So in that spirit we will have another competition in March – so stay tuned using one of the methods below.

Once again, thanks to Freetronics for the EtherMega and LeoStick prizes!

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.

March 3, 2012 Posted by | arduino, competition | , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

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:

hello!

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.

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.

February 21, 2012 Posted by | arduino, clocks, ds1307, DS3232, hardware hacking, Ikea, kvart, tutorial, Uncategorized | , , , , , , , , , , , , , , , , , , , , | 13 Comments

February 2012 Competition

Update – The competition has now finished, and the winners will be announced shortly…

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 EtherMega combines 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 – and a mystery no more. It is the new Freetronics LeoStick:

From the Freetronics website:

The LeoStick is just like the upcoming Arduino Leonardo, but given the “honey, I shrunk the kids” treatment!
Just pop it into your USB port (no cable required!) and upload straight from the Arduino IDE. We’ve even included on-board RGB LED lights and a speaker in this handy sized board. All the usual Arduino pins are present and each LeoStick comes with low profile header sockets for plugging in modules, shields and wires.

Features of the LeoStick include:

  • 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

Please note: The LeoStick currently uses 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. Don’t hassle the Arduino team with support or requests related to this board: they’re solely our responsibility. 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.

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 and LeoStick prizes!

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.

February 10, 2012 Posted by | arduino, competition | , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

Results – January 2012 Competition

Hello Readers

The January 2012 competition has now closed. For the curious, the questions and answers were:

Q – What does the acronym PWM mean?
A – Pulse-width modulation

Q – How many LEDs are contained in the Freetronics DMD?
A – 512

Q – How many digital I/O pins on an Arduino Mega2560?
A – 54

Q – What type of processor core does the PIC32 (from the Uno32 review) use?
A – MIPS (or to be more precise, 32-bit MIPS M4K Core)

Congratulations to Jack M. from the interesting state of South Australia! Jack has won the following prizes:

One v1.0 Akafugu Akafuino-X board as reviewed recently:

Jack’s Akafuino-X will have a companion on its journey which will be the Mayhew Labs “Go Between” Shield, as reviewed recently:

Thanks to Akafugu for offering the Akafuino-X prize!

The February 2012 competition will be announced soon, so in the meanwhile have fun and 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.

February 4, 2012 Posted by | arduino, competition | , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

Project: Clock One

Let‘s make a huge analogue and digital clock using a dot-matrix display. 

Updated 18/03/2013

For some strange reason I have a fascination with various types of electronic clocks (which explains this article). Therefore this project will be the start of an irregular series of clock projects whose goal will be easy to follow and produce interesting results. Our “Clock One” will use a Freetronics Dot Matrix Display board as reviewed previously. Here is an example of an operating Clock One:

As you can see, on the left half of the board we have a representation of an analogue clock. Considering we only have sixteen rows of sixteen LEDs, it isn’t too bad at all. The seconds are illuminated by sixty pixels that circumnavigate the square clock throughout the minute. On the right we display the first two letters of the day of the week, and below this the date. In the example image above, the time is 6:08. We omitted the month – if you don’t know what month it is you have larger problems.

Hardware

To make this happen you will need:

  • Freetronics Dot Matrix Display board;
  • If you want the run the display at full brightness (ouch!) you will need a 5V 2.8A power supply – however our example is running without the external supply and is pretty strong
  • An Arduino board of some sort, an Uno or Eleven is a good start
  • A Maxim DS1307 real-time clock IC circuit. How to build this is explained here. If you have a Freetronics board, you can add this circuit directly onto the board!

Software

Planning the clock was quite simple. As we can only draw lines, individual pixels, and strings of text or individual characters, some planning was required in order to control the display board. A simple method is to use some graph paper and note down where you want things and the coordinates for each pixel of interest, for example:

Using the plan you can determine where you want things to go, and then the coordinates for pixels, positions of lines and so on. The operation for this clock is as follows:

  • display the day of week
  • display the date
  • draw the hour hand
  • draw the minute hand
  • then turn on each pixel representing the seconds
  • after the 59th second, turn off the pixels on the left-hand side of the display (to wipe the clock face)

There isn’t a need to wipe the right hand side of the display, as the characters have a ‘clear’ background which takes care of this when updated. At this point you can download the Arduino sketch from here. Note that the sketch was written to get the job done and ease of reading and therefore not what some people would call efficient. Some assumed knowledge is required – to catch up on the use of the display, see here; and for DS1307 real-time clock ICs, see here.

The sketch uses the popular method of reading and writing time data to the DS1307 using functions setDateDs1307 and getDateDs1307. You can initally set the time within void setup() – after uploading the sketch, comment out the setDateDs1307 line and upload the sketch again, otherwise every time the board resets or has a power outage the time will revert to the originally-set point.

Each display function is individual and uses many switch…case statements to determine which line or pixel to draw. This was done again to draw the characters on the right due to function limitations with the display library. But again it works, so I’m satisfied with it. You are always free to download and modify the code yourself.  Moving forward, here is a short video clip of the Clock One in action:

For more information about the display used, please visit the Freetronics product pageDisclaimer – The display module used in this article is a promotional consideration made available by Freetronics.

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.

February 2, 2012 Posted by | arduino, clocks, ds1307, DS3232, timing, tutorial | , , , , , , , , , , , , , , , , , , , , | 15 Comments

January 2012 Competition

Hello Readers

The competition has now ended and the winning entry will be announced shortly. Thank you to all those who entered, and of course to Akafugu for their prize this month.

It’s that time of the month again so we are running another competition. Our prize for this month consists of two items:

One v1.0 Akafugu Akafuino-X board as reviewed recently:

The winner’s Akafuino-X will have a companion on its journey which will be the Mayhew Labs “Go Between” Shield, as reviewed recently:

— *** How to Enter *** —

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

During the second week of February, all the correct entries will be collated and one randomly chosen. The first correct entry drawn will win the prize. Entries will be accepted until 03/02/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;
  • 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/02/2012 0005h GMT.
Thanks to Akafugu for offering the Akafuino-X prize!

So have fun and keep an eye out for the four competition questions spread through the January 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.

January 22, 2012 Posted by | arduino, competition | , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

Initial Review: Akafuino-X Microcontroller Board

Hello Readers

Time to get back to work for 2012 and in doing so we review another interesting product from a new company based in Japan – akafugu. From their website:

Akafugu Corporation is a small electronics company that operates out of Tokyo, Japan. We specialize in fun and easy to use electronic gadgets. Our goal is to provide products that not only make prototyping faster and easier, but are also perfect for incorporation in finalized products.

And with this in mind we examine the Akafuino-X microcontroller board:

The observant among you will notice the similarity to our usual Arduino Uno and compatible boards. However there are some differences which bring changes and improvements over the original Arduino design. The biggest point of difference is the microcontroller, the Akafuino uses an Atmel XMega32A4. The benefit of this over the normal ATmega328 is:

  • Speed! 32 MHz – twice as fast as the ATmega328;
  • Two-channel DAC (digital to analogue) converter – output analogue signals between 0V and Vcc straight from the board. A library is included with the new IDE to control them. The DAC uses digital pins seven and eight;
  • Not one, two or even four, but five UARTs;
  • Two I2C buses;
  • Sixteen PWM pins – great for LED effects…

Thankfully the designers have detailed the extra I/O pins and other useful information on the rear of the board:

Other changes include:

  • It’s a 3.3V board – so no 5V supply for you. However the inputs are tolerant to 5V;
  • On-board real time clock. You can also add an optional 32.768 kHz crystal to increase accuracy – see the space on the board near the reset pin;
  • A very refreshing red colour (note that ‘aka(i)’ ** is red in Japanese) and a happy puffer fish (‘fugu’) on the silk-screening :)
  • And libraries for other Akafugu products such as the TWI Display module are available.

Getting started is easy, however due to the difference in hardware the Arduino IDE needs modification. But don’t panic – instead of modifying your existing v1.0 Arduino IDE – download and install the Akafuino-X version from here and run your usual and the Akauino-X IDE on the same machine (it’s ok to do this). You should also review the usage instructions here and note that this is a derivative of the v1.0 IDE. Furthermore at the time of writing the software side of things is still in beta, and can be monitored via Github - however don’t let this put you off, as the Akafuino-X has a lot of potential.

If you find any bugs in use the issue tracker in Github to let the team know.

In the meanwhile we’ve conducted a quick speed test – by running the same sketch on an Arduino Uno and also the Akafuino-X. The test is a whole lot of multiplication, nothing too scientific. At the end the duration of the exercise is shown in milliseconds. Here’s the code:

// Arduino Uno test
//
void setup()
{
 Serial.begin(9600);
}
unsigned long a,b,c,d,e;
void loop()
{
 a=millis();
 for (c=1; c<1000000; c++)
 {
   d=sq(c);
 }
 b=millis();
 e=b-a;
 Serial.print("Duration: ");
 Serial.print(e);
 Serial.println("ms");
 do {} while (1>0);
}

And here are the results of running the sketch four times on each board (click image to enlarge):

Our Akafuino-X beta only took 2704ms versus the Arduino Uno taking 4212ms. Very good so far.

Update! The team at akafugu have been experimenting with overclocking the Akafuino-X. And also check out the errata page

So there you have it, another contender in the Arduino-compatible board stakes. Considering the extra  I/O, PWM and bus connectivity the Akafuino-X is a very capable board. I look forward to the evolution of the IDE and will return with the Akafuino-X in an upcoming project. And we also have one to give away. So stay tuned! In the meanwhile the Akafuino-X and other goodies are available directly from akafugu.jp

Disclaimer – The parts reviewed in this article are a promotional consideration made available by akafugu.

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.

** Yes I know it’s an i-type adjective

January 15, 2012 Posted by | arduino, product review, review | , , , , , , , , , , , , , , , , , , | 6 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 to download.

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.

May 11, 2011 Posted by | arduino, atmega328, atmel, EEPROM, hardware hacking, microcontrollers, projects, tutorial | , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

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:

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:

… and see what we have to work with:

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:

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:

But with time and patience, the wiring was attached:

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:

Example 33.1

void setup()
{
  pinMode(9, OUTPUT); // 1 off
  pinMode(8, OUTPUT); // 1 on
  pinMode(5, OUTPUT); // 2 off
  pinMode(4, OUTPUT); // 2 on
}

void loop()
{
  // outlets on channel 1 on
  digitalWrite(8, HIGH);
  delay(1000);
  digitalWrite(8, LOW);
  delay(5000);
// outlets on channel 1 off
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(5000);
  // outlets on channel 2 on
  digitalWrite(4, HIGH);
  delay(1000);
  digitalWrite(4, LOW);
  delay(5000);
// outlets on channel 2 off
  digitalWrite(5, HIGH);
  delay(1000);
  digitalWrite(5, LOW);
  delay(5000);
}

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:

Example 33.2

#include <SoftwareSerial.h> 
char inchar; 
SoftwareSerial cell(2,3);
int aon = 8;
int aoff = 9;
int bon = 4;
int boff = 5;
int pressdelay = 1000; // duration to activate a button on remote
void setup()
{
 // prepare the digital output pins
 pinMode(aon, OUTPUT);
 pinMode(aoff, OUTPUT);
 pinMode(bon, OUTPUT);
 pinMode(boff, OUTPUT);
 //Initialize GSM module serial port for communication.
 cell.begin(9600);
 delay(30000); // give time for GSM module to register on network etc.
 cell.println("AT+CMGF=1"); // set SMS mode to text
 delay(200);
 cell.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt 
 delay(200);
}
void loop() 
{
 //If a character comes in from the cellular module...
 if(cell.available() >0)
 {
 inchar=cell.read(); 
 if (inchar=='#')
 {
 delay(10);
 inchar=cell.read(); 
 if (inchar=='a')
 {
 delay(10);
 inchar=cell.read();
 if (inchar=='0')
 {
 digitalWrite(aoff, HIGH);
 delay(pressdelay);
 digitalWrite(aoff, LOW);
 } 
 else if (inchar=='1')
 {
 digitalWrite(aon, HIGH);
 delay(pressdelay);
 digitalWrite(aon, LOW);
}
 delay(10);
 inchar=cell.read(); 
 if (inchar=='b')
 {
 inchar=cell.read();
 if (inchar=='0')
 {
 digitalWrite(boff, HIGH);
 delay(pressdelay);
 digitalWrite(boff, LOW);
} 
 else if (inchar=='1')
 {
 digitalWrite(bon, HIGH);
 delay(pressdelay);
 digitalWrite(bon, LOW);
}
 delay(10);
 inchar=cell.read(); 
 cell.println("AT+CMGD=1,4"); // delete all SMS
 }
 }
 }
 }
}

 

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:

#axbx

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.

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.

April 24, 2011 Posted by | AC power, arduino, CEL-00675, CEL-09607, cellphone hacking, cellular, GSM, hardware hacking, SMS, tutorial | , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | Leave a Comment

Follow

Get every new post delivered to your Inbox.

Join 3,843 other followers

%d bloggers like this: