Mec680 - Lab Report 2 - Group 1
Mec680 - Lab Report 2 - Group 1
LABWORK 2
PLAGIARISM STATEMENT
I/We certify that this assignment/report is my/our own work, based on my personal study and/or
research and that I/we have acknowledged all material and sources used in its preparation, whether
they be books, articles, reports, lecture notes, and any other kind of document, electronic or personal
communication. I also certify that this assignment/report has not previously been submitted for
assessment in any other unit, except where specific permission has been granted from all unit
coordinators involved, or at any other time in this unit, and that I/we have not copied in part or whole
or otherwise plagiarised the work of other students and/or persons.
● Unable to
write
abstract ● Fairly write
● Capable to write abstract CO3 [PO3]
concisely, abstract i.e.
i. Abstract concisely, informative and
informative not enough
quantitative.
and information
quantitative
.
● Unable to
● Fairly
describe
describe ● Capable to describe
background
background background and objective CO1 [PO1]
ii. Introduction and
and objective of each experiment
objective of
of each clearly.
each
experiment
experiment
● Unable to
formulate a
● Adequately
complete
formulate
theoretical
theoretical
and ● Capable to formulate a CO1 [PO1]
and
iii. Theory experiment complete theoretical and
experimental
al principle experimental principle.
principles
i.e. just
with small
write the
errors.
final
formula.
● Adequately
produce an
● Unable to appropriate
produce an procedure to
appropriate run the
● Capable to produce a
procedure experiment CO2 [PO2]
iv. Experimenta detailed procedure to run
to run the and fair
l procedure the experiment and good
experiment record
record keeping.
and poor keeping. i.e.
record missing steps
keeping. in procedure
and missing in
data record
● Unable to
● Adequately
present
present
experiment
experimental
al result ● Capable to articulate
result using
using experimental result using
appropriate CO3 [PO2]
v. Result tables, appropriate tables,
tables, charts,
charts, charts, graphs or other
graphs or
graphs or presentation formats.
other
other
presentation
presentatio
formats.
n formats.
● Unable to
relate ● Adequately
theoretical relate
analysis theoretical ● Capable to relate
with analysis with theoretical analysis with CO3 [PO3]
vi. Discussion
experiment experimental experimental result and
al result result and their practical implication.
and their their practical
practical implication.
implication.
● Unable to ● Conclusion is
come out a not clear, but
clear and yet, ● Capable to express a clear CO3 [PO3]
vii. Conclusion
understand understandab and concise conclusion.
able le in such
conclusion. manner.
● Quotes
● Unable to
included but
search and
the number
Quotes are ● Capable to search and
of references CO3 [PO3]
from Quotes are from
viii. References does not
minimum minimum ten (10) new
exceed 10
ten (10) references (last 5 years)
papers or not
new
new
references
references
● Unable to
write a lab
report
● Generally, ● Capable to write a lab
ix. Overall clearly,
follows the report clearly, precisely CO3 [PO7]
impression precisely
standard a lab and in a well-organized
of report and in a
report. manner
well-
organized
manner
● At least
discussed
once with the ● Pro-active, discussed
x. Consultation ● Unable to
instructor/ regularly with the
with portray pro-
lecturer instructor/ lecturer and
Lecturer/ active
before showed results/ finding
Instructor behaviour
submitting progressively.
the final
report.
TABLE OF CONTENTS
1.0 ABSTRACT ............................................................................................................................... 5
2.0 INTRODUCTION..................................................................................................................... 5
3.0 THEORY ................................................................................................................................... 6
4.0 EXPERIMENTAL PROCEDURE .......................................................................................... 7
4.1 APPARATUS AND SOFTWARE ....................................................................................... 7
4.2 METHODS ............................................................................................................................ 8
4.2.1 Calibration of Encoder ................................................................................................. 8
4.2.2 Calibration of DC Motor and PWM Amplifier .......................................................... 8
4.2.3 Calibration of DC Motor and Encoder ....................................................................... 9
4.2.3 Calibration of Input Voltage and No-Load Speed of the DC Motor ........................ 9
5.0 RESULTS ................................................................................................................................ 10
5.1 Calibration of Encoder .......................................................................................................... 10
5.2 Calibration of DC Motor and PWM Amplifier ..................................................................... 10
5.3 Calibration of DC Motor and Encoder .................................................................................. 11
5.4 Calibration of Input Voltage and No-Load Speed of The DC Motor ................................... 11
6.0 DISCUSSION .......................................................................................................................... 12
7.0 CONCLUSION ....................................................................................................................... 14
8.0 REFERENCES ........................................................................................................................ 15
9.0 APPENDIX .................................................................................................................................... 16
9.0 CONTRIBUTION OF EACH TEAM MEMBERS ............................................................. 23
TABLE OF FIGURES
Figure 1: Calibration of Encoder Graph .............................................................................................. 10
Figure 2: Calibration of DC Motor and PWM Amplifier Graph ......................................................... 10
Figure 3: Calibration of DC Motor and Encoder Graph ...................................................................... 11
Figure 4: Calibration of Input Voltage and No-Load Speed of The DC Motor Graph ........................ 11
LIST OF TABLES
Table 1: List of Apparatus Used ............................................................................................................ 7
Table 2: List of Software Used .............................................................................................................. 8
1.0 ABSTRACT
2.0 INTRODUCTION
Other than that, the system integration and calibration are the fundamental to
mechatronics, where it is seamless interaction between the hardware and software to
ensures precise control and a reliable performance. This experiment investigates the
integration of a mechatronic control system by connect an encoder, DC motor, and
PWM amplifier to a central controller, followed by a calibration to ensure a system
accuracy. This experiment shows the issues of synchronisation, signal processing, and
error correction in a mechatronic system while it is also illustrating the importance of
calibration in obtain the optimal function.
3.0 THEORY
1.
Power supply
2.
Arduino microcontroller
3.
Dc motor
4.
Encoder
5.
PWM Aplifier
Table 1: List of Apparatus Used
NO. SOFTWARE
1.
Putty Software
2.
4.2 METHODS
4.2.1 Calibration of Encoder
To proposed approach involves, the following steps were carried out:
Figure 4: Calibration of Input Voltage and No-Load Speed of The DC Motor Graph
6.0 DISCUSSION
In Experiment 3, Using the Arduino IDE 2.3.6 software for programming and
data collecting, as well as PuTTY software for monitoring, the encoder and DC motor
were calibrated together. According to the data, the encoder successfully recorded the
angular position and speed over time when the motor was running by a PWM signal
that was amplified by the MD10C Motor Driver. The motor's alternating rotation
directions were consistently represented by the plotted graphs for angular position vs.
time and angular speed vs. time (Figure 3). As the motor's direction changed, the
angular speed changed between positive and negative numbers. Minor fluctuations
observed in the graphs were attributed to noise in the measurements, slight variations
in motor load, or inconsistencies in sampling time.
In Experiment 4, input voltage vs no-load speed was analyzed to assess motor
system performance after integration and calibration. According to the data, the proper
system function was confirmed by series 1 correct positive trend. However, series 2 had
a negative slop, which was probably caused by software problems, wiring mistakes or
mis calibrated sensor. These differences are typical in the early stages of integration.
Obtaining an understanding of the gradient aids in defect identification and calibration
improvement. Overall, the experiment demonstrated how crucial precise system
configuration is to dependable data and operation.
Regarding the post-lab question, the sampling time was not consistent during
the experiment. This inconsistency can be due to several factors, including delays in
data transfer between the Arduino Uno and the PC (through PuTTY), processing
demands on the Arduino or interference from other concurrent processes while
collecting data. To reduce sampling time, an effective approach would be to optimize
the Arduino code to eliminate redundant calculations within the sampling loop.
Additionally, employing faster microcontrollers or real-time operating systems would
assist in achieving more consistent sampling rates.
In the next lab session, in which a computer algorithm for a motion control
system will be created and executed, the impact of sampling time will be very
important. If the sampling time is too long or inconsistent, the control system might
react slowly or unpredictably, leading to oscillations, instability, or poor tracking
performance. Thus, obtaining a reliable and sufficiently fast sampling rate, utilizing
tools such as the Arduino IDE 2.3.6 and durable hardware like the Arduino Uno, will
be crucial for the precise and steady functioning of the motion control system.
7.0 CONCLUSION
From the results obtained, the relationship between input voltage and motor
speed was clearly seen that confirmed the system could translate control inputs into
mechanical motion. The successful encoder calibration allowed the measured speeds to
align closely with expected values, demonstrating improved measurement accuracy and
repeatability. However, inconsistencies in sampling time were notice, primarily due to
limitations in data transfer speed and processing delays within the Arduino. These
inconsistencies affected real-time data acquisition, but they were recognising and
addressed in the discussion, with suggestions for improvement in future setups.
Overall, the lab proved the importance of precise calibration and robust system
integration in ensuring exact and stable performance in mechatronic systems. It
provided valuable hands-on experience in diagnosing synchronisation issues and
highlighted the impact of hardware-software interactions on system accuracy. The
findings serve as a foundation for further development in motion control applications,
especially as the complexity of systems increases.
8.0 REFERENCES
#define encoder0PinB 4
long np;
long op = 0;
unsigned long ot = 0;
long vel;
long pos;
long deg;
void setup()
pinMode(encoder0PinA, INPUT);
pinMode(encoder0PinB, INPUT);
Serial.begin (1200);
void loop()
Encoder();
//delay(2500);
}
void doEncoder()
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
encoder0Pos++;
} else {
encoder0Pos--;
void data()
Serial.print(nt);
Serial.print(",");
Serial.println(pos);
void Encoder()
np = encoder0Pos;
nt = millis();
pos = np;
data();
op = np;
ot = nt;
}
2. Part 2C: Calibration of DC Motor
int dir = 3;
int motorpin = 11;
void setup() // run once, when the sketch starts
{
Serial.begin(9600); // set up Serial library at 9600 bps
pinMode(dir, OUTPUT); // pinMode(pot, INPUT);
pinMode(motorPin, OUTPUT);
}
int motorFoward()
{
analogWrite(motorPin, 40);
delay(500);
digitalWrite(dir, HIGH);
delay(500);
}
int motorBackward()
{
analogWrite(motorPin, 40);
delay(500);
digitalWrite(dir, LOW);
delay(500);
void setup()
{
//encoder
pinMode(encoder0PinA, INPUT);
digitalWrite(encoder0PinA, HIGH); // turn on pullup resistor
pinMode(encoder0PinB, INPUT);
digitalWrite(encoder0PinB, HIGH); // turn on pullup resistor
attachInterrupt(0, doEncoder, RISING); // encoDER ON PIN 2
Serial.begin (4800);
Serial.println("start"); // a personal quirk//motor
pinMode(dir, OUTPUT);
pinMode(pwm, OUTPUT);
}
int motorFoward()
{
analogWrite(pwm, 30);
delay(500);
digitalWrite(dir, HIGH);
delay(2500);
Encoder();
}
int motorBackward()
{
analogWrite(pwm, 30);
delay(500);
digitalWrite(dir, LOW);
delay(2500);
Encoder();
void loop()
{
motorFoward();
motorBackward();
motorBackward();
motorFoward();
}
void Encoder()
{
newposition = encoder0Pos;
newtime = millis();
pos = (newposition);
data();
oldposition = newposition;
oldtime = newtime;
//delay(700);
}
void doEncoder()
{
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB))
{
encoder0Pos++;
}
else
{
encoder0Pos--;
}
}
void data()
{
Serial.print(newtime);
Serial.print(",");
Serial.println(pos);
}
4. Part 2D: Calibration of Input Voltage vs No-Load Speed of the DC Motor
#define encoder0PinA 2
#define encoder0PinB 4
int dir = 3;
int pwm = 11;
const int pwmValues[] = {30, 60, 90, 120, 150, 180, 210, 240}; // Varying PWM duty cycles
const int numPWM = sizeof(pwmValues) / sizeof(pwmValues[0]);
const int CPR = 600; // Encoder Counts Per Revolution (adjust as per your encoder)
unsigned long interval = 3000; // Time to run motor for each measurement in ms
void setup()
{
pinMode(encoder0PinA, INPUT_PULLUP);
pinMode(encoder0PinB, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(encoder0PinA), doEncoder, RISING);
pinMode(dir, OUTPUT);
pinMode(pwm, OUTPUT);
Serial.begin(9600);
Serial.println("Time(ms),PWM,Speed(RPM)");
}
void loop()
{
digitalWrite(dir, HIGH); // Run in one direction
Serial.print(millis());
Serial.print(",");
Serial.print(pwmValues[i]);
Serial.print(",");
Serial.println(rpm);
void doEncoder()
{
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB))
encoder0Pos++;
else
encoder0Pos--;
}
9.0 CONTRIBUTION OF EACH TEAM MEMBERS