Archive | learning electronics

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:

4047icsss

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]

astabledemo

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]

4047monoschematic

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, tutorial41 Comments

Project – Simple RFID access system

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

Updated 18/03/2013

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

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

articless

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

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

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

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

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

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

And here is the schematic (large version):

simplerfidschematic

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

rfidbboardss

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

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

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

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

Posted in hardware hacking, learning electronics, microcontrollers, projects, RDM630, RDM6300, rfid12 Comments

Kit Review – MDC Bare-bones Board Kit (Arduino-compatible)

Hello readers

Today we continue to examine Arduino-compatible products by assembling an interesting kit from Modern Device Company – their “Bare Bones Board” (to be referred to as BBB). The BBB kit is an inexpensive way to take advantage of the Arduino Duemilanove-compatible platform, and also fills some gaps in the marketplace. Unlike the usual Arduino and compatible boards, the BBB does not maintain the recognisable form factor – that is, you cannot use the variety of Arduino shields. However, the BBB does have all the input and output connections, just in different positions.

So why would you use this kit? If you are looking to create a more permanent Arduino-based project that did not require a shield, and you are in a hurry – the BBB could be easily integrated into your design. Money is saved by not having the usual USB connection, so uploading your sketch is achieved using a 5V FTDI cable or using another Arduino board as the programmer.

Furthermore, the PCB is designed in a way that allows you to plug the BBB into the side of a solderless breadboard, which allows prototyping more complex Arduino-based circuits very easy. But more about that later. For now, let’s have a look at construction. An excellent set of instructions and a guide to use is available for download here.

In the spirit of saving money, the kit arrives in a plastic bag of sorts:

packagingss1

And upon emptying the contents, the following parts are introduced:

partsss2

Regular readers would know that the inclusion of an IC socket makes me very happy. The PCB is thicker than average and has a great silk-screen which makes following instructions almost unnecessary. One of the benefits of this kit is the ability to connect as little or as many I/O or programming pins as required.

And for the pins A0~A5, 5V, GND and AREF you are provided with header pins and a socket, allowing you to choose. Or you could just solder directly into the board. These pins are available on the bottom-left of the PCB. However there was one tiny surprise included with the parts:

rawinductor

This is a 15uH SMD inductor, used to reduce noise on the analog/digital section. According to the instructions, this was originally required with Arduino-style boards that used the ATmega168 microcontroller – however the BBB now includes the current ATmega328 which does not require the inductor. However, it is good to get some SMD practice, so I soldered it in first:

solder1ss1

Well it works, so that was a success. Soldering the rest of the main components was quite simple, thanks to the markings on the PCB. The key is to start with the lowest-profile (height) components (such as that pesky inductor) and work your way up to the largest. For example:

solder2ss1

As you can see from the PCB close-up above, you can have control over many attributes of your board. Please note that the revision-E kit does include the ATmega328 microcontroller, not the older ‘168. For more permanent installations, you can solder directly into I/O pins, the power supply and so on.

Speaking of power, the included power regulator IC for use with the DC input has quite a low current rating – 250 mA (below left). For my use, this board will see duty in a breadboard, and also a 5V supply for the rest of the circuit, so more current will be required. Thankfully the PCB has the space and pin spacing for a 7805 5V 1A regulator (below right), so I installed my own 7805 instead:

regulators

Finally, to make my Arduino-breadboarding life easier I installed the sockets for the analogue I/O, the DC socket and a row of header pins for the digital I/O. Below is my finished example connected into a breadboard blinking some LEDs:

finishedonbbss

In this example, the board is being powered from the 5V that comes along the FTDI cable. If doing so yourself, don’t forget that there is a maximum of 500 mA available from a USB port. If you need more current (and have installed the 7805 voltage regulator) make use of the DC socket, and set the PCB power select jumper to EXT. For a better look at the kit in action, here is a short video clip:

As you can see from the various angles shown in the video, there are many points on the PCB to which you can use for power, ground, I/O connection and so on. As illustrated at the beginning of this article, a variety of header pins are included with the kit. And please note that the LED on the board is not wired into D13 as other Arduino-type boards have been… the BBB’s LED is just an “on” indicator.

However if you are using this type of kit, you most likely will not need to blink a solitary LED. However some people do use the D13 LED for trouble-shooting, so perhaps you will need it after all. Each to their own!

In conclusion, the BBB is another successful method of prototyping with the Arduino system. The kit was of a good quality, included everything required to get working the first time, and is quite inexpensive if you have a 5V FTDI cable or an Arduino Duemilanove/Uno or compatible board for sketch uploading.

Once again, thank you for reading this kit review, and I look forward to your comments and so on. Please subscribe using one of the methods at the top-right of this web page to receive updates on new posts, and if you have any questions – why not join our Google Group? It’s free and we’re all there to learn and help each other.

High resolution photos are available on flickr.

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

Posted in arduino, bare bones board, kit review, learning electronics, microcontrollers, modern devices4 Comments

Review – Fluke 233 Remote Display True RMS Multimeter

Hello readers

Several followers of my website have noticed the use of an interesting multimeter in a few of my articles, and were curious about it. So in this article we will discuss it in more detail. It is certainly novel in design, and has proven to be very convenient in use – the Fluke 233 remote-display true RMS multimeter. It arrives in a cardboard box that is easily recycled:

boxs

Upon tearing open the packaging we are presented with the following contents:

contentss

The contents of the box are as follows:

  • The meter itself;
  • a long (~1.2m) pair of Cat IV leads with very sharp points;
  • matching insulated alligator clip adaptors;
  • a K-type thermocouple;
  • a printed Getting Started manual, and the complete manual on CDROM;
  • a single, universal getting started sheet – explains how to remove battery isolation tabs.

However, a carry case was not included. Considering the cost of the meter here (Au$550 + tax), one would have expected a case. On the other hand, if you/your workplace can afford a 233, you can pay for your own case. So there’s two angles to the case perspective.

It is good to see that there isn’t too much of a printer manual, the less paper used the better. As others have said, if you have one of these meters the manual isn’t necessary apart from checking the specifications, and the same applied to myself. Thoughtfully the meter is supplied and fitted with 5 x AA Duracell alkaline cells, three in the meter body and two in the display unit. All one needs to do is pull out the plastic tabs from the battery compartments, and you’re ready to go.

Physically the unit does not disappoint. Made in the USA. First class. Another solid Fluke design, clean lines, and a great fit and finish. Futhermore it is of a good weight, so you could always bang in a nail with it, or the pointy-head boss. The exterior has the rubber-moulded housing which is not removable, however this would be recommended for the target market – as the 233 would be more of a field work than a test-bench instrument. However, if you do sit it on the bench with the tilting bail, you can still operate it with one hand as it has enough friction to stay put. It is also good to see that the box and packaging are cardboard which is easily recycled.

After flicking the meter on the first thing to do was remove the display, plug in the thermocouple, and toss the body into the freezer:

freezer-tests

Even with the meter in the freezer, I could still move the display around 1.5 meters away and it still received the data signal. Notice how the display is on the freezer door – it is magnetic. Immediately the benefits of the remote display come to mind. You can always have the display right where you want it, and the meter where it needs to be… it’s win-win. After showing it to my auto-electrician friend, she didn’t want to give it back.

The ability to set up a meter in a less than perfectly safe environment and take the display away is almost priceless. Furthermore, the backlight is a nice even blueish colour, and times out after around forty seconds. Whilst in the kitchen, I tested out the external temperature of my tea:

teas

Using the meter in general is very simple, you can hold it in one hand and select all of the functions with your thumb. Having the yellow shift key makes changing between associated readings very simple, for example after reading AC voltage:

241vacs

Then pressing the shift key changes to frequency:

50-hzss

The meter has several useful indication functions – while working with high voltages the triangular market is illuminated; when changing to temperature you are prompted with “OPEN” for the thermocouple, and changing to current you are prompted with “LEAD” to change sockets. It is obvious after a short period of time this was designed by engineers for engineers, and not made to a ‘price’. Although this is not an electronics multimeter, it still has quite a few ranges that would suit at a pinch. Plus the one-touch data hold, minimum and maximum functions are included as with other top-end Flukes. Hopefully someone at Fluke is working on a remote display version of their 87V.

Now that I have had this meter for just over five months, it has already become a worthwhile addition to my bench. For the kind of work I do, it has already replaced another multimeter, my old frequency counter and thermometer. The ranges are quite useful, and the continuity beeper is in the display not the body. According to the manual the 233 is rated for a one meter drop onto any of the six surfaces. Out of respect to the meter I will not throw it into a river or from a moving car. The other factor that prevents me from going to such extremes is the clear plastic over the LCD – there is a small amount of ‘give’ or flexibility in that area. Otherwise the 233 is as solid as they come.

The specifications can be found in detail in the manual here, however a quick glance shows:

Range                                                             Accuracy

AC voltage: 0.1mV ~ 1000V                      1~2%+3

AC current: 1mA ~ 10A                               1.5%+3

DC voltage: 0.1mV ~ 1000V                     0.25%+2

DC current: 1mA ~ 10A                               1.0%+3 ** no microamperes

resistance: 0.1 ~ 40 meg-ohm                   0.9~1.5%+2

frequency:  0.01 Hz ~ 50 kHz                    0.1%+2

capacitance: 1nF to 9999 uF                     1.9%+2

temperature: -40 ~ 400 degrees Celsius     1%+10

And there is also a diode test and continuity beeper function. Interestingly enough, I discovered by accident that the frequency counter function was slightly underrated. Some more testing showed it was good for up to 99.48 kHz:

233_freq

Not bad at all. However as with the many pros, there are  a few cons to using this meter. The auto-zero time of the display is a little slow, sometimes it can take two seconds. That doesn’t sound like much, but when you’re measuring many components the time adds up. And the LCD is not protected as well as expected, you can push into it with your finger. For a Fluke meter, one would expect it to be much more solid – if the display unit fell from a height and landed on something pointy with the display facing down, it would be ruined. So be careful if you have one.

Furthermore, the battery life is around eight to ten weeks of “daily use” (perhaps seven hours a week, usually with the backlight on). Some have said this is bad, however my opinion is that the convenience of the remote display makes up for the shorter battery life.

However at the end of the day – this is a great tool. Being able to measure something outside your field of vision, and having the results in front of you is incredibly useful. You could achieve the same functions by using a meter with a PC interface, but that can be overkill and time-consuming to set up. So if the specifications of the 233 meet your needs, this is a great tool that will serve you very well.

The Fluke 233 Remote Display True RMS Multimeter is available from your local element-14 or Fluke distributor.

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.

[Disclaimer – the Fluke 233 is a review sample made available by Fluke via element-14]

Posted in 233, fluke, learning electronics, product review, test equipment6 Comments

Tutorial: Using analog input for multiple buttons

Use multiple buttons with one analog input in chapter twenty-five of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe.

[Updated 14/03/2013]

The purpose of this article is demonstrate how you can read many push buttons (used for user-input) using only one analog input pin. This will allow you to save digital I/O pins for other uses such as LCD modules and so on. Hopefully you recall how we used analogRead() in chapter one, and how we used a potentiometer to control menu options in exercise 10.1. For this article, we will be looking at reading individual presses, not simultaneous (i.e. detecting multiple button presses).

To recap, an analog input pin is connected to an analog to digital (ADC) converter in our Arduino’s microcontroller. It has a ten bit resolution, and can return a numerical value between 0 and 1023 which relates to an analog voltage being read of between 0 and 5 volts DC. With the following sketch:

and in the following short video, we have demonstrated the possible values returned by measuring the voltage from the centre pin of a 10k ohm potentiometer, which is connected between 5V and GND:

As the potentiometer’s resistance decreases, the value returned by analogRead() increases. Therefore at certain resistance values, analogRead() will return certain numerical values. So, if we created a circuit with (for example) five buttons that allowed various voltages to be read by an analog pin, each voltage read would cause analogRead() to return a particular value. And thus we can read the status of a number of buttons using one analog pin. The following circuit is an example of using five buttons on one analog input, using the sketch from example 25.1:

example25p2

And here it is in action:

Where is the current coming from? Using pinMode(A5, INPUT_PULLUP); turns on the internal pull-up resistor in the microcontroller, which gives us ~4.8V to use. Some of you may have notice that when the right-most button is pressed, there is a direct short between A5 and GND. When that button is depressed, the current flow is less than one milliamp due to the pull-up resistor protecting us from a short circuit. Also note that you don’t have to use A5, any analog pin is fine.

As shown in the previous video clip, the values returned by analogRead() were:

  • 1023 for nothing pressed (default state)
  • 454 for button one
  • 382 for button two
  • 291 for button three
  • 168 for button four
  • 0 for button five

So for our sketches to react to the various button presses, they need to make decisions based on the value returned by analogRead(). Keeping all the resistors at the same value gives us a pretty fair spread between values, however the values can change slightly due to the tolerance of resistors and parasitic resistance in the circuit.

So after making a prototype circuit, you should determine the values for each button, and then have your sketch look at a range of values when reading the analog pin. Doing so becomes more important if you are producing more than one of your project, as resistors of the same value from the same batch can still vary slightly. Using the circuit from example 25.2, we will use a function to read the buttons and return the button number for the sketch to act upon:

And now our video demonstration:

So now you have a useful method for receiving input via buttons without wasting many digital input pins. I hope you found this article useful or at least interesting.

LEDborder

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

Posted in analog, arduino, learning electronics, lesson, microcontrollers, multiple buttons, tutorial9 Comments

Initial review: mbed LPC1768 Development Board

In this article we review the mbed NXP LPC1768 development board and the mbed system in general.

Introduction

Today we will examine the mbed NXP LPC1768 development board. The goal of the mbed system is to “provide(s) a platform for microcontroller hardware, tools, libraries and resources designed to enable rapid prototyping with microcontrollers.” (http://mbed.org/handbook/About). Personally I also see this as a good option for a “next step” for those who have outgrown their Arduino – the mbed offers much more processing power, a similar development environment and similar hardware ease of use. A great way to move from 8-bit to 32-bit power…

The NXP LCP1768 MCU on our mbed board offers the following specifications:

  • a Cortex-M3 core running at 96MHz
  • 512kb flash memory and 64kb RAM
  • powered via USB or 4.5~9V DC applied straight to the board
  • Real time clock (requires external battery backup if necessary)
  • Loads of I/O options, including:
  • USB serial
  • I2C
  • Ethernet on board
  • SPI
  • serial I/O
  • Control-area network (CAN) bus
  • 3.3v digital logic, 40mA per digital pin with a total maximum of 400 mA
  • analog and digital I/O pins

For a full description and data sheet, please visit: http://mbed.org/handbook/mbed-NXP-LPC1768.

Although a small project started by two ARM employees, the mbed has proven to be a worthy product to allow people of generally all skill levels access to powerful microcontrollers without a lot of the inherent complications. It does this in two ways:

Firstly, the hardware is very simple and designed for ease of use. The LPC1768 is mounted on a small board to convert it to a DIP format, making breadboard easy. The designers have also thought to include four blue LEDs for digital output and a nice large reset button. Interface with the PC is via USB. The mbed appears as a USB flash drive to your computer’s operating system, and compiled programs are downloaded as a single .bin file into the mbed.

Secondly, the development environment. Unlike other MCU products on the market, mbed is a completely online development environment. That is, in a manner very similar to cloud computing services such as Google Docs or Zoho Office. However there are some pros and cons of this method. The pros include not having to install any software on the PC – as long as you have a web browser and a USB port you should be fine; any new libraries or IDE updates are handled on the server leaving you to not worry about staying up to date; and the online environment can monitor and update your MCU firmware if necessary. However the cons are that you cannot work with your code off-line, and there may be some possible privacy issues. We will examine the online environment later on.

Preparing and using the mbed is incredibly simple. The designers have certainly exceeded their goal of providing a rapid prototyping environment. The process from opening the box to running your first program is (as always) quite simple.

The initial packaging is clear and inviting, and includes a getting started document, USB cable, a laminated hardware pinout card (very useful) and a bumper sticker (!):

1

 

The mbed unit itself is compact yet not too small:

2

The underside contains the USB interface and flash drive controllers:

3

The initial setup requires registration with the mbed online environment. This is done by plugging in your mbed to the USB, and visiting the web page URL stored in the mbed’s flash drive:

4

This will take you to the login page where you can create a new user profile:

5

The serial number of the mbed is recognised and linked to your user account. This means you do need to own an mbed to explore the depths of the online services available, and also serves to keep the mbed online ecosystem free of spammers and whatnot. After registration, you will be presented with the “getting started” page, which contains links to the function references, tutorials, FAQs, user forums, user-contributed content and more. All is revealed by exploring the links from this page.

After signing up, you can create a profile page which is public. This also contains tabs that contain notes, published (programs you make public) and libraries (that you have made public) Initially I thought the profile page would be private, or limited to other mbed owners, but this is not the case. From this page you can create notebook files, view your past activity and display published programs and libraries.

For example, I created a test notebook page and someone left a comment on it twenty minutes later. So be careful if you have some secrets – instead, you could cut and paste work to and from the IDE. However if you accidentally publish something it can be deleted, but remember that the internet is written in ink, not pencil.

However don’t let privacy worries put you off – just be careful not to write anything or publish programs you want to keep secret. Furthermore, as said earlier –  having an online IDE has a few advantages – you don’t need to install anything on your PC apart from an up to date web browser. This means you can work on programs from other computers with ease. Bored at work? Using a locked-down hotel or  school computer? You can still work on your mbed programs!

The openness of the mbed environment does create a positive, helpful environment similar to that found in the open-source community – there are many libraries that have been submitted that allow connection to various pieces of hardware such as LCD screens, bluetooth, Wii controllers, motors, servos, sensors and so on – as well as libraries for pachube, twitter, HTTP client and server access, and much more. These are found in the environment’s “Cookbook” section. If something interesting is on the market, there may very well be an mbed library to work with it.

The IDE is quite clear and straightforward. The program editor maintains colour-context, line numbering, support auto-formatting, and you can import or export code using the standard copy and paste keyboard shortcuts.

6

You can have multiple folders open at once, where each folder contains one program, the standard mbed function library and others you may have imported. Furthermore, there is also a very clear function reference for the standard mbed library available within the IDE – very useful. Programs are written in C++, and the online IDE takes care of everything – leaving you with only the .bin file to upload to the mbed. If you are new to programming or a little rusty with C++, books with unfortunate titles such as “C++ for Dummies” may prove useful.

7

You can also import libraries published by other mbed users into your own projects. Details of these published libraries (and programs) are listed in the mbed online environment. The speed of development is demonstrated very well in this video from the mbed team:

The support options are very good, including a members-only forum, loads of information, the Cookbook, a wiki for publishing user-contributed libraries and resources, and other FAQs and so on. If you have a question I am sure it could be answered very quickly.  When it comes time to compile and run your program, after a successful compile your computer will download a single .bin file, which is then copied over to your mbed. Then by pressing the reset button on the mbed, the program is stored into the MCU and executed. You can store more than one .bin file on the mbed, however the latest file (by time stamp) is only executed.

Overall the mbed is a refreshingly-easy point of entry to microcontrollers. The ability to quickly prototype an idea into reality is really not difficult, and those with some C++ experience (or willing to learn) will make use of the mbed environment in no time at all. And if you decide to move your prototype into production, details and schematics are provided to help implement the nxp LPC1768 into your designs. Frankly, for fast prototyping at work, or just fun for anyone interested in electronics, the mbed offers a simple yet powerful way of getting things done.

The mbed board used in this review was a promotional consideration from RS. You can purchase an mbed directly from your local RS distributor.

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 learning electronics, lesson, LPC1768, mbed, microcontrollers, product review, review, tronixstuff, tutorial10 Comments

Tutorial: Arduino and monochrome LCDs

Please note that the tutorials are not currently compatible with Arduino IDE v1.0. Please continue to use v22 or v23 until further notice. 

This is chapter twenty-four of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe.

The first chapter is here, the complete series is detailed here.

Welcome back fellow arduidans!

The purpose of this article is to summarise a range of affordable monochrome liquid-crystal display units that are available to work with our Arduino; and to replace the section about LCDs in chapter two of this series. We will first examine some fixed-character and then graphical LCD units in this article. So let’s go!

Fixed-character LCD modules

When shopping around for LCD modules, these will usually be the the most common found in retail outlets. Their size is normally measured by the number of columns and rows of characters in the display. For example, the three LCDs below are 8×2, 16×2 and 20×4 characters in size:

lcdtypesss

Currently, most LCDs should have a backlight of some sort, however you may come across some heavily-discounted models on (for example) eBay that are not. Character, background and backlight colours can vary, for example:

backlitsss

Interfacing these screens with our Arduino boards is very easy, and there are several ways to do so. These interface types can include four- and eight-bit parallel, three-wire,  serial, I2C and SPI interfaces; and the LCD price is usually inversely proportional to the ease of interface (that is, parallel are usually the cheapest).

Four-bit parallel interface

This is the cheapest method of interface, and our first example for this article. Your LCD will need a certain type of controller IC called a Hitachi HD44780 or compatible such as the KS0066. From a hardware perspective, there are sixteen pins on the LCD. These are usually in one row:

16pinsss

… or two rows of eight:

2by8pinsss

The pin labels for our example are the following:

  1. GND
  2. 5V (careful! Some LCDs use 3.3 volts – adjust according to LCD data sheet from supplier)
  3. Contrast
  4. RS
  5. RW
  6. Enable
  7. DB0 (pins DB0~DB7 are the data lines)
  8. DB1
  9. DB2
  10. DB3
  11. DB4
  12. DB5
  13. DB6
  14. DB7
  15. backlight + (unused on non-backlit LCDs) – again, check your LCD data sheet as backlight voltages can vary.
  16. backlight GND (unused on non-backlit LCDs)

As always, check your LCD’s data sheet before wiring it up.

Some LCDs may also have the pinout details on their PCB if you are lucky, however it can be hard to decipher:

Now let’s connect our example 16×2 screen to our Arduino using the following diagram.

Our LCD runs from 5V and also has a 5V backlight – yours may differ, so check the datasheet:

4bitparallel2

(Circuit layout created using Fritzing)

Notice how we have used six digital output pins on the Arduino, plus ground and 5V. The 10k ohm potentiometer connected between LCD pins 2, 3 and 5 is used to adjust the display contrast. You can use any digital out pins on your Arduino, just remember to take note of which ones are connected to the LCD as you will need to alter a function in your sketch. If your backlight is 3.3V, you can use the 3.3V pin on the Arduino.

From a software perspective, we need to use the LiquidCrystal() library. This library should be pre-installed with the Arduino IDE. So in the start of your sketch, add the following line:

Next, you need to create a variable for our LCD module, and tell the sketch which pins are connected to which digital output pins. This is done with the following function:

The parameters in the brackets define which digital output pins connect to (in order) LCD pins: RS, enable, D4, D5, D6, and D7.

Finally, in your void setup(), add the line:

This tells the sketch the dimensions in characters (columns, rows) of our LCD module defined as the variable lcd. In the following example we will get started with out LCD by using the basic setup and functions. To save space the explanation of each function will be in the sketch itself. Please note that you do not have to use an Arduino Mega – it is used in this article as my usual Arduino boards are occupied elsewhere.

And here is a quick video of the example 24.1 sketch in action:

There are also a some special effects that we can take advantage of with out display units – in that we can actually define our own characters (up to eight per sketch). That is, control the individual dots (or pixels) that make up each character. With the our character displays, each character is made up of five columns of eight rows of pixels, as illustrated in the close-up below:

pixels

In order to create our characters, we need to define which pixels are on and which are off. This is easily done with the use of an array (array? see chapter four). For example, to create a solid block character as shown in the image above, our array would look like:

Notice how we have eight elements, each representing a row (from top to bottom), and each element has five bits – representing the pixel column for each row. The next step is to reference the custom character’s array to a reference number (0~7) using the following function within void setup():

Now when you want to display the custom character, use the following function:

where 0 is the memory position of the character to display.

To help make things easier, there is a small website that does the array element creation for you. Now let’s display a couple of custom characters to get a feel for how they work. In the following sketch there are three defined characters:

And here is a quick video of the example 24.2 sketch in action:

So there you have it – a summary of the standard parallel method of connecting an LCD to your Arduino. Now let’s look at the next type:

Three-wire LCD interface

If you cannot spare many digital output pins on your Arduino, only need basic text display and don’t want to pay for a serial or I2C LCD, this could be an option for you. A 4094 shift register IC allows use of the example HD44780 LCD with only three digital output pins from your Arduino. The hardware is connected as such:

twilcd

And in real life:

exam24p3ss

From a software perspective, we need to use the LCD3Wire library, which you can download from here. To install the library, copy the folder within the .zip file to your system’s \Arduino-2x\hardware\libraries folder and restart the Arduino IDE. Then, in the start of your sketch, add the following line:

Next, you need to create a variable for our LCD module, and tell the sketch which of the 4094’s pins are connected to which digital output pins as well as define how many physical lines are in the LCD module. This is done with the following function:

Finally, in your void setup(), add the line:

The number of available LCD functions in the LCD3wire library are few – that is the current trade-off with using this method of LCD connection … you lose LCD functions but gain Arduino output pins. In the following example, we will demonstrate all of the available functions within the LCD3Wire library:

And as always, let’s see it in action. The LCD update speed is somewhat slower than using the parallel interface, this is due to the extra handling of the data by the 4094 IC:

Now for some real fun with:

Graphic LCD modules

(Un)fortunately there are many graphic LCD modules on the market. To keep things relatively simple, we will examine two – one with a parallel data interface and one with a serial data interface.

Parallel interface

Our example in this case is a 128 by 64 pixel unit with a KS0108B parallel interface:

glcdparallelss

For the more technically-minded here is the data sheet. From a hardware perspective there are twenty interface pins, and we’re going to use all of them. For breadboard use, solder in a row of header pins to save your sanity!

This particular unit runs from 5V and also has a 5V backlight. Yours may vary, so check and reduce backlight voltage if different.

You will again need a 10k ohm potentiometer to adjust the display contrast. Looking at the image above, the pin numbering runs from left to right. For our examples, please connect the LCD pins to the following Arduino Uno/Duemilanove sockets:

  1. 5V
  2. GND
  3. centre pin of 10k ohm potentiometer
  4. D8
  5. D9
  6. D10
  7. D11
  8. D4
  9. D5
  10. D6
  11. D7
  12. A0
  13. A1
  14. RST
  15. A2
  16. A3
  17. A4
  18. outer leg of potentiometer; connect other leg to GND
  19. 5V
  20. GND

A quick measurement of current shows my TwentyTen board and LCD uses 20mA with the backlight off and 160mA with it on. The display is certainly readable with the backlight off, but it looks a lot better with it on.

From a software perspective we have another library to install. By now you should be able to install a library, so download this KS0108 library and install it as usual. Once again, there are several functions that need to be called in order to activate our LCD. The first of these being:

which is placed within void setup(); The parameter sets the default pixel status. That is, with NON_INVERTED, the default display is as you would expect, pixels off unless activated; whereas INVERTED causes all pixels to be on by default, and turned off when activated. Unlike the character LCDs we don’t have to create an instance of the LCD in software, nor tell the sketch which pins to use – this is already done automatically. Also please remember that whenever coordinates are involved with the display, the X-axis is 0~127 and the Y-axis is 0~63.

There are many functions available to use with the KS0108 library, so let’s try a few of them out in this first example. Once again, we will leave the explanation in the sketch, or refer to the library’s page in the Arduino website. My creative levels are not that high, so the goal is to show you how to use the functions, then you can be creative on your own time. This example demonstrate a simpler variety of graphic display functions:

Now let’s see all of that in action:

You can also send normal characters to your KS0108 LCD. Doing so allows you to display much more information in a smaller physical size than using a character  LCD. Furthermore you can mix graphical functions with character text functions – with some careful display planning you can create quite professional installations. With a standard 5×7 pixel font, you can have eight rows of twenty-one characters each. Doing so is quite easy, we need to use another two #include statements which are detailed in the following example. You don’t need to install any more library files to use this example. Once again, function descriptions are in the sketch:

Again,  let’s see all of that in action:

If you’re looking for a very simple way of using character LCD modules, check this out.

LEDborder

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

Posted in arduino, education, LCD, LCD-00710, learning electronics, lesson, microcontrollers, tutorial52 Comments

Kit review – Sparkfun Function Generator

Hello readers

[10/09/2011 Update – It would seem that this kit has been discontinued – most likely due to the unavailability of the XR2206 function generator IC – which is a damn shame as it was a great kit. If you are ‘feeling lucky’ eBay seems to have a flood of them. Purchase at your own risk!]

Time for another kit review (anything to take the heat off from the kid-e-log!). Today we will examine the Sparkfun Function Generator kit. This is based from an original design by Nuxie and has now been given a nice thick red PCB and layout redesign. Although quite a bare-bones kit, it can provide us with the following functions:

  • sine waves
  • triangle waves
  • a 5V square wave with adjustable frequency

There are two frequency ranges to choose from, either 15~4544Hz or 4.1~659.87kHz. Your experience may vary, as these values will vary depending on the individual tolerance of your components.  The coarse and fine adjustment potentiometers do a reasonable job of adjustment, however if you were really specific perhaps a multi-turn pot could be used for the fine adjustment. With the use of a frequency counter one could calibrate this quite well.

The maximum amplitude of the sine and triangle waves is 12V peak to peak, and doing so requires a DC power supply of between 14~22 volts (it could be higher, up to 30 volts – however the included capacitors are only rated for 25V). However if you just need the 5V square-wave, or a lower amplitude, a lesser supply voltage such as 9 volts can be substituted. After running the generator from a 20V supply, the 7812 regulator started to become quite warm – a heatsink would be required for extended use. The main brains of the generator are held by the Exar XR2206 monolithic function generator IC – please see the detailed data sheet for more information.

Now what do you get? Not much, just the bare minimum once more. Everything you need and nothing you don’t …

bagpartsss

Upon turfing out the parts we are presented with:

thepartsss

Not a bad bill of materials – nice to see a DC socket for use with a plug-pack. Considering the XR2206 is somewhat expensive and rare here in the relative antipodes, an IC socket would be nice – however I have learned to just shut up and keep my own range in stock now instead of complaining. Having 5% tolerance resistors took me as a surprise at first, but considering that the kit is not really laboratory-precision equipment the tolerance should be fine. One could always measure the output and make a panel up later on.

Once again, I am impressed with the PCB from Sparkfun. Thick, heavy, a good solder mask and descriptive silk-screen:

pcbss

Which is necessary as there aren’t any instructions with the kit nor much on the Sparkfun website. The original Nuxie site does have a bit of a walk through if you like to read about things before making them. Finally, some resistors and capacitors included are so small, a decent multimeter will be necessary to read them (or at least a good magnifying glass!).

Construction was very simple, starting with the low-profile components such as resistors and capacitors:

resiscapsss

followed by the switches, terminal blocks, IC sockets and the ICs:

icsss

and finally the potentiometers:

potsss

The easiest way to solder in the pots while keeping them in line was to turn the board upside down, resting on the pots. They balance nicely and allow a quick and easy soldering job. At this point the function generator is now ready to go – after the addition of some spacers to elevate it from the bench when in use:

finishedss

Now for the obligatory demonstration video. Once again, the CRO is not in the best condition, but I hope you get the idea…


Although a very simple, barebones-style of kit (in a similar method to the JYETech Capacitance meter) this function generator will quickly knock out some functions in a hurry and at a decent price. A good kit for those who are learning to solder, perhaps a great next step from a TV-B-Gone or Simon kit. And for the more advanced among us, this kit is licensed under Creative Commons attribution+share-alike, and the full Eagle design files are available for download – so perhaps make your own? High resolution images are available on flickr.

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

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

Posted in education, kit review, KIT-10015, learning electronics, oscilloscope, test equipment, XR22060 Comments

Tutorial: Arduino and the I2C bus – Part Two

Part two of our Arduino and I2C bus tutorial.

[Updated 28/11/2014]

Today we are going to continue learning about the I2C bus and how it can work for us. If you have not already, please read and understand the first I2C article before continuing.

First of all, there are some limitations of I2C to take into account when designing your projects. One of these is the physical length of the SDA and SCL lines. If all your devices are on the same PCB, then there is nothing to worry about, however if your I2C bus is longer than around one metre, it is recommended that you use an I2C bus extender IC. These ICs reduce electrical noise over the extended-length bus runs and buffer the I2C signals to reduce signal degradation and chance of errors in the data. An example of such an IC is the NXP P82B715 (data sheet). Using a pair of these ICs, you can have cable runs of 20 to 30 metres, using shielded twisted-pair cable. Below is a good example of this, from the aforementioned NXP data sheet:

i2cbufferedss

Several applications come to mind with an extended I2C bus, for example remote temperature monitoring using the the ST Microelectronics CN75 temperature sensor from part one; or controlling several I/O ports using an I2C expander without the expense or worry of using a wireless system. Speaking of which, let’s do that now…

A very useful and inexpensive part is the PCF8574 I/O expander (data sheet.pdf). This gives us another eight outputs, in a very similar method to the 74HC595; or can be used as eight extra inputs. In fact, if you were to use more than one 74HC595 this IC might be preferable, as you can individually address each chip instead of having to readdress every IC in line as you would with shift registers. So how do we do this? First, let’s consult the pinout:

There should not be any surprises for you there. A2~A0 are used to select the last three bits of the device address, P0~P7 are the I/O pins, and INT is an interrupt output which we will not use. To address the PCF8574 we need two things, the device address, and a byte of data which represents the required output pin state. Huh? Consider:

pcf8574intdef

So if we set pins A0 to A2 to GND, our device address in binary will be 0100000, or 0x20 in hexadecimal. And the same again to set the output pins, for example to turn them all on we send binary 0 in hexadecimal which is 0; or to have the first four on and the second four off, use 00001111 which is Ox0F. Hopefully you noticed that those last two values seemed backwards – why would we send a zero to turn all the pins on?

The reason is that the PCF8574 is a current sink. This means that current runs from +5v, through into the I/O pins. For example, an LED would have the anode on the +5V, and the cathode connected to an I/O pin. Normally (for example with a 74HC595) current would run from the IC, through the resistor, LED and then to earth. That is a current source. Consider the following quick diagram:

sinksource1

In the example above, please note that the PCF8574N can take care of current limitation with LEDs, whereas the 74HC595 needs a current-limiting resistor to protect the LED.

Luckily this IC can handle higher volumes of current, so a resistor will not be required. It sounds a bit odd, but like anything is easy once you spend a few moments looking into it. So now let’s use three PCF8574s to control 24 LEDs. To recreate this masterpiece of blinkiness you will need:

  • Arduino Uno or compatible board
  • A large solderless breadboard
  • Three PCF8574 I/O extenders
  • Eight each of red, green and yellow (or your choice) LEDs, each with a current draw of no more than 20mA
  • Two 4.7 kilo ohm resistors
  • Hook-up wires
  • Three 0.1 uF ceramic capacitors

Here is the schematic:

exam21p1schemss

… and the example board layout:

example21p1boardss

and the example sketch. Note that the device addresses in the sketch match the schematic above. If for some reason you are wiring your PCF8574s differently, you will need to recalculate your device addresses:

 And finally our demonstration video:


That was a good example of controlling many outputs with our humble I2C bus. You could literally control hundreds of outputs if necessary – a quite inexpensive way of doing so. Don’t forget to take into account the total current draw of any extended circuits if you are powering from your Arduino boards.

LEDborder

The next devices to examine on our I2C bus ride are EEPROMs – Electrically Erasable Programmable Read-Only Memory. These are memory chips that can store data without requiring power to retain memory. Why would we want to use these? Sometimes you might need to store a lot of reference data for use in calculations during a sketch, such as a mathematical table; or perhaps numerical representations of maps or location data; or create your own interpreter within a sketch that takes instruction from data stored in an array.

In other words, an EEPROM can be used to store data of a more permanent use, ideal for when your main microcontroller doesn’t haven enough memory for you to store the data in the program code. However, EEPROMs are not really designed for random-access or constant read/write operations – they have a finite lifespan. But their use is quite simple, so we can take advantage of them.

EEPROMS, like anything else come in many shapes and sizes. The model we will examine today is the Microchip 24LC256 (data sheet.pdf). It can hold 256 kilobits of data (that’s 32 kilobytes) and is quite inexpensive. This model also has selectable device addresses using three pins, so we can use up to eight at once on the same bus. An example:

24lc256bb

The pinouts are very simple:

Pin 7 is “write protect” – set this low for read/write or high for read only. You could also control this in software if necessary. Once again we need to create a slave I2C device address using pins 1, 2 and 3 – these correlate to A2, A1 and A0 in the following table:

So if you were just using one 24LC256, the easiest solution would be to set A0~A2 to GND – which makes your slave address 1010000 or 0x50 in hexadecimal. There are several things to understand when it comes to reading and writing our bytes of data. As this IC has 32 kilobytes of storage, we need to be able to reference each byte in order to read or write to it. There is a slight catch in that you need more than one byte to reference 32767 (as in binary 32767 is 11111111 0100100 [16 bits]).

So when it comes time to send read and write requests, we need to send two bytes down the bus – one representing the higher end of the address (the first 8 bits from left to right), and the next one representing the lower end of the address (the final 8 bits from left to right) – see figure 6.1 on page 9 of the data sheet.

An example – we need to reference byte number 25000. In binary, 25000 is 0110000110101000. So we split that up into 01100001 and 10101000, then covert the binary values to numerical bytes with which to send using the Wire.send(). Thankfully there are two operators to help us with this. This first is >>, known as bitshift right. This will take the higher end of the byte and drop off the lower end, leaving us with the first 8 bits. To isolate the lower end of the address, we use another operator &, known as bitwise and. This unassuming character, when used with 0XFF can separate the lower bits for us. This may seem odd, but will work in the examples below.

Writing data to the 24LC256

Writing data is quite easy. But first remember that a byte of data is 11111111 in binary, or 255 in decimal. First we wake up the I2C bus with:

then send down some data. The first data are the two bytes representing the address (25000) of the byte (12) we want to write to the memory.

And finally, we send the byte of data to store at address 25000, then finish the connection:

There we have it. Now for getting it back…

Reading data from the 24LC256

Reading is quite similar. First we need to start things up and move the pointer to the data we want to read:

Then, ask for the byte(s) of data starting at the current address:

In this example, incomingbyte is a byte variable used to store the data we retrieved from the IC. Now we have the theory, let’s put it into practice with the test circuit below, which contains two 24LC256 EEPROMs. To recreate this you will need:

  • Arduino Uno or compatible board
  • A large solderless breadboard
  • Two Microchip 24LC256 EEPROMs (you can use 24LC512s as well)
  • Two 4.7 kilo ohm resistors
  • Hook-up wires
  • Two 0.1 uF ceramic capacitors

Here is the schematic:

examp21p2schemss

… the board layout:

exam21p2boardss

and the example sketch. Note that the device addresses in the sketch match the schematic above. If for some reason you are wiring your 24LC256s differently, you will need to recalculate your device addresses. To save time with future coding, we have our own functions for reading and writing bytes to the EEPROM – readData() and writeData(). Consider the sketch for our example:

And the output from the example sketch:

example21p2result

Although the sketch in itself was simple, you now have the functions to read and write byte data to EEPROMS. Now it is up to your imagination to take use of the extra memory.

If you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in 24LC256, arduino, I2C, learning electronics, lesson, microcontrollers, PCF8574, tutorial17 Comments

Kit Review – Silicon Chip Low Capacitance Meter adaptor for DMMs

Hello readers

Time again for another kit review. In the spirit of promoting all things electronic and Australian, we’re going to look at a kit that was published in our electronics magazine Silicon Chip (March 2010) – their Low-capacitance meter adaptor for DMMs. Simply put, it converts capacitance (from a theoretical 1 picofarad) to millivolts, which you can then read with almost any digital multimeter. This is useful as even more expensive multimeters (such as my Fluke 233) only measure down to 1 nanofarad (1000 picofarads). Although this kit is available on the Australian market, the retailers will export to those abroad. If you are outside Australia and having trouble sourcing one, send me an email. Moving on…

Here is our unassuming finished product:

finishedss5

Please note that this is not an open-source product, so you need to either purchase the kit of parts, or a back-issue of Silicon Chip magazine, March 2010 for the schematic and instructions. Now it is time to get started. But before that, how does it work?

Without giving too much away, a very rough explanation would be that a square wave signal is formed, then cleaned up through a Schmitt trigger-inverter. This square wave is then split into two, one signal passing through the capacitor under test and some resistors, and the other signal passing through a calibration variable capacitor and the same value resistors – thereby both signals pass through two different RC circuits. Finally the two signals are fed through a XOR gate, which creates a series of positive pulses that are a function of the capacitor under test.

Kit assembly was not that difficult, like anything just take your time, read the instructions carefully, and don’t rush things. If you are happy with your through-hole soldering skills, and have a power drill, this kit will be easy for you to work with. Unusually for some kits, this one comes with almost everything you need:

partsss3

The quality of the included housing is very good, there are metal threaded inserts for the screws; and even through the ICs are simple 74xx-series, sockets have been included. Resistors are metal film, the trimpots are enclosed multiturns – all very nice. I am a little disappointed with the housing/adhesive label combination however, in the past various kits from Jaycar would have a box with a nice silk-screened, hole-punched front panel. Such is life. The PCB is solder-masked and silk-screened, however a little less denser than PCBs from other kit suppliers:

pcbss1

And thus brings a slight issue with the housing and the PCB – either the PCB is too wide, or the box is too narrow. A quick clip of the PCB with some cutters will fix that:

filedpcbss

The instructions are quite good – they are a reprint of the magazine article, and slightly modified by the kit production company. Furthermore, the silk-screening on the PCB makes things a breeze. The simple passives were easy to install, however take care not to overheat the variable capacitor, their casings can melt rather quickly:

resiscapsss

Following that, the ICs were inserted, and the rotary switch. From experience, one should trim the shaft down to about a 25mm length before soldering it into the board. Take very good care when placing the rotary switch, there is a lump on the switch which matches the small circle at 8 o’clock on the PCB diagram. Finally, don’t forget to alter the switch so it only has four selections. Soldering it in can look difficult, but is not. Just push it into the PCB, checking it is flush, even and all the way in. Then bend a couple of the pins over, invert the PCB and solder away – as such:

solderrotaryss

Now it is time to start on the enclosure. Each end has two banana-type sockets, the left are the full binding-post, and the right are just sockets. Carefully mark where you want to start the holes – the positions are vertically half-way, and horizontally 15mm in from the edge, however double-check yourself. Always check the fit of the socket while drilling, as it is easy to go too far and make the holes too large – at which point you’ll have to buy another enclosure. Once you have the sockets fitted – on the left:

left-endss

and on the right:

right-endss

… you will need to solder the socket rear to the PCB pins (left) and a small link to the PCB pins (right). It is important to get a good, solid connection – as these sockets may come under a lot of use later on. Next it is time to start on the housing. If you can, photocopy the label so you have a drilling template:

labelsss

You will notice in the above photo one of my favourite tools, a tapered reamer. Using that, you can carefully turn a small hole into a larger hole, without risking making a mess with a drill. Again, cut the rotary switch’s shaft before soldering:

drilledboxss

And as punishment for using twitter at the same time, I had ended up drilling the back instead of the front. D’oh. However cosmetic appearance is secondary to functionality, so all is well. Next was to install the PP3 battery snap. The battery will be a tight fit, so a length of heatshrink has been supplied in order to avoid the battery case shorting with the PCB pin:

pp3snapss

And finally we have finished soldering:

donesolderingss

Now it is time for calibration. And for me to get a little cranky, which is quite rare as I am somewhat easygoing. Calibration requires three 1% tolerance capacitors, 100 pF, 1000 pF and 10000 pF. And they are not included with the kit. And can not be purchased from any of the kit retailers. So they had to be ordered from Farn… element-14 at a reasonable expense. Considering the kit production company also imports, wholesales and retails electronic components, they could have bought a volume of these special capacitors and added a few dollars to the price of the kit. Such is life. So here are the little buggers:

calibrationcapsss

From top to bottom:

  • Silvered-mica 100 picofarad 1% tolerance, element-14 # 1264880, RS # 495745;
  • Polystyrene 1000 picofarad 1% tolerance, element-14 # 9520651, RS # 495868 (silvered mica) and
  • Polystyrene 10000 picofarad 1% tolerance, element-14 # 3358951, RS # 495953 (silvered mica)

However it is worth the effort to chase them down. There is no point using this kit if you calibrate with normal capacitors; their tolerance can be as much as 20 percent either way. Thankfully the calibration process is quite simple. You will need a small, plastic flat-blade screwdriver to make the adjustments, as your body has stray energy which can alter the capacitance measurements.

Before starting, connect your multimeter to the output sockets and set the range to millivolts – then adjust the variable capacitor until you have the meter display as close to zero as possible. This is used to ‘null out’ stray capacitance. Next, set the dial to A, connect the 100 pF capacitor to the input posts, and adjust VR3 until the meter displays one volt DC – this represents 100.0 picofarads:

cal1ss

I could not for the life of me get this to 1 volt. After fitting the case at the end, I tried again with the case on with the same result. It is very important to get the capacitor as close as possible to the binding posts, with such small values stray capacitance can affect the result. However in my line of work, one-tenth of a picofarad is not relevant. For now. Next, set the dial to B, connect the 1000 pF capacitor, and adjust VR2 until the meter displays 1 volt – this represents 1000 picofarads:

cal2ss

Excellent – spot on. Unfortunately the leads on my 10000 pF capacitor were not long enough to attach into the binding posts, so that step had to be passed. I will have to re-order the correct part next week and calibrate then. However the other two setting are basically working perfectly, which is a good indication for the general performance of the kit. Kudos to Jim Rowe from Silicon Chip magazine for this design. Before closing up the enclosure, I decided to wrap the battery with some paper, as having it  rub up against other parts is not a good idea:

battpaperss

Now for a test run – time to measure the smallest capacitors I have in stock, first a 4.7 picofarad ceramic:

4p7ss

and next, a 12 picofarad ceramic:

12p0ss

Excellent, we can call these readings a success. I was also quite amazed that the tolerance of the cheap ceramic capacitors was so low. Note that in real-life, you may not be able to have the capacitor under test directly connected to the binding posts. In these cases you will need a short set of heavy-gauge leads to the test capacitor. If you do this, you will need to adjust the variable capacitor to reset the display to account for stray capacitance in the leads.

In conclusion, this kit has proved very successful, with regards to assembly, the quality of components and instructions, and of course the final result. I made a few errrors with regards to the housing, but that didn’t affect the final result. And for less than fifty Australian dollars, I have a very low value capacitance meter. However in due course I would consider the purchase of a full LCR meter for greater accuracy and ease of frequent use (some can measure down to 0.1 picofarad). But for the time being, this has been an excellent, educational  and affordable solution. You can purchase the kit directly from Jaycar. High resolution images are available on flickr.

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

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

Posted in capacitance meter, jaycar, KC5493, kit review, learning electronics2 Comments

Tutorial: Arduino and the I2C bus – Part One

This is part one of several tutorials on how to use the I2C bus with Arduino, and chapter twenty 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 28/11/2014]

In this first of several tutorials we are going to investigate the I2C data bus, and how we can control devices using it with our Arduino systems. The I2C bus can be a complex interface to master, so I will do my best to simplify it for you. In this article we will learn the necessary theory, and then apply it by controlling a variety of devices. Furthermore it would be in your interest to have an understanding of the binary, binary-coded decimal and hexadecimal number systems.

But first of all, what is it?

I2C is an acronym for “Inter-Integrated Circuit”. In the late 1970s, Philips’ semiconductor division (now NXP) saw the need for simplifying and standardising the data lines that travel between various integrated circuits in their products. Their solution was the I2C bus. This reduced the number of wires to two (SDA – data, and SCL – clock). Here is a nice introductory video from NXP:

Why would we want to use I2C devices?

As there are literally thousands of components that use the I2C interface! And our Arduino boards can control them all. There are many applications, such a real-time clocks, digital potentiometers, temperature sensors, digital compasses, memory chips, FM radio circuits, I/O expanders, LCD controllers, amplifiers, and so on. And you can have more than one on the bus at any time, in fact the maximum number of I2C devices used at any one time is 112.

From a hardware perspective, the wiring is very easy. Those of you with an Arduino Uno or 100% compatible board, you will be using pins A4 for SDA (data) and A5 for SCL (clock):

arduino-uno-i2c-pin

If you are using an Arduino Mega, SDA is pin 20 and SCL is 21, so note that shields with I2C need to be specifically for the Mega. If you have another type of board, check your data sheet or try the Arduino team’s hardware website.  And finally, if you are using a bare DIP ATmega328-PU microcontroller, you will use pins 27 for SDA and 28 for SCL. The bus wiring is simple:

nxpi2cbussmall

If you are only using one I2C device, the pull-up resistors are (normally) not required, as the ATmega328 microcontroller in our Arduino has them built-in.  However if you are running a string of devices, use two 10 kilo ohm resistors. Like anything, some testing on a breadboard or prototype circuit will determine their necessity. Sometimes you may see in a particular device’s data sheet the use of different value pull-up resistors – for example 4.7k ohm. If so, heed that advice. The maximum length of an I2C bus is around one metre, and is a function of the capacitance of the bus. This distance can be extended with the use of a special IC, which we will examine during the next I2C chapter.

Each device can be connected to the bus in any order, and devices can be masters or slaves. In our Arduino situation, the board is the master and the devices on the I2C bus are the slaves. We can write data to a device, or read data from a device. By now you should be thinking “how do we differentiate each device on the bus?”… Each device has a unique address. We use that address in the functions described later on to direct our read or write requests to the correct device. It is possible to use two devices with identical addresses on an I2C bus, but that will be discussed in a later article.

As like most devices, we make use of an Arduino library, in this case <wire.h>. Then use the function Wire.begin(); inside of void setup() and we’re ready to go.

Sending data from our Arduino to the I2C devices requires two things: the unique device address (we need this in hexadecimal) and at least one byte of data to send. For example, the address of the part in example 20.1 (below) is 00101111 (binary) which is 0X2F in hexadecimal. Then we want to set the wiper value, which is a value between 0 and 127, or 0x00 and 0x7F in hexadecimal. So to set the wiper to zero, we would use the following three functions:

This sends the device address down the SDA (data) line of the bus. It travels along the bus, and “notifies” the matching device that it has some data coming…

This sends the byte of data to the device – into the device register (or memory of sorts), which is waiting for it with open arms. Any other devices on the bus will ignore this. Note that you can only perform one I2C operation at a time! Then when we have finished sending data to the device, we “end transmission”. This tells the device that we’re finished, and frees up the I2C bus for the next operation:

Some devices may have more than one register, and require more bytes of data in each transmission. For example, the DS1307 real-time clock IC has eight registers to store timing data, each requiring eight bits of data (one byte):

ds1307registers

However with the DS1307  – the entire lot need to be rewritten every time. So in this case we would use eight wire.send(); functions every time. Each device will interpret the byte of data sent to it, so you need the data sheet for your device to understand how to use it.

Receiving data from an I2C device into our Arduino requires two things: the unique device address (we need this in hexadecimal) and the number of bytes of data to accept from the device. Receiving data at this point is a two stage process. If you review the table above from the DS1307 data sheet, note that there is eight registers, or bytes of data in there. The first thing we need to do is have the I2C device start reading from the first register, which is done by sending a zero to the device:

Now the I2C device will send data from the first register when requested. We now need to ask the device for the data, and how many bytes we want. For example, if a device held three bytes of data, we would ask for three, and store each byte in its own variable (for example, we have three variables of type byte: a, b, and c. The first function to execute is:

Which tells the device to send three bytes of data back to the Arduino. We then immediately follow this with:

We do not need to use Wire.endTransmission() when reading data. Now that the requested data is in their respective variables, you can treat them like any ordinary byte variable. For a more detailed explanation of the I2C bus, read this explanatory document by NXP. Now let’s use our I2C knowledge by controlling a range of devices…

The Microchip MCP4018T digital linear potentiometer. The value of this model is 10 kilo ohms. Inside this tiny, tiny SMD part is a resistor array consisting of 127 elements and a wiper that we control by sending a value of between 0 and 127 (in hexadecimal) down the I2C bus. This is a volatile digital potentiometer, it forgets the wiper position when the power is removed. However naturally there is a compromise with using such a small part, it is only rated for 2.5 milliamps – but used in conjunction with op amps and so on. For more information, please consult the data sheet. As this is an SMD part, for breadboard prototyping purposes it needed to be mounted on a breakout board. Here it is in raw form:

mcp4018raw

Above the IC is a breakout board. Consider that the graph paper is 5mm square! It is the incorrect size, but all I have. However soldering was bearable. Put a drop of solder on one pad of the breakout board, then hold the IC with tweezers in one hand, and reheat the solder with the other hand – then push the IC into place. A few more tiny blobs of solder over the remaining pins, and remove the excess with solder wick. Well … it worked for me:

mcp4018cooked

Our example schematic is as follows:

mcp4018sch

As you can see, the part is simple to use, your signal enters pin 6 and the result of the voltage division is found on pin 5. Please note that this is not a replacement for a typical mechanical potentiometer, we can’t just hook this up as a volume or motor-speed control! Again, please read the data sheet.

Control is very simple, we only need to send one byte of data down, the hexadecimal reference point for the wiper, e.g.:

Here is a quick demonstration that moves the wiper across all points:

 and a video demonstration:


Now we will read some data from an I2C device. Our test subject is the ST Microelectronics CN75 temperature sensor. Again, we have another SMD component, but the CN75 is the next stage larger than the part from example 20.1. Thankfully this makes the soldering process much easier, however still requiring some delicate handiwork:

cn75solder1

First, a small blob of solder, then slide the IC into it. Once that has cooled, you can complete the rest and solder the header pins into the breakout board:

cn75solder2ss

Our example schematic is as follows:

cn75schem

Pins 5, 6 and 7 determine the final three bits of the device address – in this case they are all set to GND, which sets the address to 1001000. This allows you to use multiple sensors on the same bus. Pin 3 is not used for basic temperature use, however it is an output for the thermostat functions, which we will examine in the next chapter.

As a thermometer it can return temperatures down to the nearest half of a degree Celsius. Although that may not be accurate enough, it was designed for automotive and thermostat use. For more details please read the data sheet. The CN75 stores the temperature data in two bytes, let’s call them A and B. So we use

with the second parameter as 2, as we want two bytes of data. Which we then store using the following functions:

where *a and *b are variables of the type byte. And as always, there is a twist to decoding the temperature from these bytes. Here are two example pieces of sample data:

The bits in each byte note particular values… the most significant bit (leftmost) of byte A determines whether it is below or above zero degrees – 1 for below zero. The remaining seven bits are the binary representation of the integer part of the temperature; if it is below zero, we subtract 128 from the value of the whole byte and multiply by -1. The most significant bit of byte B determines the fraction, either zero or half a degree. So as you will see in the following example sketch, there is some decision making done in showCN75data():

And here is the result from the serial monitor:

Now that we know how to read and write data to devices on the I2C bus – here is an example of doing both, with a very popular device – the Maxim DS1307 real-time clock IC. Before moving on, consider reading their good data sheet.

ds1307small

Furthermore, it also has a programmable square-wave generator. Connection and use is quite simple:

ds1307schem

However some external components are required: a 32.768 kHz crystal, a 3V battery for time retention when the power is off, and a 10k ohm pullup resistor is required if using as a square-wave generator, and 10k ohm pull-up resistors on the SCL and SDA lines. You can use the SQW and timing simultaneously. If we have a more detailed look at the register map for the DS1307:

ds1307registers

We see that the first seven registers are for timing data, the eighth is the square-wave control, and then another eight RAM registers. In this chapter we will look at the first eight only. Hopefully you have noticed that various time parameters are represented by less than eight bits of data – the DS1307 uses binary-coded decimal. But don’t panic, we have some functions to do the conversions for us.

However, in general  – remember that each bit in each register can only be zero or one – so how do we represent a register’s contents in hexadecimal? First, we need to find the binary representation, then convert that to hexadecimal. So, using the third register of the DS1307 as an example, and a time of 12:34 pm – we will read from left to right. Bit 7 is unused, so it is 0. Bit 6 determines whether the time kept is 12- or 24-hour time. So we’ll choose 1 for 12-hour time. Bit 5 (when bit 6 is 0) is the AM/PM indicator – choose 1 for PM. Bit 4 represents the left-most digit of the time, that is the 1 in 12:34 pm. So we’ll choose 1. Bits 3 to 0 represent the BCD version of 2 which is 0010.

So to store 12pm as hours we need to write 00110010 as hexadecimal into the hours register – which is 0x32. Reading data from the DS1307 should be easy for you now, reset the register pointed, then request seven bytes of data and receive them into seven variables. The device address is 0x68.  For example:

At which point the time data will need to be converted to decimal numbers, which we will take care of in the example sketch later. Setting the time, or controlling the square-wave output is another long operation – you need to write seven variables to set the time or eight to change the square-wave output. For example, the time:

The decToBcd is a function defined in our example to convert the decimal numbers to BCD suitable for the DS1307.

You can also address each register individually. We will demonstrate doing this with an explanation of how to control the DS1037’s in built square-wave generator:

Here is the SQW output in action – we measure the frequency using my very old Tek CFC-250:

For further DS1307 examples, I will not repeat myself and instead direct you to the list of many tronixstuff articles that make use of the DS1307.

So there you have it – hopefully an easy to understand introduction to the world of the I2C bus and how to control the devices within. Part two of the I2C tutorial has now been published, as well as an article about the NXP SAA1064 LED display driver IC and the Microchip MC23017 16-bit port expander IC.

 

And if you enjoyed this article, or want to introduce someone else to the interesting world of Arduino – check out my book (now in a fourth printing!) “Arduino Workshop”.

visit tronixlabs.com

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our forum – dedicated to the projects and related items on this website.

Posted in arduino, CN75, ds1307, education, I2C, learning electronics, lesson, MCP4018T, microcontrollers, tutorial22 Comments

Kit Review – Sparkfun “Simon Game”

Hello everyone

Time for a fun kit review. Aren’t all kit reviews fun? I think so, however sometimes kits can be very practical in use and perhaps not fun – unlike this little monkey. Some of you, including myself, may have childhood memories of the computer game unit from Milton-Bradley called the “Simon”. As demonstrated by the children in this video clip, Simon was a noisy game with four illuminated buttons, your task being to mimic the ever-increasing pattern of flashing buttons and matching sounds:

At first it looks easy, and it is –  however after a few repetitions the length of pattern increases and becomes more complex, forcing you to use your brain and take notice. Some would say it is useful for brain training as well.  This can only be a good thing… which brings me to this kit. The packaging is very good for a change, something you could give as a gift to a non-technical person. That is,  you could give a geek a kit in an anti-static bag, and they would understand, however a beginner may not:

boxss

The contents reveal several pleasant surprises:

partsss1

Finally – a battery-powered kit that actually includes the required power source; and not yum-cha cells, actual Duracells. Nice one Sparkfun. (If you haven’t seen that type of Duracell before, they are “trade-only” versions, generally used to deter theft). The other surprise was the inclusion of an ATmega328-PU microcontroller …

mcuss

… the exact same model as the Arduino Uno and compatible boards. Simon was starting to become more interesting every minute. But more about that later. The final object of interest is a real, live, instruction book. (You can download a copy from here). At this point you can tell this kit is made for beginners (of all ages). There is also a surface-mount component version, which people tell me is great for learning SMD work. Not for me! Good packaging, simple instructions, and a PCB that is solid and well marked out:

pcbrearss

Again, some more interesting things – what looks to be holes that would match up to an FTDI cable, in-circuit programming interface as well as some pinouts for the ATmega328.

[Update – if you’re the hacking type, it would pay to mount the IC in a socket, just in case]

However I will move forward and start the soldering. This was quite simple, just follow the guide and all is well. The instructions make a good note when a component is polarised or needs to be inserted in a certain way, very helpful for the beginner:

bottom-solderedss

and the other side was equally as simple:

top-solderedss

On this side you also need to get those AA cell clips installed. The push into their respective holes on the PCB easily, however they can be a trap to solder. Consider the following photo of one of the clips:

batt-clipss

Although the large hole in the PCB is necessary, it has left quite a gap around the wide pin. The inexperienced may end up melting lots of solder and watching it fall through to the other side; to prevent this, place the tip of your soldering iron under the acute side of the pin, and apply solder on the other side. This will force the solder to melt back onto the exposed ring on the PCB and make a good connection, instead of allowing gravity to take over the situation.

After the soldering was finished, the next task is to place the rubber button-mould over the LEDs, and then the black plastic bezel on top. The included screws go through each corner of the bezel, through the white moulding and PCB, and finally break through to the other side – where you can attach the stand-offs. Which leaves us with the final product:

finishedss1

After inserting the AA cells into their new homes, the power was turned on and the unit blinks the LEDs in a sequence until you press a button to start the game. However at this point one of the LEDs did not come on at at all. A quick check with the meter showed it was being fed almost 2.8 volts, but alas – no blinkiness. After a quick desolder/resolder job a green LED from my stock made a replacement. This would have been the only downfall for a beginner, not everyone has boxes of electronics components laying about – nor the high-intensity versions used in this kit.

However life goes on, and Simon still works just as the originals did all those years ago. Here is an example of him in action:


This is something I will need some practice on. Furthermore, the ability to control the sounds is a bonus as well; however if this Simon is aimed for small children, one could be tempted to not install the piezo transducer at all (mini speaker)! So at this stage we have an easy-to-assemble kit that is colourful, noisy and fun – a good start to help introduce another person to our fascinating world of electronics.

But wait – there’s more! Now it is time to revisit those programming holes and see what other secondary uses we can find for Simon. Seeing one of the LEDs isn’t the brightest, I will keep this one for myself, and experiment further. Therefore, the next thing to do to is solder in some header pins to allow connection to an FTDI cable:

simonftdiss

This cable converts the USB interface down to serial line levels suitable for our Simon, in the same way as the FTDI chip does for the Arduino boards (except the Uno). At this point please note you’re on your own, so if you fritz your Simon don’t take it out on me! With hindsight it would be a good idea to use an IC socket for the microcontroller.

Looking at the schematic, we can determine the pins for the LEDs, buttons and so on. The included ATmega328 has the serial bootloader for Arduino programming, so we can have a lot of easily-generated fun with it. However, note that the board does not have an external crystal or oscillator, so timing may not be as accurate as expected.

Disclaimer  – this worked for me, however your experience may vary. Alter your Simon at your own risk!

Anyhow, to use with the Arduino environment, insert the AA cells, plug in your FTDI cable, and select the board type in the environment:

arduinosetupss

Select the second option Arduino Duemilanove or Nano w/ ATmega328. Now you can upload sketches as you would a normal board. The setup functions for the LEDs are:

and for the buttons:

So armed with that knowledge you could create some  custom interactivity with your Simon hardware. If you are unsure about Arduino programming, there is a small tutorial over here that you will find helpful.

Update – New post from Sparkfun about modding your Simon. High resolution images are available on flickr. You can purchase the kit directly from Sparkfun and their resellers. 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 arduino, games, kit review, KIT-10547, KIT-10935, learning electronics, microcontrollers, simon2 Comments

Australian Electronics Nostalgia – “Funway Kits”

Hello readers

After viewing the trailer for Karl von Muller’s upcoming documentary State of Electronics – A discussion on the Electronics Industry in Australia, it brought back some fond memories of bashing about with a range of kits from many years ago. So today we will have a look at a few of them. But first some history (feel free to correct me here)…

In 1968 an enthusiastic man by the name of Dick Smith started a small car radio shop in Neutral Bay, Sydney. Although he had many ups and downs – through extremely hard work, marketing in ways Australia had never seen before (see the bus below), and revolutionising electronics and computer retailing in this country – he built up Dick Smith Electronics to a company so large he sold it for a huge sum and moved on to other successful ventures. You can download his biography from here.

Dick Smith Electronics’ stores were the place to go for components, a huge range of electronic kits, an interesting range of computers (in [earlier] kit and assembled form), amateur and CB radio – all the fun stuff. You would almost need a shotgun to clear the store out on a Thursday night or Saturday afternoon. There were also repair centres in each capital city and head office, that employed people to fix things for warranty service (and they would fix kits for a price as well). Before the internet one would stalk the mailbox waiting for the new catalogue to arrive. I even worked there for four years in the 1990s. Unfortunately due to market changes and carbon-based factors, the stores are now just glorified flat-screen TV and video game outlets.

However, partly to educate people (and probably to make more money), Dick Smith wrote a series of books titled “Fun Way into Electronics”, starting with the first in 1979. This entailed twenty very basic electronic circuits, such as flashing LEDs using a multivibrator, basic transistor amplifiers, and a “beer powered radio” (I wonder how many children tried that fuel cell?). The book had paper overlays which you would glue onto a piece of chipboard, and screw the components down to form a circuit. Later editions would use a plastic board with holes:

3143205539_96d689c02e_z

The Funway book was very popular (and still is with some schools, Scout groups and so on), so Dick published volume two from 1980. Finally some “real” projects – twenty kits that required soldering and could be of some real use in the world. Items such as a shortwave radio, intercom, timing devices, digital counters, and a mosquito repeller of dubiuos success. However they sold very well, and in 1984 the final volume of the Funway trilogy was published – another ten projects – “each with an integrated circuit!”

The books were illustrated in a very clear, simple way sometimes hand-drawn but very neat. I suspect some women in the books were meant to resemble associates of Dick Smith, and in general the book is a ‘snapshot’ of the times. For example, the transistor radio:

radiobikewoman

Please note that I will not email you a .pdf of any of the books mentioned, so kindly don’t ask – they’re still Copyright DSE Pty Ltd. Part of my reasoning for this article was the fact that the Funway era has now drawn to a close. Whilst recently wandering about in a Dick Smith store for some reminiscing, I noticed the remaining stock of Funway 2 kits on the clearance bench and the matching volume two books, which compelled me to rescue them.

At the register, the sales clerk asked me “Why would you want to make a radio?” … ugh

So let’s take a trip back to 1980 and see how they perform!

[Update 07/07/2013]

Wow! I found another kit – project seventeen, the LED level display. It was designed to show audio levels in a blinky form – the addition of a pair to your home or car hi-fi would put those analogue VU meters to shame whilst impressing your friends. When fitted inside the optional box and the label applied, you could be as cool as the guy below looking like he’s getting revved up for a night at the discotheque:

discodude

So time to give it a whirl. I remember this kit back in 1985 when a friend gave it to me from someone else, he cut off the LEDs for himself, and I ended up with the useless board. Thanks Tony. Well 28 years later here I am with the brand-new version:

proj17

Otherwise everything was as expected, all the parts and the poor PCB included:

parts

pcb

Construction was relatively simple but tedious, 22 resistors, 10 diodes, 10 LEDs, 11 transistors etc… just careful and steady work to get it done. This would have kept a teenager busy for a good weekend inside. After an hour and an espresso the board was populated:

board

Not wanting to chop up any audio leads to test the kit, I’ve instead put some pins on the power supply and input pairs for a quick demonstration. For a signal I’ve attached a function generator and fed a sine wave at various low frequencies. Here it is in action:

In hindsight that’s a pretty fun kit, and with some careful work it would have looked good in a contemporary audio system. It probably could have been done a lot easier with an LM3914 however the cost may have been prohibitive at the time.

Next we have Project Sixteen –  the Electronic Siren. This is basically two 555 oscillators, one for the sound, and the other for the duration – which combined with a basic amplifier make a “hee-haw” sound. This kit would have been included as a good sales add-on for the Home and Car alarm kit also described in the book. Typical of the series, when you purchased a kit it would come with the bare minimum, just enough to make it work (excluding the battery):

sirenpartsss

Naturally a full range of extras would be mentioned in the book, available from the store when required. The PCB looks like it was made at home – examining this one I can now be more grateful than ever for silk-screening and solder-masking on current PCBs:

sirenpcbss

To make annoying people easier I will add in a SPDT toggle switch, and use some IC sockets for the 555s. Assembling the kit took no time at all, the instructions were clear and easy to follow:

sirenbookss

Starting the soldering caused some flashbacks to my childhood, which were interesting. Assembling this at my age was much quicker than as a young lad – my soldering style has changed, and I also have a Fluke 233 to check the resistor and capacitor values. There was one nod to the future in the kit, the polyester capacitor was replaced by an MKT. The only reason to use the IC sockets was so I could reuse the 555s later on. Moving on, here is the finished article:

sirenfinishedss

And did it work? Absolutely – have a listen:


It is really quite loud, that 0.25 watt speaker is being pushed quite hard. According to the book you can connect a horn-speaker directly to the output. Furthermore there are suggestions on how to alter the frequency and duration of the sounds. So overall, this was an easy to assemble kit that was still some fun even to this day.

The next kit to examine is Project Eleven – FM wireless microphone. This consists of an oscillator of around 100 MHz, which receives a signal via the tiny electret microphone. The book illustration shows a Donna Summer lookalike with a guitar, however one could imagine people building these kits and using them as ‘bugs’ and generally getting up to no good:

txbookss

Again, the clear images and instruction layouts are constant throughout the book. There were two errata sheets included with the components, as the design has been altered a few times. However they were easy enough to follow, and the correct replacement parts had been included:

txbitsss

Once more the PCB was a product of the time. After having issues with the siren kit’s PCB, I gave this one a good squirt with some Servisol PCB cleaner – that made a difference when it was time to solder:

txpcbss

From a beginner’s perspective, this would have been a slightly more difficult kit to assemble, due to the all the vertical resistors and the close spacing between the components. However this was to enable budding ASIO operatives to make their ‘bug’ as small as possible. From memory this is the trickiest of them all, the rest of the Funway 2 kits had generous PCB spacing. I must admit to breaking a 470 pF ceramic capacitor, but that was my own silly fault. However at the end it all came together nicely:

txworkss

And it worked.  I have a feeling that the variable capacitor was damaged a little from heat due to the soldering process, for some insane reason DSE supplied a plastic-encased version. Later on I will replace it and see how we go. But for the meanwhile, with a 20cm aerial wire, I could get about 5 metres out of it with a brick wall in between. Considering the target market for this, that’s pretty good.

The next kit is Project Seven – Pocket Transistor Radio. This is a basic amplitude-modulation radio receiver making use of the MK484 radio-receiver IC. This is a bog-standard simple AM receiver circuit that dates back to the early 1970s. However, it is simple and uses very few parts. Originally the kit was sold without an earpiece or socket, but the last few batches included everything but the battery and a switch:

radiopartsss

Once again there were two errata sheets – one explaining the different pinouts of the MK484/ZN414 radio IC, and another showing the evolution of the radio circuit, a capacitor had been replaced with a resistor. There were a couple of tricks to assembling this kit, some pin spacings were unnecessarily close together, and the leads on the antenna coils were terribly difficult for me to discern. Thankfully the book offered some great advice – use a multimeter to determine the resistance of each coil. The coil with the lower resistance is the aerial coil, and the higher resistance is the main coil. And once again I have added a power switch. After some trepidation, the main board was finished:

rxfinishedss

Ah – where is the 9V battery? With regards to the circuit, versions as published in the book and the errata sheet are quite inefficient with regards to power usage. Let’s have a look:

radiocircuitss

As part of my electronics learning process, I like to follow the circuit through to see what is going on. The book has the power being supplied by a 9V battery, then using a 6.8V Zener diode. What was the point of that? Instead, I put a link on the PCB instead of the zener, and now the power is from a single AA cell. Much, much cheaper to run now, the receiver only draws nine milliamps of current:

And to think some people have to recharge their music players every day. The radio worked from the first time the battery was connected, and is working very well. The volume/gain is controlled by the 5k trimpot, I have this set to around half-way to a comfortable volume. The reception is highly relative to the positioning of the ferrite rod aerial, so I have locked it into place using some blutac. It receives local AM stations very well, and also some rural stations from interstate. For the price and the amount of parts, this is a very simple, easy to construct receiver with excellent power consumption – which is begging for a solar panel for daytime use. Maybe next week! So we have another success.

Update! I found another kit – the “Universal Timer”. This is basically an over-engineered 555 timer that controls a simple SPDT relay. The 555 is configured as a monostable timer, and the duration controlled by a 1 mega ohm trimpot. I have a feeling the design brief was for an egg timer, based on the illustrations:

timerbookss

Once again, the illustrations of the final product don’t bear much of a resemblance to the contents of the basic kit:

timerpartsss

Again, the PCB was quite basic and needed a good clean:

timerpcbss

Construction was quite simple, all of the parts fitted nicely where they were meant to. Not bad considering the PCB was designed around thirty years ago, and the parts are much more recent – especially the relay. To make some sort of demonstration I had to add a few extras – a power switch, the piezo buzzer, IC socket and a potentiometer instead of the trimpot:

timerfinishedss

Though once again it worked, and I actually have a use for it – a shower timer for an intelligent person who seems to forget the concept of time when in the bathroom. A quick trip to the store for a moisture-proof IP67-rated box and we’ll be set.

Unfortunately with the discontinuation of these Funway kits means another opportunity to teach people has gone. I hope you found this article interesting, and helped motivate you to expand your knowledge and those of others in the STEM (science, technology, electronics and maths) area. If you have any Funway projects to share, please get in touch. Some higher-resolution images available on flickr.

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

Posted in education, electronics, funway, history, kit review, learning electronics16 Comments

Moving Forward with Arduino – Chapter 19 – GPS part II

Learn more about Arduino and GPS in chapter nineteen of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 24/01/2013

In this instalment we will continue to examine the use of our GPS system and Arduino through creating two more applications. Some of them may seem simple, but we will build on them later on to make more complex things. To review previous information, the first GPS instalment was chapter seventeen.

“Household official time”

At home we often have various discussions about what the actual time is. At first it sounds silly, but when you have clocks on the microwave, kitchen wall, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half has all her clocks ten minutes fast. Insanity may prevail! So let’s make a nice big LED-display reference clock – something that wouldn’t look out of place in a radio or television studio:

Then when people start arguing over the time, you can point at your new clock and smile. From a hardware perspective, we will combine three or four things: our Arduino board, our GPS system, and the MAX7219 display driver. We will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • Maxim MAX7219 display driver IC
  • two four-digit, seven-segment LED displays (common cathode). You could also rig up four separate digits with some patience;
  • one 1 kilo ohm resistor
  • one 10 kilo ohm resistor
  • one single pole, double-throw switch
  • a nice breadboard and some connecting wire
  • a separate 5V power supply – all those LED segments are thirsty, the completed clock uses under 350 milliamps with a brightness setting of 8:

exam19p1currss

Here is the schematic:

exam19p1schematicss

 

Although the sketch (download) may seem quite complex, it is just made up of things we have already examined in the past. The only unfamiliar part could be the MAX7219 display driver IC, which in itself is quite easy to use. There is a full part review and explanation here. It is most likely that everyone will have different LED display units, as the 4-digit modules can be hard to track for some people or too expensive –  so some more explanation is in order.

You will need common-cathode display modules. If you line the digits up from left to right, they will be numbered zero to nine with respect to the MAX7219 – so connect MAX7219 pin 2 to the cathode of your first display, and so on. With regards to the anodes (a~g and dp [decimal point]) – link each anode type together.

For example, if you have eight separate 7-segment display modules, connect each ‘a’ pin together, then to MAX pin 14. And so on. Here is the board layout – a real mess:

exam19p1boardss

And our action video:

An interesting twist you might find of interest is the function:

Which allows you to alter the brightness of the LED display(s). The range is 0 to 18 – in my examples it has been set to 8. You could then make your clock dim the display brightness between (for example) 11pm and 5am – so when you wake up in the middle of the night the display won’t act like a frickin’  laser-beam burning into your eyeballs. Furthermore, dropping the brightness reduces the power consumption.

gps_satellite_nasa_art-iif

 “You went… where?”

Now it is time for what most of you have been waiting for – making a GPS tracking device. Now before you get too excited, it would be proper to make sure you have the permission of someone before you track them. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

Download the Example 19.2 sketch from here.

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

Although the hardware wasn’t that interesting to plug together, what can be done with it and the data it captures is quite fascinating. To generate some sample data, I have taken the hardware for a walk to the post office. We will now open the file produced by our hardware and examine it further. If you would like to follow along, you can download the file from here.

The file is a typical, comma-delimited text file. You can examine it further using common spreadsheet software such as LibreOffice Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

import

You can see that the data delimits quite easily. Just click “OK” and the file will be presented to you.

gpslogcsv

So as you can see, there is time, date (remember – GMT), latitude and longitude, my speed (with a couple of anomalies) and random sensor data results (see the sketch). We can have this data converted into a much more useful form by using the GPS Visualiser website. Save the data as a .csv file. Then visit http://www.gpsvisualizer.com/, and use the Get Started Now box in the middle of the web page. Select Google Maps as the output format, then upload the file. This will result in the following:

gpswalk

Just like normal Google Maps there are many display options you can choose from, and the GPS Visualiser web site has many tutorials about making the most of their service. If you look in detail you will see some “jittering” along parts of the track that are not representative of my movements (though I had just taken my morning coffee). This could be the result of the receiver module moving about in all three axes during my walk, one would imagine it would be a lot smoother inside a motor vehicle. So have fun with that.

LEDborder

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

Posted in arduino, COM-09622, DEV-09802, GPS, learning electronics, lesson, microcontrollers, RTL-10709, tronixstuff, tutorial2 Comments

Add a real-time clock to the Freetronics Eleven

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

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

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

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

problemss

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

schematicss

So the parts required for our clock circuit will be:

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

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

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

layoutsss

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

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

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

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

resisleadsss

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

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

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

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

backlinkss

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

toplinksss

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

i2css

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

finishedss

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


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

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

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

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

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

Posted in arduino, clocks, ds1307, freetronics, hardware hacking, learning electronics, microcontrollers, tutorial4 Comments

Quick Project – 20th Century Electronic Dice

In this tutorial we make electronic dice without using a microcontroller!

Updated 18/03/2013

After publishing an article which described the design of an electronic die (dice), one of my twitter followers said that they made them in the past just with a 555 timer IC and a 4017 logic IC. A fair point, as one does sometimes get carried away with microcontrollers sometimes. Just to show that I haven’t lost touch, here is a basic rendition of the die project again but without any of that fancy microcontroller jibber-jabber. I will just present the schematic and demonstration, however if you want to make one on some protoboard, doing so should be quite simple.

First off, here is the schematic. I really should learn to use Eagle or somesuch, but a pen and paper is so much quicker:

die1schemss

Now what is happening here? I’m glad you asked. On the left we have a 555 timer in astable mode. For more information about 555 ICs, please visit our part review. When the user presses SW1, power is applied to the 555 and it merrily sends out pulses from pin 3. To increase the speed of the pulses, decrease the values for R1 and R2.

The pulses are received into IC2, a “4017 five-stage Johnson decade counter”. [data sheet] This is still a very old yet useful IC. It has ten output pins, Q0~Q9. Every time the 4017 receives a pulse, starting from power-on or a reset, starting from Q0 it sets an output pin to high (pins default to low). We have sourced LEDs D1~D6 from the first six output pins on our 4017. So when it receives the fast pulses from the 555, it quickly blinks the LEDs in order. When the user releases SW1, the pulses stop arriving from the 555, and the 4017 stops counting – and leaves the current pin HIGH so we can read the value. And here it is in real life:

die1boardss

The parts list:

  • R1, R2 – 82k ohm resistors
  • R3 – 1.8k ohm resistor
  • C1, C3 – 100 nF polyester capacitors
  • C2 – 10nF polyester capacitor
  • D1~D6 – typical LEDs of your choice
  • IC1 – 555 timer IC
  • IC2 – 4017 CMOS counter IC
  • SW1 – normally-open button
  • 5 V power supply (use an LM7805 regulator if 5 V not available)

There are a few things to take note of if building this circuit. The 4017 IC is quite prone to static, so please take care. Furthermore, all unused output pins need to be connected to ground. (Yes, I missed that in the schematic for pin 9). And finally, you can only source 10mA per output pin, which explains the higher than usual value for R3.

Quick note: In the past we have discussed capacitors and their use for smoothing noise from DC current. The circuit above is a perfect example – the 4017 is quite susceptible to noise and will not count properly without C3 between 5V and GND.

Finally, in the spirit of this article, less is more. We could use another 555 in a monostable configuration to limit the running time of the astable 555 pulse-generating timer, but a human can do that with their digits. Furthermore, a reset button could be added onto the 4017, so that’s up to you. Finally, here it is in action:

So there. However you can now see the advantages of using a microcontroller. Each extra function or ‘trick’ created by a line or two of code with our new die could require an exponential amount of hardware, power consumption, board space and possibly a total redesign. However doing it ‘the old way’ is interesting and helps prototyping practice and troubleshooting.

But while we have all of these parts out, we’ll have a little more fun… let’s do it with an actual number being display, instead of a flurry of blinking LEDs. We still need the 555 timer to create our pulses, so that remains the same:

die2aschemss

and here is the rest of the circuit:

die2bschemss

So in this example, the 555 is sending out pulses on request via SW1. However this time, the 4518 BCD counter [data sheet] receives those pulses, counts them (from zero to nine then repeat) and converts the current value to binary-coded decimal. Next, the BCD value is sent over to the 4511 BCD to 7-segment driver IC [data sheet]. This IC converts reads the BCD and sets outputs that are suitable for driving 7-segment LED modules. These outputs are sent via 330 ohm resistors to protect the LED segments. Then finally, the digit zero to nine can be displayed on the LED unit.

With some trickery we could limit this display to the numbers 1~6, if you want to do that go for it. So in this case our ‘die’ has in fact 10 values. I’m sure there are some games that could make use of it. Anyhow, here it is in real life:

die2boardss

You may be wondering what happened to R3~R9. In this case I am using a DIP resistor array. This is just eight resistors in one package, which makes life easier.

The parts list:

  • R1, R2 – 82k ohm resistors
  • R3~R9 – 330 ohm resistors
  • C1, 100 nF polyester capacitor
  • C2 – 10nF polyester capacitor
  • D1 – common-cathode 7-segment LED display
  • IC1 – 555 timer IC
  • IC2 – 4518 CMOS counter IC
  • IC3 – 4511 BCD to 7-segment IC
  • SW1 – normally-open button
  • 5V power supply (use an LM7805 regulator if 5V not available)

And here it is in action:

You can now see why the Arduino and other microcontrollers have taken off in popularity. They really do lighten the load with regards to planning and hardware construction. However it is enjoyable to do things the old way sometimes, ergo this article. If you are interested in articles like this one that use digital electronics, please let me know via the Google Group and there will be more projects similar to this one, but in greater detail. One day I may even pull the finger out and make a TTL clock…

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 4017, 4511, 4518, 555, dice, learning electronics, tutorial2 Comments

Moving Forward with Arduino – Chapter 18 – RGB LED Matrix

Use an RGB LED matrix with Arduino in chapter 18  of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

[Updated 09/01/2013]

In this instalment we will take a turn away from the serious things for a while, (plus I wanted a bit of a break) and instead enjoy some introductory fun with common-cathode RGB LED matrices. (Matrices is the plural form of matrix). I am sure some of you have seen these do all sorts of things, so now it is time for me to learn about them and share this with you.

topss

Quite large – 60 by 60 mm. Thankfully this unit has the diffused/opaque LED surfaces – some cheaper ones have clear surfaces which don’ t look that good – it is like looking directly at an incandescent light globe, you can see the element more than the colour it emits. When you turn the matrix over, there are less pins than a newcomer may expect:

bottomss

Two rows of sixteen pins. Considering there is so much real-estate on the bottom, one would think the manufacturer could print some markings on there – but they don’t. So you need the (example) data sheet.pdf. The three most important things we need to know are:

  • the forward voltages: red – 2 V, green and blue – 3.3;
  • the current at the recommended forward voltage – 20 milliamps;
  • and the pinouts:

pinouts

It looks like a mess but isn’t that hard to work out. Do you remember how we used the 8×8 red LED matrix back in chapter nine? We will work on the same style of design in this chapter as well. I do realise there are chips from TI, Maxim and so on that are quite tricky – but I am trying to keep the cost down, of which I am sure you would appreciate. So instead we will use four 74HC595 shift registers (one to control the anodes of each colour, and one to control the cathodes via a bank of switching transistors.

To get this started, first let’s get the hardware out of the way. To fire this baby up we will need:

  • an Arduino Uno or 100% compatible board;
  • a common-cathode RGB LED matrix;
  • 24 x 560 ohm resistors (this value may seem like a bit much – but the display was still very bright)
  • 8 x 1 kilo ohm resistors (for transistors)
  • 8 x BC548 transistors
  • 4 x 74HC595 shift registers (IC1~4)
  • 1 x 1uF 16V (or higher) electrolytic capacitor
  • 1 x 0.1 uF 16V (or higher) ceramic capacitor
  • a nice large breadboard
  • plenty of connecting wire

Initially I was concerned about the amount of current this circuit would draw, however it was not to be an issue. With all the LEDs on, using the 560 ohm current-limiting resistors, the drain was much less than expected. To check, I powered the lot from a 9V PP3 battery and measured the current flow. 135 milliamps, not bad at all.

exam18p1current

It just occurred to me that if you had an Arduino Mega-compatible board – it could directly take care of everything instead of using three of the shift registers. So here is our schematic:

schematicss2

In the schematic above, there are eight transistor-resistor combinations between the cathodes of the matrix (pins 25, 24, 23, 10, 9, 8, 7 and IC4. And there are 560 ohm resistors on all output pins of ICs 1~3.  Furthermore,  note that your LED matrix’s pinouts may vary – so please check your data sheet before wiring it all up… having to retrace all those wires once they’re in is a real problem. As you can see from the resulting breadboard photo:

boardss

Now how does all this work?

Quite easily really, the hardest part is putting the hardware together. First of all, please review how we used shift registers in chapter four. And, you may recall how we used two 74HC595 shift registers to control an 8×8 red LED matrix back in chapter nine. This is just the same type of set up, but with two more shift registers – now we have one for the cathodes (as we did before), and one shift register each for the red, green and blue LEDs.

Instead of sending out two bytes of data using shiftOut();, we need to send out four bytes. For example, to turn on every LED at once (thereby mixing red, green and blue – producing white) we would create a function such as:

So as you can see, the first byte out the door is the data for the cathodes, in this case 255 – which is 11111111 in binary, or in 74HC595-speak “hey, turn on all outputs”. And the same again in turn for each bank of colours, the other three registers are told to open all gates and let current flow through the LEDs to the common-cathode lines controlled by IC4. So naturally, using some binary to base-10 conversion you can set which LEDs to come on and where. And of course, by mixing the primary colours – you can create new ones. For example, the additive colour chart gives us:

So now you can create yellow with red and green; red and blue makes purple; green and blue makes aqua or teal, etc. However I am colour blind, so you tell me. This time we will view the demonstration video first:

Download the matching sketchNow to examine how each of the effects were created, so you can understand,  use and modify them yourself.

The basic operations are contained in these four lines:

So all you need to do is replace r, b, g and c with the base-10 values you want. For example, to light up the red LED in position 1, 1 – use 1, 0, 0, 1. Or if you want the whole first line to be green, use: 255, 0, 0, 1. After a few moments you should become proficient at converting binary to base-10. This chart from chapter four should help you:

binary2

Remember that you can also create patterns and so on. For example, if you only wanted LEDs 1 and 8 for your x-axis, you would add 1 and 128 together, and use the sum (129) for your x-value. To save some time, I have created a few functions for you to use. For example:

So instead of having to manually repeat a lot of code, you can just insert the values into displayLEDs();. Another handy thing to know about is looping. When looking at the matrix it is easy to accidentally think “Oh, I can just loop from 1 to 8″… No. Remember your binary to base-10 conversions. So if you wanted to scroll a horizontal line of red LEDs your cathode or y-axis value must increment as such: 1, 2, 4, 8, 16, 32, 64, 128. Every time the loop cycles, it needs to double the value. To do this, consider:

Notice the q*=2? This will multiply the value of q by 2 every loop. Very useful. Another method would be to create an array, as such:

and refer to the elements as required. This is done within the function lostinspace(); within example 18.1.

The next thing to take into account is the screen refresh. Every time you send four bytes of data through the shift registers, those new bytes will ‘shift’ the old bytes out of the way. So if you want to alter the display even by just one LED, you need to redraw the entire display over again with four new bytes of data. Also note that to ‘hold’ an image on the display, you only need to send the data once – the shift registers will stay put until the next four bytes of data come along.

And sometimes, you might just want to turn off the display. Just send four zeros down to the registers, as the function clearMatrix(); does in the example sketch.

For now, please review the various functions found in example 18.1 – alter them, mess about and have some fun. Thus concludes our introduction to RGB LED matrices.

LEDborder

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

Posted in arduino, COM-00683, education, learning electronics, LED, lesson, matrix, microcontrollers, rgb, tutorial2 Comments

Education – Introduction to the Optocoupler

Hello everyone!

Today we are going to start examining Optocouplers. These are an interesting and quite convenient component, and relatively easy to implement.

First of all, what is an optocoupler?

It is a small device that allows the transmission of a signal between parts of a circuit while keeping those two parts electrically isolated. How is this so? Inside our typical optocoupler are two things – an LED and a phototransistor. When a current runs through the LED, it switches on  – at which point the phototransitor detects the light and allows another current to flow through it. And then when the LED is off, current cannot flow through the phototransistor. All the while the two currents are completely electrically isolated (when operated within their stated parameters!)

Let’s have a look at some typical optocouplers. Here are the schematic symbols for some more common units:

schematicsss

Switching DC current will flow from A to B, causing current to flow from C to D. The schematic for figure one is a simple optocoupler, consisting of the LED and the photo-transistor. However, this is not suitable for AC current, as the diode will only conduct current in one direction. For AC currents, we have an example in figure two – it has diodes positioned to allow current to flow in either polarity. Figure three is an optocoupler with a photodarlington output type. These have a much higher output gain, however can only handle lesser frequencies (that is, they need more time to switch on and off).

Physically, optocouplers can be found in the usual range of packaging, such as:

4n25

Notice the DIP casing doesn’t have the semi-circle moulded into one end like ICs do, so the white dot indicates pin one.

TO-78 (“Sputnik!”)

surface-mount SOIC-8

Some of you may be thinking “why use an optocoupler, I have a relay?” Good question. There are many reasons, including:

  • Size and weight. Relays are much larger, and heavier;
  • Solid state – no moving parts, so no metal fatigue;
  • Optocouplers are more suited to digital electronics – as they don’t have moving parts they can switch on and off much quicker than a relay;
  • Much less current required to activate than a relay coil
  • The input signal’s impedance may change, which could affect the circuit – using an optocoupler to split the signal removes this issue;

Furthermore, the optocoupler has many more interesting uses. Their property of electrical isolation between the two signals allows many things to be done. For example:

  • you might wish to detect when a telephone is ringing, in order to switch on a beacon. However you cannot just tap into the telephone line. As the ring is an AC current, this can be used with an AC-input optocoupler. Then when the line current starts (ring signal) the optocoupler can turn on the rest of your beacon circuit. Please note that you most likely need to be licensed to do such things. Have a look at the example circuits in this guide from Vishay: Vishay Optocouplers.pdf.
  • You need to send digital signals from an external device into a computer input – an optocoupler allows the signals to pass while keeping the external device electrically isolated from the computer
  • You need to switch a very large current or voltage, but with a very small input current;
  • and so on…

But as expected, the optocoupler has several parameters to be aware of. Let’s look at a data sheet for a very common optocoupler, the 4N25 – 4N25 data sheet.pdf – and turn to page two. The parameters for the input and output stages are quite simple, as they resemble those of the LED and transistor. Then there is the input to output isolation voltage – which is critical. This is the highest voltage that can usually be applied for one second that will not breach the isolation inside the optocoupler.

Side note: You may hear about optoisolators. These are generally known as optocouplers that have output isolation voltages of greater than 5000 volts; however some people regularly interchange optocouplers and optoisolators.

The next parameter of interest is the current-transfer ratio, or CTR. This is the ratio between the output current flow and the input current that caused it. Normally this is around ten to fifty percent – our 4N25 example is twenty percent at optimum input current. CTR will be at a maximum when the LED is the brightest – and not necessarily at the maximum current the LED can handle. Once the CTR is known, you can configure your circuit for an analogue response, in that the input current (due to the CTR) controls the output current.

needabench

Finally, the frequency, or bandwidth the optocoupler can accept.  Although this can be measured in microseconds, these parameters can be altered by other factors. For example, the higher the frequency of the current through the input stage, the less accurate the output stage can render the signal. The phototransistors can also be a function of the maximum bandwidth; furthermore if the optocoupler has a darlington output stage, the bandwidth can be reduced by a factor of ten. Here is an example shown on the old cathode-ray oscilloscope. I have set up a digital pulse, at varying frequencies. The upper channel on the display is the input stage, and the lower channel is the output stage:

Notice as the frequency increases, the ability of the output stage to accurately represent the input signal decreases, for example the jitter and the generally slow fall time. Therefore, especially working with high speed digital electronics, the bandwidth of your optocoupler choice does need to be taken into account.

Thus ends the introduction to optocouplers. I hope you understood and can apply what we have discussed today. 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.

Some information from various Isocom and Vishay data sheets and publications; various optocoupler images from element14.

Posted in 4N25, education, learning electronics, lesson, optocoupler, tutorial14 Comments

Tutorial – Arduino and EM406A GPS

Learn how to use GPS and Arduino in chapter seventeen of a series originally titled “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here. If you have a MediaTek 3329 GPS module, please visit the separate tutorial.

Updated 14/01/2014

In this instalment we will introduce and examine the use of the Global Positioning System receivers with Arduino systems. What is the GPS? In very simple terms, a fleet of satellites orbit the earth, transmitting signals from space. Your GPS receiver uses signals from these satellites to triangulate position, altitude, compass headings, etc.; and also receives a time and date signal from these satellites. The most popular GPS belongs to the USA, and was originally for military use – however it is now available for users in the free world.

Interestingly, the US can switch off or reduce accuracy of their GPS in various regions if necessary, however many people tell me this is not an issue unless you’re in a combat zone against the US forces. For more information, have a look at Wikipedia or the USAF Space Command GPS Ops Centre site. As expected,  other countries have their own GPS as well – such as Russia, China, and the EU is working on one as well.

So – how can us mere mortals take advantage of a multi-billion dollar space navigation system just with our simple Arduino? Easy – with an inexpensive GPS receiver and shield. When searching for some hardware to use, I took the easy way out and ordered this retail GPS packwhich includes the required Arduino shield and header sockets, short connecting cable and an EM-406A 20-channel GPS receiver with in-built antenna:

packcontentsss

For reference now and in the future, here is the data book for the GPS receiver: EM-406 manual.pdf. All you will need is an Arduino Uno or 100% compatible board, and the usual odds and ends. When it comes time to solder up your shield, if possible try and sit it into another shield or board – this keeps the pins in line and saves a lot of trouble later on:

howtosolderss

And we’re done:

readyfor-workss

Please notice in the photo above the cable is a lot longer between the shield and the GPS receiver. This was an extra cable, which makes things a lot more convenient, and it never hurts to have a spare. Finally, on the shield please take note of the following  two switches – the shield/GPS power switch:

shieldonoffss

and the UART/DLINE switch:

uartdliness

For now, leave this set to UART while a sketch is running. When uploading a sketch to the board, this needs to be on DLINE. Always turn off your GPS shield board before changing  this switch to avoid damage.

Is anyone out there?

Now, let’s get some of that juicy GPS data from outer space. You will need:

Once you have your hardware assembled, upload the following sketch:

Now for desk jockeys such as myself, there is a catch – as a GPS receives signals from satellites the receiver will need to be in line of sight with the open sky. If you have your desk next to a window, or a portable computer you’re in luck.  Look at the LED on your GPS receiver – if it is blinking, it has a lock (this is what you want); on – it is searching for satellites; off – it is off (!). The first time you power up your receiver, it may take a  minute or so to lock onto the available satellites, this period of time is the cold start time.

This will be in ideal conditions – i.e. with a clear line of sight from the unit to the sky (clouds excepted!). Once this has been done, the next time you power it up, the searching time is reduced somewhat as our receiver stores some energy in a supercap (very high-value capacitor) to remember the satellite data, which it will use the next time to reduce the search time (as it already has a “fair idea” where the satellites are). Now open the serial monitor box, sit back and wait a moment or two, and you should be presented with something very similar to this:

example17p1data

What a mess. What on earth does all that mean? For one thing the hardware is working correctly. Excellent! Now how do we decode these space-signals… They are called NMEA codes. Let’s break down one and see what it means. For example, the line: $GPRMC,165307.000,A,2728.9620,S,15259.5159,E,0.20,48.84,140910,,*27 Each field represents:

  • $GPRMC tells us the following data is essential point-velocity-time data;
  • 165307.000 is the universal time constant (Greenwich Mean Time) – 16:53:07 (hours, minutes, seconds). So you now have a clock as well.
  • A is status – A for active and data is valid, V for void and data is not valid.
  • 2728.9620 is degrees latitude position data = 27 degrees, 28.962′
  • S for south (south is negative, north is positive)
  • 15259.5159 is degrees longitude position data = 152 degrees, 59.5159′
  • E for east (east is positive, west is negative)
  • 0.20 is my speed in knots over ground. This shows the inaccuracy  that can be caused by not having a clear view of the sky
  • 48.84 – course over ground (0 is north, 180 is south, 270 is west, 90 is east)
  • 140910 is the date – 14th September, 2010
  • the next is magnetic variation for which we don’t have a value
  • checksum number

Thankfully the data is separated by commas. This will be useful if you are logging the data to a text file using a microSD shield, you will then be able to use the data in a spreadsheet very easily. Later on we will work with data from other codes, but if you can’t wait, here is the NMEA Reference Manual that explains them all. In the meanwhile, how can we convert the location data (longitude and latitude) received into a position on a map?

  • Visit this website
  • In the box that says “paste your data here”, enter (for example, using my data above)

For example:

visualiser

Then click “Draw the Map”, and you will be presented with a Google map in a new window that you can zoom around in, change views and so on. Interestingly enough the coordinates returned in the test above were accurate down to around three meters. Later on that website will be of great use, as you can import text files of coordinates, and it will plot them out for you. If you use this mapping site a lot, please consider making a donation to help them out. Now as always, there is an easier way. The purpose of the previous demonstrations were to see the raw data that comes from a receiver, and understand how to work with it.

gps_satellite_nasa_art-iif

Moving on… now we can receive GPS signals – and in the past we have used LCD modules – so we can make our own variations of portable (!) GPS modules and other devices. At this point you will need to install another Arduino library – TinyGPSSo download and install that before moving forward.

“My First GPS”

Using various pieces of hardware from the past, we will build a simple, portable unit to display our data.

You will need:

  • Arduino Uno or compatible board
  • a suitable GPS setup – for example the GPS shield bundle
  • An LCD with HD44780 interface that has the ability to connect to your Arduino system. The size is up to you, we’re using a 20 x 4 character unit. If you have dropped in or are a bit rusty on LCDs, please read chapter twenty-four;
  • An external power supply for your setup (if you want to walk up and down the street at midnight like I did) – for example, a 9V battery snap soldered to a DC plug is a quick and dirty solution!

Luckily I have made an LCD shield in the past which works nicely, and doesn’t use digital pins D0 and D1 – these are used by the GPS shield to get the data back to the Arduino. Therefore the whole lot just plugged in together as shields do. Here is the sketch for your consideration:

Before uploading the sketch, turn off the GPS shield, set the DLINE/UART switch on the GPS shield to DLINE, upload the sketch, then set it back again, then back on with the GPS shield. So here it is all thrown together in my lunch box:

exam17p2boxss

And a close-up view of the LCD. There was not room for the course data, but you can modify the sketch accordingly. The data will be a little off due to the photo being taken indoors:

exam17p2lcdss

Now for some outdoor fun. In the video clip below, we take a ride on the bus and see our GPS in action. I had to take an old bus that wasn’t full of security cameras, so the ride is bumpy:

sl250ss

As we have a lot of electronics in this setup, it would be interesting to know the current draw – to help plan for an appropriate power supply. The trusty meter gives us:

exam17p2currentss

Wow – a maximum of 122 milliamps even with that LCD backlight blazing away. So when we make some GPS logging devices without such a monstrous LCD, we should be able to get the current draw down a lot more. The purpose of this example was to show how you can manipulate the data from the GPS receiver.

“Household official time”

At home we often have various discussions about what the actual time is. At first it sounds silly, but when you have clocks on the microwave, kitchen wall, a wristwatch, mobile phone, clock-radio, and so on – things can get a little out of hand. And my better half has all her clocks ten minutes fast. Insanity may prevail! So let’s make a nice big LED-display reference clock – something that wouldn’t look out of place in a radio or television studio:

Then when people start arguing over the time, you can point at your new clock and smile. From a hardware perspective, we will combine three or four things: our Arduino board, our GPS system, and the MAX7219 display driver. We will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • Maxim MAX7219 display driver IC
  • two four-digit, seven-segment LED displays (common cathode). You could also rig up four separate digits with some patience;
  • one 1 kilo ohm resistor
  • one 10 kilo ohm resistor
  • one single pole, double-throw switch
  • a nice breadboard and some connecting wire
  • a separate 5V power supply – all those LED segments are thirsty, the completed clock uses under 350 milliamps with a brightness setting of 8:

 

Here is the schematic:

And the sketch:

Although the sketch may seem quite complex, it is just made up of things we have already examined in the past. The only unfamiliar part could be the MAX7219 display driver IC, which in itself is quite easy to use. There is a full part review and explanation here. It is most likely that everyone will have different LED display units, as the 4-digit modules can be hard to track for some people or too expensive –  so some more explanation is in order.

You will need common-cathode display modules. If you line the digits up from left to right, they will be numbered zero to nine with respect to the MAX7219 – so connect MAX7219 pin 2 to the cathode of your first display, and so on. With regards to the anodes (a~g and dp [decimal point]) – link each anode type together.

For example, if you have eight separate 7-segment display modules, connect each ‘a’ pin together, then to MAX pin 14. And so on. Here is the board layout – a real mess:

And our action video:

An interesting twist you might find of interest is the function:


Which allows you to alter the brightness of the LED display(s). The range is 0 to 18 – in my examples it has been set to 8. You could then make your clock dim the display brightness between (for example) 11pm and 5am – so when you wake up in the middle of the night the display won’t act like a frickin’  laser-beam burning into your eyeballs. Furthermore, dropping the brightness reduces the power consumption.

”You went… where?”

Now it is time for what most of you have been waiting for – making a GPS tracking device. Now before you get too excited, it would be proper to make sure you have the permission of someone before you track them. From a hardware perspective this example is a lot easier that you think – it is just the Arduino board, GPS shield and microSD shield. You will need to install TinyGPS library if not already installed.

Then, we will need the following items:

  • Arduino Uno or compatible board
  • the GPS shield bundle
  • microSD shield and a matching memory card up to 2GB in size
  • portable power, for example an alkaline 9V PP3 battery and adaptor cable

And here is the sketch:

Don’t forget to format the microSD card to FAT16 before use. Once power is applied, the system will take a position reading and write it to the microSD card every 30 seconds. You can alter this period by changing the value in the delay() function at the end of  void getgps(TinyGPS &gps). The text file is closed after every write, so you can just turn it off when finished then take the memory card to the computer to copy the data.

Although the hardware wasn’t that interesting to plug together, what can be done with it and the data it captures is quite fascinating. To generate some sample data, I have taken the hardware for a walk to the post office. We will now open the file produced by our hardware and examine it further. If you would like to follow along, you can download the file from here.

The file is a typical, comma-delimited text file. You can examine it further using common spreadsheet software such as LibreOffice Calc. For example, if you open the file of GPS data from here, you will be presented with the following window:

You can see that the data delimits quite easily. Just click “OK” and the file will be presented to you.

So as you can see, there is time, date (remember – GMT), latitude and longitude, my speed (with a couple of anomalies) and random sensor data results (see the sketch). We can have this data converted into a much more useful form by using the GPS Visualiser website. Save the data as a .csv file. Then visit http://www.gpsvisualizer.com/, and use the Get Started Now box in the middle of the web page. SelectGoogle Maps as the output format, then upload the file. This will result in the following:

Just like normal Google Maps there are many display options you can choose from, and the GPS Visualiser web site has many tutorials about making the most of their service. If you look in detail you will see some “jittering” along parts of the track that are not representative of my movements (though I had just taken my morning coffee). This could be the result of the receiver module moving about in all three axes during my walk, one would imagine it would be a lot smoother inside a motor vehicle. So have fun with that.

LEDborder

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

Posted in arduino, beginnner, education, GPS, GPS-09123, learning electronics, lesson, microcontrollers, RTL-10709, tutorial13 Comments

Moving Forward with Arduino – Chapter 16 – Ethernet

Use Ethernet with Arduino in chapter sixteen of “Getting Started with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

[Updated 09/01/2013]

In this instalment we will introduce and examine the use of Ethernet networking with Arduino systems. This tutorial covers receiving data from an Arduino over the Internet. If you are interested in controlling an Arduino over the Internet, see here. It will be assumed that you have a basic understanding of computer networking, such as the knowledge of how to connect computers to a hub/router with RJ45 cables, what an IP and MAC address is, and so on. Furthermore, here is a good quick rundown about Ethernet.

First of all, you will need an Ethernet shield. There are a few on the market, such as the original version by the Arduino team. Readers of my articles will know my preference is for the Australian-designed Freetronics line of hardware, so I will be using their EtherTen – which combines an Arduino Uno-compatible board with an Ethernet shield. Plus it also has some interesting power-over-Ethernet features which you can read about here. However as long as your Arduino Ethernet shield has the W5100 controller IC – you’re fine.

Now, let’s get started!

This is an ethernet shield on top of an Arduino-compatible board. Nothing new here – just a nice RJ45 socket which you connect to your router/hub/modem with a patch lead:

shieldbss

First of all, let’s do something quick and easy to check that all is functional. Open the Arduino IDE and select File > Examples > Ethernet > Webserver. This loads a simple sketch which will display data gathered from the analogue inputs on a web browser. However don’t upload it yet, it needs a slight modification.

You need to specify the IP address of the ethernet shield – which is done inside the sketch. This is simple, go to the line:

And alter it to match your own setup. For example, in my home the router’s IP address is 10.1.1.1, the printer is 10.1.1.50 and all PCs are below …50. So I will set my shield IP to 10.1.1.77 by altering the line to:

You also have the opportunity to change your MAC address. Each piece of networking equipment has a unique serial number to identify itself over a network, and this is normall hard-programmed into the equipments’ firmware. However with Arduino we can define the MAC address ourselves. If you are running more than one ethernet shield on your network, ensure they have different MAC addresses by altering the hexadecimal values in the line:

However if you only have one shield just leave it be. There may be the very, very, statistically rare chance of having a MAC address the same as your existing hardware, so that would be another time to change it. Once you have made your alterations, save and upload the sketch to your Arduino or compatible board. If you haven’t already, disconnect the power and add your Ethernet shield.

Now, connect the shield to your router or hub with an RJ45 cable, and the Arduino board to the power via USB or external power supply. Then return to your computer, and using your web browser, enter your Ethernet shield’s IP address into the URL bar. The web browser will query the Ethernet shield, which will return the values from the analogue ports on the Arduino board, as such:

As there isn’t anything plugged into the analog inputs, their value will change constantly. Neat – your Arduino is now serving data over a network. It is quite motivating to see it actually work.

At this point – please note that the Ethernet shields use digital pins 10~13, so you can’t use those for anything else. Some Arduino Ethernet shields may also have a microSD card socket, which also uses another digital pin – so check with the documentation to find out which one. If you are considering using an Arduino Mega and Ethernet – check out the EtherMega.

Nevertheless, now that we can see the Ethernet shield is working we can move on to something more useful. Let’s dissect the previous example in a simple way, and see how we can distribute and display more interesting data over the network. For reference, all of the Ethernet-related functions are handled by the Ethernet Arduino library. If you examine the previous sketch we just used, the section that will be of interest is: