Tag Archive | "wave"

Rapid stripboard prototyping made easy with Lochmaster


As a beginner in the world of electronics, sooner or later you’ll want to make a more permanent project than what can be constructed on the solderless breadboard. It’s easy to say “make your own PCBs” – however this can introduce a steep learning curve, not to mention the cost and time involved in waiting for PCBs to arrive – and hoping they’re correct. Thus for many people a happy medium is transferring prototype circuits over to stripboard – it’s really cheap (check ebay), you can keep various sizes on hand, and it’s quick.

However planning more complex circuits can be difficult – so it would be much easier with the use of a software design tool. Which brings us to the subject of our review – the Lochmaster v4.0 software from Abacom. It’s an incredibly easy to use developer’s tool for strip board projects. No more loose pieces of graph paper, soldering parts “one row too far over”, or lost design plans – you can now design stripboard projects efficiently and with ease.


Available for all versions of Windows from XP to 8, Lochmaster is less than ten megabytes and is distributed electronically after purchase – so backup your installation file when received. Otherwise it’s a quick install, you don’t need any extra framework software and due to the size will run well on less-specified machines. Although we have screen shots in the review below, you can download a trial version – so it won’t cost you anything to check it out yourself.

Designing your circuits

Once installed, opening Lochmaster for the first time you’re presented with a blank example of stripboard ready for your components:


However you can also use different types of prototyping board, such as varieties with all holes, edge connectors, mounting holes, different copper directions – or even make your own board to match a preferred style. Boar dimensions can be displayed in measurement units as well as “holes”. Then it’s a simple matter of selecting a part library from the drop-down list on the left of the window. For example, to add a 555 timer (which is an 8-pin DIL part) select the “ICs” library, click on the 8-pin enclosure and the following window appears, prompting you to fill out the appropriate details such as label, type etc:

Lochmaster 555

… then you can drop the 555 on the board. It then becomes an object which can be dragged around and placed where you need it. You can also create and modify the component libraries, and also create your own custom parts.

At that point, you might want to cut the tracks on the other side of the board. By clicking the “turn around” button the menu bar, you’re presented with the bottom of the board. Using the “add/split” button on the vertical toolbar between the library and the board, you can then virtually cut the tracks, for example:


You can also see the rounded circles which represent solder joints. After a few minutes we found dragging and dropping components onto the board very simple, and with the turn-around button you can easily flip sides until the placement looks good. After placing components, running the necessary links or wires is simple with the “draw jumper wire” tool. They can run in any direction, and also have corners, for example:

Lochmaster wires

You can also adjust the colours and thickness of the wires,  and of course can also be placed on the other side of the board – just flip it around and place the wires. After wiring things up and getting to the stage when you’re ready to build – you can test the connections to ensure you haven’t mis-counted holes or tracks. Using the “Test mode” tool you can click on tracks and the sections that are electrically connected to the point with the cursor are all highlighted – for example if you click on the point marked by the black arrow below, the connected tracks are highlighted:

lochmaster test

If you don’t like the 3D-rendered components, you can also work with normal 2D in colour or black and white:

lochmaster 2D

For final quality-control, you can also review the project at any time with “X-ray” view, which shows an outline of the parts on the other side, for example when looking at the bottom of the board, turning on X-ray results with:

Lochmaster xray

You can also generate component lists, which are great for documentation or simply making up a shopping list. It can be exported to .xls or text file, for example:

lochmaster list

And then you can export your project as an image (.jpg or .bmp), HPGL machine file – and print out both sides to serve as an assembly guide. There is also standalone file-viewer software, so you can share your designs with others who haven’t got the full Lochmaster software installed.

Example project

After experimenting with Lochmaster for a short while, we decided to test using it with a real project that a beginner might assemble. For example, a square wave oscillator from an old Talking Electronics magazine (click image for larger version):

square wave oscillator

Nothing too complex, but a useful tool for anyone experimenting with electronics. It’s a 555 astable with six different RC values which allows you to select from 1, 10, 100, 1 k, 10 k and 100 kHz outputs. The first step is to gather all the components together, so you know the widths and number of holes each needs on the stripboard:


The next step is to measure the board, as you can enter the dimensions via Board>Edit board layout… into Lochmaster to avoid having excess space in the design plan. Then after consulting the schematic and the single-layer PCB layout from the magazine, it’s a simple matter of placing the parts onto the virtual board after checking how the fit in on the real thing:

osciillator top

… and the flip-side:

oscillator bottom

Not a work of art – but it works.  (We didn’t fit the 100 kHz setting, as the capacitor wasn’t in stock). And that’s the neat thing – you can experiment with placement until you’re happy, then double-check connections before soldering. You might find even after some planning, that you may deviate from the plan. Fair enough, but just double-check what you’re doing. And a short while later, the results, top and bottom:

oscillator PCB top

oscillator PCB bottom


If you’re a beginner and don’t have the time, money and patience to design your own PCBs – Lochmaster is ideal. It’s a neater way to visualise physical circuits, as well as filing and sharing them with others.   To order your own copy, get the trial version, or if you have any questions please contact Abacom. Full-sized images of the screen-shots can be found on flickr. And if you made it this far – check out my new book “Arduino Workshop” from No Starch Press.

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

[Note – Lochmaster software license was a promotional consideration from Abacom]

Posted in lochmaster, software review, stripboard, tronixstuff, tutorial, veroboardComments (1)

Kit Review – JYE Tech FG085 DDS Function Generator


There has been a lot of talk lately about inexpensive DDS (direct digital synthesis) function generators, and I always enjoy a kit – so it was time to check out the subject of this review. It’s the “FG085 miniDDS function generator” from JYE Tech. JYE is a small company in China that makes inexpensive test equipment kits, for example their capacitance meter (my first kit review!) and DSO. The capacitance meter was good, the DSO not so good – so let’s hope this is better than their last efforts.


The instructions (AssemblyGuide_085G) are much better than previous efforts, and if you have bought the kit – read them. The kit arrives in a large zip-lock bag, with the following bundle of parts:

The AC adaptor is 100~240V in, 15V DC out. Everything is included with the kit including a short BNC to alligator clips lead for output. The PCBs are very good, with a nice solder mask and silk screen:

and back:

At this point we realise that most of the work is already done. There’s two microcontrollers ATmega48 and ATmega168- one for display and user-interface control, and the other for function generation. It takes only a few minutes to solder in the through-hole parts, headers and sockets:

… then you flip over the PCB and add the LCD:

… followed by the buttons and rotary encoder. From previous research this is the part that causes people a lot of trouble – so read carefully. There’s a lot of buttons – and if they aren’t inserted into the PCB correctly your life will become very difficult. The buttons must be inserted a certain way – they’re “polarised” – for example:

As you can see above, one side has a double-vertical line and the other side has a single. When you fit the buttons to the PCB – the side with the double-vertical must face the left-hand side of the PCB – the side with the DC socket. For example:

Furthermore, don’t be in a rush and put all the buttons in then try to solder them all at once.  Do them one at a time, and hold them tight to the PCB with some blu-tac or similar. If they don’t sit flush with the PCB the front panel won’t fit properly and the buttons will stick when in use. So exercise some patience, and you’ll be rewarded with an easy to use function generator. Rush them in and you’ll be very unhappy. I warned you! After fitting each button, test fit the front panel to check the alignment, for example:

Then you end up with nicely-aligned buttons:

… which all operate smoothly when the panel is fitted:

After the buttons comes the rotary encoder. Be very careful when fitting it to the PCB – the data legs are really weak, and bend without much effort. If you push in the encoder, be mindful of the legs not going through the holes and bending upwards. Furthermore, when soldering in the encoder note that you’re really close to an electrolytic – you don’t want to stab it with a hot iron:

The CP2012 chip in the image above is for the USB interface. More on that later. Now the next stage is the power-test. Connect DC power and turn it on – you should be greeted by a short copyright message followed by the operation display:

If you didn’t – remove the power and check your soldering –  including the capacitor polarities and look for bridges, especially around the USB socket. Now it’s time to fit the output BNC socket. For some reason only known to the designers, they have this poking out the front of the panel for the kit – however previous revisions have used a simple side-entry socket. Thus you need to do some modifications to the supplied socket. First, chop the tag from the sprocket washer:

… then remove the paper from the front panel:

Now solder a link to the washer in a vertical position:

… then fit the BNC socket to the panel, with the washer aligned as such:

Finally, align the top panel with the PCB so the BNC socket pin and washer link drop into the PCB and solder them in:

If you want to use the servo mode, solder three short wires that can attach to a servo form the three “output” pads between the BNC and USB socket.

Finally, screw in the panels and you’re finished!

Using the function generator

Operation is quite simple, and your first reference should be the manual (manual.pdf). The display defaults to normal function generator mode at power-up – where you can adjust the frequency, offset, amplitude and type of output – sine, square, triangle, ramp up, ramp down, staircase up and down:

The ranges for all functions is 0~10 khz, except for sine which can hit 200 kHz. You can enter higher frequencies, such as up to 250 kHz for sine – but the results aren’t so good.

Instead of filling this review with lots of screen dumps from an oscilloscope to demonstrate the output – I’ve made the following video where you can see various functions being displayed on a DSO:

You can also create signals to test servos, with adjustable pulse-width, amplitude and cycle times. However you’ll need to solder three wires onto the PCB (next to the BNC socket area) to attach to the servo.

According to the user manual and various retailers’ websites – the FG085 can generate frequency sweeping signals. These are signals that sweep from a start to as finish frequency over a period of time. However the firmware on the supplied unit is old and needs updating to enable this function. You can download the firmware in .hex file format from here. Then go and dig up an AVR programmer and avrdudeAt the time of writing we had some issues with the signature not being recognised when updating the firmware, and solidly bricked the FG085. Our fault – so when that’s sorted out we’ll update the review – stay tuned.

There is also a USB port on the side – after installing CP2102 drivers in Windows we could connect at 115200 bps with terminal, however all the FG085 returned was the firmware version number. Perhaps later on the designers will update the firmware to allow for PC control. Somehow I wouldn’t bank on it.

Oh – if you’re wondering what DDS is – click here!


It’s an interesting piece of equipment. Putting the firmware upgrade issues to one side, the FG085 does what it sets out to do. During testing it worked well, and we didn’t come across any obvious inaccuracies during use.  The price varies between US$43 and $50 – so for that money it’s  a good kit. Just take care during construction and you’ll be fine.

The function generator is available in kit form or assembled, with or without panels from China. The kit version with panels is also available from Sparkfun (KIT-11394) and their resellers. Full-sized images available on flickr. This kit was purchased and reviewed without notifying the supplier.

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 dds, ds2102, FG085, function generator, jyetech, kit review, KIT-11394, learning electronics, rigol, test equipmentComments (7)

Various 555 Timer circuits

Hello readers

The purpose of this article is to follow on from our explanation of the 555 timer IC by demonstrating some simple yet interesting, noisy and plain annoying uses of the 555. They are by no means that complex, and intended to help move theory into practice.

Button de-bouncer

De-bouncer? How does one bounce a button in the first place? Many years ago I bounced a button on the arcade Sonic the Hedgehog – hit it so hard it popped out and bounced over the table… But seriously, when working with digital logic circuits, you may need to use  a momentary button to accept user input. For example, to pulse a trigger or so on. However with some buttons, they are not all that they seem to be. You press them once, but they can register multiple contacts – i.e. register two or more ‘presses’ for what seems like only one press. This could possibly cause trouble, so we can use a 555 timer monostable circuit to solver the problem. In our de-bounce example, when the button is pressed, the output is kept at high for around half a second. Here is the schematic:


What we have is a basic monostable timer circuit. For my example the output delay (t) is to be half a second. The formula for t is: t=1.1xR1xC1. The closest resistor I had at hand was 2k ohms, so to find the required value for C1, the formula is rearranged into: C1=t/(1.1xR1). Substituting the values for t and R1 gives a value of C1 as 227.274 uF. So for C1 we have used a 220 uF capacitor.

Now for a visual demonstration of the de-bouncer at work. In the following video clip, the oscilloscope is displaying the button level on the lower channel, and the output level on the upper channel. The button level when open is high, as the 555 requires a low pulse to activate. The output level is normally low. You can see when the button is pressed that the button level momentarily drops to low, and then the output level goes high for around half a second:

Make some noise

As we know the 555 can oscillate at frequencies from less than 1Hz to around 500 kHz. The human ear can theoretically hear sounds between (approximately) 20 and 20 kHz. So if we create an astable timing circuit with an output frequency that falls within the range of the human ear, and connect that output to a small speaker – a range of tones can be emitted.

The circuit required is a standard 555 astable, with the output signal heading through a small 8 ohm 0.25 watt speaker and a 4.7 uF electrolytic capacitor to ground. The capacitor stops any DC current flowing to ground, without this we will overload the current-handling ability of the 555. (I couldn’t help myself by trying it without the capacitor – pulled 550 mA from the 555 before it stopped working…). To choose the values of R1 and C1 to emit out required frequency, the following formula is used: f (frequency) = 1.4 / {(R1 + [2 x R2]) x C1}. To cover the range required, a 100k ohm trimpot was used for R1. Here is the resulting schematic:


The input voltage can fall within the specification of the 555, however for optimum results a supply of between 5 and 9 volts DC should be used. In the following demonstration, we used a 9V supply. The purpose of the video is to learn the relationship between the tones and their frequencies. You can see the frequency on my old counter and hopefully hear the result:

Our next example is to create a  siren effect, using two 555 circuits – one for a low frequency and one for a high frequency. To determine the value for R1 for the low and high frequency, I used the previous circuit and chose two tones that were quite different, and measured the resistance of the trimpot (R1) at those frequencies. My R1 value for the ‘low’ tone is 82k ohm and 36k ohm for the ‘high’ frequency.

The switching between low and high frequency will be handled by a 4047 multivibrator – the Q and Q outputs will control NPN transistors. The transistors are used as switches to allow current to flow from the supply to the 555 high or low tone circuit. We use this method as the 4047 is not able to source enough current to drive the 555 circuits. Here is the schematic:


Don’t forget to connect pin 14 of the 4047 to supply voltage. This circuit has been tested with a supply voltage between 5 and 12 volts. As the supply voltage increases, so does the amplitude of the square wave emanating from the 555 output pins, which in turn in creases the volume of the siren. At 5 volts, the entire circuit drew only 20 milliamps. Speaking of which, you can listen to a recording of the output here. If you wish to alter the time for each tone, adjust the value of what is the 47k ohm resistor on pins 2 and 3 of the 4047.

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 4047, 555, arduino, COM-09273, education, learning electronics, lesson, tutorialComments (0)

Review – CD4047 Astable/Monostable Multivibrator

Hello readers!

Today we are going to examine an older but still highly useful integrated circuit – the 4047 Astable/Monostable multivibrator:


My reason for doing this is to demonstrate another way to create a square-wave output for digital circuits (astable mode) and also generate single pulses (monostable mode). Sometimes one can get carried away with using a microcontroller by default – and forget that there often can be simpler and much cheaper ways of doing things. And finally, the two can often work together to solve a problem.

What is a multivibrator? In electronics terms this means more than one vibrator. It creates an electrical signal that changes state on a regular basis (astable) or on demand (monostable). You may recall creating monostable and astable timers using the 555 timer described in an earlier article. One of the benefits of the 4047 is being able to do so as well, but with fewer external components. Here is the pinout diagram for a 4047 (from the Fairchild data sheet):

Note that there are three outputs, Q, Q and OSC out. Q is the normal output, Q is the inverse of Q – that is if Q is high, Q is low – at the same frequency. OSC output provides a signal that is very close to twice the frequency of Q. We will consider the other pins as we go along. In the following small video, we have LEDs connected to all three outputs – you can see how Q and Q alternate, and the increased frequency of OSC out:

That was an example of the astable mode.  The circuit used is shown below. The only drawback of using a 4047 is that you cannot alter the duty cycle of your astable output – it will always be 50% high and 50% low. The oscillator output is not guaranteed to have a 50% duty cycle, but comes close. The time period (and therefore the frequency) is determined by two components – R1 and the capacitor:

[Quick update – in the schematic below, also connect 4047 pin 14 to +5V]


The values for R2~R4 are 560 ohms, for the LEDs. R1 and the capacitor form an RC circuit, which controls the oscillation frequency. How can we calculate the frequency? The data sheet tells us that time (period of time the oscillator is ‘high’) is equal to 4.4 multiplied by the value of R1 and the capacitor. As the duty cycle is always 50%, we double this value, then divide the result into one. In other words:

And as the frequency from the OSC out pin is twice that of Q or Q, the formula for the OSC out frequency is:

However the most useful formula would allow you to work with the values of R and C to use for a desired frequency f:

When calculating your values, remember that you need to work with whole units, such as Farads and Ohms- not microfarads, mega-ohms, etc. This chart of SI prefixes may be useful for conversions.

The only thing to take note of is the tolerance of your resistor and capacitor. If you require a certain, exact frequency try to use some low-tolerance capacitors, or replace the resistor with a trimpot of a value just over your required resistor value. Then you can make adjustments and measure the result with a frequency counter. For example, when using a value of 0.1uF for C and 15 k ohm for R, the theoretical frequency is 151.51 Hz; however in practice this resulted with a frequency of 144.78 Hz.

Don’t forget that the duty cycle is not guaranteed to be 50% from the OSC out pin. This is shown in the following demonstration video. We measure the frequency from all three output pins, then measure the duty cycle from the same pins:

(The auto-ranging on that multimeter is somewhat annoying).

Now for some more more explanation about the 4047. You can activate the oscillations in two ways, via a high signal into pin 5 (pin 4 must then be low) or via a low signal into pin 4 (and pin 5 must be low). Setting pin 9 high will reset the oscillator, so Q is low and Q is high.

The monostable mode is also simple to create and activate. I have not made a video clip of monstable operation, as this would only comprise of staring at an LED. However, here is an example circuit with two buttons added, one to trigger the pulse (or start it), and another to reset the timer (cancel any pulse and start again):

[Quick update – in the schematic below, also connect 4047 pin 14 to +5V]


The following formula is used to calculate the duration of the pulse time:

Where time is in seconds, R is Ohms, and C is Farads. Once again, the OSC output pin also has a modified output – it’s time period will be 1.2RC.

To conclude, the 4047 offers a simple and cheap way to generate a 50% duty cycle  square wave or use as a monostable timer. The cost is low and the part is easy to source. As always, avoid the risk of counterfeit ICs and get yours from a reputable distributor. Living in Australia, mine came from element-14. Thanks to Fairchild Semiconductor for product information from their 4047 data sheet.

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 4047, education, learning electronics, lesson, part review, tutorialComments (41)

Kit Review – adafruit industries waveshield kit

Hello readers

Today we are going introduce another useful kit from adafruit industries – their waveshild Arduino shield kit. The purpose of this shield is to play audio files sourced from a computer, at the request of an Arduino sketch. It is an interesting product in that it meets one of the needs of the original concept of Arduino, that is:

… It’s intended for artists, designers, hobbyists, and anyone interested in creating interactive objects or environments. (arduino.cc)

Yes – yes indeed. For a while I had seen this kit, and though that there wasn’t much point to it. But if you spend a few moments contemplating how the control of sounds or recorded voice could be used, suddenly you have a “light bulb moment” and come up with all sorts of things, both crazy and sensible.  Once again, this kit arrives in typical adafruit packaging, a simple reusable antistatic bag:


and emptying the contents onto the desk reveals the following:


And before anyone asks me, no the parts don’t arrange themselves as they fall out of the bag. If they did, we’d have some much larger problems in the world. At first glance I was worried that not all of the parts had been included, however this is kit version 1.1, and there will be empty spaces on the PCB. Speaking of which, once again it is a nice thick, solder-masked and nicely silk screened PCB.

The pre-assembly checklist, assembly instructions and all other documentation and required software links can be found on the adafruit website. After checking off the included parts against the adafruit bill of materials, it was time to start. You will need a few extra things, for example a speaker if necessary, an SD memory card (up to one gigabyte in size) – and in my case two 8-pin IC sockets. When you live in an area where finding specialised ICs is difficult or just time-consuming, IC sockets are very cheap insurance.

The first item to solder in is the SD card, and this is a surface-mount part. But don’t let that worry you, it ‘clicks’ into the PCB, and you then just hold it down with one hand while holding some solder, and with the other hand heat each pad for two seconds and let some solder flow over the pads:


And you don’t need to solder in the last three, narrower contacts of the reader – they are not used. Everything else is standard through hole, nothing much to worry about apart from burning yourself while listening to the radio. Except for one resistor, R6 – the one next to IC4. If you solder in the resistor first, even though it sits normally – it is about one millimetre too close to the IC. So if you are going to assemble this, solder in IC4 before R6:


However it isn’t anything to panic about, just something to keep an eye out for. Moving forward, everything else went in easily:


The last basic soldering to take care of is the expansion pins for the shield to able to mate with other shields. The easiest way to solder these in is to first drop the new pins into an existing, matching board – as such:


Then drop the waveshield on top of the pins and solder away:


And finally, some links from the circuit to the digital pins… Then lo and behold, we’re finished:


During the initial testing and experimenting, I was going to use a set of earphones to listen to the output, however instead ended up installing a small 0.25 watt 8 ohm speaker. The solder pads for the speaker are between the rear of the headphone socket and C9. If you decide to use both headphones and a speaker, the circuit is designed in such a way as the headphone socket will cut off the speaker when headphones are in use. adafruit also sell the waveshield party pack which includes a memory card and speaker to save you shopping around.

Note that this shield will need digital pins 2~5 and 10~13 – as noted in Jon Oxer’s new website – shieldlist.org.

Now that the hardware has been taken care of, let’s get our Arduino talking and grooving. The first thing to do is install the wavehc library into your Arduino IDE software. The library and related buffering use a fair amount of memory, so if you are running an Arduino with the old ‘168 MCU, it’s time to find the $6 and upgrade to the ATmega328.

Next, visit the tronixstuff file repository. Download the waveshieldtest.pde sketch; and also download this audio file onto the SD card. Finally, insert the SD card, upload the sketch, insert your headphones and the board should play the file. Don’t forget to turn the volume up a little, yours may be set to off by default.

Now that we know it is working, it is time to examine how we can control things in more detail. The most important thing is to have your .wav sound files in the correct format. The maximum sampling rate is 22 kHz, depth of 16-bit, and in mono PCM format. You can download an open-source audio editor package to do the conversions for you here. ladyada has also written a good conversion tutorial for you here.

Apart from converting audio files for playback, if you want to get some backchat you will need to find a speech-synthesiser. You can make use of the AT+T Labs Natural Voices (R) Text to Speech demo website for this. Just enter some text, and then you can download the .wav file:


Now let’s have a quick look at how we can play files on demand, to let our own projects make some noise. Please download the sketch waveshieldtest2.pde. Although there is a large amount of code in there, what we’re interested in is just the void loop(); function. To play a .wav file, such as “wisdom.wav”, just use

So you can just mash that sketch and your own code together to get some files playing, however don’t forget your attributions to the original authors. Here is a … longer demonstration of waveshieldtest2.pde:

You can purchase the waveshield kit directly from adafruit industries.  High resolution images are available on flickr.

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

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

Posted in adafruit, arduino, kit review, microcontrollers, tutorial, waveshieldComments (11)

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:


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:


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:


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:


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:


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:


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:


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.


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, tutorialComments (4)

Kit Review – adafruit industries DS1307 Real Time Clock breakout board kit

Hello readers

Today we are going to examine another small yet useful kit from adafruit industries – their DS1307 Real Time Clock breakout board kit. My purpose of acquiring this kit was to make life easier when prototyping my clock and timer Arduino-based projects on a breadboard. For example, blinky, or the various clock projects in the Arduino tutorials.

When breadboarding a DS1307 circuit, there are a few problems – the legs of the crystal are very fine, and break easily, and trying to mount the backup battery holder on the breadboard can be difficult due to their odd pin-spacing. That is why this breakout board is just perfect for breadboarding. Finally, (in Australia anyway) the price of the kit is less than the sum of the retail cost of the parts required. Anyhow, time to get cracking!

Again, as usual the adafruit kit packaging is simple, safe and reusable:


And with regards to the contents within:


… no surprises here, another quality solder-masked, silk-screened PCB  that has everything you need to know printed on it. Now that you can see the crystal (above image, bottom-right) you can realise why this board is a good idea. Furthermore, the inclusion of a quality battery and not some yum-cha special is a nice touch.

Assembly is incredibly simple. The IC position is printed on the PCB, the resistors are the same, and the capacitor and crystal are not polarised. Again, no IC socket, but perhaps it is time not to worry about that anymore – my soldering skills have improved somewhat in the last twelve months. Plus the DS1307 can handle 260 degrees Celsius for ten seconds when soldering (according to the data sheet.pdf).

However if you like to read instructions (which is generally a good idea) the excellent documentation is laid out here for your perusal.

Soldering the board is quite straightforward, however when it comes time to solder in the coin cell holder, note that there are large gaps in the mounting holes:


It is important to solder the pins solidly to the PCB, without letting lots of solder flow through the hole and block the other side. If you can bend the pins slightly closer to the circumference of the hole, soldering will be a lot easier. And don’t forget to put a blob of solder on the top-facing pad between the two pin holes before soldering in the coin cell holder.

Finally, when time to solder in the header pins, mount the lot onto a breadboard, and support the gap between the PCB and the breadboard at the opposite end of the PCB. An old CD works very well:


And within ten minutes of starting, we have finished!


Insert the backup cell (writing facing up!) in the holder and you’re ready to time. A new backup cell should last between seven to ten years, so unless you want to reset the clock completely, leave the cell in the board.

Now it is time to use the board. My only experience is with the Arduino-based systems, and even so using the DS1307 can seem quite difficult at the start. However with the right library and some basic reusable sketch modules you can do it quite successfully. The board is a standard DS1307 circuit, and is explained in great detail within the data sheet.pdf.

Don’t forget you can get a nice 1 Hz (or 4, 8 or 32 kHz) square wave from this IC – here is a sketch that allows you to control the square-wave generator:

And a video demonstration:

Well I hope you found this review interesting, and helped motivate you to expand your knowledge and work with real-time clocks, Arduino and the I2C bus.

You can purchase the kit directly from adafruit industries.

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

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

Posted in adafruit, ds1307, kit review, microcontrollers, real time clock, tutorialComments (6)

Subscribe via email

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: