element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Blog Arduino as (slow) oscilloscope
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: strb
  • Date Created: 7 Feb 2016 9:30 PM Date Created
  • Views 3657 views
  • Likes 3 likes
  • Comments 15 comments
  • oscilloscope
  • labview
  • arduino
Related
Recommended

Arduino as (slow) oscilloscope

strb
strb
7 Feb 2016

A couple of days ago Ben in The Ben Heck show made a oscilloscope using raspberry pi and bitscope, now I want to show you how I made my personal oscilloscope using arduino and LabView.

 

Let's start!

First of all we have to know the speed limitation of analogRead, infact this instruction takes a bit more than 0.1 ms to execute, so the theoretical max speed that we can reach is lower than 10Khz. Umm..... it doesn't sound good! So the first step is to speed up analogRead, to do this we have to find the atmega328 datasheet and then study the chapter that explain how the adc works.Great, I just have to set a couple of registers to increase the conversion's speed (it seems easy but this was the first time that I changed the default settings so I spent few hours of "study" for it).Basically the adc take the system clock and divide its frequency with a certain factor specified into a register before using it for timing, so decreasing this number we can increase the speed.We also need to set the voltage reference, the input pin and the "format" of the adc output.

The next step is to create a fast data flow from arduino to pc, this is really easy because we have only to find the maximum speed using "standard" arduino communication, after a bit of try I found that the max speed is about 4000000 baud/s (500KByte/s, not bad!).

Beware! You can't use this speed to display data with the standard serial monitor, you have to made a specific program that can read data at those speed.

Below here you can see the program running on arduino:

byte mask=B01000000;//mask for start of conversion & state of conversion
char t=' ';

void setup()
{
  Serial.begin(4000000);//500kByte/s, super speed!
  ADMUX=B01100000;//I'm using input A0,result is left adjusted
  DIDR0=0x01;//shut off digital input for A0
  ADCSRA=B11000011;//I'm using 8 as division factor,with 4 I obtain quite noisy measurements
  ADCSRB=0x00;//free running, default setting
}

void loop()
{
  startofconversion();//start a new conversion
  Serial.print(t);//send old data
  t=waitandget();//obtain new data, it will be send next cicle
}

void startofconversion()
{
  ADCSRA=ADCSRA|mask;//let's start a conversion!
}

byte waitandget()
{
  while((ADCSRA&mask)==mask)//wait
  {
  }

  return ADCH;
}

With this I reach a sample rate of about 85/90 Khz(It's an estimate, i can't measure it because I haven't an oscilloscope),of course it isn't comparable with a real oscilloscope but it's enough if you have to display for example an audio waveform or if you have to check the pwm for a motor.

The precision is 8 bit.

 

Pc program

To make the pc interface I used LabView, the program still have some little problems but it works, with it I can see in real time the signal and the current value:

image

Of course I can zoom in to see it better image

image

You can also freeze current measurements to see it in the "Static graph" and then take data using windows on the upper right.

image

In this image I'm visualizing the voltage on a capacitor and below the old measurements of the square wave, as you can see the measured frequency is 1129 Hz, the calculated one is 1300 Hz so it isn't perfect but it can give you a quite accurate idea of what your circuit is doing (I was checking an oscillator made with a 555).

 

I will work to make it better, more precise and stable and probably I will create a small circuit to increase the range (0-5V is a quite poor range).

Attachments:
programs.zip
  • Sign in to reply

Top Comments

  • DAB
    DAB over 10 years ago in reply to strb +2
    I agree. I did a lot of debugging work with an old Dumont oscilloscope that could only see about 100 KHz signals, which was plenty for the old TVs at the time. DAB
  • clem57
    clem57 over 10 years ago in reply to strb +1
    Not quite. You can use interrupt timer to perform time sensitive gathering data while looping sending data. This will be bursty sending on USB while being interrupted. Clem
  • strb
    strb over 10 years ago +1
    I've update the two programs, I've partially followed your suggest. Basically now I acquire a data packet of 1500 sample and simultaneously I measure the total time of sample acquisition and after I send…
  • DAB
    DAB over 10 years ago

    I built one of the first digital oscilloscopes using an 8085 back in the early 1980's.

     

    We were capturing radar patterns using a mixing device that would demodulate the signal and provide us with the power lobes.

     

    We used a 32k byte RAM buffer and a fast 8 bit ADC to capture the data.

     

    I programmed the software to display the plot and provide the user an ability to find signals and expand the time scale.

    Once they had the area of interest the software would do a bunch of calculations and display the results overlayed on the signal display.

     

    So I see no reason why you cannot do some reasonable work with an Arduino and a good display.

     

    Sure you will be limited, but for most hobby/maker needs, it would be a reasonable capability.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • strb
    strb over 10 years ago in reply to clem57

    Ok, thanks a lot to your suggestion image I'll try it as soon as possible

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to strb

    Not quite. You can use interrupt timer to perform time sensitive gathering data while looping sending data. This will be bursty sending on USB while being interrupted.
    Clem

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • strb
    strb over 10 years ago in reply to clem57

    I don't know how bulk mode works, but I've found this:

    "Bulk Transfer is typically used for devices that transfer large amounts of non-time sensitive data, and that can use any available bandwidth, such as printers and scanners.

    This transfer type can be used by full-speed and high-speed devices, but not by low-speed devices.

    Bulk transfer is non-periodic, large packet, bursty communication.

    Bulk transfer allows access to the bus on an "as-available" basis, guarantees the data transfer but not the latency, and provides an error check mechanism with retries attempts. If part of the USB bandwidth is not being used for other transfers, the system will use it for bulk transfer.

    Like the other stream pipes (isochronous and interrupt), the bulk pipe is also unidirectional, so bi-directional transfers require two endpoints.

    The maximum packet size for bulk endpoints can be 8, 16, 32, or 64 bytes for full-speed devices, and 512 bytes for high-speed devices."

    Is it true?

    Because if bulk mode has this characteristics I don't think it will fit good for my purpose because arduino isn't an high speed device (I'm using an arduino uno) and also when I have to send  a packet I have to stop data acquiring for an undefined ammount of time and this is a big issue for samples interpolation. Is it right? Thanks.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago

    A usb can run in bulk mode handling more data. https://en.wikipedia.org/wiki/USB#Media_Transfer_Protocol

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube