Mechatronics Boot Camp - May2022

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 60

American University of Sharjah

College of Engineering
Mechanical Engineering Department

Explore, Design and Build:


A Mechanical Engineering Boot Camp

Module 5: Crash Course on Mechatronics

Instructor: Wasim Al-Masri


2
Why are you here?
3 Schedule
Day Gr#1, EB2-104 Gr#2, EB2-109

Saturday  21/5 Robotics Mechatronics

Sunday     22/5 Mechatronics Robotics

Microfluidics (10:00 am – 12:15) Renewable Automotive (10:00 am –12:15)

Saturday  28/5
Renewable & Automotive (12:45 – 3:00 pm) Microfluidics (12:45 – 3:00 pm)

Sunday     29/5 Design Build Let’s Make Products

Saturday  04/6 Let’s Make Products Design Build


4 Today’s Agenda
Mechanical Engineering
 The field of mechanical engineering can be thought of as a collection
of many mechanical engineering science disciplines. 
 Mechanics: it’s the study of forces (i.e., loads) and their effect upon matter.
 Mechatronics and robotics: It is an interdisciplinary branch of mechanical
engineering, electrical engineering and software engineering that is
concerned with integrating electrical and mechanical engineering to create
hybrid automation systems.
 Thermodynamics and thermo-science: the study of energy, its use and
transformation through a system
 Design and drafting: is the means by which mechanical engineers design
products and create instructions for manufacturing parts.
https://en.wikipedia.org/wiki/Mechanical_engineering#Subdisciplines
Mechatronics

 Mechatronics is a multidisciplinary field of
engineering that includes a combination
of mechanical
engineering, electronics, computer
engineering, telecommunications
engineering, systems engineering and control
engineering.
Mechatronics Fields
 Machine vision
 Automation and robotics
 Servo-mechanics
 Sensing and control systems
 Automotive engineering, automotive equipment in
the design of subsystems such as anti-lock braking
systems
 Computer-machine controls, such as computer
driven machines like CNC milling machines, CNC
waterjets, and CNC plasma cutters
Mechatronics System brains
Micro-Controllers
In any mechatronics system, there is a component acts
like a brain which is responsible for complex
computations and decisions making based on a
predefined program.
Some examples:
 Micro-controllers
myRio PLC
 Computers
 programmable logic controller (PLC)
 myRIO 
Micro-Controller:
It is a micro-computer. As any
computer it has internal CPU,
RAM, IOs interface.
It is used for control purposes, and
for data analysis.

Famous microcontroller
manufacturers are MicroChip,
Atmel, Intel, Analog devices, and
more.
Computer vs. Microcontroller
What is Arduino?
• A microcontroller board, contains:
• on-board power supply.
• USB port to communicate with PC.
• Atmel microcontroller chip.

• It simplify the process of creating any control system by


providing the standard board that can be programmed and
connected to the system without the need to any
sophisticated PCB design and implementation.

• It is an open-source hardware, any one can get the details of


its design and modify it or make his own one himself.
Arduino boards:
Different Arduino boards exist, each with different capabilities (processing speed, number of pins ..etc).

UNO Mega LilyPad

Arduino BT Arduino Nano Arduino Mini


13 SparkFun Arduino inventor kit 4.1
Arduino UNO:
Digital output
~: PWM. In circuit Serial
0,1: Serial port. programming

Atmel
MicroController
USB port

Power input

Analog input.
Power Supply
Arduino
Power pins, including:
UNO Board
1. Vin pin: this pin can be used to give power
to the Arduino.

2. GNDs.

3. 5V: regulated 5 volt (max. current 200 mA).

4. 3.3: regulated 3.3 volt.

5. Reset pin: used to externally reset the


Arduino, when the pin is connected to the
ground and then released, the Arduino will
reset.
Arduino UNO Board
Analog pins, including:

•These pins can be used as analog input


pins
Arduino UNO Board
Digital pins, including:

• Pin 0, pin 1: used for serial UART


communication (will be covered later on).

• Pin 3,5,6,9,10,11 (pins with ~ symbol)


can be used to generated PWM output.

• Max. current for each digital pin is 40


mA.
Bread Board
Arduino IDE (Integrated Development
Environment)
Arduino IDE (Integrated Development Environment)
When you open the IDE, you will see the
following:

1-setup function:
•Anything you put here will be executed
only once.
•Usually people use it to do the
configurations (defining pin modes, setting
the serial communication speed...etc).

