Make a simple oscilloscope to 5 based on the Arduino UNO

  • Dec 26, 2019

We will need to work:

  • The board Arduino UNO;
  • USB cable to connect the Arduino to the PC;
  • 2 wires (male to male);
  • laptop or PC with installed software for Arduino.
This we need to create your own "mini-oscilloscope"
This we need to create your own "mini-oscilloscope"

Next, insert one end of the wire in A0, and the other end of the wire to GND (see. figure below). All oscilloscope ready. These 2 wires you will use to measure the voltage.

Next, connect the Arduino to your computer using a USB cable. The computer must have installed the Arduino software. That's it and you want to run.

Explanation of work and code

The latest version of Arduino software is a tool that makes the creation of an oscilloscope is very simple!

It is called "Serial Plotter " and works as follows.

He listens to the serial port and displays each number which sees.

This means that the creation of an oscilloscope is all you need to do is to write code that prints the value of the voltage to the analog input and the plotter Arduino takes care of everything else.

I have used only 7 lines of code to make this work!

instagram viewer
void setup () {
Serial.begin (115,200); // opens serial port, sets the speed of 115,200 bits / c
}
void loop () {
int val = analogRead (A0); // read the value A0
Serial.println (val); // write the analog value to the serial port
}

Next, compile and download the code to the Arduino. Next, go to the Serial Plotter. You should see something like this:

Analog input Arduino UNO may take up to 5 V. Make sure you do not exceed this limit, as can damage the Arduino.

If you need to measure the signal of a higher voltage, you can use voltage divider.

nuances

I chose to 115200 baud. This is the number of bits per second. To send a character via the serial port, you usually need 10 bits. 8 bits for a symbol in addition to the one initial bit and one stop bit.

So this gives me a rate of 11,520 characters per second.

Values ​​for schedule written in the text. Thus, the number 800 is sent as an "8", then "0", then "0". It is three characters.

Let's simplify and say that all the numbers are in the range from 100 to 999. Then, the maximum number of measurements that the oscilloscope can perform per second is 11520 divided by 3, which is 3840. It is called sampling frequency.

You can measure the frequency only, which account for up to half the sampling frequency. Half of 3840 - 1920 is. This means that you can measure the frequency of approximately 1.9 kHz with this oscilloscope.

Another problem with this oscilloscope is that for measurements, which give the number of below 100 or above 999, you have less or more than 3 characters to send. This would increase or decrease the sampling rate, and signal to spoil "Serial Plotter "

You can fix this by making sure you always send 4 characters. For example, "0013" instead of "13". "0390" instead of "390".

The above oscilloscope - fairly quick and fairly simple to set up. But at the same time, there are many ways to improve it! Maybe you have any ideas on this?

Subscribe to my channel and do not forget to leave comments!