INTERN Mechatronics
INTERN Mechatronics
Last but not least, I would want to express my gratitude for all the
knowledge I have gained from Mr.Thinh and the guidance I have gotten.
Sincerely,
2
Content
PART 1: OVERVIEW 4
2.2. LED………………………………………………………………………………….. 7
PART 3: CONCLUSION 27
3
PART 1: OVERVIEW
1.1 About Labs in Workshop C1
Address: 286 Ly Thuong Kiet street, District 10, Ho Chi Minh city.
Founded since: The predecessor of the HCMUT was the National Technical Center,
established in 1957, not until 27th October that it was renamed Ho Chi Minh City
University of Technology.
- 2 industrial robots
4
PART 2: INTERNSHIP CONTENT
2.1. Arduino UNO R3
Working voltage 5V – DC
Current 30mA
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
5
Energy pin:
IOREF (I/0 Reference Voltage): Provide the voltage reference with which the
microcontroller operates.
RESET: Pressing the Reset button on the board to reset the microcontroller is
similar to connecting RESET pin to GND with a 10KΩ resistor.
GND: Ground
5V and 3.3V: Provide regulated 5V and 3.3V
Vin (Voltage Input): The input voltage to the Arduino while it is using an
exterior power supply
Digital pin:
Serial Port: 0, 1:
o RXD (0): Received data
o TXD (1): Transmitted data
6
PWM (~): 3, 5, 6, 9, 10, 11: Provide PWM (Pulse Width Modulation) with 8
bit of resolution ( value varies from 0 → 28-1 corresponding to 0V → 5V) by
using function analogWrite().
SPI pins (Serial Peripheral Bus): 10 (SS), 11 (MOSI), 12 (MISO), 13
(SCK):
o SS: Slave Select
o MOSI: Master out – Slave in
o MISO: Master in – Slave out
o SCK: Serial Clock
2.2. LED
CODE Explanation
void setup() {
void loop() {
delay(1000); level)
7
b) Control 8 LED ON and OFF in series using IC 595
For IC 595:
8
Arduino to IC HC595:
Simulation by Proteus
9
2.3. Control 7-segment, Module 7-segment LED
Using function attachInterrupt() to call out a function whenever the condition is met.
For example: attachInterrupt(0, tang, RISING);
Whenever there is a change in button state (from LOW to HIGH), function “tang” is
called, which controls the 7-segment LED to increase by 1.
Simulation by Proteus
10
int LED1 = A1; int LED2 = A2; int LED3 = A3; int LED4 = A4;
unsigned char Code7seg[] = {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8,
0x80, 0x90};
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(SHCP, OUTPUT);
pinMode(DS, OUTPUT);
pinMode(STCP, OUTPUT);
unsigned char i;
digitalWrite(SHCP,LOW);
digitalWrite(SHCP,HIGH);
digitalWrite(STCP,LOW);
digitalWrite(STCP,HIGH);
11
void loop() {
unsigned char i;
nghin = dem/1000;
tram = (dem%1000)/100;
chuc = ((dem%1000)%100)/10;
dvi = ((dem%1000)%100)%10;
12
2.4. LED Matrix 8x8
At first, we didn’t know which pin controls which led because there is no label on the
equipment. Therefore, we had to test each pin individually and noted. Here is the
result:
Upper
1 2 3 4 5 6 7 8
pin
Row 6 3 1 2 4
Column 5 3 2
Lower
1 2 3 4 5 6 7 8
pin
Row 8 5 7
Column 4 6 1 7 8
13
Then we continued to connect 16 pins of matrix LED 8x8 to digital pin 2 -> 13 and
analog pin A0 -> A3 of Arduino Uno R3.
Argorithm:
14
2.5. Control DC Motor
a) Encoder
Definition:
Encoder is a sensor that can sense position, direction, speed or count, providing
information in digital without the need of a Analog – Digital converter. Encoders are
used as feedback component for CNC machines and robots.
Basic structure:
Code disk
Light source
Light sensor
Working principle
The Code Disk has pattered blurred lines like spokes found on a bike’s wheel. With
each rotation of the encoder shaft, there’s an interruption of light beams from the LED
by opaque lines on the Code Disk before being picked by the photosensor.
Consequently, a pulse signal like light = on; no light = off. Signals are sent to the
counter or controller, that will, in turn, send signals to give the desired function.
15
Classification:
Code disk Using disk in binary code, Count the number of times the
Gray code or BCD code signal on and off
b) Driver L298N
To reverse diretion, we need a bridge circuit
When S1, S4 is closed and S2, S3 is opened, the motor rotates in 1 direction. When we
do the opposite, the motor rotates in the other direction
16
To control speed, we need to use PWM (Pulse Width modulation)
PWM is the state HIGH – LOW of voltage repeating continuosly. Depening on the
duty cycle, which is the percentage of time ON over the period, we can produce the
desired voltage between max and min value instead of just HIGH and LOW states.
Therefore, we can control the speed by control the output voltage.
This is why driver L298N is used. Because it can do both of the function above.
17
Input pin: IN1, IN2, IN3, IN4: Receive control signal.
18
c) Design DC motor kit
Prepare:
1 Arduino UNO R3
2 Terminal
1 driver L298N
1 DC Servo motor
1 motor holder
Purpose:
Result:
19
2.6. Learn to use AC Servo Kit
20
Jogging
Change to Fn002
Encoder resolution
Delay time= × Required revolutions
Gear ratio × Arduino PIN frequency
Speed control
21
PART 3: CONCLUSION
At Workshop C1, I was given the opportunity to conduct hands-on experiments
in my study field. Here, I was given tools and equipment to use the knowledge I had
gained to build my first projects. By conducting experiments, I learned the distinction
between theory and practice. When it comes to practice, numerous issues arise.
For example, we knew how to use Arduino, the L298N driver, and the motor
separately, but when we built the DC motor kit, we failed several times due to
mechanical design or coding errors. That is why the lab holds seminars every
Saturday. In a weekly seminar, I had the opportunity to learn about various fields
presented by other groups. Mr.Thinh provided us with hints at the end of each
presentation, which was extremely helpful in our problem-solving efforts. Aside from
major-related knowledge, I've learned a variety of skills that will be useful in the
future.
I learned how to be organized, save money, and do a lot of small things that will
complete me as a person and engineer during my time working in C1, thanks to the
Electromechanical and Mr. Thinh.
22