Posts | Comments

Planet Arduino

Archive for the ‘oscilloscope’ Category


Arduino LCD Oscilloscope

arduino, KS0108, LCD, oscilloscope, PIC18F2550, Test/Measurements Commenti disabilitati su Arduino LCD Oscilloscope 

IMG_4199 writes:

It has been 7 years (!) since I posted my PIC18F2550 KS0108 Graphical LCD Oscilloscope code and schematics. I have long since taken the circuit apart, sold my PIC microcontrollers, and moved on in my life (as one can surmise from my most recent posts detailing my graduate and postdoctoral work). However, I still get inquiries about the Microchip PIC oscilloscope, so I decided to recreate it using a simpler setup using my Arduino Fio.


Arduino LCD Oscilloscope - [Link]

Hello readers

Today we are going to examine the Texas Instruments TLC5940 16-channel LED driver IC. My reason for doing this is to demonstrate another, easier way of driving many LEDs as well as LED display modules that are common-anode. If you have a common-cathode display module, you should have a look at the Maxim MAX7219. Moving along, here is the IC:

Another nice big DIP IC. Also available in HTSSOP and QFN packaging. What can this IC do for us? It can control 16 LEDs per IC, and also be cascaded to control more and more, with the display data arriving via a serial line in the same manner as a 74HC595 shift register. Furthermore, another benefit of this IC is that you don’t need matching current-limiting resistors for your LEDs, as this IC is a current sink, in that the current flows from the 5V rail, through the LED, then into the IC. However, it can control the brightness of the LEDs using pulse-width modulation over 4096 steps via software, or using a single resistor.

What is pulse-width modulation? Normally an LED might be on, or off. But if you switch it on and off very quickly, it does not look as bright (as it is not on 100% of the time). If you alter the period of time between on and off, you can alter the perceived brightness of the LED. Here is an example, compare the brightness of the LED bars against the display of the CRO – as the brightness increases, the voltage (amplitude [vertical thickness]) spreads across the entire time period (horizontal axis); as the brightness decreases, the voltage spread across time retreats:

Using the IC is very easy on the hardware front. Here is the data sheet: TLC5940.pdf. The pinout diagram is quite self-explanatory:

Pins OUT0~OUT15 are the current-sink pins for each LED. When one is selected they allow current to flow into the IC from the 5V rail, with the LED in between – turning it on. However it is easier to understand with a practical example, such as this (click to enlarge):

Here we have our Arduino board or compatible sending serial data to the TLC5940 to control sixteen LEDs. The 2k ohm resistor is required to set the maximum current available to flow through the LEDs, thereby adjusting their brightness. Using software you can adjust the brightness with PWM for each LED by itself. Very important: this circuit will need external power into the Arduino or a separate 5V power supply. The circuitry on the breadboard draws up to ~318 mA by itself – running the Arduino from USB only made it somewhat flaky in operation. Here is the circuit in action with an ammeter between the breadboard and 5V out on the Arduino:

Anyhow, let’s get moving once more – here is the assembled demonstration circuit:

For our example, we will be using the Arduino way of doing things. Thankfully (once more) there is a library to make controlling the IC exponentially easier. The library page and download files are available from here; the documentation page is here.  If you need guidance on installing a library, please visit here. However the commands to control the IC are quite simple with the Arduino library.

First of all, include the TLC5940 library, as such:

#include “Tlc5940.h”

Then in void setup(); you create the object using the function:


You can insert a number between 0 and 4095 to set the starting PWM (LED brightness) value, however this is optional.

Setting an output for display requires two functions, first Tlc.set(l, p); where l is the output (0~15) and p is the PWM brightness level – then execute Tlc.update(); which sends the command to the IC to be executed. The sketch below is easy to follow and understand the process involved.

Moving forward with the demonstration, here is the sketch  – TLC5940demo.pdf, and the video clip of operation:

When the LEDs are glowing from dim to bright and return, we are altering the PWM value of the LEDs to adjust their brightness. This also occurs during the last operation where the LEDs are operating like the bonnet of KITT.

Well once again that’s enough blinkiness for now, again this is another useful IC that helps simplify things and be creative. As always, avoid the risk of counterfeit ICs  – so please avoid disappointment, support your local teams and buy from a reputable distributor. Living in Australia, mine came from Farnell (part number 1226306). So have fun!

Remember, if you have any questions at all please leave a comment (below). We also have a Google Group dedicated to the projects and related items on the website – please sign up, it’s free and we can all learn something. High resolution photos are available from flickr.

Otherwise, have fun, stay safe, be good to each other – and make something! :)

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

Hello everyone

Today we are going to continue exploring alternating current, with regards to how resistors and capacitors deal with AC. This chapter is part two, chapter one is here.

To help with the explanations, remember this diagram:

That is, note that there are three possible voltage values, Vpp, Vp and Vrms. Moving on. Alternating current flows through various components just like direct current. Let’s examine some components and see.

First, the resistor. It operates in the same way with AC as it does DC, and the usual calculations apply with regards to Ohm’s law, dividing voltage and so on. However you must keep in mind the type of voltage value. For example, 10Vrms + 20Vpp does NOT equal 30 of anything. But we can work it out. 20Vpp is 10Vp,  which is 7.07Vrms… plus 10Vrms = 17.07Vrms. Therefore, 10Vrms + 20Vpp = 17.07Vrms.

Furthermore, when using Ohm’s law, or calculating power, the result of your equation must always reflect the type of voltage used in the calculations. For example:

Next, the capacitor. Capacitors oppose the flow of alternating current in an interesting way – in simple terms, the greater the frequency of the current, the less opposition to the current. However, we call this opposition reactance, which is measured in ohms. Here is the formula to calculate reactance:

the result Xc is measured in Ohms, f is frequency is Hertz, and C is capacitance in Farads. Here are two examples – note to convert the value of the capacitor back to Farads

Also consider if you have identical frequencies, a smaller capacitor will offer a higher resistance than a larger capacitor. Why is this so? A smaller capacitor will reach the peak voltages quicker as it charges in less time (as it has less capacitance); wheras a larger capacitor will take longer to charge and reach the peak voltage, therefore slowing down the current flow which in turn offers a higher reactance.

Resistors and capacitors can also work together as an AC voltage divider. Consider the following schematic:

As opposed to a DC voltage divider, R2 has been replaced with C1, the 0.1 uF capacitor. In order to calculate Vout, we will need the reactance of C1 – and subsitute that value for R2:

However, once the voltage has been divided, Vout has been transformed slightly – it is now out of phase. This means that Vout oscillates at the same frequency, but at different time intervals than Vin. The easiest way to visualise this is with an oscilloscope, which you can view below:

Please note that my CRO is not in the best condition. In the clip it was set to a time base of 2 milliseconds/division horizontal and 5 volts/division vertical.

Thus ends chapter two of our introduction to alternating current. I hope you understood and can apply what we have discussed today. 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, you can either leave a comment below or email me – john at tronixstuff dot com.

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 and post your questions there.

Otherwise, have fun, be good to each other – and make something! :)

Hello everyone!

Today we are going to introduce the basics of AC – alternating current. This is necessary in order to understand future articles, and also to explain in layperson’s terms what AC is all about. So let’s go!

AC – Alternating Current. We see those two letters all around us. But what is alternating current? How does current alternate? We know that DC (direct current) is the result of a chemical reaction of some sort – for example in a battery, or from a solar cell. We know that it can travel in either direction, and we have made use of it in our experimenting. DC voltage does not alter (unless we want it to).

Therein lies the basic difference – and why alternating current is what is is – it alternates! :) This is due to the way AC current is created, usually by a generator of some sort. In simple terms a generator can be thought of as containing a rotating coil of wire between two magnets. When a coil passes a magnet, a current is induced by the magnetic field. So when the coil rotates, a current is induced, and the resulting voltage is relative to the coil’s positioning with the magnets.

For example, consider the diagram below (exploded view, it is normally more compact):

This is a very basic generator. A rotating coil of wire is between two magnets. The spacing of the magnets in real life is much closer. So as the coil rotates, the magnetic fields induce a current through the coil, which is our alternating current. But as the coil rotates around and around, the level of voltage is relative to the distance between the coil and the magnet. The voltage increases from zero, then decreases, then increases… as the coil constantly rotates. If you were to graph the voltage level (y-axis) against time (x-axis), it would look something like below:

That graph is a sine wave… and is a representation of perfect AC current. If you were to graph DC voltage against time, it would be a straight horizontal line. For example, compare the two images below, 2 volts DC and AC, shown on an oscilloscope:

2 volts DC

The following clip is 2 volts AC, as shown on the oscilloscope:

So as you can see, AC is not a negative and positive current like DC, it swings between negative and positive very quickly. So how do you take the voltage measurement? Consider the following:

