Posts | Comments

Planet Arduino

Archive for the ‘DS1307’ Category

Mar
17

RTCSetup – configure an RTC chip using your PC

arduino, DS1307, i2c, RTC, serial Comments Off on RTCSetup – configure an RTC chip using your PC 

rtc_3

luca @ lucadentella.it build a nice app that let you configure an RTC chip using a PC GUI and your Arduino board. The system is composed by two elements, the PC GUI written in C# and a sketch running on Arduino. The RTC is connected on the Arduino using I2C interface and Arduino is connected to PC using a simple serial protocol.

I chose to use the Adafruit’s RTClib library to talk with the DS1307 chip, that is for sure one of the most used RTC in the hobbistic world. The connection between the IC and Arduino is established using the I2C bus.

RTCSetup – configure an RTC chip using your PC - [Link]

Introduction

The subject of our latest kit review is the “Epoch Clock” from Maniacal Labs, a new organisation started by three young lads with some interesting ideas. Regular readers will know we love a clock – so when the opportunity came to review this one, we couldn’t say no.

At this point you may be thinking “what is Epoch time anyway?”. Good question! It is the number of seconds elapsed since the first of January, 1970 (UTC) – and used by Unix-based computers as the start of their time universe. (For more on the theory of Epoch time, check out Wikipedia). For example - 1379226077 Epoch time is Sun, 15 Sep 2013 06:21:17 GMT. That’s a lot of seconds. If you’re curious, you can do more calculations with the EpochTime website.

Moving forward, this clock kit will show Epoch time in full 32-bit binary glory, using a DS1307 real-time clock IC (with backup battery) and is controlled with an ATmega328P-PU – so you can modify the code easily with the Arduino IDE or WinAVR (etc).

Assembly

The creators have spent a lot of time on not only the packaging and out-of-box-experience, but also the documentation and setup guide – so as long as you’re fine with simple through-hole soldering the kit will not present any challenges. The kit arrives in a sturdy box:

binary epoch clock kit box

… with well packaged components. Everything is included for the finished product, as well as IC sockets, the RTC backup battery and a USB cable so you can power the clock from a USB hub:

binary epoch clock kit box contents

binary epoch clock kit parts contents

The PCB is a good thickness, and has a clear silk-screen and solder mask:

binary epoch clock kit PCB

binary epoch clock kit PCB bottom

Construction is simple, just follow the step-by-step instructions. Starting with the USB socket for power:

binary epoch clock kit USB socket

binary epoch clock kit USB socket bottom

… then the resistors:

binary epoch clock kit resistors

… the LEDs:

binary epoch clock kit first LEDs

… all 32 of them. Note that the LEDs don’t sit flush with the PCB, so a little effort is required to keep them aligned:

binary epoch clock kit all LEDs

 Then the rest of the components just fit as expected. I’ve also added the included header pins for an FTDI programming cable and ICSP to keep my options open:

binary epoch clock kit almost finished

Then simply fit the battery, insert the ICs and you’re done:

binary epoch clock kit finished

Using the clock

The microcontroller is pre-programmed, so you can use the clock straight away. You will however need to set the time first. To make this incredibly easy, there is a special web page that displays the current time and Epoch time, which steps you through the process of setting the time using the buttons.

Or with some code available on the kit github page and a programming cable, you can automatically sync it to the clock. Once setup, the battery will keep the current time in the RTC nicely. The clock is powered by 5V, which is easily supplied with the included USB cable, or you can always hack in your own feed.

So what does Epoch time in 32-bit binary look like? Here’s a short video of the clock in action:

Reading the time requires converting the binary number displayed with the LEDs back to a decimal number – which is of course the Epoch count of seconds since 1/1/1970. Math teachers will love this thing.

But wait, there’s more!

If you get tired of the blinking, there’s a test function which is enabled by holding down both buttons for a second, which turns the Epoch Clock into a nifty Larson Scanner:

To create your own sketches or examine the design files in more detail, it’s all on the clock github page. From a hardware perspective you have an ATmega328P-PU development board with a DS1307 battery-backed real-time clock – with 32 LEDs. So you could also create your own kind of clock or other multi-LED blinking project without too much effort. Review the EpochClockSchematic (.pdf) to examine this in more detail.

Conclusion

I really enjoyed this kit – it was easy to assemble, I learned something new and frankly the blinking LEDs can be quite soothing. The clock would make a great for a conversation-starter in the office, or would make an ideal gift for any Sheldon Cooper-types you might be associated with. Or have competitions to see who can convert the display to normal time. After shots.

Nevertheless it’s a fun and imaginative piece of kit, fully Open Hardware-compliant – and if you’ve made it this far – get some and have fun. Full-sized images are on flickr. Interested in Arduino? Check out my new book “Arduino Workshop” from No Starch Press.

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

[Note - The kit reviewed was a promotional consideration from Maniacal Labs]

The post Kit Review – Maniacal Labs Epoch Clock appeared first on tronixstuff.

Jul
31

Various 1 Hz Oscillator Methods

1 hz, 555, 74hc14, astable, clock, clocks, digital, DS1307, DS3232, em406a, gps, logic, pps, timebase, tronixstuff, TTL, tutorial Comments Off on Various 1 Hz Oscillator Methods 

Introduction

During the fun and enjoyment of experimenting with electronics there will come a time when you need a nice 1 Hz oscillator to generate a square-wave signal to drive something in the circuit. On… off… on… off… for all sorts of things. Perhaps a metronome, to drive a TTL clock, blink some LEDs, or for more nefarious purposes. No matter what you need that magic 1 Hz for – there’s a variety of methods to generate it – some more expensive than others – and some more accurate than others.

A few of you may be thinking “pull out the Arduino” and yes, you could knock out a reasonable 1 Hz – however that’s fine for the bench, but wild overkill for embedding a project as a single purpose. So in this article we’ll run through three oscillator methods that can generate a 1 Hz signal (and other frequencies) using methods that vary in cost, accuracy and difficulty – and don’t rely on mains AC. That will be a topic for another day.

Using a 555 timer IC

You can solve this problem quite well for under a dollar with the 555, however the accuracy is going to heavily rely on having the correct values for the passive components. We’ll use the 555 in astable mode, and from a previous article here’s the circuit:

555 astable 1 Hz circuit

 And with a 5V power supply, here’s the result:

555-1

As you can see the cycle time isn’t the best, which can be attributed to the tolerance of the resistors and capacitor C1. A method to increase the accuracy would be to add small trimpots in series with the resistors (and reduce their value accordingly by the trimpot value) – then measure the output with a frequency counter (etc). whilst adjusting the trimpots. If you’re curious about not using C2, the result of doing so introduces some noise on the rising edge, for example:

555-2noise

So if you’ve no other option, or have the right values for the passives – the 555 can do the job. Or get yourself a 555 and experiment with it, there’s lots of fun to be had with it.

Using a GPS receiver module

A variety of GPS modules have a one pulse per second output (PPS) and this includes my well-worn EM406A module (as used in the Arduino tutorials):

EM406AGPS

With a little work you can turn that PPS output into a usable and incredibly accurate source of 1 Hz. As long as your GPS can receive a signal. In fact, this has been demonstrated in the April 2013 edition of Silicon Chip magazine, in their frequency counter timebase project. But I digress.

If you have an EM406A you most likely have the cable and if not, get one to save your sanity as the connector is quite non-standard. If you’re experimenting a breakout board will also be quite convenient, however you can make your own by just chopping off one end of the cable and soldering the required pins – for example:

EM406Abreakout

You will need access to pins 6, 5, 2 and 1. Looking at the socket on the GPS module, they are numbered 6 to 1 from left to right. Pin 6 is the PPS output, 5 is GND, 2 is for 5V and 1 is GND. Both the GNDs need to be connected together.

Before moving forward you’re probably curious about the pulse, and want to see it. Good idea! However the PPS signal is incredibly quick and has an amplitude of about 2.85 V. If you put a DSO on the PPS and GND output, you can see the pulses as shown below:

GPS-raw-PPS

 To find the length of the pulse, we had to really zoom in to a 2 uS timebase:

GPS-PPS-zoom

 Wow, that’s small. So a little external circuitry is required to convert that minuscule pulse into something more useful and friendly. We’ll increase the pulse length by using a “pulse stretcher”. To do this we make a monostable timer (“one shot”) with a 555. For around a half-second pulse we’ll use 47k0 for R1 and 10uF for C1. However this triggers on a low signal, so we first pass the PPS signal through a 74HC14 Schmitt inverter – a handy part which turns irregular signals into more sharply defined ones – and also inverts it which can then be used to trigger the monostable. Our circuit:

GPSPPS_schem

 and here’s the result – the PPS signal is shown with the matching “stretched” signal on the DSO:

GPS-1-Hz1

So if you’re a stickley for accuracy, or just want something different for portable or battery-powered applications, using the GPS is a relatively simple solution.

Using a Maxim DS1307/DS3232 real-time clock IC

Those of you with a microcontroller bent may have a Maxim DS1307 or DS3232. Apart from being pretty easy to use as a real-time clock, both of them have a programmable square wave output. Connection via your MCU’s I2C bus is quite easy, for example with the DS1307:

squarewave_schem

Using a DS3232 is equally as simple. We use a pre-built module with a similar schematic. Once you have either of them connected, the code is quite simple. For the DS1307 (bus address 0×68), write 0×07 then 0×11 to the I2C bus – or for the DS3232 (bus address is also 0×68) write 0x0E then 0×00. Finally, let’s see the 1 Hz on the DSO:

ds32321hz

Certainly not the cheapest method, however it gives you an excellent level of accuracy without the GPS.

Conclusion

By no means is this list exhaustive, however hopefully it was interesting and useful. If there’s any other methods you’d like to see demonstrated, leave a comment below and we’ll see what’s possible. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

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.

The post Various 1 Hz Oscillator Methods appeared first on tronixstuff.

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.

04/07/2013 – (my fellow) Australians – currently the easiest way of getting a print version is from Little Bird Electronics.

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.


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.

The post Book – “Arduino Workshop – A Hands-On Introduction with 65 Projects” appeared first on tronixstuff.

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.


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. Please use IDE 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.

The post Project: Clock Four – Scrolling text clock appeared first on tronixstuff.

Jun
05

Introduction

Finally another kit review! Thanks to akafugu in Japan (the people who brought us the Akafuino-X) we have a new clock kit to assemble – the Simpleclock. But first, what is it?

A clock – yes. You can never have too many clocks. Also, a digital thermometer and an alarm clock. It is based on the Atmel ATmega328 and Arduino IDE, with open-source firmware. The real-time clock uses the DS1307 circuit with battery backup that we know and love. This means you can completely modify the clock or concoct a completely different use for your Simpleclock. Countdown timer? There’s an idea…

Furthemore, the display module is their individual I2C-interface TWI Display. Therefore you have a clock as well as some Arduino-based hardware to experiment with later on. However, let’s assemble it first.

Assembly

Putting it all together was quite straight-forward. You can follow the detailed instructions at the akafugu site. All the parts required to make a functional clock as advertised are included with the kit:

Here are the brains of the operation – the pre-programmed microcontroller and the DS1307 real-time clock IC: 

You do receive an IC socket for the MCU, but not for the RTC – however this shouldn’t be an issue – just double-check your soldering and have some confidence. The PCBs are nicely laid out with solder-masking and a clear silk-screen:

The PCB on the left in the images above is for the display module – it runs an ATtiny microcontroller than can be worked with separately. Moving forward, you start with the lowest-profile components including the resistors and capacitors:

Take note of the vice – these are great, and light years ahead of the “helping hands” things you see around the traps. This was a Stanley model from element14. The resistors sit in nicely:

The next step is to put a blob of solder on the solder pad which will be beneath the backup battery holder – this forces contact between the negative side of the coin cell battery and the PCB:

Everything else went smoothly – I did have a small worry about the pin spacing for the USB power socket, however a clean tip and a steady hand solved that problem:

The rest of the clock board is much easier – just follow the instructions, take your time and relax. Soon enough you’ll be finished:

However I did have one “oops” moment – I left the PTC in too tall, so it needed to be bent over a little to give way for the display module when inserted:

The next task is to solder the four digit display to the display PCB – nothing new here:

Which leaves you with the standalone display module:

Using the Simpleclock

