Arduino Simulink tutorial 4: Reading Analog Voltage

How to read analog voltage using Simulink Support for Arduino Hardware analaog input block

In this part of Arduino Simulink tutorial we want to show how to read analog voltage using Simulink Support for Arduino Hardware analaog input block. For the purpose of demonstration we will read analog voltage signal from A0 pin on the Arduino board and display it on the Time Scope in Simulink. So this is much like an Oscilloscope which displays analog signal.

For our analog signal we will simply use a 10kOhm Potentiometer connected in series with another 10Kohm resistor. The Potentiometer middle output is connected to the A0 pin on the Arduino board. This is much like our earlier Arduino tutorial Connect and Read Photoresistor with Arduino on analogRead() function where we used a photoresistor instead of potentiometer.

See below diagram to know how to connect the potentiometer to the analog pin A0 and 10kOhm resistor.

potentiometer connection to Arduino schematic diagram

Whereas the physical circuit is shown below.

potentiometer physical circuit connection to Arduino UNO

Next connect the Arduino USB to your Computer.

Now we will make the Simulink model for reading the analog voltage and display it on Time Scope in Simulink. This is similar to the tutorial Real Time Analog Voltage in Matlab using Arduino where we displayed analog voltage in real time using Matlab code instead of simulink.

Next make the following Simulink model.

Reading Analog Voltage using Analog Input in Simulink

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

using analog input block in simulink

The default pin that will be used is the Pin 0 but you could also use any other analog pin on the Arduino board.

After that you have to configure Simulink to work with Arduino board. You can use most of the Arduino Board like UNO, Mega etc. In this example Arduino UNO board was used. How to configure simulink is explained in details in the beginning tutorial Arduino Simulink Tutorial 1 – LED blinking.

Once you configured simulink, click on the Run button on the toolbar. Matlab/Simulink will check your setting, compile and upload the program into Arduino Microcontroller. After that analog voltage signal will be read into Simulink and displayed on the Time Scope. Then change the potentiometer value and observe the time scope plot. You will see that the analog signal graph will change in real time as displayed in time scope. So this is one way to read analog signal and display it in time scope for real time simulation.

You can see the following video demonstration of plotting analog voltage signal on the time scope.

We hope you liked this tutorial and if you did, share it and subscribe to our blog posts. For other Arduino related tutorials and not just Arduino-Simulink 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

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

sending pwm pulses from simulink model to Arduino

Sending PWM pulses using Repeating Sequence – Arduino Simulink Tutorial

Real Time Oscilloscope using Simulink and Arduino

Real Time Oscilloscope using Simulink and Arduino