2-loop function:
• Anything you write here will be executed
for ever.
Terminology
Some important functions related Digital I/0
pinMode(pin, mode)
Sets pin to either INPUT or OUTPUT
digitalRead(pin)
Reads HIGH or LOW from a pin
digitalWrite(pin, value)
Writes HIGH or LOW to a pin
Arduino Timing Functions

• delay(ms)
– Pauses for a few milliseconds
• delayMicroseconds(us)
– Pauses for a few microseconds

More commands:
arduino.cc/en/Reference/HomePage
Let's Start..

Blinking LED
Example
Blinking LED

Cathode
_
+
Anode
Longer leg
Circuit#1 : Blinking LED
Why we need a resistor? What is a
resistor?
A resistor is an electric device that limits and reduces the
electric current flowing in a circuit.

Current is the flow of electrons in a conductor.

When there is current flowing in the circuit, things will


work. If it it's an LED it will light up, if it's a motor it will
rotate, if it's your body you will die!
* 100 mA of current across the heart can kill you
Why weis need
A resistor a resistor?
needed when we connect an LED to limit the current,
this is why it is called current limiting resistor.

If we don't do this the current that goes from the Arduino pin will be
at its maximum. Maximum current from the Arduino pin is 40 mA.

This is not safe for both the Arduino and the LED (LED might burn).

So max. current will flow (40 mA). For LEDs the maximum


current is usually 20mA
Tasks

 Do all the requirements to make a single


blinking LED

 Design and Implement Traffic Light Using


Arduino kit. (The sequence is: red-yellow-
green- yellow-red- yellow- ……. etc)
Digital input/output
The Chip on the Arduino board is a standard 5 v TTL level, so:
voltage
VOH – Minimum OUTPUTlevel
provide for a HIGH signal.
Voltage level a TTL device will

VOL – Maximum OUTPUT Voltage level a device will


provide for a LOW signal.

VIH – Minimum INPUT Voltage level to be considered a


HIGH.
VIL – Maximum INPUT Voltage level to still be considered a
LOW.

Not all devices are TTL. That's why there are level converters!
Computers have serial ports that are not TTL level.
The voltage can range from -13 V to 13 V.
digitalRead(pin): is used to read digital value
on a pinDigital Read

It returns HIGH or LOW (equivalent to 1 and 0), so it


can be used directly
as condition for Example:

If( digitalRead(pin) )
{ code }
https://www.youtube.com/watch?v=wxjerCHCEMg

Digital Read
digitalRead will be used to read the push button
output.
The push button can be connected to Arduino by
using
pull down resistor or pull up resistor,
5V
as follows:

Arduino Pin

GND

pull down resistor (input will pull up resistor (input will


become high when the button is become low when the button is
pressed) pressed)
Example
 
LED is connected to pin 8. Button is connected to pin 9 with pull down resistor. Pressing a
pushbutton connected to a digital input will turn the LED on
pinMode

Syntax
pinMode(pin, mode)
Parameters
pin: the Arduino pin number to set the mode of.
mode: INPUT, OUTPUT, or INPUT_PULLUP.
Arduino has build-in pull-up resistor and you can implement it by changing the
mode in pinMode command.
Tasks
 Implement a circuit by using one LED and push button.
 Pressing a push button connected to a digital input will
turn the LED on and stopping the pressing will turn the
LED off. Use a pull-down resistor (use 10 kΩ).

 Do the same thing as in question 1 but by using a pull-up


resistor.
Pulse Width Modulation (PWM) Signal
PWM Using AnalogWrite()
AnalogWrite: is used to generate a PWM
Signal on digital pins marked with ~.

Signal frequency is 490 Hz


(on UNO boards, pin 5 and 6 have higher frequency of 980 Hz)

Synatx:

AnalogWrite(pin, DutyCycle)

DutyCycle: is an intger between 0 – 255


0 means a duty cycle of 0% (always off)
255 means a duty cycle of 100% (always on)
PWM: Pulsed with modulation
 PWM simulates DC voltage control for small loads

 The effective voltage is

 is called the duty cycle

3
PWM Using AnalogWrite()
AnalogWrite(pin,25)

AnalogWrite(pin,127)

AnalogWrite(pin,229)
Fading LED

Cathode
_

