+ All Categories
Home > Documents > Make an Oscilloscope Using the SainSmart Mega2560

Make an Oscilloscope Using the SainSmart Mega2560

Date post: 09-Oct-2015
Category:
Upload: mariusdanila8736
View: 372 times
Download: 15 times
Share this document with a friend
Description:
Make an Oscilloscope Using the SainSmart Mega2560
Popular Tags:

of 21

Transcript
  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Food Living Outside Play Technology Workshop

    Make an Oscilloscope Using the SainSmart Mega2560 with the TFT LCD shieldand the 3.5 "color touch screenby johnag on July 19, 2013

    Table of Contents

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

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

    Step 1: UPDATE: Sketch to convert Oscope to 3 Channel DVM with graphic display + Lego enclosure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    Step 2: Parts list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    Step 3: Build the hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    Step 4: The software: UTFT library test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Step 5: The software: UTouch library test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    Step 6: The Oscilloscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    Step 7: Video of the Oscope in action . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Step 8: Another video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Advertisements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    How to make an Arduino oscilloscope probe by NeoRecasata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Intro: Make an Oscilloscope Using the SainSmart Mega2560 with the TFT LCD shield and the 3.5 "color touch screenThis instructable will show you how to build a portable Touch ScreenOscilloscope for less than 40 U$!The oscilloscope is one of the most powerful electronic instruments thatis available to electronics hobbyist, experimenters, and engineers. It ismainly used to measue time-varying signals. Any time you have a signalthat varies with time( slowly, quickly, and /or periodically ) you can usean oscilloscope to measure it , visualize it, and to find any unexpectedfeatures in it.

    We can use an oscilloscope to observe and study signal characteristicsthat 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 timevarying signals by Writing a program that will also display those signalsin a 3.8" TFT LCD touch display, and we will input data to modify theoscilloscope behavior, using the touch capabilities of the screen display.

    Before we start building and programming, lets review some basiccharacteristics 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 alsobe referred to as the horizontal sensitivity.

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

    A trigger signal can be generated when the signal value reaches someparticular level - the trigger level. In most cases you can set the triggerlevel to a voltage value of your choosing. A trigger is used to capture andstabilize the waveform on the screen, or to wait for an event beforecapturing the data.

    The oscilloscope, like my 4 channel DC DVM, will not be as accurate asa commercial unit, but it works pretty good for low voltage and low frequencies.

    Image Notes1. Triangle Wave from 555 Multivibrator2. Delay touch button3. Trigger touch button4. Horizontal position touch button5. Reserved for menu or vertical sensitivity6. Voltage peak to peak7. Instantaneous voltage8. Sample capture time display9. 555 IC circuit running as astable multivibrator10. LM317 variable voltage regulator11. Jumper wirer from A0 used as test probe12. jumper wire From GND pin, connect to ground of circuit under test.13. USB cable connected to Computer14. Sainsmart ArduinoMega with shield and TFT LCD touch Display kit

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Step 1: UPDATE: Sketch to convert Oscope to 3 Channel DVM with graphic display + Lego enclosureThank you to all who voted for me! This Instructable won 3rd prize in the Arduino contest, and first prize in the Gadget contest...

    Included are pictures and code to convert your oscope to a 3 Channel DVM and to show the output of each channel individually in the scope display by pressing a softkey on the display. ( the third button from the top)you will need an L shaped female pin connector if you want to have the flexibility of inserting jumpers, otherwise, just bend the pins on one side of the jumpers to insertthem in the analog channels (A0- A3) to use them as your probes.Just download the sketch and upload it to the Arduino.

    You can label each channel individually, just change the wording in the sketch.I have also made a lego enclosure for the scope..check out the pictures.

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Image Notes1. Lego enclosure for the scope2. Te three signal voltages in A0-A33. Softswitch to change the input channei that is graphed

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    File Downloads

    OscopemegavwDVM.ino (7 KB)[NOTE: When saving, if you see .tmp as the file ext, rename it to 'OscopemegavwDVM.ino']

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Step 2: Parts listYou will need :

    A Sainsmart mega2560 board with 3.5" tft lcd touch module display and shield kitA PC with the arduino IDE and a free USB port.A USB cableJumper cablesUTFT library and the UTouch library from Henning Karlsen. web: http://www.henningkarlsen.com/electronics

    Image Notes1. SainSmart 3.2" TFT LCD Display is a LCD touch screen module.2. SainSmart Mega 25603. SainSmart 3.2 inch LCD shield

    Step 3: Build the hardware.Construction of the Oscilloscope is fairly simple. You just have to put the parts of the Sainsmart kit together. All you need to do is add two jumpers; one for ground, andthe other to use as your oscilloscope test probe.

    You will need to bend the pins on one side of the jumper wires, and insert them into the A0 pin and GND pin of the Arduino (see pictures for detail), before installing thedisplay shield, as the display shield will cover the ports once it's in place.

    Plug the Shield into the Arduino , then plug the display into the shield, and you're done!!!

    Now let's test the display before we turn it into an oscilloscope.

    Image Notes1. Sainsmart kit

    Image Notes1. Kit put together and plugged into USB

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Image Notes1. Display inserted in shield

    Image Notes1. Display plugged into shield, side view

    Image Notes1. Side view of display,shield and Mega

    Image Notes1. Front view of Display, shield and Mega

    Image Notes1. Close up view of the kit. Notice the space between the free mega connectors2. Space to insert bent pins3. Space to insert bent pins

    Image Notes1. Arduino Mega2. Jumper with bent pin inserted to GND3. Jumper inserted to A0 pin used as test probe

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Image Notes1. View of Mega with jumper pins bent for insertion to connectors

    Step 4: The software: UTFT library test.If you finished putting your kit together, plug it into the USB cable that connects to your PC running the Arduino IDE.

    If you haven't done so, download the UTFT and UTouch Libraries, and copy them to the libraries folder where you have the arduino IDE installed.

    If the libraries installed properly, you will see the UTFT and the UTouch options when you click on the Files option, and scroll down to examples.

    If the UTFT option is in your menu list, select it, then select arduino, and finally, UTFT_Demo_320x240. This will load the cool demo program.

    With the program loaded in the IDE, scroll down to view the following code:

    // Uncomment the next line for Arduino 2009/Uno//UTFT myGLCD(ITDB32S,19,18,17,16); // Remember to change the model parameter to suit your display module!// Uncomment the next line for Arduino MegaUTFT myGLCD(ITDB32S,38,39,40,41); // Remember to change the model parameter to suit your display module!Comment out the command for the UNO , and uncomment the command for the Mega ,as I did.

    Now, go to the tools menu, click on board, and select Arduino Mega 2560 or Mega ADK , if not already selected.

    Click on verify to compile the program. If there are no errors, click on upload to load and execute the program.

    If everything is Ok, you will see a cool demo program running. Pictures in this step, show screenshots of the demo running.

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Step 5: The software: UTouch library test.Now we need to test the Utouch Library

    Go to the files menu and select ; Examples>UTouch>Arduino>Utouch_ButtonTest and load the program to the IDE.Verify and run the program.

    You should see a keypad show up in the display, and, as you press the number keys, they should show up at the bottom of the screen.

    If all went well, we are ready to load the Oscilloscope software.

    Image Notes1. press the buttons and you should see them at the bottom of the display

    Step 6: The OscilloscopeBelow, you will find the sketch for the Oscilloscope. Before we copy and paste the program, let's review some limitations and explain the program.

    I've had to do a fair amount of research to come up with the code, and many snippets have been "borrowed" from several sources.

    I divided the program into several subrutines to make it easier to understand. The code is well documented, but, if you have trouble understanding it, leave a commentand I'll try to explain it.

    The Oscilloscope bandwidth is limited to about 1 khz, but there is room for improvement.

    The input is limited to a 5volt peak to peak waveform, unless you use a voltage divider at the input, and also limited to positive waveforms from 0 to 5 volts.

    I used some code I found at: http://www.microsmart.co.za/technical/2014/03/01/advanced-arduino-adc/ to adjust the ADC sample time.The graphics and touch functions were modified, and borrowed, from the Henning Karlsen examples provided in his libraries.

    I used a LM 317 voltage regulator, and a 555 IC timer as an astable ocillator, to create the signals used to test the oscilloscope input.

    Hope you enjoyed reading and hopefully building this instructable. If you find it useful, please vote for me in the contests.Copy and paste the sketch to your Arduino IDE

    //----------------------START PROGRAM

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    /*--------------------------------------------------------------Program: OscopetouchLCDmega

    Description: Digital Oscilloscope with data displayedon Color TFT LCD with touch screen

    Hardware: sainsmart mega2560 board with 3.5" tft lcd touch module display and shield kithttp://www.sainsmart.com/home-page-view/sainsmart-mega2560-board-3-5-tft-lcd-module-display-shield-kit-for-atmel-atmega-avr-16au-atmega8u2.html

    Software: Developed using Arduino 1.0.3 softwareThis program requires the UTFT library and theUTouch library from Henning Karlsen.web: http://www.henningkarlsen.com/electronicsVersion 1.00Date: 5 April 2014

    Author: johnag--------------------------------------------------------------*/

    #include #include // Declare which fonts we will be usingextern uint8_t SmallFont[];// Initialize Screen and touch functionsUTFT myGLCD(ITDB32S,38,39,40,41);UTouch myTouch(6,5,4,3,2);// Declare variableschar buf[12];int x,y;int Input = 0;byte Sample[320];byte OldSample[320];int StartSample = 0;int EndSample = 0;int Max = 100;int Min = 100;int mode = 0;int dTime = 1;int tmode = 0;int Trigger = 0;int SampleSize = 0;int SampleTime = 0;int dgvh;int hpos = 50; //set 0v on horizontal gridint vsens = 4; // vertical sensitivity

    // Define various ADC prescalerconst unsigned char PS_16 = (1

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    if (mode == 6) dTime = 30;if (mode == 7) dTime = 50;if (mode == 8) dTime = 100;if (mode == 9) dTime = 200;if (mode == 10) dTime = 500;if (mode > 10) mode = 0;

    }}if ((y>=70) & (y=250) & (x 5)tmode = 0;}}if ((y>=130) & (y=250) & (x 60)hpos = 50;}}}}//----------wait for touch subvoid waitForIt(int x1, int y1, int x2, int y2){while (myTouch.dataAvailable())myTouch.read();}//----------draw grid subvoid DrawGrid(){myGLCD.setColor( 0, 200, 0);for( dgvh = 0; dgvh < 5; dgvh ++){myGLCD.drawLine( dgvh * 50, 0, dgvh * 50, 240);myGLCD.drawLine( 0, dgvh * 50, 245 ,dgvh * 50);}myGLCD.drawLine( 245, 0, 245, 240);myGLCD.drawLine( 0, 239, 245, 239);myGLCD.setColor(255, 255, 255);myGLCD.drawRoundRect (250, 1, 310, 50);myGLCD.drawRoundRect (250, 55, 310, 105);myGLCD.drawRoundRect (250, 110, 310, 160);myGLCD.drawRoundRect (250, 165, 310, 215);}// ------ Wait for input to be greater than trigger subvoid trigger(){while (Input < Trigger){ Input = analogRead(A0)*5/100;}}//---------------End Subrutines ----------------------

    void setup() {myGLCD.InitLCD();myGLCD.clrScr();myTouch.InitTouch();myTouch.setPrecision(PREC_MEDIUM);buttons();pinMode(0, INPUT);// set up the ADCADCSRA & ~PS_128; // remove bits set by Arduino library

    // you can choose a prescaler from below.// PS_16, PS_32, PS_64 or PS_128ADCSRA |= PS_64; // set our own prescaler}

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    void loop() {while(1) {DrawGrid();touch();trigger();// Collect the analog data into an array

    StartSample = micros();for( int xpos = 0;xpos < 240; xpos ++) { Sample[ xpos] = analogRead(A0)*5/102;delayMicroseconds(dTime);}EndSample = micros();// Display the collected analog data from arrayfor( int xpos = 0; xpos < 239;xpos ++){// Erase previous displaymyGLCD.setColor( 0, 0, 0);myGLCD.drawLine (xpos + 1, 255-OldSample[ xpos + 1]* vsens-hpos, xpos + 2, 255-OldSample[ xpos + 2]* vsens-hpos);if (xpos == 0) myGLCD.drawLine (xpos + 1, 1, xpos + 1, 239);// Draw the new datamyGLCD.setColor (255, 255, 255);myGLCD.drawLine (xpos, 255-Sample[ xpos]* vsens-hpos, xpos + 1, 255-Sample[ xpos + 1]* vsens-hpos);}// Determine sample voltage peak to peakMax = Sample[ 100];Min = Sample[ 100];for( int xpos = 0;xpos < 240; xpos ++){OldSample[ xpos] = Sample[ xpos];if (Sample[ xpos] > Max) Max = Sample[ xpos];if (Sample[ xpos] < Min) Min = Sample[ xpos];}// display the sample time, delay time and trigger levelmyGLCD.setBackColor( 0, 0, 255);myGLCD.setFont( SmallFont);myGLCD.setBackColor( 0, 0, 255);myGLCD.print("Delay", 260, 5);myGLCD.print(" ", 270, 20);myGLCD.print(itoa ( dTime, buf, 10), 270, 20);myGLCD.print("Trig.", 260, 60);myGLCD.print(" ", 270, 75);myGLCD.print(itoa( Trigger, buf, 10), 270, 75);myGLCD.print("H Pos.", 260, 120);myGLCD.print( itoa( hpos, buf, 10), 270, 135);//myGLCD.setBackColor( 0, 0, 0);SampleTime =( EndSample-StartSample)/1000;myGLCD.print("Sec.", 205, 210);myGLCD.print(" ", 280, 30);myGLCD.print(itoa( SampleTime, buf, 10), 205, 220);// Range of 0 to 64 * 78 = 4992 mVSampleSize =( Max-Min)*78;myGLCD.print("mVolt", 5, 210);myGLCD.print( itoa( SampleSize, buf, 10),5, 220);myGLCD.print(itoa( analogRead(A0)*4.15/10.23, buf, 10),110 ,220);}}//-------------------------END PROGRAM

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    Step 7: Video of the Oscope in action

    Step 8: Another video

    Related Instructables

    My SecondProject: Arduino2.4" TFT byRookie P

    Mini Arduinoenvironmentmonitor **UPDATE -Added RTC ***by johnag

    Mini ArduinoMulti FunctionController w/LCD Display byjohnag

    Make a MiniArduinoprogrammable 4channel DC-DVM by johnag

    Moving MySecond Project:2.4" TFTForward byRookie P

    Mini ArduinoPortable EEG -Brain WaveMonitor + byjohnag

    Advertisements

    Comments48 comments Add Comment

    grumpyboots says: Apr 20, 2014. 5:52 PM REPLYneato! thanks, maybe ill see what uses i can for this

    johnag says: Apr 20, 2014. 7:02 PM REPLYCool grumpyboots.. thanks for sharimg!

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    rroque5 says: Jul 7, 2014. 2:39 PM REPLYIs to do this using a nano aruino v3.0?

    johnag says: Jul 8, 2014. 7:56 PM REPLYI don't.think. so, sorry

    rroque5 says: Jul 8, 2014. 8:56 PM REPLYThanks!

    alejandroym93 says: May 13, 2014. 4:30 PM REPLYNice 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 says: May 13, 2014. 6:15 PM REPLYcheck tis instructabel to giv you an idea:

    How to make an Arduinooscilloscope probe byNeoRecasata

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

    alejandroym93 says: May 14, 2014. 4:01 PM REPLYindeed it graph most part of the signal with the probe, but it keeps cutting a minimum part of the signal.

    johnag says: May 14, 2014. 5:00 PM REPLYthe 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 thesignal 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 acapacitor 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 dcof 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 5volts peak to peak,if it is not, you. Will need to attenuate it using a potentiometer..

    alejandroym93 says: May 16, 2014. 7:48 PM REPLYthank you a lot man, it worked perfectly:)

    johnag says: May 17, 2014. 4:44 PM REPLYglad to help...click the I made it button and share a picture if you want...

    johnag says: May 13, 2014. 5:40 PM REPLYUse a voltage divider and a capacitor at the input.

    Jan_Henrik says: May 1, 2014. 10:20 PM REPLYAwesome project, I love it!!!

    johnag says: May 7, 2014. 8:11 PM REPLYthanks...you've got some awesome projects too!

    Jan_Henrik says: May 8, 2014. 10:32 PM REPLYThank you! :)

    Mr. E says: May 4, 2014. 1:34 PM REPLYNicely done ! Something every work bench should have.

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    johnag says: May 7, 2014. 7:47 AM REPLYThanks Mr. E, By the way, I tried your http://www.instructables.com/id/Donut-Protection-Device-Advanced-Arduino-Technique/ , another awesomeproject, thanks for sharing

    wisconsinjimmy says: May 2, 2014. 9:23 AM REPLYOK 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 wellthanks and sorry to have bothered you.

    Jim

    murfmv says: Apr 30, 2014. 9:12 AM REPLYJohnag, Thought I was having trouble compiling because of different Arduino versions, but then realized where are the libraries after the include statementand 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 befollowing ur blog.

    Great Job!!

    johnag says: Apr 30, 2014. 10:47 AM REPLYGlad you worked out the problem. Take a picture, and click on the I made it button! Have fun using it.

    dustint2004 says: Apr 23, 2014. 8:05 PM REPLYSooo. If you have specific parameters already set.

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

    johnag says: Apr 30, 2014. 10:44 AM REPLYno it doesn't need to be connected to the PC, and you can vary some of the parameters with the touch screen buttons.

    murfmv says: Apr 30, 2014. 7:14 AM REPLYHello 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!

    30-06 says: Apr 21, 2014. 6:36 AM REPLYCould this read from 10Hz to 20kHz?

    johnag says: Apr 21, 2014. 7:46 AM REPLYProbably not without an external ADC due to the limitations of the Arduino. But, the fundamentals of human voices are roughly in the range of 80 Hz to1100 Hz, so you can use it to monitor voice patterns for stress and lie detection. The audio range of the human ear is from 20 hz to 20 khz which, Ipresume, is what you want to monitor.

    I haven't finished tweaking the code, so if I figure out a way to increase the bandwidth without additional hardware I will update the instructuble.

    grumpyboots says: Apr 20, 2014. 6:02 PM REPLYwhat would be the usable limits for this scope, without dividers and such I mean?

    Volts peak to peak etc

    freq?

    johnag says: Apr 20, 2014. 7:30 PM REPLYThe Oscilloscope bandwidth is limited to about 1 khz

    The input is limited to a 5volt peak to peak waveform, unless you use a voltage divider at the input, and also limited to positive waveforms from 0 to 5volts.

    you can build an oscillator with a 555 timer IC and watch square and triangle waves, or you you can use a thermistor with a resistor to see temperaturechanges, or with a photo resistor to see light variations or just touch the probe and you should the a sine wave from the electrical power. at 60 hz if youare in the states, 50 hz if you live in europe. have fun!!!

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    bob3030 says: Apr 17, 2014. 10:39 PM REPLYInteresting thanks for posting.

    johnag says: Apr 20, 2014. 5:28 PM REPLYyou're. Welcome

    Treknology says: Apr 20, 2014. 3:12 PM REPLYA very nice little project. I still use a 20MHz analog scope for most of my work, although if working in lower frequency ranges, your project would saveconsiderable electricity.

    I'm actually proposing a reverse project. I have some old 6" (maybe only 4") black & white TVs that are useless in the digital age (the don't even havecomposite inputs). As many people with CROs who don't know how to use them properly and ultimately end up wasting them by attaching them to thestereo, I'm going to convert these TVs into "sloppy" CROs for just that purpose!

    johnag says: Apr 20, 2014. 5:26 PM REPLYthanks, and good luck with your projects, if you do make them, share them I'd lik to see them.

    dirty_valentine says: Apr 20, 2014. 6:52 AM REPLYNice project. I think your scope could really use an adjustable trigger so that the waveform is not jumping all over the screen. A good trigger is hard to designthough. Ideally you would use an interrupt input to trigger sampling, but that would require an external comparator an reference. The next best way would beto sample at the highest rate and do a compare to detect the threshold crossing. Then start sampling at the scope rate. Don't change the avr sample rate,just drop the samples you don't need. This will probably work for slow moving input signals, but will fall apart as you approach the avr sampling rate.

    johnag says: Apr 20, 2014. 5:24 PM REPLYthe scope has a software trigger, but you're right maybe I'll. try some thing like what you suggest, but my proggramimg skills aren't that great.

    alzie says: Apr 20, 2014. 8:06 AM REPLYScool project!Its tough making a good scope.

    Also, check out:

    http://www.seeedstudio.com/depot/DSO-Nano-v3-p-135...

    I have their V2 nano scope.

    Works well, i love it, is portable, and

    is isolated from the AC line for power measurements.

    johnag says: Apr 20, 2014. 5:20 PM REPLYYea, there are some pretty cool oscopes sainsmart has some too, and they cost less than 100. One that caught. My attemtion and it cost only 50$ismtheXMEGA XProtolab

    It fits in your breadboard and is multu functional. Check it out here:

    harleyrogengineer says: Apr 19, 2014. 9:43 AM REPLYThere is a due kit version available from sainsmart...would this work and be faster??

    Just wondering?

    Otherwise i'll be building this Very soon! Excellent instructable Sir!

    johnag says: Apr 20, 2014. 5:12 PM REPLYI was reading about the due in http://arduino.cc/en/Main/arduinoBoardDue

    This paragraph caught. My attention.

    Before you buy the kit make sure it will work for you.Warning: Unlike other Arduino boards, the Arduino Due board runs at3.3V. The maximum voltage that the I/O pins can tolerate is 3.3V.Providing higher voltages, like 5V to an I/O pin could damage the

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    board.

    johnag says: Apr 19, 2014. 11:07 PM REPLYI haven't tried it because I don"t have a due, but I don't see why it wouldn't. Work. The due, however, has a much higher clock speed and the ADC is 12bits. You might have to play with the sketch a little to make it work.

    carlos66ba says: Apr 11, 2014. 3:16 PM REPLYVery cool! What is the maximum speed it can capture?

    nqtronix says: Apr 16, 2014. 3:29 AM REPLYAn atmega2560 is the core of this "ocilloscope". The ADC (Analog to Digital Converter, just in case you're wondering) supports up to 76.9kSPS (SamplesPer Second). However I doubt that this speed can be archieved. If the atmega wpuld run at its maximum speed of 20Mhz roughly 260 operations couldbe done to store, calculate and display each value. Plus the controller has to manage all inputs (touchscreen).The maximum frequency of a signal (bandwith) an ocilloscope can measure acurate enough for practical purposes is roughly 10% of the sampling rate,thus a bandwith of roughly 8khz can be expected, at best (!). Even for "home purposes" this thing is partical unsusable. This thing is simply not made tobe an ocilloscope.

    Don't get me wrong, beside the functionality of this "ocilloscope" the project isn't bad at all and I'm sure you learnt much during the process. And if youdecide anytime to buy a proper ocilloscope (they start @ ~200, for 535 you get the cheapest 4 channel scope, the rigol1052Z) you can still reuse thisproject and just slam other code on to turn it into something new :)

    johnag says: Apr 16, 2014. 8:10 AM REPLYThe AVR ADC has a recommended clock speed of between 50 kHz and 200 kHz when 10 bit resolution is desired. This is 50,000 to 200,000 cyclesper second. Any faster and the resolution will start to degrade. There is a prescaler to control the ADC clock. This means that it is prescaled down bysome factor from the core clock speed.

    To set the prescaling, the ADPS bits (2..0) in the ADCSRA register are set. Prescaler values of 2, 4, 8, 16, 32, 64 & 128 are provided. A typical coreclock speed is 16 MHz, although the core can run up to 20 MHz. So if you are running your Arduino or other AVR board at 16Mhz, you can set theADC clock to one of the following values:

    16 MHz / 2 = 8 MHz16 MHz / 4 = 4 MHz16 MHz / 8 = 2 MHz16 MHz / 16 = 1 MHz16 MHz / 32 = 500 kHz16 MHz / 64 = 250 kHz16 MHz / 128 = 125 kHz

    Since the ADC clock needs to be between 50 kHz & 200 kHz for 10 bit accuracy, we can only use the 128 prescaler and can achieve a 125 kHz ADCclock. If our core was at 20 Mhz and we use the 128 prescaler our ADC would be running at about 156 kHz.

    To achieve a higher ADC clock, we could slow down the core. A core running at 12 Mhz with a prescaler of 64 will achieve an ADC clock of around187 kHz. These are the tradeoffs we make when designing a system.

    A normal conversion in the ADC takes 13 ADC clock cycles. The first conversion takes 25 clock cycles. So our ADC clock speed needs to befactored down by 13 to figure out how many samples we will be able to achieve per second.

    You can run the ADC in parallel mode using the PINC command and capture the data from a front end ADC chip to achieve a bandwidth of morethan 200khz. Granted it's no industrial oscilloscope, but as I mentioned, its for hobby use and you can view many waveforms that you couldotherwise not see, like the charging of a capacitor, etc...

    Like you mention, it is programable, and you can reuse the hardware for many other projects. something you can't do with a dedicated oscilloscope

    nqtronix says: Apr 16, 2014. 8:51 AM REPLYIn the official datasheet for the atmega2560 (here: http://www.atmel.com/Images/Atmel-2549-8-bit-AVR-M... ) in chapter 26 page 268 themaximum speed of the ADC is defined as "up to 76.9kSPS (Up to 15kSPS at Maximum Resolution)". Near all low to mid range ocilloscopes useonly 8 bit resolution, I calculated with the maximum sampling rate. Sure, you can run the whole thing out of specefication, but the precision willdecrease. I honestly didn't knew the avr chip series support parallel mode of the ADCs, but that sounds like a huge improvement to me.

    So, if you don't mind, I'd like to see a "real waveform" displayed, that should make things clearer. I don't think you own a funktion generator sowhat about generating 20khz sine with the soundcard of your computer? I'd offer a video proof of the 1074Z as comparison (yeah, I know, prettyunfair, but still).

    johnag says: Apr 16, 2014. 9:53 AM REPLYThe CA3306 Flash analog to digital converter can be used as a front end ADC to increase the bandwidth to 5MHZ you would need to modifythe sketch to read the ADCoutput in parallel. The resolution will be 6 bits. but, this will add cost and complexity to the project. I wanted to keepthe instructable as simple and low cost as possible.

  • http://www.instructables.com/id/Make-an-Oscilloscope-Using-the-SainSmart-Mega2560-/

    nqtronix says: Apr 16, 2014. 10:10 AM REPLYSure you can add additional parts to increase the spec in any way, but that was not what carlos66ba had asked for. I just wanted to pointout the limitations of the current design without going too far into the details.

    carlos66ba says: Apr 18, 2014. 3:19 AM REPLYThanks for the detailed answers! I think that for a scope, 8 bit suffices so you can probably bump the clock a bit higher than therecommended specs.

    johnag says: Apr 16, 2014. 12:12 PM REPLYwell, in that case, the maximum bandwidth is about 1Khz, as mentioned in the Instructable. carlos66ba I hope this clarifies yourquestion. Thanks for your comments nqtronix it's always good to have some feedback .

    nqtronix says: Apr 16, 2014. 4:05 AM REPLYWell, 2 small corrections:

    1. The atmega2560 runs at 16Mhz max, that would result in only 208 operations.

    2. I meant the rigol 1074Z...

    What a shame instructables doesn't support editing of comments...

    mrandle says: Apr 12, 2014. 11:15 AM REPLYthe kit comes with an arduino mega and its only 40 bucks! Sweet deal!


Recommended