Reading sinusoidal analog signal using Arduino Due

In this tutorial you will learn how to acquire and plot sinusoidal signal with Arduino Due. The sinusoidal signal is generated using Arduino UNO.

Here we will show how to read sinusoidal analog signal using Arduino Due. After reading it we will plot it to show the signal in real time. For this we will use the Matlab Simulink. More specifically we will use the S-Function Builder block in Simulink to read the analog signal and plot in real time on DSP time scope.

The Matlab Simulink setup is shown below.

How to setup the S-Function builder and how to read analog signal was already explained in the previous two tutorials- Reading analog signal with Arduino Due and Simulink Part 1 tutorial and Reading analog signal with Arduino Due and Simulink Part 2 tutorial.

Once you have setup this Simulink part we next explain the generation of sinusoidal signal. We can generate sinusoidal signal from Arduino UNO digital pulses. By passing the digital pulses of some frequency to a RC low pass filter we will get approximate sinusoidal signal. This also was already explained in the previous tutorial Create sine signal from digital pulses using Arduino.

The diagram is reshown here.

The output of the RC LPF should be connected to the Arduino Due analog pin A0. However we have to change the above LPF a little bit. That is because Arduino Due accepts maximum voltage of 3.3V. The output from the above LPF is signal with amplitude of 5V because the digital pulses from Arduino UNO is +5V for logic high. See graph below.

So in order to sense the sinusoidal signal with Arduino Due, we have to adjust the filter so that the output from the filter has sinusoidal signal with amplitude within 3.3V.

How to do this? To do this we apply the voltage divider rule.

The frequency is 0.5Hz and the capacitor is 1uF. Hence the resistor value was 318KOhm in the above diagram.

If we connect another resistor R2 in parallel to R1 in the above circuit diagram then the equivalent resistor Req should be now 318KOhm so that Req together will C=1uF gives still the same frequency 0.5Hz. See the figure below how to connect the R2 resistor in parallel with R1.

Now the voltage at the junction between R1 and R2 is 2.5V ideally due to voltage divider rule.

Now to recalculate R1 and value of R2 so the we get Req of 318KOhm we use the resistor in parallel formula.

\frac{1}{Req} = \frac{1}{R1}+\frac{1}{R2}

Choosing R1 = R2 = R we get,

R = 2*Req

Hence R = 636KOhm, that is R1 = R2 = R = 636KOhm

By simulating we get the following graph for input and output voltage for LPF.

As you can see the approximated sinusoidal signal is at peak of 2.5V. This signal therefore can now be acquired by Arduino Due because it falls within the voltage range of Arduino Due.

Leave a Reply

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