Professional Documents
Culture Documents
Universidad Politecnica de Yucatán
Universidad Politecnica de Yucatán
Universidad Politecnica de Yucatán
21-01-2022
1
The objective of this practice is to learn how to control the direction
Index
Introduction: ................................................................................................................................ 4
Objetive: ...................................................................................................................................... 4
Analog Signal............................................................................................................................ 5
Materials: .................................................................................................................................. 9
Procedure: ................................................................................................................................. 9
Code: ....................................................................................................................................... 12
Conclusion ................................................................................................................................. 15
Pwm Signal
• Introduction:
In this work we work different components to be able to perform the practice successfully, but
before that we define about the concept of the PMW, as well as about the terms of analog and
digital signal, as well as about the frequency of the ATmega328p and more, since all this is
something that helps us to understand the theoretical part and to be able to pass to the practice
• Objetive:
We have to learn how to control the speed and direction with the ponteciometer using the gear
motors and with the oscilloscope to observe the voltage measurement of the requested and be
successful.
• Theoretical Framework:
PWM signal
Pulse-Width Modulation (See figure 1-PWM) is a powerful technique for controlling analog
A PWM is basically a digital unipolar square wave signal where the duration of the ON time
can be adjusted or modulated as desired. This way the power delivered to the load can be
A signal is an electromagnetic or electrical current that is used for carrying data from one
system or network to another. The signal is a function that conveys information about a
phenomenon.
electromagnetic wave which carries information. A signal can also be defined as an observable
change in quality such as quantity. There are two main types of signals: Analog signal and
Digital signal.
Analog Signal
Analogue signals are transmitted using a continuously changing quantity as a reference. Data
as input and produces a computer-readable binary number as output. The A/D converter (ADC) is
one of the most important components of the data acquisition system, its performance
determining the accuracy and rate at which digitised samples can be acquired.
Analog signals are often calculated responses to changes in light, sound, temperature,
position, pressure, or other physical phenomena. When plotted on a voltage vs. time graph, an
analog signal should produce a smooth and continuous curve. There should not be any discrete
Digital Signal
A digital signal is a signal that represents data as a sequence of discrete values. A digital
signal can only take on one value from a finite set of possible values at a given time. With digital
signals, the physical quantity representing the information can be many things:
• Acoustic pressure
Digital signals are used in all digital electronics, including computing equipment and data
transmission devices. When plotted on a voltage vs. time graph, digital signals are one of two
values, and are usually between 0V and VCC (usually 1.8V, 3.3V, or 5V) (See Figure 3).
Knowing the concepts of Analog and Digital signal, we can now mention some of their
To record an analog signal, the technique used, In recording digital signal, the sample signals are
Examples of analog signals are Human voice, Examples of digital signals are Computers,
Recall that the ATmega328p is the most popular on the Arduino UNO. However, the
ATmega328p's 28 PDIP package can easily be used without any boards. Simply place it on a
breadboard, and connect a TTL adapter and an ISP and you're ready to go.
And typically, a servo motor anticipates an update every 20 ms with a pulse between 1 ms and
2 ms. This equates to a duty cycle of 5% to 10% at 50 Hz. Now, if the pulse is at 1.5 ms, the
servo motor will be at 90-degrees, at 1 ms, 0-degrees, and at 2 ms, 180 degrees.
frequency of 30 Hz.
Figure 4: PWM and Duty Cycle Diagram
Atmega 328P Frequency is: 1MHz/8MHz (Up to 20MHz with external clock)
Here we explain a little more about this, the ATmega328p has two internal oscillators clocked at
8MHz and 128kHz which allows it to run without any external clock source or crystal. By
default, the fuses are configured to use the internal 8MHz oscillator and a clock divider resulting
• Practical development:
Materials:
1pz H-bridge
1pz Potentiometer
1pz Protoboard
Dupont cables
Procedure:
For the first step was to make the code so that when activating the PWM signal the motors
were activated and began to rotate faster as the signal was stronger.
After that was to connect the inputs that we had defined in our code, as well as the EnA and
EnB since in our case we use 2 motors, as important information the ports EnA and EnB must be
connected to the PWM signal that is represented with a ~. We connect both motors to the
corresponding Outputs.
Then we go to the breadboard where we connect the potentiometer, which will be responsible
To finish with the assembly, we connect to the Arduino the pins that we had already chosen in
our code, as well as the analog signal of the potentiometer and its pins.
Once the assembly is finished, we will give power which in this case will be with an
equipment of the laboratory which we must always check that it marks 0 in both Amperage and
Voltage. Once this is checked we place in amperage 2 and in voltage 9 since when using 2 motors
We connect the alligators corresponding to the negative and the positive to the 12V and to the
While it is in operation, we connect the oscilloscope to the pin of the PWM signal in this case
the "5", to be able to observe the frequency and as it is seen through this device.
Code:
/*Variables*/
void setup() {
pinMode (in1,OUTPUT);
pinMode (in2,OUTPUT);
pinMode (in4,OUTPUT);
void loop() {
val= analogRead(pot);// Value of the potentiometer (It could be a value between 0 and 1023)
//Left
if(val,128){
digitalWrite(in2,LOW);
digitalWrite(in1,HIGH);
digitalWrite(EnA,vel);
digitalWrite(in4,LOW);
digitalWrite(in3,HIGH);
analogWrite(EnB, vel);
//Stop
else{
digitalWrite(EnA,LOW);
digitalWrite(EnB,LOW);
delay(15);
Conclusion
In this practice we learned about the PWM signal as it is, what it is for, how it works, as well
as the digital and analog signal. We put together a small robot prototype, which when activating
the potentiometer must increase the PWM signal so that the motors start to rotate or move
forward. The PWM signal is found on the pins that have this symbol on their ~ side, with this we
already know that the signal we are looking for exists. And all the above mentioned can be very
useful, since they are concepts that come together and can be used later both as a review, as for
Bibliographic References
+ Storr, W. (2020, August 5th). Pulse Width Modulation Used for Motor Control. Basic
modulation.html
+ S.A. (S. F.). Pulse Width Modulation - an overview | ScienceDirect Topics. Sciencedirect.
https://www.sciencedirect.com/topics/engineering/pulse-width-modulation
+ Williams, L. (2022, February 2sd). Analog vs Digital: What is the Difference Between Analog
+ S.A. (S. F.). Activity: Pulse Width Modulation [Analog Devices Wiki]. Wikianalog.
https://wiki.analog.com/university/courses/electronics/electronics-lab-pulse-width-
modulation
+ Arrow Electronics. (2021, February 10th). Analog vs. Digital Signals - What the Difference?
Arrow.Com. https://www.arrow.com/en/research-and-events/articles/analog-vs-digital-
what-is-an-analog-signal
+ S.A. (S. F.). Difference Between Analog Signals and Digital Signals - Javatpoint.
Www.Javatpoint.Com. https://www.javatpoint.com/difference-between-analog-signals-
and-digital-signals
+ S.A. (S. F.). Analog vs. Digital Signals: Uses, Advantages and Disadvantages | Article | MPS.
Monolithicpower. https://www.monolithicpower.com/en/analog-vs-digital-signal
https://www.sciencedirect.com/topics/computer-science/analogue-signal
+ E. (2021, November 20th). ATmega328P Fast PWM mode Programming Examples. Ee-Diary.
https://ee-diary.blogspot.com/2021/07/atmega328p-fast-pwm-mode-
programming.html#:%7E:text=The%20following%20is%20then%20the,75%25%20using
%20Timer%2FCounter0.&text=The%20following%20schematic%20diagram%20shows,(
port%20D%20pin%206).
os.org/group__boards__atmega328p.html
+ Mariscalchi, A. (2021). Anda Fournel, Thea Ionescu et Jean-Pascal Simon (dir.), Geste, parole
+ Author, G. (2020, December 3rd). Gears Magazine - Exploring PWM, Frequency and Duty
and-duty-cycle/
+ S.A. (S.F.). Pulse Width Modulation Characteristics and the Effects of Frequency and Duty
characteristics-and-the-effects-of-frequency-and-duty-
cycle#:~:text=PWM%20Frequency&text=Typically%2C%20a%20servo%20motor%20an
ticipates,at%202%20ms%2C%20180%20degrees.