SlideShare uma empresa Scribd logo
1 de 133
Baixar para ler offline
MECHATRONICS 2
Interfacing and PC based
Computer
AIN SHAMS UNIVERSITY
FACULTY OF ENGINEERING
MECHATRONICS ENGINEERING DEPARTMENT
1
Dr. Shady A. Maged
Interfacing in the Mechatronics System
ConfigurationMechanical
System
Controller
Actuators
Sensors
Signal
Processing
Power
Amplification
Interfacing
2
Interfacing a switch (input device) to a
digital circuit:
Using pull-up resistor Using pull-down resistor
When the switch is open the voltage of the gate
input is pulled up to the level of Vin. When the
switch is closed, the input voltage at the gate
goes to ground.
Pull-up and pull-down resistors are used in electronic logic circuits to ensure that
inputs to logic systems settle at expected logic levels if external devices are
disconnected or high-impedance is introduced. They may also be used at the
interface between two different types of logic devices, possibly operating at different
power supply voltages.
3
Pull-up and down resistors
4
Mechanical switch
The function of a switch is simple. When we press a switch,
two contacts are joined together and connection is made. Still,
it is not that simple. The problem lies in the imperfection of
mechanical contacts. That is to say, before contact is made or
cut off, there is a short time period when vibration (oscillation)
can occur as a result of unevenness of mechanical contacts, or
as a result of the different speed in pressing a key (this
depends on person who presses the key). The term given to
this phenomenon is called SWITCH (CONTACT) DEBOUNCE.
Bouncing while transition from high to low
Bouncing while transition from low to high
Switch De-bouncing
5
Due to this problem, there won't be a clean transition from a state to another, but
instead there will be a series of high and low states spikes as shown in figure 1B.
The 'unknown' range can be recognized by some a digital circuit as 1 or 0, but in a
completely random manner.
This series of spikes can be interpreted by a microcontroller (or any digital circuit)
as if the button was pressed many times. It may even have happened to you
before when you connected a switch to a counter of any kind, and notice that one
press on the button is sometimes counted as more than one push.
Fig. 1A: A simple switch configuration
without a de-bouncing circuit
Fig. 1B: Behavior of a switch without a
de-bouncing circuit
De-bouncing
6
There are 2 common solutions to this problem. Analog solution and digital
micro-controller based solution. Both are commonly used, and sometimes,
both are used at the same time to provide a very stable design.
The analog de-bouncing circuit
Fig. 2A: A switch with a de-
bouncing circuit
Fig. 2B: A switch with a de-
bouncing circuit
• The analog solution relies principally on a capacitor, which plays the role of
resisting the voltage changes on the output.
De-bouncing
7
The software based de-bouncing
the idea here is not to prevent voltage spikes to occur, but rather to record them
and analyze them in real-time using simple software routines.
The timing T1, T2 and T3 corresponds to the low (logic =0) pulses being sent to the
microcontroller from the switch. T1 and T2 are the length of the reading we want to
get rid off, or more scientifically, that we want to filter. T3 is a valid reading that we
want to take in account. It is clear that the difference between those three periods
is their length, and that is how the micro-controller will be able to differentiate
between valid and un-valid pulses.
8
There are many ways to implement digital de-bouncing or filtering using a
microcontroller, one simple method is to make a counter count up as long as
the signal is Low, and reset this counter when the signal is high. If the counter
reach a certain fixed value, which should be 1 or 2 times bigger than T1 or T2
(noise pulses), this means that the current pulse is a valid pulse (corresponds
to T3 in our example).
Another way to de-bounce using software is to wait for a certain time interval until
the switch oscillations disappear. i.e. after the MICROCONTROLLER realizes the
first state transition it waits for a certain period say (100 ms) then it takes the
action that corresponds to this transition.
9
Example:
Required: Write a code that turns
the LED on when T2 is pressed,
and turns it off when T1 is
pressed. You have to come over
switch de-bounce in your software
This circuit has 2 inputs and 1 output
Input T1 Output LED Input T2 Output LED
RA3 RB7 RA2 RB7
0 Unchanged 0 Unchanged
1 OFF (0) 1 ON (1)
10
RA3 and RA2 are
inputs, RB7 is output
T2
pressed?
T2
pressed?
YES
LED is ON
NO
NO
Call Delay
YES
START
LED is OFF
T1
pressed?
T1
pressed?
CallDelay
YESNO
NO
Flow Chart
11
Transistor
A transistor is a semiconductor device used to amplify and switch electronic
signals. Transistors are commonly used as electronic switches. You can imagine
the collector and emitter as two contact points of a switch. If the base is activated,
then both contact points are closed Together; otherwise they are opened.
Interfacing an inductive load to a
digital circuit through a transistor
When the voltage
across an inductive
load is reduced or
removed a sudden
spike voltage is
seen across the
load
• A resistor (e.g., 1k) to limit
the base current while
ensuring the transistor is in
full saturation
• 24 V DC capable of at least
1A of current
• power diode capable of
carrying at least 1A for
flyback protection (Free
Wheeling Diode) used
whenever inductive loads are
switched off by silicon
components
• ground
12
Darlington Pair
The above schematic represents a transistor called as a Darlington Pair which
usually comes in a single package. The advantage of this combination is that the
current gain is the product of two individual transistor gains and can exceed 10000.
They may often be found in power circuits for mechatronic systems.
13
Seven-Segment Display (multiplexing)
Circuit diagram for Common
Cathode 7-Segment Display
Circuit diagram for Common
Anode 7-Segment Display
•The segments in a 7-segment display are arranged to form a single digit from 0
to F
• Even though LCD displays are more comfortable to work with, 7-segment
displays are still standard in the industry.
• The 8 LEDs inside each display can be arranged with a common cathode or
common anode.
14
•The simplest way to drive a display is via a display driver. These are available for up
to 4 displays.
LT =Lamp Test, BI = Blanking Input, LE = Latch Enable
15
•Alternatively displays can be driven by a microcontroller and if more than one
display is required, the method of driving them is called "multiplexing.”
• If a single display is to be driven from a microcontroller, 7 lines will be needed plus
one for the decimal point. For each additional display, only one extra line is needed.
• To produce a 4, 5 or 6 digit display, all the 7-segment displays are connected in
parallel. The common line (the common-cathode line) is taken out separately and
this line is taken low for a short period of time to turn on the display.
• Each display is turned on at a rate above 100 times per second, and it will
appear that all the displays are turned on at the same time. As each display is
turned on, the appropriate information must be delivered to it so that it will give the
correct reading.
16
Example
Required: Write a code that displays the number 21 on the common cathode 7-
segment displays using transistors where the hardware connections are shown
above.
17
Optocoupler combines a LED
and photo-transistor in the same
case. The purpose of an
optocoupler is to separate two
parts of a circuit.
Why optocoupler?
Interference. One part of a circuit may be in a location where it picks up a
lot of interference (such as from electric motors, welding equipment,
petrol motors etc.) If the output of this circuit goes through an optocoupler to
another circuit, only the intended signals will pass through the
optocoupler. The interference signals will not have enough "strength" to
activate the LED in the optocoupler and thus they are eliminated. To protect a
section of the device. Typical examples are industrial units with lots of
interferences which affect signals in the wires. If these interferences affect the
function of control section, errors will occur and the unit will stop working.
Optocoupler
18
•Simultaneous separation and intensification of a signal. A signal as low as
3v is able to activate an optocoupler and the output of the optocoupler can be
connected to an input line of a microcontroller. The microcontroller requires an
input swing of 5v and in this case the 3v signal is amplified to 5v. It can also be
used to amplify the current of a signal.
• High Voltage Separation. Optocouplers have inherent high voltage
separation qualities. Since the LED is completely separate from the photo-
transistor, optocouplers can exhibit voltage isolation of 3kv or higher.
Optocouplers can be used as input or output device. They can have
additional functions such as Schmitt triggering (the output of a Schmitt trigger
is either 0 or 1 - it changes slow rising and falling waveforms into definite
low or high values). Optocouplers are packaged as a single unit or in groups of
two or more in one housing. They are also called PHOTO INTERRUPTERS
where a spoked wheel is inserted in a slot between the LED and phototransistor
and each time the light is interrupted, the transistor produces a pulse.Each
optocoupler needs two supplies in order to function. They can be used with one
supply, but the voltage isolation feature is lost.
19
Example:
This example is a counter, used for counting products on production line. Let the
sensor be a micro-switch. Each time the switch is closed, the LED is illuminated.
The LED transfers the signal to the photo-transistor and the operation of the photo-
transistor delivers a LOW to input RA4 of a microcontroller.
Required: write a program that counts the products, and indicates the current
count on any of the outputs of the microcontroller.
Input T1 Output LED
RA4/TCK0 PORTB
Each negative edge Increase by 1
20
The Relay
The relay is an electromechanical device, which transforms an electrical signal
into mechanical movement. It consists of a coil of insulated wire on a metal core,
and a metal armature with one or more contacts. When a supply voltage was
delivered to the coil, current would flow and a magnetic field would be produced
that moves the armature to close one set of contacts and/or open another set.
When power is removed from the relay, the magnetic flux in the coil collapses and
produces a fairly high voltage in the opposite direction.
21
Interfacing an AC load to a digital
circuit through a relay
Interfacing a DC load to a digital
circuit through a relay
Examples:
22
Example on Micro:
Required: Write a code that activates the Relay on when T2 is pressed, and
turns it off when T1 is pressed. You have to come over switch debounce in your
software.
23
CONTROL OF DC
MOTOR USING
H-BRIDGE AND PWM
24
SPEED CONTROL
(PWM)
25
Pulse Width Modulation
26
Controlling the power delivered to the motor to control
the speed .
PWM (pulse width modulation) is the most common way to control the
power delivered to the motor, thus the speed of the motor. It's also the
most efficient method. This article does not intent to explain PWM, but
here is how in works, in very simplified way: The microcontroller generate
pulses of electricity for the motor (instead of constant DC voltage). The
frequency of those pulses remain constant, while the ON period of the
pulse is varied to increase or decrease the speed of the motor. the
Average voltage of the wave of pulses increases gradually as the duty
cycle increases (duty cycle is the ratio of the 'ON' period over the total
period of the pulse). As the average voltage increases, the speed of the
motor will increase gradually.
27
Controlling the power delivered to the motor to control
the speed .
Making a speed control program
using the PWM theory is very
simple, which is a code
targeted for any microcontroller
to run the motor at half speed
(50/100) and where the Enable
pin of the motor controller is
connected to specific pin of the
microcontroller:
28
CONTROL THE DIRECTION
OF THE MOTOR USING H-
BRIDGE
29
H-Bridge
High Side
Left
High Side
Right
Lower
Left
Lower
Right Quadrant Description
On Off Off On Motor goes Clockwise
Off On On Off Motor goes Counter-clockwise
On On Off Off Motor "brakes" and decelerates
Off Off On On Motor "brakes" and decelerates
30
L289
DULL-FULL BRIDGE DRIVER
31
32
PIN FUNCTIONS
33
4A H bridge motor driver using the L298 IC
34
Brief Circuit explanation
This is an implementation of the L298 to drive motors and inductive
loads up to 4A continuously. Initially the L298 contains 2 separate
channels, each one capable of driving 2A loads. Connecting them
in parallel as in the schematic makes a single 4A driver.
The two wire connections W1 and W2 are to control the direction
of the motor according to that table:
35
Brief Circuit explanation
The 2 transistors Q1 and Q2 act as an OR gate enabling the L298 if
any of the two signals W1 or W2 are high. If both W1 and W2 are
low (logic 0), the driver is disabled and provides a high impedance
on its output, causing an eventually connected motor to move
freely with its inertia.
C1 and C2 are 10 nF decoupling capacitors.
D1 to D4 are flyback diodes. Their forward current should
correspond with the the expected load.
The two leads of the motor are directly connected to J1.
The circuit can be powered with 9 to 35V
36
ANALOG TO DIGITAL
CONVERSATION (ADC)
37
The Analog-to-Digital Converter
There is a device commonly
in microcontrollers called
ADC (Analog to digital
converter). An ADC converts
a varying (analog) voltage
level into a corresponding
digital number.
ADC 0808 which has 8 –
analog inputs (8 - channels)
and gives an 8 – bits value
out as the result of
conversion
38
ADC0808 (8-channels 8-bit)
8-channels (8-analog input)
Example : 8 - sensors
8 – bit value out as a result
Of the conversion
3-MUX input select
address lines (Appendix A)
DATA BUS
+5V
GROUND
SUPPLY
500 kHz
39
40
CONTROL LINES
Output Enable line for reading
the ADC (TRI STATE OUTPUT LATCH)
End of Convert line that signals the
Host that the conversion is complete
normaly 1 when finish convert to 0.
Start / ALE line that are tied together
And connected as 1 to the host
BLOCK DIAGRAM
How does the ADC work ?
Time Diagram
Hardware Implementation
GND +5V
Analog
Signal
Analog
Signal
OUTPUT
ON LEDS
OUTPUT
CONNECTION
O/P FROM
MICRO 500 kHz
O/P FROM
MICRO
O/P FROM
MICRO
I/P TO
MICRO
Example on MICRO with built-in ADC
Construct the hardware connection and the flowchart (for a
Microcontroller) that reads analogue value from channel 2 and
displays it on PORTD (lower 8 bits) and PORTB (2 most significant
bits).
45
45
Example on MICRO with built-in ADC
Construct the hardware connection and the flowchart (for a
Microcontroller) that reads analogue value from channel 2 and
displays it on PORTD (lower 8 bits) and PORTB (2 most significant
bits).
46
46
RA2 is input, Port D, RB6
and RB7 are outputs
START
Analogue
value=Temp_res
Port D=Temp_res
Port B=Temp_res>>2
Closed loop vs Open loop control
47
OPEN LOOP SPEED
CONTROLLER
48
Example: Open loop Speed Controller
Write a program that control the speed and the direction of
the DC motor using H-bridge and PWM signal with a duty
cycle based on the analogue input comes from
potentiometer
49
SOFTWARE APPROACH
1. Initialize the I/O ports
2. Controlling the ADC and reading the digital value (I/p to the micro)
3. Check if the I/p is 0V therefore the motor is OFF
4. Check if the I/p is 5V therefore the motor is ON
5. knowing that the Duty Cycle= t_high/T *100(%)
and to obtain at 5V, D=100%,
6. Calculate t_high and t_low from the following equations
t_high = digital I/P from input port
t_low= 255 - t_high
7. Obtain delay equals to t_high
8. Clear the output and then obtain delay equals to t_low
9. set the output
10. Repeat steps 7,8 and 9.
50
Notice how the heat sink is firmly attached to the driver. this
protects the IC from eventually burning-up from stall
currents .
51
LECTURE
52
CLOSED LOOP SPEED
CONTROLLER
(PROPORTIONAL CONTROLLER)
53
Objective:
you will learn here how to implement a digital
proportional gain controller, i.e. a servomotor
controller. The objective of this is to write a program
that generates a PWM signal with a duty cycle based
on the output of a proportional gain controller whose
input is a signal from a potentiometer or encoder
mounted on the shaft of the DC motor. This program
is similar in concept to the open loop speed
controller; however the duty cycle of the PWM signal
is now determined from the error of the input-
feedback calculation.
54
Problem Statement:
Write a program that controls the position of the DC motor. The
program should implement a proportional control algorithm. The
system diagram looks like
55
Overview
56
Closed Loop Vs Open Loop Control
57
58
59
60
30x40
61
62
General software approach
The program should perform the following sequence of tasks:
Sample the position using ADC.
Calculate the amount and direction of control using a P, or a
PID equation
Output the PWM signal based on the control amount (related
to position error)
Recall from control, that the simplest closed-loop,
proportional feedback controller defines the output as:
Output = K. (Input-Feedback) = K.error
You will need to scale your error signal by some value, k, for
your PWM duty cycle to be high enough to achieve acceptable
system time response. You can easily multiply the error signal
by factors of 2
63
SERIAL INTERFACE BETWEEN
MICROCONTROLLER
AND
PC
64
Serial/paralell
LogicTTLRS-232
High+2V … +5V-15V … -3V
Low0V … +0.8V+3V … +15V
MAX 232
The MAX232 is an integrated circuit that
converts signals from an RS-232 serial port to
signals suitable for use in TTL compatible
digital logic circuits.
65
MAX 232
MAX 232
66
Connection for Max 232
67
Connect the serial to serial cable (RS232) to
the Serial to breadboard converter.
68
1.Working On Hyper Terminal
69
2. In case of making phone or modem
connection you must specify your location
but in our case just press cancel as shown
70
3. Press yes then ok
71
4. Choose Name
and icon for your
connection
5.Again repeat
this step then Yes
then Ok
72
6. Choose the port of connection then
press Ok
73
7. Choose the Com properties as shown in
the following pictures, this properties varies
from connection to another
74
8. Continue Choosing the properties
75
9. Press Ok
76
10. The message will be shown on this
screen
77
11.To quit from the HT you must disconnect the
connection first by pressing Ok
78
12. Choose yes if you want to save your
work
79
PC BASED CONTROLLER
FOR MECHATRONICS
SYSTEM
80
Controller in the Mechatronics System
ConfigurationMechanical
System
PC
Controller
Actuators
Sensors
Signal
Conditioning
Power
Amplification
81
The controller is the PC (Personal Computer)
Computer-Based Controllers
Controller
PC
Pc Board
GPIB Serial/paralell
CAN BUS
82
Higher level Programming languages,
Programming Languages
Matlab Labview
83
Data acquisition is the process of measuring an electrical or
physical phenomenon such as voltage, current, temperature,
pressure, or sound. PC-based data acquisition uses a combination
of modular hardware, application software, and a computer to take
measurements. While each data acquisition (DAQ) system is defined
by its application requirements, every system shares a common goal
of acquiring, analyzing, and presenting information. Data
acquisition systems incorporate signals, sensors, actuators, signal
conditioning, DAQ devices, and application software.
Data Acquisition Cards
84
Example
NI USB-6008
The National Instruments USB-6008 provides basic data acquisition functionality
Analog Inputs: 8 SE/4 DI · 10 kS/s · 12 bits
Analog Outputs: 2 · 150 S/s · 12 bits
Digital I/O: 12 DIO
Counter/Timers: 1 · 32 bits · 5 MHz
Measurement Type: Voltage
85
NI USB-6251 BNC
The National Instruments USB-6251 BNC is a USB high-performance M
Series multifunction data acquisition
Analog Inputs: 8 SE/4 DI · 1.25 MS/s · 16 bits
Analog Outputs: 2 · 2.86 MS/s · 16 bits
Digital I/O: 24 DIO · 1 MHz
Counter/Timers: 2 · 32 bits · 80 MHz
Measurement Type: Quadrature encoder, Voltage
Example
86
Reference Single Ended (RSE)
87
Measurement System
Differential Mode (DI)
•Differential Mode
• Two channels used for each signal
• ACH 0 is paired with ACH 8, ACH 1 is paired with ACH 9, etc.
• Rejects common-mode voltage and common-mode noise
88
Differential Mode
89
Why would I ever want to use
differential mode?
Placing your measurement system in
differential mode will give you better
measurements, because it allows the
amplifier to reject common-mode voltage
and any common-mode noise that is
present in your signal. Common-mode
voltage is any voltage present at the
instrumentation amplifier inputs with
respect to the amplifier ground.
Data Acquisition Programming
Matlab
Labview
90
The big issue with digital conversion:
A continuous value is made discrete
1. In amplitude (Y axis issues)
• Resolution
• Saturation
2. In time (X axis issues)
• Aliasing
• Leakage
• Frequency resolution
Digital Data Acquisition
91
Analogue Digital conversion:
quantization:
 A continuous value is compared with a series of fixed,
discrete intervals (states)
encoding:
 The interval mean value is converted into a digital, usually
binary, chain of elements
Digital Data Acquisition
92
Binary representation:
• Data type length = N bit
• Binary encoding = O / 1
Having only two states possible per element allows
for very robust handling and trasmission systems
since the diffence between states can be high and
electronics is simple and cheap.
Digital Data Acquisition
93
DIGITAL RESOLUTION
Having N bit data length  2N different states
3 bit  23 =8 different states (1 byte = 8 bit)
8 bit  28 =256 states
10 bit  210 =1024 states
12 bit  212 =4096 states
14 bit  214 =16384 states
16 bit  216 =65536 states
Digital Data Acquisition
94
AD converter transfer function is not linear: output = 2N states
input = continuous value
input
output
Digital Data Acquisition
95
Resolution = minimum variation of the input quantity
that can be detected by the AD converter.
It is equal to the value of the least significant bit (the
smallest one)
LSB=“least significant bit”
1 LSB = FS / 2N
Digital Data Acquisition
96
Resolution depends on both the full scale input of
DAQ converter and bit length of data field
Es: FS=10 V N=3 bit LSB=1.25 V
FS=10 V N=8 bit LSB=39 mV
FS=10 V N=12 bit LSB=2.44mV
n
FSFS
resolution
2
minmax 

Digital Data Acquisition
97
100 200150500
Time (ms)
0
1.25
5.00
2.50
3.75
6.25
7.50
8.75
10.00
Amplitude
(volts)
16-Bit Versus 3-Bit Resolution
(5kHz Sine Wave)
16-bit resolution
3-bit resolution
000
001
010
011
100
101
110
111
| ||||
Resolution Example
3-bit resolution can represent 8 voltage levels (10/23)
16-bit resolution can represent 65,536 voltage levels
98
Signal
3 bit
5 bit
Digital Data Acquisition
99
SIGNAL SAMPLING
FREQUENCY ISSUES
(X axis issues)
Digital Data Acquisition
100
SAMPLING:
Conversion of a time continuous value into a chain of values
V
(ti , Vi) i=1,...... N
t
t
V
Digital Data Acquisition
101
Both V amplitude and it’s time coordinates are discrete
values depending on ADC capabilities and configuration
SAMPLING TIME tC = ti - ti-1
SAMPLING FREQUENCY fC = 1 / tC
t
V
ti-1 ti ti+1
Digital Data Acquisition
102
With sampling frequency can be used to
represent a signal without altering it?
t
V
t
V
both OK, but somehow different
Digital Data Acquisition
103
If sampling frequency is too low a problem with frequency
representation can occurr: we have “aliasing”
t
V
Sampling signal is no longer recognizable, and its
frequency seems lower than the original one.
Digital Data Acquisition
104
The issue of aliasing is related to the ratio between sampling
frequency fS and signal frequency fA
fS < 2 fA  “aliasing” occurs
fS > 2 fA
fS = 2 fA
fS < 2 fA
Digital Data Acquisition
105
Nyquist-Shannon theorem:
if a continuous signal with a top limited
bandwidth contains only components with
frequency up to fAmax therefore a coherent
representation could be achieved by a
sampling frequency fS > 2 fAmax
Digital Data Acquisition
106
f S = 1 / tS
fA = 1 / TA
being fS > 2fA tS < TA / 2
We require at least two samples
for each half period...
Digital Data Acquisition
107
Nyquist Example
Aliased Signal
Adequately Sampled
for Frequency Only
(Same # of cycles)
Adequately Sampled
for Frequency and
Shape
100Hz Sine Wave
100Hz Sine Wave
Sampled at 100Hz
Sampled at 200Hz
Sampled at 1kHz100Hz Sine Wave
108
DAQ Hardware
1. Signal
2. Terminal Block
3. Cable
4. DAQ Device
5. Computer
109
DIGITAL-TO-ANALOG
CONVERSION [DAC]
110
Digital-to-Analog Converters (DACs)
• A DAC accepts digital information and transforms it into an analog voltage.
• The digital information is in the form of a binary number (word) with some fixed number
of bits.
• A unipolar DAC converts a digital word into an analog voltage by scaling the analog
output to be zero when all bits are zero and some maximum value when all bits are
one.
• This can be mathematically represented by treating the binary number that the word
represents as a fractional number.
• In this context, the output of the DAC can be defined as a scaling of some reference
voltage:
• The minimum Vout is zero, and the maximum is determined by the size of the binary
word because, with all bits set to one, the decimal equivalent approaches VR as the
number of bits increases.
•
111
112
Example
113
Bipolar DAC
114
Example
115
Conversion Resolution
116
Example
117
Example
118
DAC Structure
119
120
121
ANALOG-TO-DIGITAL
CONVERSION [ADC]
122
ADC
123
ADC
124
Example
125
Solution Cont.
126
Example
127
ADC
128
129
ADC Structure Successive
Approximation
130
131
Example
132
THANK YOU
133

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Actuators
ActuatorsActuators
Actuators
 
Design of Mechatronics System
Design of Mechatronics SystemDesign of Mechatronics System
Design of Mechatronics System
 
Various types of actuators
Various types of actuatorsVarious types of actuators
Various types of actuators
 
PLC (Programmable Logic Circuit)
PLC (Programmable Logic Circuit)PLC (Programmable Logic Circuit)
PLC (Programmable Logic Circuit)
 
PLC - Programmable Logic Controller
PLC - Programmable Logic ControllerPLC - Programmable Logic Controller
PLC - Programmable Logic Controller
 
Controller ppt
Controller pptController ppt
Controller ppt
 
Actuators
ActuatorsActuators
Actuators
 
Sensors
SensorsSensors
Sensors
 
PLC (PROGRAMMABLE LOGIC CONTROLLER)
PLC (PROGRAMMABLE LOGIC CONTROLLER)PLC (PROGRAMMABLE LOGIC CONTROLLER)
PLC (PROGRAMMABLE LOGIC CONTROLLER)
 
L6 Electrical Actuation system
L6 Electrical Actuation systemL6 Electrical Actuation system
L6 Electrical Actuation system
 
ppt on PLC automation
ppt on PLC automationppt on PLC automation
ppt on PLC automation
 
PLC Ladder Programming [Mechatronics]
PLC Ladder Programming [Mechatronics]PLC Ladder Programming [Mechatronics]
PLC Ladder Programming [Mechatronics]
 
Ppt of servomotor
Ppt of servomotorPpt of servomotor
Ppt of servomotor
 
Robot control
Robot controlRobot control
Robot control
 
Unit III-- senors in robotics
Unit III-- senors in roboticsUnit III-- senors in robotics
Unit III-- senors in robotics
 
Plc timers
Plc timersPlc timers
Plc timers
 
Adaptive Control System
Adaptive Control SystemAdaptive Control System
Adaptive Control System
 
Dc servo motor
Dc servo motorDc servo motor
Dc servo motor
 
Introduction to Mechatronics, Sensors and Transducers
Introduction to Mechatronics, Sensors and TransducersIntroduction to Mechatronics, Sensors and Transducers
Introduction to Mechatronics, Sensors and Transducers
 
Displacement measurement
Displacement measurementDisplacement measurement
Displacement measurement
 

Semelhante a Lec 8,9,10 (interfacing)

Visiter counter doc
Visiter counter docVisiter counter doc
Visiter counter docPrem Kumar
 
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCYAUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCYGaurav Singh
 
File 1389427052
File 1389427052File 1389427052
File 1389427052Aman_preet
 
Cockpit White Box
Cockpit White BoxCockpit White Box
Cockpit White Boxncct
 
One Touch Electrical Appliances Control Using Microcontroller 89C51
One Touch Electrical Appliances Control Using Microcontroller 89C51One Touch Electrical Appliances Control Using Microcontroller 89C51
One Touch Electrical Appliances Control Using Microcontroller 89C51Pawan Bahuguna
 
power grid synchronization failure detection
power grid synchronization failure detectionpower grid synchronization failure detection
power grid synchronization failure detectionJay Hind
 
Grid synchronisation
Grid synchronisationGrid synchronisation
Grid synchronisationmanogna gwen
 
Emotional Stress Indicator and Digital Thermometer-Project-8thsem
Emotional Stress Indicator and Digital Thermometer-Project-8thsemEmotional Stress Indicator and Digital Thermometer-Project-8thsem
Emotional Stress Indicator and Digital Thermometer-Project-8thsemkaushikbandopadhyay
 
BHH POWER PLANT ppt.pptx
BHH POWER PLANT ppt.pptxBHH POWER PLANT ppt.pptx
BHH POWER PLANT ppt.pptxAnil764767
 
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITYELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITYEldhose George
 
Speed Control of DC motor using AT89C52 IC
Speed Control of DC motor using AT89C52 ICSpeed Control of DC motor using AT89C52 IC
Speed Control of DC motor using AT89C52 ICDisha Modi
 
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...IRJET Journal
 
329292817-PLC-Training for new person pptx
329292817-PLC-Training for new person pptx329292817-PLC-Training for new person pptx
329292817-PLC-Training for new person pptxviveksingh2418
 
under grund fault ppt (1).pptx
under grund fault ppt (1).pptxunder grund fault ppt (1).pptx
under grund fault ppt (1).pptxPoojaG86
 

Semelhante a Lec 8,9,10 (interfacing) (20)

Visiter counter doc
Visiter counter docVisiter counter doc
Visiter counter doc
 
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCYAUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
AUTOMATIC GRID ON SENSING BAD VOLTAGE OR FREQUENCY
 
File 1389427052
File 1389427052File 1389427052
File 1389427052
 
Cockpit White Box
Cockpit White BoxCockpit White Box
Cockpit White Box
 
One Touch Electrical Appliances Control Using Microcontroller 89C51
One Touch Electrical Appliances Control Using Microcontroller 89C51One Touch Electrical Appliances Control Using Microcontroller 89C51
One Touch Electrical Appliances Control Using Microcontroller 89C51
 
power grid synchronization failure detection
power grid synchronization failure detectionpower grid synchronization failure detection
power grid synchronization failure detection
 
Grid synchronisation
Grid synchronisationGrid synchronisation
Grid synchronisation
 
Emotional Stress Indicator and Digital Thermometer-Project-8thsem
Emotional Stress Indicator and Digital Thermometer-Project-8thsemEmotional Stress Indicator and Digital Thermometer-Project-8thsem
Emotional Stress Indicator and Digital Thermometer-Project-8thsem
 
BHH POWER PLANT ppt.pptx
BHH POWER PLANT ppt.pptxBHH POWER PLANT ppt.pptx
BHH POWER PLANT ppt.pptx
 
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITYELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
ELECTRONICS PROJECT REPORT OF HOME AUTOMATION CUM BUILDING SECUIRITY
 
Optocoup
OptocoupOptocoup
Optocoup
 
Automatic mall elevator
Automatic mall elevatorAutomatic mall elevator
Automatic mall elevator
 
Speed Control of DC motor using AT89C52 IC
Speed Control of DC motor using AT89C52 ICSpeed Control of DC motor using AT89C52 IC
Speed Control of DC motor using AT89C52 IC
 
Speed control of motor
Speed control of motorSpeed control of motor
Speed control of motor
 
embedded system
embedded system  embedded system
embedded system
 
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...
IRJET- Phase Changer Mechanism in Abnormal Conditions for Single Phase Applic...
 
Final ppt
Final pptFinal ppt
Final ppt
 
329292817-PLC-Training for new person pptx
329292817-PLC-Training for new person pptx329292817-PLC-Training for new person pptx
329292817-PLC-Training for new person pptx
 
under grund fault ppt (1).pptx
under grund fault ppt (1).pptxunder grund fault ppt (1).pptx
under grund fault ppt (1).pptx
 
Apfc final seminar
Apfc final seminarApfc final seminar
Apfc final seminar
 

Mais de Mohamed Atef

Lecture 10.cont,11 (plc)
Lecture 10.cont,11 (plc)Lecture 10.cont,11 (plc)
Lecture 10.cont,11 (plc)Mohamed Atef
 
Lec 05(actuator sizing).pdf
Lec 05(actuator sizing).pdfLec 05(actuator sizing).pdf
Lec 05(actuator sizing).pdfMohamed Atef
 
Lec 04(actuators).pdf
Lec 04(actuators).pdfLec 04(actuators).pdf
Lec 04(actuators).pdfMohamed Atef
 
Lec 03(VDIdr shady)
Lec 03(VDIdr shady)Lec 03(VDIdr shady)
Lec 03(VDIdr shady)Mohamed Atef
 
Lec 02(VDI dr mohamed)
Lec 02(VDI  dr mohamed)Lec 02(VDI  dr mohamed)
Lec 02(VDI dr mohamed)Mohamed Atef
 
Lec 01(introduction) Mechatronic systems
Lec 01(introduction) Mechatronic systems Lec 01(introduction) Mechatronic systems
Lec 01(introduction) Mechatronic systems Mohamed Atef
 

Mais de Mohamed Atef (11)

Lecture 10.cont,11 (plc)
Lecture 10.cont,11 (plc)Lecture 10.cont,11 (plc)
Lecture 10.cont,11 (plc)
 
Lec 12 (cont plc)
Lec 12 (cont plc)Lec 12 (cont plc)
Lec 12 (cont plc)
 
Lec 07(sensors 2)
Lec 07(sensors 2)Lec 07(sensors 2)
Lec 07(sensors 2)
 
Lec 05(actuator sizing).pdf
Lec 05(actuator sizing).pdfLec 05(actuator sizing).pdf
Lec 05(actuator sizing).pdf
 
Lec 04(actuators).pdf
Lec 04(actuators).pdfLec 04(actuators).pdf
Lec 04(actuators).pdf
 
Lec 03(VDIdr shady)
Lec 03(VDIdr shady)Lec 03(VDIdr shady)
Lec 03(VDIdr shady)
 
Lec 02(VDI dr mohamed)
Lec 02(VDI  dr mohamed)Lec 02(VDI  dr mohamed)
Lec 02(VDI dr mohamed)
 
Lec 01(introduction) Mechatronic systems
Lec 01(introduction) Mechatronic systems Lec 01(introduction) Mechatronic systems
Lec 01(introduction) Mechatronic systems
 
Cnc lecture3
Cnc lecture3Cnc lecture3
Cnc lecture3
 
Cnc lecture2
Cnc lecture2Cnc lecture2
Cnc lecture2
 
Cnc lecture1
Cnc lecture1Cnc lecture1
Cnc lecture1
 

Último

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 

Último (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 

Lec 8,9,10 (interfacing)

  • 1. MECHATRONICS 2 Interfacing and PC based Computer AIN SHAMS UNIVERSITY FACULTY OF ENGINEERING MECHATRONICS ENGINEERING DEPARTMENT 1 Dr. Shady A. Maged
  • 2. Interfacing in the Mechatronics System ConfigurationMechanical System Controller Actuators Sensors Signal Processing Power Amplification Interfacing 2
  • 3. Interfacing a switch (input device) to a digital circuit: Using pull-up resistor Using pull-down resistor When the switch is open the voltage of the gate input is pulled up to the level of Vin. When the switch is closed, the input voltage at the gate goes to ground. Pull-up and pull-down resistors are used in electronic logic circuits to ensure that inputs to logic systems settle at expected logic levels if external devices are disconnected or high-impedance is introduced. They may also be used at the interface between two different types of logic devices, possibly operating at different power supply voltages. 3
  • 4. Pull-up and down resistors 4
  • 5. Mechanical switch The function of a switch is simple. When we press a switch, two contacts are joined together and connection is made. Still, it is not that simple. The problem lies in the imperfection of mechanical contacts. That is to say, before contact is made or cut off, there is a short time period when vibration (oscillation) can occur as a result of unevenness of mechanical contacts, or as a result of the different speed in pressing a key (this depends on person who presses the key). The term given to this phenomenon is called SWITCH (CONTACT) DEBOUNCE. Bouncing while transition from high to low Bouncing while transition from low to high Switch De-bouncing 5
  • 6. Due to this problem, there won't be a clean transition from a state to another, but instead there will be a series of high and low states spikes as shown in figure 1B. The 'unknown' range can be recognized by some a digital circuit as 1 or 0, but in a completely random manner. This series of spikes can be interpreted by a microcontroller (or any digital circuit) as if the button was pressed many times. It may even have happened to you before when you connected a switch to a counter of any kind, and notice that one press on the button is sometimes counted as more than one push. Fig. 1A: A simple switch configuration without a de-bouncing circuit Fig. 1B: Behavior of a switch without a de-bouncing circuit De-bouncing 6
  • 7. There are 2 common solutions to this problem. Analog solution and digital micro-controller based solution. Both are commonly used, and sometimes, both are used at the same time to provide a very stable design. The analog de-bouncing circuit Fig. 2A: A switch with a de- bouncing circuit Fig. 2B: A switch with a de- bouncing circuit • The analog solution relies principally on a capacitor, which plays the role of resisting the voltage changes on the output. De-bouncing 7
  • 8. The software based de-bouncing the idea here is not to prevent voltage spikes to occur, but rather to record them and analyze them in real-time using simple software routines. The timing T1, T2 and T3 corresponds to the low (logic =0) pulses being sent to the microcontroller from the switch. T1 and T2 are the length of the reading we want to get rid off, or more scientifically, that we want to filter. T3 is a valid reading that we want to take in account. It is clear that the difference between those three periods is their length, and that is how the micro-controller will be able to differentiate between valid and un-valid pulses. 8
  • 9. There are many ways to implement digital de-bouncing or filtering using a microcontroller, one simple method is to make a counter count up as long as the signal is Low, and reset this counter when the signal is high. If the counter reach a certain fixed value, which should be 1 or 2 times bigger than T1 or T2 (noise pulses), this means that the current pulse is a valid pulse (corresponds to T3 in our example). Another way to de-bounce using software is to wait for a certain time interval until the switch oscillations disappear. i.e. after the MICROCONTROLLER realizes the first state transition it waits for a certain period say (100 ms) then it takes the action that corresponds to this transition. 9
  • 10. Example: Required: Write a code that turns the LED on when T2 is pressed, and turns it off when T1 is pressed. You have to come over switch de-bounce in your software This circuit has 2 inputs and 1 output Input T1 Output LED Input T2 Output LED RA3 RB7 RA2 RB7 0 Unchanged 0 Unchanged 1 OFF (0) 1 ON (1) 10
  • 11. RA3 and RA2 are inputs, RB7 is output T2 pressed? T2 pressed? YES LED is ON NO NO Call Delay YES START LED is OFF T1 pressed? T1 pressed? CallDelay YESNO NO Flow Chart 11
  • 12. Transistor A transistor is a semiconductor device used to amplify and switch electronic signals. Transistors are commonly used as electronic switches. You can imagine the collector and emitter as two contact points of a switch. If the base is activated, then both contact points are closed Together; otherwise they are opened. Interfacing an inductive load to a digital circuit through a transistor When the voltage across an inductive load is reduced or removed a sudden spike voltage is seen across the load • A resistor (e.g., 1k) to limit the base current while ensuring the transistor is in full saturation • 24 V DC capable of at least 1A of current • power diode capable of carrying at least 1A for flyback protection (Free Wheeling Diode) used whenever inductive loads are switched off by silicon components • ground 12
  • 13. Darlington Pair The above schematic represents a transistor called as a Darlington Pair which usually comes in a single package. The advantage of this combination is that the current gain is the product of two individual transistor gains and can exceed 10000. They may often be found in power circuits for mechatronic systems. 13
  • 14. Seven-Segment Display (multiplexing) Circuit diagram for Common Cathode 7-Segment Display Circuit diagram for Common Anode 7-Segment Display •The segments in a 7-segment display are arranged to form a single digit from 0 to F • Even though LCD displays are more comfortable to work with, 7-segment displays are still standard in the industry. • The 8 LEDs inside each display can be arranged with a common cathode or common anode. 14
  • 15. •The simplest way to drive a display is via a display driver. These are available for up to 4 displays. LT =Lamp Test, BI = Blanking Input, LE = Latch Enable 15
  • 16. •Alternatively displays can be driven by a microcontroller and if more than one display is required, the method of driving them is called "multiplexing.” • If a single display is to be driven from a microcontroller, 7 lines will be needed plus one for the decimal point. For each additional display, only one extra line is needed. • To produce a 4, 5 or 6 digit display, all the 7-segment displays are connected in parallel. The common line (the common-cathode line) is taken out separately and this line is taken low for a short period of time to turn on the display. • Each display is turned on at a rate above 100 times per second, and it will appear that all the displays are turned on at the same time. As each display is turned on, the appropriate information must be delivered to it so that it will give the correct reading. 16
  • 17. Example Required: Write a code that displays the number 21 on the common cathode 7- segment displays using transistors where the hardware connections are shown above. 17
  • 18. Optocoupler combines a LED and photo-transistor in the same case. The purpose of an optocoupler is to separate two parts of a circuit. Why optocoupler? Interference. One part of a circuit may be in a location where it picks up a lot of interference (such as from electric motors, welding equipment, petrol motors etc.) If the output of this circuit goes through an optocoupler to another circuit, only the intended signals will pass through the optocoupler. The interference signals will not have enough "strength" to activate the LED in the optocoupler and thus they are eliminated. To protect a section of the device. Typical examples are industrial units with lots of interferences which affect signals in the wires. If these interferences affect the function of control section, errors will occur and the unit will stop working. Optocoupler 18
  • 19. •Simultaneous separation and intensification of a signal. A signal as low as 3v is able to activate an optocoupler and the output of the optocoupler can be connected to an input line of a microcontroller. The microcontroller requires an input swing of 5v and in this case the 3v signal is amplified to 5v. It can also be used to amplify the current of a signal. • High Voltage Separation. Optocouplers have inherent high voltage separation qualities. Since the LED is completely separate from the photo- transistor, optocouplers can exhibit voltage isolation of 3kv or higher. Optocouplers can be used as input or output device. They can have additional functions such as Schmitt triggering (the output of a Schmitt trigger is either 0 or 1 - it changes slow rising and falling waveforms into definite low or high values). Optocouplers are packaged as a single unit or in groups of two or more in one housing. They are also called PHOTO INTERRUPTERS where a spoked wheel is inserted in a slot between the LED and phototransistor and each time the light is interrupted, the transistor produces a pulse.Each optocoupler needs two supplies in order to function. They can be used with one supply, but the voltage isolation feature is lost. 19
  • 20. Example: This example is a counter, used for counting products on production line. Let the sensor be a micro-switch. Each time the switch is closed, the LED is illuminated. The LED transfers the signal to the photo-transistor and the operation of the photo- transistor delivers a LOW to input RA4 of a microcontroller. Required: write a program that counts the products, and indicates the current count on any of the outputs of the microcontroller. Input T1 Output LED RA4/TCK0 PORTB Each negative edge Increase by 1 20
  • 21. The Relay The relay is an electromechanical device, which transforms an electrical signal into mechanical movement. It consists of a coil of insulated wire on a metal core, and a metal armature with one or more contacts. When a supply voltage was delivered to the coil, current would flow and a magnetic field would be produced that moves the armature to close one set of contacts and/or open another set. When power is removed from the relay, the magnetic flux in the coil collapses and produces a fairly high voltage in the opposite direction. 21
  • 22. Interfacing an AC load to a digital circuit through a relay Interfacing a DC load to a digital circuit through a relay Examples: 22
  • 23. Example on Micro: Required: Write a code that activates the Relay on when T2 is pressed, and turns it off when T1 is pressed. You have to come over switch debounce in your software. 23
  • 24. CONTROL OF DC MOTOR USING H-BRIDGE AND PWM 24
  • 27. Controlling the power delivered to the motor to control the speed . PWM (pulse width modulation) is the most common way to control the power delivered to the motor, thus the speed of the motor. It's also the most efficient method. This article does not intent to explain PWM, but here is how in works, in very simplified way: The microcontroller generate pulses of electricity for the motor (instead of constant DC voltage). The frequency of those pulses remain constant, while the ON period of the pulse is varied to increase or decrease the speed of the motor. the Average voltage of the wave of pulses increases gradually as the duty cycle increases (duty cycle is the ratio of the 'ON' period over the total period of the pulse). As the average voltage increases, the speed of the motor will increase gradually. 27
  • 28. Controlling the power delivered to the motor to control the speed . Making a speed control program using the PWM theory is very simple, which is a code targeted for any microcontroller to run the motor at half speed (50/100) and where the Enable pin of the motor controller is connected to specific pin of the microcontroller: 28
  • 29. CONTROL THE DIRECTION OF THE MOTOR USING H- BRIDGE 29
  • 30. H-Bridge High Side Left High Side Right Lower Left Lower Right Quadrant Description On Off Off On Motor goes Clockwise Off On On Off Motor goes Counter-clockwise On On Off Off Motor "brakes" and decelerates Off Off On On Motor "brakes" and decelerates 30
  • 32. 32
  • 34. 4A H bridge motor driver using the L298 IC 34
  • 35. Brief Circuit explanation This is an implementation of the L298 to drive motors and inductive loads up to 4A continuously. Initially the L298 contains 2 separate channels, each one capable of driving 2A loads. Connecting them in parallel as in the schematic makes a single 4A driver. The two wire connections W1 and W2 are to control the direction of the motor according to that table: 35
  • 36. Brief Circuit explanation The 2 transistors Q1 and Q2 act as an OR gate enabling the L298 if any of the two signals W1 or W2 are high. If both W1 and W2 are low (logic 0), the driver is disabled and provides a high impedance on its output, causing an eventually connected motor to move freely with its inertia. C1 and C2 are 10 nF decoupling capacitors. D1 to D4 are flyback diodes. Their forward current should correspond with the the expected load. The two leads of the motor are directly connected to J1. The circuit can be powered with 9 to 35V 36
  • 38. The Analog-to-Digital Converter There is a device commonly in microcontrollers called ADC (Analog to digital converter). An ADC converts a varying (analog) voltage level into a corresponding digital number. ADC 0808 which has 8 – analog inputs (8 - channels) and gives an 8 – bits value out as the result of conversion 38
  • 39. ADC0808 (8-channels 8-bit) 8-channels (8-analog input) Example : 8 - sensors 8 – bit value out as a result Of the conversion 3-MUX input select address lines (Appendix A) DATA BUS +5V GROUND SUPPLY 500 kHz 39
  • 40. 40
  • 41. CONTROL LINES Output Enable line for reading the ADC (TRI STATE OUTPUT LATCH) End of Convert line that signals the Host that the conversion is complete normaly 1 when finish convert to 0. Start / ALE line that are tied together And connected as 1 to the host
  • 43. How does the ADC work ? Time Diagram
  • 44. Hardware Implementation GND +5V Analog Signal Analog Signal OUTPUT ON LEDS OUTPUT CONNECTION O/P FROM MICRO 500 kHz O/P FROM MICRO O/P FROM MICRO I/P TO MICRO
  • 45. Example on MICRO with built-in ADC Construct the hardware connection and the flowchart (for a Microcontroller) that reads analogue value from channel 2 and displays it on PORTD (lower 8 bits) and PORTB (2 most significant bits). 45 45
  • 46. Example on MICRO with built-in ADC Construct the hardware connection and the flowchart (for a Microcontroller) that reads analogue value from channel 2 and displays it on PORTD (lower 8 bits) and PORTB (2 most significant bits). 46 46 RA2 is input, Port D, RB6 and RB7 are outputs START Analogue value=Temp_res Port D=Temp_res Port B=Temp_res>>2
  • 47. Closed loop vs Open loop control 47
  • 49. Example: Open loop Speed Controller Write a program that control the speed and the direction of the DC motor using H-bridge and PWM signal with a duty cycle based on the analogue input comes from potentiometer 49
  • 50. SOFTWARE APPROACH 1. Initialize the I/O ports 2. Controlling the ADC and reading the digital value (I/p to the micro) 3. Check if the I/p is 0V therefore the motor is OFF 4. Check if the I/p is 5V therefore the motor is ON 5. knowing that the Duty Cycle= t_high/T *100(%) and to obtain at 5V, D=100%, 6. Calculate t_high and t_low from the following equations t_high = digital I/P from input port t_low= 255 - t_high 7. Obtain delay equals to t_high 8. Clear the output and then obtain delay equals to t_low 9. set the output 10. Repeat steps 7,8 and 9. 50
  • 51. Notice how the heat sink is firmly attached to the driver. this protects the IC from eventually burning-up from stall currents . 51
  • 54. Objective: you will learn here how to implement a digital proportional gain controller, i.e. a servomotor controller. The objective of this is to write a program that generates a PWM signal with a duty cycle based on the output of a proportional gain controller whose input is a signal from a potentiometer or encoder mounted on the shaft of the DC motor. This program is similar in concept to the open loop speed controller; however the duty cycle of the PWM signal is now determined from the error of the input- feedback calculation. 54
  • 55. Problem Statement: Write a program that controls the position of the DC motor. The program should implement a proportional control algorithm. The system diagram looks like 55
  • 57. Closed Loop Vs Open Loop Control 57
  • 58. 58
  • 59. 59
  • 61. 61
  • 62. 62
  • 63. General software approach The program should perform the following sequence of tasks: Sample the position using ADC. Calculate the amount and direction of control using a P, or a PID equation Output the PWM signal based on the control amount (related to position error) Recall from control, that the simplest closed-loop, proportional feedback controller defines the output as: Output = K. (Input-Feedback) = K.error You will need to scale your error signal by some value, k, for your PWM duty cycle to be high enough to achieve acceptable system time response. You can easily multiply the error signal by factors of 2 63
  • 65. LogicTTLRS-232 High+2V … +5V-15V … -3V Low0V … +0.8V+3V … +15V MAX 232 The MAX232 is an integrated circuit that converts signals from an RS-232 serial port to signals suitable for use in TTL compatible digital logic circuits. 65
  • 68. Connect the serial to serial cable (RS232) to the Serial to breadboard converter. 68
  • 69. 1.Working On Hyper Terminal 69
  • 70. 2. In case of making phone or modem connection you must specify your location but in our case just press cancel as shown 70
  • 71. 3. Press yes then ok 71
  • 72. 4. Choose Name and icon for your connection 5.Again repeat this step then Yes then Ok 72
  • 73. 6. Choose the port of connection then press Ok 73
  • 74. 7. Choose the Com properties as shown in the following pictures, this properties varies from connection to another 74
  • 75. 8. Continue Choosing the properties 75
  • 77. 10. The message will be shown on this screen 77
  • 78. 11.To quit from the HT you must disconnect the connection first by pressing Ok 78
  • 79. 12. Choose yes if you want to save your work 79
  • 80. PC BASED CONTROLLER FOR MECHATRONICS SYSTEM 80
  • 81. Controller in the Mechatronics System ConfigurationMechanical System PC Controller Actuators Sensors Signal Conditioning Power Amplification 81
  • 82. The controller is the PC (Personal Computer) Computer-Based Controllers Controller PC Pc Board GPIB Serial/paralell CAN BUS 82
  • 83. Higher level Programming languages, Programming Languages Matlab Labview 83
  • 84. Data acquisition is the process of measuring an electrical or physical phenomenon such as voltage, current, temperature, pressure, or sound. PC-based data acquisition uses a combination of modular hardware, application software, and a computer to take measurements. While each data acquisition (DAQ) system is defined by its application requirements, every system shares a common goal of acquiring, analyzing, and presenting information. Data acquisition systems incorporate signals, sensors, actuators, signal conditioning, DAQ devices, and application software. Data Acquisition Cards 84
  • 85. Example NI USB-6008 The National Instruments USB-6008 provides basic data acquisition functionality Analog Inputs: 8 SE/4 DI · 10 kS/s · 12 bits Analog Outputs: 2 · 150 S/s · 12 bits Digital I/O: 12 DIO Counter/Timers: 1 · 32 bits · 5 MHz Measurement Type: Voltage 85
  • 86. NI USB-6251 BNC The National Instruments USB-6251 BNC is a USB high-performance M Series multifunction data acquisition Analog Inputs: 8 SE/4 DI · 1.25 MS/s · 16 bits Analog Outputs: 2 · 2.86 MS/s · 16 bits Digital I/O: 24 DIO · 1 MHz Counter/Timers: 2 · 32 bits · 80 MHz Measurement Type: Quadrature encoder, Voltage Example 86
  • 88. Measurement System Differential Mode (DI) •Differential Mode • Two channels used for each signal • ACH 0 is paired with ACH 8, ACH 1 is paired with ACH 9, etc. • Rejects common-mode voltage and common-mode noise 88
  • 89. Differential Mode 89 Why would I ever want to use differential mode? Placing your measurement system in differential mode will give you better measurements, because it allows the amplifier to reject common-mode voltage and any common-mode noise that is present in your signal. Common-mode voltage is any voltage present at the instrumentation amplifier inputs with respect to the amplifier ground.
  • 91. The big issue with digital conversion: A continuous value is made discrete 1. In amplitude (Y axis issues) • Resolution • Saturation 2. In time (X axis issues) • Aliasing • Leakage • Frequency resolution Digital Data Acquisition 91
  • 92. Analogue Digital conversion: quantization:  A continuous value is compared with a series of fixed, discrete intervals (states) encoding:  The interval mean value is converted into a digital, usually binary, chain of elements Digital Data Acquisition 92
  • 93. Binary representation: • Data type length = N bit • Binary encoding = O / 1 Having only two states possible per element allows for very robust handling and trasmission systems since the diffence between states can be high and electronics is simple and cheap. Digital Data Acquisition 93
  • 94. DIGITAL RESOLUTION Having N bit data length  2N different states 3 bit  23 =8 different states (1 byte = 8 bit) 8 bit  28 =256 states 10 bit  210 =1024 states 12 bit  212 =4096 states 14 bit  214 =16384 states 16 bit  216 =65536 states Digital Data Acquisition 94
  • 95. AD converter transfer function is not linear: output = 2N states input = continuous value input output Digital Data Acquisition 95
  • 96. Resolution = minimum variation of the input quantity that can be detected by the AD converter. It is equal to the value of the least significant bit (the smallest one) LSB=“least significant bit” 1 LSB = FS / 2N Digital Data Acquisition 96
  • 97. Resolution depends on both the full scale input of DAQ converter and bit length of data field Es: FS=10 V N=3 bit LSB=1.25 V FS=10 V N=8 bit LSB=39 mV FS=10 V N=12 bit LSB=2.44mV n FSFS resolution 2 minmax   Digital Data Acquisition 97
  • 98. 100 200150500 Time (ms) 0 1.25 5.00 2.50 3.75 6.25 7.50 8.75 10.00 Amplitude (volts) 16-Bit Versus 3-Bit Resolution (5kHz Sine Wave) 16-bit resolution 3-bit resolution 000 001 010 011 100 101 110 111 | |||| Resolution Example 3-bit resolution can represent 8 voltage levels (10/23) 16-bit resolution can represent 65,536 voltage levels 98
  • 99. Signal 3 bit 5 bit Digital Data Acquisition 99
  • 100. SIGNAL SAMPLING FREQUENCY ISSUES (X axis issues) Digital Data Acquisition 100
  • 101. SAMPLING: Conversion of a time continuous value into a chain of values V (ti , Vi) i=1,...... N t t V Digital Data Acquisition 101
  • 102. Both V amplitude and it’s time coordinates are discrete values depending on ADC capabilities and configuration SAMPLING TIME tC = ti - ti-1 SAMPLING FREQUENCY fC = 1 / tC t V ti-1 ti ti+1 Digital Data Acquisition 102
  • 103. With sampling frequency can be used to represent a signal without altering it? t V t V both OK, but somehow different Digital Data Acquisition 103
  • 104. If sampling frequency is too low a problem with frequency representation can occurr: we have “aliasing” t V Sampling signal is no longer recognizable, and its frequency seems lower than the original one. Digital Data Acquisition 104
  • 105. The issue of aliasing is related to the ratio between sampling frequency fS and signal frequency fA fS < 2 fA  “aliasing” occurs fS > 2 fA fS = 2 fA fS < 2 fA Digital Data Acquisition 105
  • 106. Nyquist-Shannon theorem: if a continuous signal with a top limited bandwidth contains only components with frequency up to fAmax therefore a coherent representation could be achieved by a sampling frequency fS > 2 fAmax Digital Data Acquisition 106
  • 107. f S = 1 / tS fA = 1 / TA being fS > 2fA tS < TA / 2 We require at least two samples for each half period... Digital Data Acquisition 107
  • 108. Nyquist Example Aliased Signal Adequately Sampled for Frequency Only (Same # of cycles) Adequately Sampled for Frequency and Shape 100Hz Sine Wave 100Hz Sine Wave Sampled at 100Hz Sampled at 200Hz Sampled at 1kHz100Hz Sine Wave 108
  • 109. DAQ Hardware 1. Signal 2. Terminal Block 3. Cable 4. DAQ Device 5. Computer 109
  • 111. Digital-to-Analog Converters (DACs) • A DAC accepts digital information and transforms it into an analog voltage. • The digital information is in the form of a binary number (word) with some fixed number of bits. • A unipolar DAC converts a digital word into an analog voltage by scaling the analog output to be zero when all bits are zero and some maximum value when all bits are one. • This can be mathematically represented by treating the binary number that the word represents as a fractional number. • In this context, the output of the DAC can be defined as a scaling of some reference voltage: • The minimum Vout is zero, and the maximum is determined by the size of the binary word because, with all bits set to one, the decimal equivalent approaches VR as the number of bits increases. • 111
  • 112. 112
  • 120. 120
  • 121. 121
  • 129. 129
  • 131. 131