The zero-axis is the point of reference with regards to voltage. That is, it is the point of zero volts. In the oscilloscope video above, the maximum and minimum was 2 volts. Therefore we would say it was 2 volts peak, or 2Vp. It could also be referred to as 4 volts peak to peak, or 4Vpp – as there is a four volt spread between the maximum and minimum values of the sine wave. There is another measurement in the diagram above – Vrms, or volts root mean squared. The Vrms value is the amount of AC that can do the same amount of work as the equivalent DC voltage. Vrms = 0.707 x Vp; and Vp = 1.41 * Vrms. Voltages of power outlets are rated at Vrms instead of peak as this is relative to calculations. For example, in Australia we have 240 volts:

DO NOT do this

Well, close enough. In fact, our electricity distributor says we can have a tolerance of +/- 10%… some rural households can have around 260 volts. Moving on…

The final parameter of AC is the frequency, or how many times per second the voltage changes from zero to each peak then back to zero. That is the time for one complete cycle. The number of times this happens per second is the frequency, and is measured in Hertz (Hz). The most common frequency you will hear about is your domestic supply frequency. Australia is 50 Hz, the US is 60 Hz, etc. In areas that have a frequency of 60 Hz, accurate mains-powered time pieces can be used, as the seconds hand or counter can be driven from the frequency of the AC current.

The higher the frequency, the shorter the period of time taken by one cycle. The frequency and time are inversely proportional, so frequency = 1/time; and time – 1/frequency. For example, if your domestic supply is 50 Hz, the time for each cycle is 1/50 = 0.02 seconds. This change can be demonstrated quite well on an oscilloscope, for example:

In the video above there is 2 volts AC, and the frequency starts from 100 Hz, then moves around the range of 10 to 200 Hz. As you can see, the amplitude of the sine wave does not change (the height, which indicates the voltage) but the time period does alter, indicating the frequency is changing. And here is the opposite:

This video is a demonstration of changing the voltage, whilst maintaining a fixed frequency.

Thus ends the introduction to alternating current. In the next instalment about AC we will look at how AC works in electronic circuits, and how it is handled by various components.

I hope you understood and can apply what we have discussed today. 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 and post your questions there.

Otherwise, have fun, be good to each other – and make something! :)


An oscilloscope.

[update: usage photos 12/05/2010]

Since returning to the world of electronics and general gadgetry, an oscilloscope has always been on my shopping list. However, they are not cheap. Sure, I could get a second-hand one from eBay, but here in Australia there are not that many floating around; the used ‘scopes are generally ex-defence or education and looked pretty whipped. However, being an impatient person a kit from JYETech (the same people who make the capacitance meter kit I reviewed in March) really grabbed my imagination – a kit digital oscilloscope! Cheap, low specification, but interesting nevertheless. After thinking about it too much, and after watching all the youtube videos about it… I ordered one.

Let’s see what happens…

After a week my parcel arrived. Once again JYE Tech have not spared any expense on the packaging for the actual kit, just enough for everything to be safe.

The kit has some nice panels, front and rear, and a great solder-masked, silkscreened PCB. Thankfully I ordered the version that had the SMD components already soldered. (This kit is available in three versions: full kit, SMD soldered, and totally assembled [not really a kit...!]).

And time to check all the pieces have been included. There is no list inclued, so you have to check off against the BOM from the JYE Tech website for your particular version of the kit. This is not a kit you can just jump into and solder…

The instructions are very… sparse, confusing and time-consuming. One double-sided A4 piece of paper, one side with the schematic, and the other with a “quick reference”, internet links to support and a photo of the populated PCB. Thankfully, the JYETech website has all the documentation ready for download, and they also run a very well supported Google Group. Phew. They even publish the .dxf CAD files. So after downloading and printing off all of the documentation, it was time to review it and have lunch.

There is an amusing line in the instructions – “you will probably need to make a simple probe”. Yes, indeed. Included are enough parts to make a simple probe – with alligator clips at the end. Let’s call them semi-useful. They will do for the meanwhile, however a real probe set will be ordered shortly.

Anyhow, enough preparation and reading. Time to build. NOTE: There are several versions of this kit – please double-check you have the correct assembly instructions. Look at your PCB – there is a white sticker on the edge with a code such as “06202KP…”  - make sure that you have the correct sheet for your kit. There is no guarantee the correct sheet will ship with the meter!

Thankfully due to the SMD nature of most of the parts, there isn’t that much to solder. Firstly, I wanted to get the 7805 regulator and heatsink in:

… and the rest of the parts – 7 capacitors, a diode and an inductor. You really need to have your wits about you – there are places on the PCB and parts in the schematic for which you are not to use – it is easy to get lost if you don’t concentrate. Just remember to match the physical components supplied against the BOM from the website, and only install those – after considering the assembly instructions. Another caveat is that you need to check you have the correct documentation for your PCB. For example, mine was a 06202KP, whereas the website had something different. Thankfully the Google Group had the correct .pdf file.

Remember that positive pins of capacitors into square pads. There seems to be an ambiguity in the instructions regarding C14 – for the 06202 model, C14 positive is on the right hand side.

Next, the sockets for signal and DC, switches and push buttons. You need to get the switches and buttons flush with the PCB, otherwise you will have issues with the top panel and button caps.

Don’t forget the 2×4 pin header – solder it in before the LCD! Now for the LCD.

Stop now. Make sure you run the power tests as per the assembly instructions. Once that LCD is soldered in, having to take it out again will be a huge PITA.

When you look at the rear of the LCD module, there are two rows of 20 holes – solder the row of pins into the row with markings (GND~NC). I found the easiest way to do this was to sit the row of pins into the main PCB, sit the LCD on top and solder the pins into the LCD module. The solder in the 2 pairs of pins that support the LCD. You may find the heatsink blocks one of the pins – just cut one pin off and use that then.

Now it is seven hours later. To cut a long story short – be very careful when soldering the LCD pins. It is very easy to cause a bridge which will wreak havoc and short out something, which cooks the LCD, 7805 and the microprocessor. If your unit heats up like a stove, unplug it and triple check your soldering under a magnifying glass. Run continuity tests to be sure you haven’t shorted out anything.

But thankfully – after all my time working on it, hunched over a hot iron in a dark room, and staring through a magnifying glass:

Woohoo! We have life!

I had that heatsink on just in case  - didn’t take it off for the photo. Now it is time to assemble the body and make it look presentable:

And of course … I’ll need a set of probes. So I assembled them using the parts included in the kit. They will have to do until my real one arrives.

Finally – I can clean up the desk and wash my hands. Originally I was going to write a whole section explaining how oscilloscopes work and the terminology. But thankfully the good people at Tektronix have done this already and made a nice little e-book for us. So here it is: XYZs of Oscilloscopes (Tektronix) PDF.

Now, let’s spend some time examining what this baby can do. Just a note at this point, if you didn’t install the heatsink, you should install a clip-on heatsink over the 7805. After sitting on my desk for around 30 minutes the 7805 does get warm.

[update] Here are some photos of the scope in use:

14.2 volts AC. The scope should have displayed the minimum and maximum, but for some reason has clipped them.

In order to see half of the full wave, the V.POS was lowered to the minimum. This is indicated by the tiny marker at the bottom left of the LCD

Again with V.POS at the minimum, the time period was altered, and the display frozen to see the maximum.

5 volts DC at 5 volts per division

5 volts DC at 2 volts per division

By dropping V.POS to the minimum, you can increase the maximum amplitude possible. Note the tiny marker at the bottom-left of the screen, indicating the new 0V line.

5 volts DC using 1 volt per division.

2 volts DC at 0.5 volts per division (using x5 and 0.1 settings)

1.25 volts DC at 0.5 volts per division

By default it shows 50Hz as that is the frequency of mains voltage in Australia (probes not connected, it gets the default frequency through the power supply [Australia is 240V 50 Hz]).

And now for a video, a short compilation of various measurements: DC voltage, frequency, FFT and pulse-width modulation.

You can also upgrade the firmware and save screen shots if you attach a cable to the jumpers on the rear of the main PCB. If you were to do this often enough, it would be wise to cut a rectangle out of the back panel.


To be honest, I found this kit very challenging to assemble, finding the correct instructions the second time around was very frustrating, and the documentation is very poor. This is not a kit for beginners, more of a curiosity for those experienced in electronics work and fault-finding. In saying that, I’m glad I had a go – assembling and getting it to work taught me a lot about my own abilities, fault-finding, and tested my patience. But it gave me a real buzz once I got it working.

It was rather annoying to use such a low screen resolution, you won’t be detecting too much ripple on your DC power supplies with this one. But for the price, it is an interesting piece of gear. I will probably end up giving it away as a prize or something. It has a maximum of 50 volts peak to peak input amplitude, but I couldn’t for the life of me hone the display down to show 12 volts AC without cutting off the minimum and maximum. Will persevere and spend more time with it.

Furthermore, it is a good stepping stone to acquiring a full oscilloscope – if you find yourself using this one and getting frustrated with the limitations, it’s time you bought a full ‘scope!

This kit is available from a variety of sources, and Little Bird Electronics has all three variants available in stock.

Thank you for reading and I look forward to your comments and so on. High resolution photos are available on flickr.

Please subscribe (see the top right of this page) to receive notifications of new articles. If you have any questions at all please leave a comment (below).

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

  • Newsletter

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

  • Like Us on Facebook