Instructables

Make an Oscilloscope Using the SainSmart Mega2560 with the TFT LCD shield and the 3.5 "color touch screen

FeaturedContest WinnerContest Winner
Picture of Make an Oscilloscope Using the SainSmart Mega2560 with the TFT LCD shield and the 3.5
megascope2.jpg
WP_20140406_007.jpg
WP_20140406_004.jpg
megascope1.jpg

This instructable will show you how to build a portable Touch Screen
Oscilloscope for less than 40 U$!


The oscilloscope is one of the most powerful electronic instruments that
is available to electronics hobbyist, experimenters, and engineers. It is
mainly used to measue time-varying signals. Any time you have a signal
that varies with time( slowly, quickly, and /or periodically ) you can use
an oscilloscope to measure it , visualize it, and to find any unexpected
features in it.

We can use an oscilloscope to observe and study signal characteristics
that we could otherwise not see .

You will learn about the Arduino mega analog to digital converter( ADC).

We will be using the Arduino analog A0 input to sample and capture time
varying signals by Writing a program that will also display those signals
in a 3.8" TFT LCD touch display, and we will input data to modify the
oscilloscope behavior, using the touch capabilities of the screen display.

Before we start building and programming, lets review some basic
characteristics of an oscilloscope.

These are functions you can control on most oscilloscopes:

Sweep speed. Sweep speed is usually measured in units of time per distance,
like milliseconds/centimeter or milliseconds per division.This might also
be referred to as the horizontal sensitivity.

Vertical sensitivity. That's the measure of how sensitive the display dot
is to voltage applied to the input terminals. It is usually measured in
volts/centimeter or volts per division.

A trigger signal can be generated when the signal value reaches some
particular level - the trigger level. In most cases you can set the trigger
level to a voltage value of your choosing. A trigger is used to capture and
stabilize the waveform on the screen, or to wait for an event before
capturing the data
.
The oscilloscope, like my 4 channel DC DVM, will not be as accurate as
a commercial unit, but it works pretty good for low voltage and low frequencies.

 
Remove these adsRemove these ads by Signing Up
1-40 of 65Next »

An excellent article!

I will be looking for a tft for my mega!

What sort of refresh rate do you think your tft has?

Have you considered reading the analogue port by interrupt-

I have a 153K oscilloscope design using a mega with hardware and software triggering.

http://www.instructables.com/id/Arduino-High-speed...

It would be interesting to bring the two concepts together.

johnag (author)  DavidPatterson2 months ago

Sorry for the delay in responding. Thanks for your comment. I don't know the refresh rate of the screen, haven't checked the specs in detail. It would definitely improve the scope if you could increase the bandwidth by using your design. If you get the kit and try your concepts on it , please share.. If I have time I might try it myself..Again thanks.

The 3.2 inch screen and Shield finally arrived. I used my Mega rather than the Sainsmart.

Assembly was easy- I added connecters for the analogue port, pwm10, zero and 5V. Programming was not difficult- Henning, the library author has excellent documentation. I found no issues in implementing his protocols.

My scope runs at up to 237-238 Khz.

The sdcard reader which is on the shield, works and opens up the possibility of data saving. (Not to mention adding pictures)

This has produced a very nice stand alone oscilloscope.

Thanks for your work.

connections.jpgendview.jpginfo.jpgrun.jpgstartup2.jpginsidebox2.jpg

How did you add images ?

Hi,

For this application I used
Henning's loadBitmap function- which is documented in the examples
supplied with his library. This requires that you convert a screen sized
(or less) picture to raw format. He supplies a program with his library
download for this. Or you can use his online converter at :

http://www.henningkarlsen.com/electronics/t_imagec...

I used a screen sized (320 x 240) file.

#include <tinyFAT.h>
#include <UTFT.h>
#include <UTFT_tinyFAT.h>
#include <UTouch.h>

// Initialize Screen and touch functions
UTFT myGLCD(ITDB32S,38,39,40,41);
UTFT_tinyFAT myFiles(&myGLCD);
UTouch myTouch(6,5,4,3,2);
boolean logo = true;

word res;

const int chipSelect = 53; // sd select pin

void setup(){

pinMode(chipSelect, OUTPUT);

myGLCD.InitLCD();
myGLCD.clrScr();

int picsize_x = myGLCD.getDisplayXSize();
int picsize_y = myGLCD.getDisplayYSize();

if (logo){
if (file.initFAT()==0){
switch (picsize_x);
res = myFiles.loadBitmap(0, 0, picsize_x, picsize_y, "LOGO.RAW");
if (res == 0){
delay(5000);
myGLCD.clrScr();
}

}

}

// more setup stuff

}

The use of the raw file for a one off display is fine.

However
having to convert multiple files seemed a little time consuming to me.
So I wrote an addition to the Henning's utft library to process 24 bit
bmp files directly. This works great and does not require UTFT_tinyFat
and tinyFat. The sdcard can be accessed using the standard arduino sd
library. My patch will load a screen sized bitmap in 1.79S, which is a
little faster than Henning's system.

I have also utilised the sd for data recording.

All in all John has detailed a very useful shield and lcd!

Hi,

I ordered the lcd a month ago- apparently it is somewhere between China and the uk.

In the mean time I have developed code which runs at

237.3 Khz, with configurable software triggering.

http://forum.arduino.cc/index.php?PHPSESSID=3e1pvs...

I have also written software which runs at 1.2MHz using a TLV571, also with software triggering.

Whitmore12 made it!2 months ago

Great Instructable! It got me thinking and I decided to make my own PipBoy from it!

MyPipBoy.jpgOscilloscope.jpgPipboyOscope.jpg
johnag (author)  Whitmore122 months ago
Cool, thanks forsharing..
grumpyboots made it!8 months ago

neato! thanks, maybe ill see what uses i can for this

Photo on 2014-04-20 at 5.51 PM.jpg
johnag (author)  grumpyboots8 months ago

Cool grumpyboots.. thanks for sharimg!

mimhs23 days ago

I made it. Good tutorial-impressive work. Thank you.

Hamzaikky1 month ago

Can this program work on aurdino UNO aswell ? how many pins does the lcd shied have ?

Looks more complicated the it is. The Lego enclosure is a nice touch!

johnag (author)  peter.kocsis.779641 month ago

thannks..:)

guys my library shows a problem in this line UTFT myGLCD (ITDB24E_16,38,39,40,41). with the following Message: UTF does not name a type. can someone help me?

johnag (author)  Rogério Santana4 months ago

Make sure you have the library properly instaled and that you run the demo programs, as described in steps. 4 and 5 before loading the oscpe sketch

johnag (author)  Rogério Santana4 months ago

if you are usimg the sainsmart kit the line should read::

UTFT myGLCD(ITDB32S,38,39,40,41);

what does ('UTFT' does not name a type) mean I get this when I told it to load the sketch.

Jim

UTFT myGLCD(ITDB32S,38,39,40,41);

rroque55 months ago

Is to do this using a nano aruino v3.0?

johnag (author)  rroque55 months ago

I don't.think. so, sorry

rroque5 johnag5 months ago

Thanks!

alejandroym937 months ago

Nice work! Only one thing, how did you solved the problem of the negative part of the signal when you plug in the function generator?

johnag (author)  alejandroym937 months ago

check tis instructabel to giv you an idea:

How to make an Arduino oscilloscope probe by NeoRecasata

http://m.instructables.com/id/How-to-make-an-Arduino-oscilloscope-probe/

indeed it graph most part of the signal with the probe, but it keeps cutting a minimum part of the signal.

johnag (author)  alejandroym937 months ago

the signal needs to be "conditioned " to be between 0 and 5 volts before it is input into the arduino analog input. You may need to attenuate the signal and float it on a dc voltage. Use two resistors in series connect one end to ground and the other to the 5 volt arduino pin, connect a capacitor to the junction and to your function generator. Connect a jumper from the junction to the analog pin. This will float the waveform on a dc of 2.5 volts. You can use two 1 meg resistors and a .47 micro farad capacitor. Remember the voltage. From your function generator has to be 5 volts peak to peak,if it is not, you. Will need to attenuate it using a potentiometer..

thank you a lot man, it worked perfectly:)

johnag (author)  alejandroym937 months ago

glad to help...click the I made it button and share a picture if you want...

johnag (author)  alejandroym937 months ago
Use a voltage divider and a capacitor at the input.
Jan_Henrik7 months ago

Awesome project, I love it!!!

johnag (author)  Jan_Henrik7 months ago

thanks...you've got some awesome projects too!

Jan_Henrik johnag7 months ago

Thank you! :)

Mr. E7 months ago

Nicely done ! Something every work bench should have.

johnag (author)  Mr. E7 months ago

Thanks Mr. E, By the way, I tried your http://www.instructables.com/id/Donut-Protection-Device-Advanced-Arduino-Technique/ , another awesome project, thanks for sharing

OK I see where the pins go, from the PDF it did not show this and now looking at your design on the Instructables Interweb site I must have been off in well thanks and sorry to have bothered you.

Jim

murfmv7 months ago

Johnag, Thought I was having trouble compiling because of different Arduino versions, but then realized where are the libraries after the include statement and also problems cutting and IDE code. It's up and running and can't to test something. Always wanted an oscilloscope, now I have one and will be following ur blog.

Great Job!!

johnag (author)  murfmv7 months ago

Glad you worked out the problem. Take a picture, and click on the I made it button! Have fun using it.

dustint20048 months ago

Sooo. If you have specific parameters already set.

Does PC still need to be connected to test or capture data?

johnag (author)  dustint20047 months ago

no it doesn't need to be connected to the PC, and you can vary some of the parameters with the touch screen buttons.

murfmv7 months ago

Hello Johnag,

Great thing I'm unable to compile your program in version 1.05 after running the TFT examples. I've gotten no errors, but suspect that might be the problem. I'm certainly looking forward making this work!

1-40 of 65Next »