Real Time Oscilloscope using Simulink and Arduino

How to make Real Time Oscillscope using Simulink and Arduino

Fig: real time oscilloscope using Simulink and Arduino

In this Arduino Simulink tutorial we will show how you can make Real Time Oscilloscope using Simulink and Arduino. To illustrate this, we will read analog voltage signal from a potentiometer which is connected to the analog pin A0 on the Arduino UNO R3 board. We use the Analog Input block to read in the analog signal and display it on the Simulink Time scope. You will observe the analog signal on the time scope in real time in the same way as you would observe signal on a Oscilloscope.

This is much like the Real-Time data acquisition from Arduino to Matlab but instead of using Matlab program we are using here Simulink graphical programming method. Also we will get a scrolling graph with the Time Scope like the one we see on real oscilloscope.

Physical Hardware Connection for Real Time Oscilloscope using Simulink and Arduino

The arduino development environment for real time oscilloscope is shown below.

arduino hardware setup for real time oscilloscope using simulink
Fig: arduino hardware setup for real time oscilloscope using simulink

In the figure, a 10KOhm potentiometer is connected to Arduino UNO board such that one pin is connected to the 5V supply, the other end is connected to the ground and the third middle is connected to the analog pin A0. The connection is via breadboard to avoid direct connection to the arduino pins in order to protect the pins.

If you are confused about this connection see the following diagram on how to connect.

schematic diagram for reading analog signal

Once you have set up the hardware connection plug the Arduino USB to your Computer.

Simulink Model and Configuration for Real Time Oscilloscope using Simulink and Arduino

Now make the following simulink model.


simulink model for reading analog voltage signal for real time display

You can find the Analog Input block in the Simulink Support for Arduino Hardware/ Common library.

using analog input block in simulink

The Product block is in the Math library and the Constant is in the Source library. The scope is in the Simulink/Sink library.

The answer to question of why product block and constant block are used is the following. The output from the Analog Input are analog voltage signal signal directly from the Arduino internal ADC. So the analog signal is in fact quantized digital sample values from 0 to 1024 because the Arduino internal ADC is 10 bit ADC(Analog to Digital Converter). The input voltage range from Potentiometer is 0V to 5V. These voltage values are converted to range 0 to 1024 by the 10-bit ADC.

Now to display the analog signal in the range 0V to 5V on the Time scope we use the product and the constant block. That is we multiple the sampled values(0 to 1024) with 5/1024 constant value. Thus the constant block is set to 5/1024 and each sample is multiplied by the product block with 5/1024 constant. Hence we get 0 to 5V range in our Time Scope.

The next thing we need to do is to set-up the Time Scope properly so that it displays the required voltage range and that it displays the signal in a scrolling manner like that in real oscilloscope.

Double click on the Time Scope and go to the Time tab. There change the Time span overrun action to Scroll. Also, although not necessary, change the Time units to Metric(based on Time Span). This setting is shown below.

Next go to the Display tab. There, you can change the Title of the display like Real Time Analog Voltage Graph in this example. Change the minimum and maximum Y-limits to -0.5 and 6 so that you can see the voltage signal. Also you can change the Y-label to something descriptive like Voltage(V) in this example.

Now you have to configure the Simulink simulation setting so that it can co-work with Arduino UNO board. You can read it in the tutorial Arduino Simulink Tutorial 1 – LED blinking how to do this.


The final step is running the simulink model. To start the simulation click on the Run button. When you do that Matlab/Simulink will check your model, compile code and upload to your Arduino board. Then it will read in the analog voltage from the Ardiuno pin A0. This is then displayed after scaling the values on the Time Scope. See the following picture of how it looks like.

real time oscilloscope using Simulink and Arduino
Fig: real time oscilloscope using Simulink and Arduino

Video Demonstration

The following video shows the working of real time oscilloscope, hardware connection and changing the potentiometer.

Hopefully you liked this tutorial. If you did, share it and also subscribe to our blog posts. For more tutorials see Arduino Matlab Simulink Tutorials.

What do you think?

0 points
Upvote Downvote

Total votes: 0

Upvotes: 0

Upvotes percentage: 0.000000%

Downvotes: 0

Downvotes percentage: 0.000000%


Leave a Reply
  1. HI,
    I wanted to connect the Arduino with an oscilloscope to measure the supply AC voltage of the oscilloscope in Arduino.
    I tried a similar program in Simulink. but I couldn’t able to get the responses as like in your video.
    Do I need to change any constant values?

    • i think it has to do with your probe. you need to have connection via some voltage divider using resistors so that both positive and negative voltage swing are shown. I will see if I can make a post, hopefully soon, not sure though.

Leave a Reply

Your email address will not be published. Required fields are marked *

potentiometer physical circuit connection to Arduino UNO

Arduino Simulink tutorial 4: Reading Analog Voltage

Programming Arduino using Python

Programming Arduino using Python