Arduino Simulink as Oscilloscope to Capture Square Wave

Here we will show you how you can use Arduino Due with Simulink to capture square wave signal and display them on the Time scope. Essentially, using Arduino and Simulink as a DIY oscilloscope. To make use of we used three square wave from three different sources- 555 Timer, ATmega32 and Arduino Due itself. We generated square wave using 555 timer, ATmega32 and Arduino Due and fed them to analog pins A0, A1 and A2 of Arduino Due. The Arduino Due was linked with simulink using the Simulink Support Package for Arduino Hardware.

The 555 Timer circuit from our earlier tutorial was used which generated 1.5Hz square wave signal. The output from the timer was fed into the analog A0 pin of the Arduino due. The ATmega32 microcontroller was used to generate 1Hz square wave signal. This 1Hz signal from ATmega32 was fed into the analog A1 pin of the Arduino Due. Also we used the same Arduino Due to generate 1Hz signal in pin 9 and was fed to the analog A2 pin of the Arduino due. 


The Simulink model diagram is as shown below. 

Simulink Model to capture square wave

The first setup is for the square wave capture coming from the 555 Timer. The second setup is capturing square coming from its own digital pin 9. To do this, we used pulse generator(you could also use Waveform Generator Simulink), where we specified the frequency as 1Hz. The third setup is for the capturing the square wave generated by ATmega32 microcontroller. The gain block has been set to value of 3.3/(2^12-1). This is because the Arduino Due is 3.3V microcontroller and it's ADC has 12 bit resolution.

On the breadboard, the setup looks like in the picture below.

Arduino Simulink as Oscilloscope to Capture Square Wave

 The picture above shows ATmega32 Port D7 pin connected to the A2 analog pin of Arduino Due. The 555 Timer output from it's pin 3 is connected to the A0 analog pin of Arduino Due. Also the Arduino Due digital pin 9 is connected to the analog pin A0.

After running simulation we got the following waveforms. 

For 555 Timer which generated 1.5Hz square wave signal, the waveform on the time scope looked like this-

Arduino Simulink as Oscilloscope to Capture Square Wave

 For Arduino Due generated 1Hz square wave, the waveform captured and displayed on the timescope looked like this-
Arduino Simulink as Oscilloscope to Capture Square Wave

For the ATmega32 microcontroller which generated 1Hz square wave signal the waveform on the timescope looked like this-

Arduino Simulink as Oscilloscope to Capture Square Wave


Video Demonstration

Watch the following video that illustrates Arduino Due with Simulink as a DIY oscilloscope.

 

Here we have used simulink but we can do the same thing using Matlab code. See How to plot real time data from arduino in matlab. Another way is to use the PC audio input to acquire signal and plot it in real time which is illustrated in the tutorial How to use Matlab Simulink as Oscilloscope.

Post a Comment

Previous Post Next Post