+
Anode
Longer leg
Acquire Analog Signal
AnalogRead(pin): reads the analog
Reading Analog Signal
voltage on the pin specified.
Returns
Integer value between (0 to 1023)

The Chip on Arduino UNO is atmega328

This Chip has a 10-bit ADC

Default reference voltage is 0-5 volts

0 5 volts
00000000000 1111111111
0 1023
Potentiometer
Potentiometer
 A potentiometer is a 3-pin variable resistor.
 When powered with 5V, the middle pin outputs a voltage between 0V and
5V, depending on the position of the knob on the potentiometer.
 Internal to the trimpot is a single resistor and a wiper, which cuts the resistor
in two and moves to adjust the ratio between both halves (i.e. voltage
division)
 Potentiometer are not polarized and can be installed in either direction. Note
that swapping the 5V and GND pins will reverse its behavior.
 It can be used to make volume controls, speed controls, angle sensors and a
ton of other useful inputs for your projects.
Example
We will read the analog voltage on the potentiometer
and control light intensity on the LED

PWM pin
We will read the analog voltage on the potentiometer and control

Example
light intensity on the LED

PWM pin
Temperature sensor (TMP36)
Introduction to Temp. sensor
  The TMP36 is a low voltage, precision centigrade temperature sensor. It
provides a voltage output that is linearly proportional to the Celsius
temperature. It also doesn’t require any external calibration to provide
typical accuracies of ±1°C at +25°C and ±2°C over the −40°C to +125°C
temperature range.
 We like it because it’s so easy to use: Just give the device a ground and 2.7
to 5.5 VDC and read the voltage on the Vout pin. The output voltage can
be converted to temperature easily using the scale factor of 10 mV/°C.

 More information on the sensor is available in the datasheet:


http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Temp/TMP35_36_37.pdf
Connection
The code (don’t use map here)
Tasks
 Design and implement a circuit using LED and potentiometer.
Use the potentiometer to control the brightness of the LED

 Design and implement a circuit using one led and temperature


sensor. Use the temperature sensor to measure the room
temperature and if the temperature goes up 27 C, the LED will
turn on.
What is a servo?

A servo-motor is an actuator with a built-in feedback


mechanism that responds to a control signal by
moving to and holding a position, or by moving at a
continuous speed.

Industrial Servo Motors Hobby Servo

https://www.youtube.com/watch?v=_B3gWd3A_SI
Hobby Servo functionality
 Servos have integrated gears and a shaft that can be
precisely controlled.
 Standard servos allow the shaft to be positioned at various
angles, usually between 0 and 180 degrees.
 Continuous rotation servos allow the rotation of the shaft
to be set to various speeds.
Servo components
1. Small DC motor
2. Gearbox with small plastic gears to reduce the RPM and increase output torque
3. Special electronics to interpret a pulse signal and deliver power to the motor
Hobby Servo Wires

Black: GND
Red: 5V

Yellow/orange/white: Signal
Arduino Servo library:
 Servo library supports up to 12 motors on most Arduino boards 
 Standard servos allow the shaft to be positioned at various angles,
usually between 0 and 180 degrees.
 Continuous rotation servos allow the rotation of the shaft to be set to
various speeds.
 From the Arduino web site:

“…use of the library disables analogWrite() (PWM)


functionality on pins 9 and 10, whether or not there is a Servo
on those pins”

http://www.arduino.cc/en/Reference/Servo
Arduino Servo library
https://www.arduino.cc/en/reference/servo
 Create the servo object
Servo my_servo_object;
Name of the object is like a
variable name.
 Attach the object
my_servo_object.attach(servo_pin);

 Send control signal attach and write are pre-


defined methods that act
my_servo_object.write(pos); on the servo object.
Servo Motor
Tasks
 Let the servo motor sweep from zero to 180 with a speed of 5 rpm, then from 180
to 0 with a speed of 10 rpm.
 Connect a servo motor to the Arduino.
 Use the pulse width values found in the previous question.

 Adjust servo position with a potentiometer and map the range from 0-5 v to 0-
180o :
 Connect a potentiometer to an analog input
 Connect a servo motor to the Arduino.
 Use the potentiometer to control the servo position.
Additional Resources

 www.arduino.cc

 https://www.edx.org/course/c-programming-getting-started?index=p
roduct&queryID=edd3a96ca53684fbc9989532243ed95a&position=
1

 https://www.sparkfun.com/products/15267

You might also like