The firmware for clock use as described in the product page is already loaded in the MCU, so you can use it without needing and programming time or effort. It is powered via a mini-USB cable which you will need to acquire yourself. Frankly the design should have a DC socket and regulator – perhaps for the second revision :)  With second thought, it’s better running from USB. When I turn on the computer in the morning the Simpleclock beeps and ‘wakes up’. The menu system is simple and setting the time and alarm is deceptively so. Some thought has been put into the user interface so once assembled, you could always give the clock away as a gift without fear of being asked for help. However mine is staying on top of the monitor for the office PC:

And here it is in action on the bench:

If you get the urge to modify and update the code, it is easily done. As the Simpleclock kit is open source, all the data required is available from Akafugu’s github page. Please read the notes and other documentation before updating your clock. The easiest way to physically upload the new code will be with a 5V FTDI to USB adaptor or cable.

Conclusion

The Simpleclock was easy to assemble and works very well. It would make a fun kit for those learning to solder, as they have something that once completed is a reminder of their success and useful in daily life. Apart from using USB for power instead of a DC socket – it’s a great kit and I would recommend it to anyone interested in clocks, enjoys kit assembly, or as a gift to a young one to introduce them to electronics and microcontrollers.

Note – the Simpleclock kit was a promotional consideration from akafugu.jp, however the opinions stated are purely my own.

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.

The post Kit Review – akafugu Simpleclock appeared first on tronixstuff.

In this article we examine another style of vintage display technology – the incandescent seven-segment digital display. We are using the FFD51 by the IEE company (data sheet.pdf) – dating back to the early 1970s. Here is a close-up of our example:

You can see the filaments for each of the segments, as well as the small coiled ‘decimal point’ filament at the top-right of the image above.  This model has pins in a typical DIP format, making use in a solderless breadboard or integration into a PCB very simple:

It operates in a similar manner to a normal light bulb – the filaments are in a vacuum, and when a current is applied the filament glows nicely. The benefit of using such as display is their brightness – they could be read in direct sunlight, as well as looking good inside.  At five volts each segment draws around 30mA. For demonstration purposes I have been running them at a lower voltage (3.5~4V), as they are old and I don’t want to accidentally burn out any of the elements.

Using these with an Arduino is very easy as they segments can be driven from a 74HC595 shift register using logic from Arduino digital out pins. (If you are unfamiliar with doing so, please read chapters four and five of my tutorial series). For my first round of experimenting, a solderless breadboard was used, along with the usual Freetronics board and some shift register modules:

Although the modules are larger than a DIP 74HC595, I like to use these instead. Once you solder in the header pins they are easier to insert and remove from breadboards, have the pinouts labelled clearly, are almost impossible to physically damage, have a 100nF capacitor for smoothing and a nice blue LED indicating power is applied.

Moving forward – using four shift register modules and displays, a simple four-digit circuit can be created. Note from the datasheet that all the common pins need to be connected together to GND. Otherwise you can just connect the outputs from the shift register (Q0~Q7) directly to the display’s a~dp pins.

Some of you may be thinking “Oh at 30mA a pin, you’re exceeding the limits of the 74HC595!”… well yes, we are. However after several hours they still worked fine and without any heat build-up. However if you displayed all eight segments continuously there may be some issues. So take care. As mentioned earlier we ran the displays at a lower voltage (3.5~4V) and they still displayed nicely. Furthermore at the lower voltage the entire circuit including the Arduino-compatible board used less than 730mA with all segments on –  for example:

 For the non-believers, here is the circuit in action:

Here is the Arduino sketch for the demonstration above:

Now for the prototype of something more useful – another clock. :) Time to once again pull out my Arduino-compatible board with onboard DS1307 real-time clock. For more information on the RTC IC and getting time data with an Arduino please visit chapter twenty of my tutorials. For this example we will use the first two digits for the hours, and the last two digits for minutes. The display will then rotate to showing the numerical day and month of the year – then repeat.

Operation is simple – just get the time from the DS1307, then place the four digits in an array. The elements of the array are then sent in reverse order to the shift registers. The procedure is repeated for the date. Anyhow, here is the sketch:

#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
// note the digital pins of the arduino that are connected to the nixie driver
int clockPin = 7;
int latchPin = 8;
int dataPin = 9;
int clockArray[5]; // holds the digits to display
int a=0;
// the bits represent segments a~dp from left to right
// if you add one to the number (or turn on the last bit) the decimal point turns on
byte numbers[]={
 B11111100, // digit zero
 B01100000,
 B11011010,
 B11110010,
 B01100110,
 B10110110,
 B10111110,
 B11100000,
 B11111110,
 B11110110}; // digit nine
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
 return ( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
 return ( (val/16*10) + (val%16) );
}
void setDateDs1307(byte second, // 0-59
byte minute, // 0-59
byte hour, // 1-23
byte dayOfWeek, // 1-7
byte dayOfMonth, // 1-28/29/30/31
byte month, // 1-12
byte year) // 0-99
{
 Wire.beginTransmission(DS1307_I2C_ADDRESS);
 Wire.send(0);
 Wire.send(decToBcd(second)); // 0 to bit 7 starts the clock
 Wire.send(decToBcd(minute));
 Wire.send(decToBcd(hour)); 
 Wire.send(decToBcd(dayOfWeek));
 Wire.send(decToBcd(dayOfMonth));
 Wire.send(decToBcd(month));
 Wire.send(decToBcd(year));
 Wire.send(0x10); // sends 0x10 (hex) 00010000 (binary) to control register - turns on square wave
 Wire.endTransmission();
}
// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
 // Reset the register pointer
 Wire.beginTransmission(DS1307_I2C_ADDRESS);
 Wire.send(0);
 Wire.endTransmission();
 Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
 // A few of these need masks because certain bits are control bits
 *second = bcdToDec(Wire.receive() & 0x7f);
 *minute = bcdToDec(Wire.receive());
 *hour = bcdToDec(Wire.receive() & 0x3f); // Need to change this if 12 hour am/pm
 *dayOfWeek = bcdToDec(Wire.receive());
 *dayOfMonth = bcdToDec(Wire.receive());
 *month = bcdToDec(Wire.receive());
 *year = bcdToDec(Wire.receive());
}
void setup()
{
 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 pinMode(latchPin, OUTPUT);
 pinMode(clockPin, OUTPUT);
 pinMode(dataPin, OUTPUT);
 Wire.begin();
// Change these values to what you want to set your clock to.
 // You probably only want to set your clock once and then remove
 // the setDateDs1307 call.
second = 00;
 minute = 35;
 hour = 17;
 dayOfWeek = 5;
 dayOfMonth = 29;
 month = 4;
 year = 12;
 // setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
}
void showTime()
{
 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

 if (hour<10)
 {
 clockArray[1]=0;
 clockArray[2]=hour;
 }
 if (hour>9)
 {
 clockArray[1]=int(hour/10);
 clockArray[2]=hour%10;
 } 
 if (minute<10)
 {
 clockArray[3]=0;
 clockArray[4]=minute;
 }
 if (minute>9)
 {
 clockArray[3]=int(minute/10);
 clockArray[4]=minute%10;
 }
 displayArray();
}
void showDate()
{
 byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
 getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

 if (dayOfMonth<10)
 {
 clockArray[1]=0;
 clockArray[2]=dayOfMonth;
 }
 if (dayOfMonth>10)
 {
 clockArray[1]=int(dayOfMonth/10);
 clockArray[2]=dayOfMonth%10;
 }
 if (month<10)
 {
 clockArray[3]=0;
 clockArray[4]=month;
 }
 if (month>10)
 {
 clockArray[3]=int(month/10);
 clockArray[4]=month%10;
 }
 displayArray();
}
void displayArray()
// sends the data from clockArray[] to the shift registers
{
 digitalWrite(latchPin, LOW);
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[clockArray[4]]); // digit 4 
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[clockArray[3]]); // digit 3 
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[clockArray[2]]+1); // digit 2 and decimal point
 shiftOut(dataPin, clockPin, LSBFIRST, numbers[clockArray[1]]); // digit 1
 digitalWrite(latchPin, HIGH);
}
void loop()
{
 showTime(); // display the time 
 delay(5000);
 showDate(); // display the date (day and month) for two seconds
 delay(2000);
}

and the clock in action:

So there you have it – another older style of technology dragged into the 21st century. If you enjoyed this article you may also like to read about vintage HP LED displays. Once again, I hope you found this article of interest. Thanks to the Vintage Technology Association website for background information.

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.

The post Arduino and FFD51 Incandescent Displays appeared first on tronixstuff.

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.

The post Project: Clock Three – A pillow clock appeared first on tronixstuff.



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook