ME 362: Measurement & Instrumentation Sessional

advertisement
ME 362:
Measurement &
Instrumentation
Sessional
Department of Mechanical Engineering
BUET
Electrical Switching____________________
using BJT
using Relay
Motor Control________________________
DC Motors:
Direction of DC Motors can be controlled by using a simple circuit known as
H Bridge
H Bridge____________________________
Motor Control_____________________
Stepper Motors:
Types –
1. Unipolar
2. Bipolar
These were made by a number of companies including
Tendon themselves and Japan Servo Motors - type KP4M4-001
Minebea Co., Ltd - type 17PS-C007-04
Shinano Kenshi Co., Ltd - type STH-42G100
usual specifications:
+12v dc, four-phase, 1.8o, 3.6° etc… per step.
Stepping Sequences: Single Coil-Excitation
Single-Coil Excitation - Each successive coil is energized in turn.
Step
Coil 4
Coil 3
Coil 2
Coil 1
a.1
on
off
off
off
a.2
off
on
off
off
a.3
off
off
on
off
a.4
off
off
off
on
This sequence produces the smoothest movement and consumes
least power.
Stepping Sequences: Two-Coil Excitation
Two-Coil Excitation - Each successive pair of adjacent coils is
energized in turn.
Step
Coil 4
Coil 3
Coil 2
Coil 1
b.1
on
on
off
off
b.2
off
on
on
off
b.3
off
off
on
on
b.4
on
off
off
on
This is not as smooth and uses more power but produces greater
torque.
Stepping Sequences: Half-Stepping
Interleaving the two sequences will cause the motor to half-step
Step
Coil 4
Coil 3
Coil 2
Coil 1
a.1
on
off
off
off
b.1
on
on
off
off
a.2
off
on
off
off
b.2
off
on
on
off
a.3
off
off
on
off
b.3
off
off
on
on
a.4
off
off
off
on
b.4
on
off
off
on
This gives twice as many stationary positions between steps.
PC Interfacing________________________
Peripheral
Interface
Computer
Interface
Peripheral
Sensors
Computer
Actuator, Motors, Relay
Input and Output Interface
Computer Ports_______________________
Computer Ports (contd.)________________
Parallel data transmission
Transmit data bits
simultaneously
High data transfer rate
Only used over short
distance
Maxm voltage +5V
Serial data transmission
Transmit data bit by bit
sequentially
Slow data transfer rate
Used for long distance
Maxm voltage +25 V
Parallel Ports_________________________
• The Parallel Port is the most commonly used port for
interfacing.
• This port will allow the input of 5 to 8 bits or the output of 12
bits at any one given time, thus requiring minimal external
circuitry to implement many simpler tasks.
• The port is composed of 4 control lines, 5 status lines and 8
data lines.
• It's found commonly on the back of your PC as a D-Type 25 Pin
female connector. There may also be a D-Type 25 pin male
connector.
IBM-PC Parallel Printer Port_____________
•
•
•
•
8 output pins accessed via the DATA Port
5 input pins (one inverted) accessed via the STATUS Port
4 output pins (three inverted) accessed via the CONTROL Port
The remaining 8 pins are grounded
25-way Female D-Type Connector
IBM-PC Parallel Printer Port_____________
Data Port
Pin 2-9
Status Port
Pin 10, 11, 12, 13, 15
Control Port
Pin 1, 14, 16, 17
Port Address
Data Port
0x378
Status Port
0x379
Control Port
0x37a
I/O Port Access in Turbo C______________
# include <dos.h>
• int inportb(int portid);
/* returns a byte read from the I/O port portid */
void outportb(int portid, unsigned char value);
/* writes the byte value to the I/O port portid */
Calculate your own values to send to program___
Pin
Bit
9
D7
27
Value 128
8
D6
26
64
7
D5
25
32
6
D4
24
16
5
D3
23
8
4
D2
22
4
3
D1
21
2
2
D0
20
1
• If we want to set pins 2 and 3 to logic 1 (led on) then output
value 1+2=3.
• If we want to set on pins 3, 5 and 6 then we need to output
value 2+8+16=26.
Simple LED driving circuit_______________
Control Program______________________
#include <conio.h>
#include <dos.h> // For outportb
#define data 0x378 // Data Port Address of the parallel cable
void main (void)
{
outportb (data, 255); // For all lights on
outportb (data, 0); // For all lights off
}
Stepper Motor Driver___________________
The ULN2003 is a 7-bit 50V 500mA TTL-input NPN
darlington driver.
This is more than adequate to control a four phase unipolar
stepper motor such as the KP4M4-001.
It is recommended to connect a 12V zener diode between
the power supply and VDD (Pin 9) on the chip, to absorb
reverse (or "back") EMF from the magnetic field collapsing
when motor coils are switched off.
Four-Coil Connection diagram (using data pins)
Pin 18
Ground
Driving Code: Single-Coil Excitation___________
#define data 0x378
int i,t = 50; // interval in millisecond
void main (void)
{
for(i=0;i<=10;i++){
outportb (data, 1); // Coil 1 on
delay(t);
outportb (data, 2); // Coil 2 on
delay(t);
outportb (data, 4); // Coil 3 on
delay(t);
outportb (data, 8); // Coil 4 on
delay(t);}
}
8
D3
0
0
0
1
4
D2
0
0
1
0
2
D1
0
1
0
0
1
D0
1
0
0
0
Driving Code (Reverse Direction)_____________
#define data 0x378
int t = 50; // interval in millisecond
void main (void)
{
outportb (data, 8); // Coil 4 on
delay(t);
outportb (data, 4); // Coil 3 on
delay(t);
outportb (data, 2); // Coil 2 on
delay(t);
outportb (data, 1); // Coil 1 on
delay(t);
}
8
D3
1
0
0
0
4
D2
0
1
0
0
2
D1
0
0
1
0
1
D0
0
0
0
1
Four-Coil Connection diagram (using control pin)
Pin 18
Ground
Driving code: using control pins______________
#define ctrl 0x37a
int t = 50; // interval in millisecond
void main (void)
{
outportb (ctrl, 10); // Coil 1 on
delay(t);
outportb (ctrl, 9); // Coil 2 on
delay(t);
outportb (ctrl, 15); // Coil 3 on
delay(t);
outportb (ctrl, 3); // Coil 4 on
delay(t);
}
8
C3
1
1
1
0
4
C2
0
0
1
0
2
C1
1
0
1
1
1
C0
0
1
1
1
Driving Code: Two-Coil Excitation_____________
#define data 0x378
int t = 50; // interval in millisecond
void main (void)
{
outportb (data, 3); // Coil 1-2 on
delay(t);
outportb (data, 6); // Coil 2-3 on
delay(t);
outportb (data, 12); // Coil 3-4 on
delay(t);
outportb (data, 9); // Coil 4-1 on
delay(t);
}
8
D3
0
0
1
1
4
D2
0
1
1
0
2
D1
1
1
0
0
1
D0
1
0
0
1
Driving Code: Half Stepping_________________
void main (void){
outportb (data, 1); // Coil 1 on
delay(t);
outportb (data, 3); // Coil 1 & 2 on
delay(t);
outportb (data, 2); // Coil 2 on
delay(t);
outportb (data, 6); // Coil 2 & 3 on
delay(t);
outportb (data, 4); // Coil 3 on
delay(t);
outportb (data, 12); // Coil 3 & 4 on
delay(t);
outportb (data, 8); // Coil 4 on
delay(t);
outportb (data, 9); // Coil 4 & 1 on
delay(t);
}
8
D3
0
4
D2
0
2
D1
0
1
D0
1
0
0
0
0
0
1
1
1
1
1
0
0
0
1
1
1
0
0
0
0
1
0
0
0
1
0
0
1
Two-coil Connection_______________________
With the addition of a few resistors, you can control this
kind of motor with only two data lines (compared with the
Four-Wire Connection).
This uses the fact that, with Two-Coil Excitation, at any
time two of the coils have the inverse excitation (on/off) of
the other two.
You only need to supply the on/off signals for coils 3 and 2,
according to the Two-Coil Excitation sequence.
The corresponding inverted signals for coils 1 and 4 are
supplied by the circuit itself.
Two-coil Connection diagram (using 2 data pin)
Pin 18
Ground
Download