Skip to content

6. Electronics Design

Group Assignment

We were lucky to be given a workshop by our second instructor, Onik Babajanyan. In this workshop, we got familiar with the oscilloscope. It is an instrument that enables us to plot the voltage between two probes as a function of time.

oscilloscope

In order to demonstrate its capabilities, Onik wanted to generate a sine function as well as a periodic ramp function. Since the Arduino board doesn’t have a digital to analog converter, it would be hard to generate the signals with this microcontroller. It is apparently possible to do it by using Pulse Width Modulation and adding an external RC filter, but the signal would probably not be very “clean”. Fortunately, we also have some STM32 microcontrollers in the Fablab, and those have a Digital to Analog Converter built in.

In order to generate the code for these functions, we tried to ask chatGPT. We used the following prompts:

ramp genertation using stm32f3discovery by dac

sinusoid genertation using stm32f3discovery by dac

The code for the functions was the following:

code

Using the STM32Cube IDE, we selected the OUT1 configuration. This enabled us to use the pin PA4 as output for our signal. The measurement was realised by attaching one probe to the USB port and the other one to the PA4 pin:

measurement

We first observed the ramp signal:

Since the ramp function had a very low frequency, the oscilloscope didn’t manage to detect and “focus” the signal automatically. We had to use the TIME/DIV and VOLTS/DIV knobs in order to observe it.

We then generated the sine function and observed it:

sinusoid

Reflection by Maxime

It was interesting to generate some code with chatGPT. I was first skeptical that the code would be usable, but was surprised when it produced the desired result. However, it was funny to see that it generated some useless code by multiplying by 1000 before dividing by 33000:

*1000 / 33000;

It was also surprising that the frequency detected for our ramp function was 2Hz, since it was repeated every second:

After some searching, I realised that even when there is no signal fed to the device, the displayed frequency is 2Hz:

The device probably didn’t manage to properly detect the signal frequency and is just displaying a default value.

Since we didn’t have yet the recitation on debugging, it was hard for me to imagine use cases for how to use the oscilloscope. I checked the slides from last year and this website of a constructor to understand two use cases:


Last update: March 14, 2023