Anda di halaman 1dari 4

Lobrigas, Jake C.

Date Performed: 12/12/ 2016


Evaluation and Recommendation for ADC (Polling Mode)
Lab Report 3

Experiment 3 makes use of Analog-Digital Converter pin operating in Polling Mode in the
STM32L053Tx Microcontroller. This experiment involves the use of a potentiometer- a variable
resistor that changes its resistance as its knob is being rotated. The potentiometer is used in
implementing a voltage divider circuit by connecting the potentiometer separately with ground,
3.3V, and Analog-Digital Converter Pin connected- which was declared with the use of the
STM32CubeMx software. STM32CubeMx software is being used in order to declare the usage
of pins in the microcontroller, and configure the microcontroller's clock. Generally, this program
provides initialization which generates a source code in the IAR workbench which corresponds
to the settings and configurations made by the user from the STM32CubeMx. This experiment
involves two variables- the ADC Value and the Analog Value. In which the ADC value is the
value being read by the microcontroller from the potentiometer as its resistance is being varied.
The ADC value is then converted to its equivalent Analog Value using a given formula. These
calculation is made by creating an algorithm in the source code of the program to be uploaded
in the microcontroller. Using the "live watch" option in the debugging window, the correlation
between the behavior of the ADC value and Analog Value is observed. Whenever the shaft of
the potentiometer is being rotated, the amount of resistance is being varied in either side of the
wiper which is connected. Based on my observations in this experiment, rotating the shaft
clockwise (towards the 3.3V pin) produces an Analog Value of 3.3V. As the shaft is being rotated
counterclockwise (towards the ground pin), the Analog Value decreases as it approaches to a
very small value which is approximately equal to 0.
Reading Number
Reading1
Reading2
Reading3

adcValue
72
1876
4095

analogValue
.00588
1.51
3.3

Description
Towards the Ground
Middle
Towards 3.3V

Table1. ADC Value and Analog Value in Response to Potentiometer Rotation

After conducting the first part of the experiment, we then proceed in making the exercise.
The exercise makes use of an Analogy Discovery and Digilent software in order to view the
output waveforms of this activity. This exercise still uses the potentiometer in order to implement
a voltage divider circuit, the same set-up was being used. But this time, an output waveform
with a specific duty cycle is required for a specific range of Analog Values based on the
potentiometer's reading. The task was to create an algorithm that creates an output of a
specified duty cycle within an allotted range of analog values. The following table shows the
conditions which should be used in creating the algorithm of the program.
analogValue range
0 analogValu < 1.1
1.1 analogValue 2.2
2.2 < analogValue 3.3

Duty Cycle
25%
50%
75%

Table 2. Range of analogValue with its corresponding Duty Cycle

An additional output pin is required for this experiment, this output pin will be connected
with the Analog Discovery in order to show the output waveform which corresponds with the
current Analog Value being read. The algorithm for this code is composed of if-else statements
which satisfies the conditions being specified in Table 2. The source code for the program is
being shown in Figure 1. It can be observed the duty cycle is the ratio of the logic value HIGH
state and the period, this idea lead to the implementation of this source code which is
observable with the "HAL_Delay" syntax being used.

Figure 1. Exercise Source Code

In the proceeding figures, the output waveforms are being obtained along with the "live
watch" in order to show the current Analog Value if it does correspond with the output waveform
required. This waveform is obtained through the Digilent software configured as a scope in
order to produce an output that shows the frequency and duty cycle of the waveform.

Figure 2. 25% Duty Cycle with 10Hz Frequency at Analog Value of approximately 0.005157

Figure 3. 50% Duty Cycle with 10Hz Frequency at Analog Value of 1.74

Figure 4. 75% Duty Cycle with 10Hz Frequency at Analog Value of 3.28

This experiment is really good and the instructions and procedures stated in the
laboratory manual are clear and understandable. This is a good experiment and exercise
because we were able to collaborate ideas with one another because the exercise were done in
pairs due to the shortage of the materials such as the Analog Discovery. This experiment
enabled us to recall and apply the things we have learned during our program classes due to
the fact that the software uses C language. We were able to perform the experiment and finish it
on time with understanding and a sufficient amount of learning. My only recommendation is to
show the derivation as to why the ADC value being read is converted to Analog Value with the
given formula and state some common applications that this experiment can be applied.

Anda mungkin juga menyukai