You are on page 1of 8

Digital Signal Filtering

Rodriguez, John Michael

Batangas State University, Alangilan Batangas City, Philippines


College of Engineering, Architecture and Fine Arts
ECE/ICE/MEXE Department
April071995@gmail.com

Abstract – The aim of this paper is to build a robot car that operates through a straight path on a
revolving platform. The robot car is equipped with MPU6050 sensor an Inertia Measurement Unit
or IMU used for motion processing. The robot DC motors is controlled using L298 motor driver. To
compensate for the gyro drifts and stabilize the motion of the robot an exponential filter is used.

I. INTRODUCTION Digital filter samples the analogue


signal and convert it into a set of binary
A robot is a machine programmed and numbers. These numbers are stored as digital
designed to carry through one or more tasks data in a hard disk drive, processed, and
automatically with fast action and preciseness. manipulated digitally. One example is
There are as many different types of robots as exponential filter. The exponential filter is a
there are tasks for them to perform. Robots that weighted combination of the previous estimate
appear like humans are known as androids; (output) with the newest input data, with the
however, many robots aren't built to resemble sum of the weights equal to 1 so that the output
human model. Industrial robots, for example, matches the input at steady state.
are often created to perform monotonous tasks
that aren't facilitated by a human-like The Exponential Filter class implements
a simple linear recursive exponential filter for
construction. Some robots are remotely
controlled by a human , even from a great the Arduino. It provides a simple way to smooth
noisy measurements from analogue sensors
distance. An autonomous robot acts as a stand-
without using as much memory.
alone system, complete with its own computer
(called the controller).Today many robots are
containing sensors and programmable
II. OBJECTIVES
controllers.

An inertial measurement unit (IMU) is a  To build a robot that operates through a


device that directly measures the three linear straight path on a revolving platform.
acceleration components and the three rotational  Implement a filter to raw data for the
rate components (6-DOF) of a vehicle. An IMU robot to run smoother.
is unique among the sensors typically found in
an autonomous vehicle because an IMU requires III. LITERATURE REVIEW
no connection or knowledge of the external
world.
A two-wheeled self-balancing robot with Arduino
dynamics model

Based on the published paper of Md.


Iman Ali and Md. Modasser Hossen, Robot is
inherently unstable, it is necessary to implement
a control system to keep the system in balanced.
The paper examines the stability and evaluates
the performance of a PID controller in the self- Figure 1.
balancing robot. They focus on the main
challenging issues are when an external force is Arduino Uno is an open-source
applied and reducing vibration in order to microcontroller board based on the
improve the stability of the robot.. Besides the Microchip ATmega328P microcontroll
simulation of the transfer function, poles and er and developed by Arduino.cc.
zeros, Kalman filter are the cause which
MPU-6050
determines the performance of the self-
balancing robot.[1]

Implementation of Autonomous Line


Follower Robot

According to the paper of Kazi


Mahmud Hasan et.al ,the line follower is an
Figure 2.
autonomous robot that detects and follows a
line. The path they used can be visible like a The MPU 6050 is a 6 DOF (degrees of
black line on a white surface or may be reverse freedom) or a six-axis IMU sensor,
of that or it can be invisible like a magnetic which means that it gives six values as
field. In order for robot to sense a line and output: three values from the
maneuvers accordingly to stay on the line, a accelerometer and three from the
close loop control system is used in the robot. gyroscope.
[I]. The robot is designed to follow very tight
L298n motor driver
curves as the data from the sensors are
continuous in nature. This robot is simple but
effective having straightforward design to
Figure 3.
perform line following task.[2]
The
L298N is a
IV. MATERIALS dual H-Bridge
motor driver which allows speed and
direction control of two DC motors at beginners to add micro-controller(such
the same time. The module can drive as Arduino/Raspberry pi) and some
DC motors that have voltages between 5 module to build their own robot car.
and 35V, with a peak current up to 2A.
Connecting wires
Stepper Motor

Figure 7.
Figure 4.
Connecting wires allows an
It is a DC motor used to drive electrical current to travel from one
the revolving platform. point on a circuit to another because
electricity needs a medium through
Power bank
which it can move.

4 AA alkaline batteries

Figure 5.

A portable power supply used


to power up the Arduino uno.

4WD motor chassis Figure 8.

A disposable power source used


to drive the dc motors.

Round platform

Figure 6.

The robot chassis kit is a good


platform for electronic enthusiasts or
5. Mount the Arduino board and apply the
proper connections of the wires.
6. Mount the sensor and the driver and
assemble its proper connections to the
Arduino board and motor.

Figure 9.

Testing platform of the robot


car.

V. METHODOLOGY

A. Construction of the revolving platform


1. Cut the plywood to a circular form Figure 10.Completed robot car
approx. 48 in in diameter.
2. Create a motor base at the center under C. Choose the desired filter for the robot.
the platform. D. Write the program of the robot and
3. Attach a motor to the base of the revolving platform in Arduino IDE.
platform.
B. Construction of the robot Code for the Platform
1. Prepare the chassis parts contained in
the 4WD chassis package.
#include <Stepper.h>
2. Assemble the motor of the wheels. Use
four long bolts to attach two motors to const int stepsPerRevolution = 72 ; //to achieve
5 degree per step 360/72 equal to 5 degree
each of the side plates. Ensure the motor
is flat against the plate and tighten the
// initialize the stepper library on pins 8 through
nuts firmly but take care not to use too
11:
much force. Stepper myStepper(stepsPerRevolution, 8, 9, 10,
11);
3. Assemble the chassis, use Phillips
screwdriver to tighten the screws. The int stepCount = 0; // number of steps the
motor has taken
battery pack is knotted to the top chassis
plate together with the l298n driver
4. Solder the power and motor void setup() {
// initialize the serial port:
connections. Serial.begin(9600);
}
void loop() {
// step one step:
myStepper.step(1);
Serial.print("steps:");
Serial.println(stepCount);
stepCount++;
delay(1500);
}

Code of the filter

Figure.14

Figure.11 This section show the control of


This section indicates the the motor speed based on the filtered
library used and the Filter setting used
for the robot. raw values.

Code for the MPU6050

Figure.12
This section shows the value to
be filtered and the function use to filter
the raw data.

Figure 15.
Code for the Car’s motor
For the code of MPU6050 we
just modified the example sketch from
MPU6050 library and combined all the previous
codes for the robot car to work.

E. Test the functionality of the robot.


1. Calibrate the sensors using
calibration sketch.

Figure.13 Figure 19.


This section shows the
declaration of pins and data type for 2. Change the offset using the result
each values. on step one.
• yn is the output of the filter at a
moment in time n
• xn is the new input value at a
Figure 16.
moment in time n
• yn – 1 is the previous output
3. Don’t move the robot for 30 second
value of the filter
to find the offset of the yaw value.
w is the weighting factor in the range
[0, 100]. High values of w (90, for
example) favour new data over old data.
Figure 17.
The output responds quickly to changes
in the input but is not smoothed much.
4. Change the offset of the yaw value
Low values of w (10, for example)
using the result of the previous step.
favour old data over new data. The filter
Then set the settings of the filter in
output is heavily smoothed and
the code. (50 is the smoothening
responds slowly to changes (noisy or
constant and 0 is the initial value).
not) in the input. [3]

We have our first RawValue = -1.9


Figure 18.
,w=50 or (0.5), new input xn=-2.15 and
our first smoothened value 0.
5. Upload the sketch again. This time
Substituting these to the equation we
the values will be less sensitive.
get:
6. Power-up the robot using power
bank.
yn= (0.50)(-2.15)+(1-0.50)(0)
7. Start the revolving platform.
yn= -1.075 ≈ -1
8. Place the robot car on the top of
revolving platform and observe its
yn=(0.50)(-2.42)+(1-0.50)(-1.075)
behaviour.
yn=-1.21+0.5375
yn=-0.6725 ≈ -1
VI. DATA AND RESULTS

yn=(0.50)(-2.7)+(1-0.50)(-0.6725)
1. Exponential Filter Formula.
yn=-2.2+0.33625
yn=-1.86375≈ -2
yn = w × xn + (1 – w) × yn – 1 (Eq. 1)

Computing and substituting all given


Here:
raw values in the equation will have
these following results.
Figure 20. Filtered data when
smoothing constant is 50. Figure 24.
The figure shows the Filtered

2. Actual testing of the robot car on the (red) and Unfiltered (blue) yaw values

platform. read from arduino. Due to the constant


rotation, unevenness of some parts of
the platform and the natural yaw drift of
MPU6050, noises were observed during
testing. But the exponential filter
manages to smoothen the signal and
minimize the noises mentioned.

We had a major problem


regarding with the revolving platform.
Initial position. Final position.
Even though we supply it with the
Figure 21-22.
correct power supply (12V/2A), the
stepper motor is unable to rotate
3. Filtered and unfiltered data when
constantly due to the weight of the
robot car is not moving.
platform disc. To solve this problem we
tried to rotate the platform manually
simulating the 5 degree/sec rotation of
the stepper motor. Though it is not as
accurate as what the stepper motor can
Figure 23. do, the robot still responded well on our
action.
The blue line represents the unfiltered Upon testing and setting the
data, while the red line represents the initial yaw orientation for the robot, we
filtered data. The two data values are actually observed how the robot
almost same in magnitude. managed to keep track of its original
4. Filtered and unfiltered data when yaw orientation even the platform is
robot car is moving. rotating. The robot was able to run on a
straight path. Though upon trials, we http://ieeexplore.ieee.org/document/6317486
observed that the robot needed to have [3] Exponential Filter
better design because the wheels can’t https://www.megunolink.com/documentation/ar
get a good grip on the platform in some duino-libraries/exponential-filter/
occasions which lead the car to stop in [4]L298N Datasheet
the middle of testing. Another thing is http://www.handsontec.com/dataspecs/L298N%
that the robot can only keep track of its 20Motor%20Driver.pdf
original yaw orientation at approx. ±10
[5] MPU6050 Datasheet
degrees from the offset.
https://www.invensense.com/wp-
content/uploads/2015/02/MPU-6000-
VII. CONCLUSION
Datasheet1.pdf

To build the robot, all parts must [6] Exponential Filter


properly connected so that no lose parts will https://gregstanleyandassociates.com/whitepape
hinder its performance. The MPU 6050 rs/FaultDiagnosis/Filtering/Exponential-
sensor did a great job of making the robot Filter/exponential-filter.htm
run on a straight path using its DMP or
[7] MPU6050
Digital Motion Processing.
https://www.invensense.com/products/motion-
Even though DMP compensates MPU
tracking/6-axis/mpu-6050/
6050 lack of magnetometer, natural gyro
drift still occur in the system. Using a filter
like exponential filter minimized the effect
of this said phenomenon on the system. The
noisy raw data was smoothened, minimizing
the effect of the noise in the operation of the
robot. Though its effect is not noticeable on
actual action, because the differences of the
data were in decimal at most, its effect can
be observe through the use of the serial
plotter of arduino ide.

VIII. REFERENCES

[1] A two-wheeled Self-Balancing Robot with


Dynamic model.
https://ieeexplore.ieee.org/document/4109027/
[2] Implementation Of Autonomous Line Follower
Robot .

You might also like