In real time mechanical systems, we
need to rotate screw as per our required alignment and depending on the output,
the range of motion may change. This project is an attempt to automate such a
manually difficult task. So that we can use electronics to calculate the linear
motion needed, synchronize it with the needed angular motion and in turn the
desired movement of the screw arrangement.
A stepper motor is an
electromechanical device which converts electrical pulses into discrete
mechanical movements. The shaft of the motor rotates in discrete step
increments when electrical command pulses are applied to it. The sequence of
applied pulses is directly related to the direction of rotation. The speed of
motor shaft rotation is directly related to the frequency of input pulses and
the length of rotation is directly related to the number of input pulses
applied.
A stepper motor can be used to
advantage where controlled movement is required such as to control rotation
angle, speed, position and synchronism. Here stepper motor is used to control
position. A lead screw assembly with scale is connected to the shaft of the
motor. The nut on the screw changes its position as the shaft rotates. A scale
is placed to show the exact displacement of the nut from zero position.
SPECIFICATION
Electrical Specifications
IC 89C51 and LCD operate on +5V
Step down Transformer specifications:
230 V primary
12 V Secondary
19:1 turns ratio
1A current
DESIGN
The 8052 is an 8-bit microcontroller.
It consists of CPU, two kinds of memory sections (data and program memory),
input/output ports, special function registers and control logic.
P1.0 VCC
P1.1 P0.0
(AD0)
P1.2 P0.1
(AD1)
P1.3 P0.2
(AD2)
P1.4 P0.3
(AD3)
P1.5 P0.4
(AD4)
P1.6 P0.5
(AD5)
P1.7 P0.6
(AD6)
RST P0.7
(AD7)
(RXD)P3.0 EA/VPP
(TXD)P3.1 ALE/PROG
(INT0)P3.2 PSEN
(INT1)P3.3 P2.7 (A15)
(T0) P3.4 P2.6 (A14)
(T1) P3.5 P2.5 (A13)
(WR)P3.6 P2.4 (A12)
(RD)P3.7 P2.3 (A11)
XTAL2 P2.2 (A10)
XTAL1
P2.1 (A9)
GND P2.0 (A8)
The AT89C52 is a low-power,
high-performance CMOS 8-bit microcomputer with 8 Kbytes of Flash programmable
and erasable read only memory (PEROM). The device is manufactured using Atmel’s
high-density nonvolatile memory technology and is compatible with the
industry-standard 80C51 and 80C52 instruction set and pin out. The on-chip
Flash allows the program memory to be reprogrammed in-system or by a conventional
nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on
a monolithic chip, the Atmel AT89C52 is a powerful microcomputer which provides
a highly-flexible and cost-effective solution to many embedded control applications.
Features
• Compatible with MCS-51™ Products
• 8K Bytes of In-System Reprogrammable
Flash Memory
• Endurance: 1,000 Write/Erase Cycles
• Fully Static Operation: 0 Hz to 24
MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters
• Eight Interrupt Sources
• Programmable Serial Channel
• Low-power Idle and Power-down Modes
Stepper motor
Stepper motors have multiple
"toothed" electromagnets arranged around a central gear-shaped piece
of iron. The electromagnets are energized by an external control circuit, such
as a microcontroller. To make the motor shaft turn, first one electromagnet is
given power, which makes the gear's teeth magnetically attracted to the
electromagnet's teeth. When the gear's teeth are thus aligned to the first
electromagnet, they are slightly offset from the next electromagnet. So when
the next electromagnet is turned on and the first is turned off, the gear
rotates slightly to align with the next one and from there the process is
repeated. Each of those slight rotations is called a "step," with an
integer number of steps making a full rotation. In that way, the motor can be
turned by a precise angle.
Full step mode
The stepper motor uses a four-step
switching sequence, which is called a full-step switching sequence. Figure 2-1
shows a switching diagram and a table that indicates the sequence for the four
switches used to control the stepper motor. The diagram shows four switches
with four separate amplifiers. Each of the windings is tapped at one end and
they are connected through a resistor to the negative terminal of the power
supply.
LCD Display
The 2 line x 16 character LCD modules are
available from a wide range of manufacturers and should all be compatible with
the HD44780.
Pin No. Name Description
Pin no. 14 D7 Data bus line 7
(MSB)
Pin no. 13 D6 Data bus line 6
Pin no. 12 D5 Data bus line 5
Pin no. 11 D4 Data bus line 4
Pin no. 10 D3 Data bus line 3
Pin no. 9 D2 Data bus line
2
Pin no. 8 D1 Data bus line
1
Pin no. 7 D0 Data bus line
0 (LSB)
Pin no. 6 EN1 Enable signal
for row 0 and 1 (1stcontroller)
Pin no. 5 R/W 0 = Write to
LCD module
1 = Read from LCD module
Pin no. 4 RS 0 =
Instruction input
1 = Data input
Pin no. 3 VEE Contrast
adjust
Pin no. 1 VSS Power supply
(GND)
Pin no. 2 VCC Power supply
(+5V)
Pin no. 15 EN2 Enable signal
for row 2 and 3 (2ndcontroller)
Pin no. 16 NC Not Connected
We make no effort to place the Data
bus into reverse direction. Therefore we hard wire the W/R line of the LCD
panel, into write mode. This will cause no bus conflicts on the data lines. As
a result we cannot read back the LCD's internal Busy Flag which tells us if the
LCD has accepted and finished processing the last instruction. This problem is
overcome by inserting known delays into our program. The 10k Potentiometer controls the contrast of
the LCD panel. Nothing fancy here. As with all the examples, I've left the
power supply out. You can use a bench power supply set to 5v or use a onboard
+5 regulator.
Keyboard
Keyboards are organized in matrix of
rows and columns.CPU accesses both rows and columns through ports.4*4 matrix is
connected to one port.
Key detection mechanism is based on
matrix arrangement of keyboard. The rows are connected to an o/p port and the
columns are connected an i/p port. If no key has been pressed, reading the i/p port will yield ones for all columns since
they are connected to Vcc. If all rows are grounded and a key is pressed, one
of the columns will have zero since the key pressed provides the path to
ground. To detect a pressed key, the micro-controller grounds all rows by
providing zero to the o/p latch, then it reads the columns. If the data read
from the columns is 1111, no key has been pressed and the process continues
until a key press is detected. However, if one of the column bits has 0, this
means that a key press has occurred.
Power supply design
In many applications,it is necessary
to supply constant dc voltage. The conversion of ac to dc is achieved by
rectifier supplied with ac signal using step down transformer. Output of
rectifier contains pulsating dc which can be removed by use of filter circuit.
The IC78XX series of 3 terminal regulators are available with fixed positive voltages.
These IC’s has internal thermal shutdown and short circuit current limiting.
Working
Here, we are going to ask the user to
enter the amount of displacement by which he/she wants to displace the screw.
The displacement can be in terms of angular rotations or in terms of a linear
movement, say in cm, mm, etc. This value is taken by a 4*4 matrix keyboard
interfaced to the microcontroller. The value is processed by the
microcontroller and accordingly the nut on the on the screw is moved linearly
clockwise or anticlockwise. The movement of the motor (clockwise or
anticlockwise) is also accepted from the user. To display the error messages
and the value entered by the user a 16*2 LCD is also included in the project.
Assembly program code
org 00h
sjmp
main
org
0030h
main: mov
r2,00h
mov
p0,00h
mov
p1,00h
acall
dispmsg1
acall
getkey
cjne
a,#0ah,disp
acall
err1
disp: acall
display
mov
r2,a
clr
a
up: mov
b,#10
mul
ab
add
a,r2
mov
r2,a
jc
err2
acall
display
acall
getkey
cjne
a,#0ah,up
mov b,#02
div
ab
l2: acall
dispmsg2
acall
getkey
acall
display
subb
a,#01h
jz
clk1
subb
a,#02h
jz
anclk1
acall
err3
sjmp
main
err1: acall
clrlcd
mov
dptr,#no2
acall
l1
ret
err2: acall
clrlcd
mov
dptr,#no5
acall
l1
sjmp
main
err3: acall
clrlcd
mov
dptr,#no6
acall
l1
mov
a,#0c0h
acall
command
mov
dptr,#no7
acall
getkey
sjmp
l2
dispmsg1:
acall
clrlcd
mov
dptr,#no1
acall
l1
ret
l1: clr
a
movc
a,@a+dptr
acall
display
inc
dptr
jnz
l1
ret
dispmsg2:
acall
clrlcd
mov
dptr,#no3
acall
l1
mov
a,#0c0h
acall
command
mov
dptr,#no4
acall
l1
ret
clrlcd: mov dptr,#comm
c1: clr
a
movc
a,@a+dptr
acall
command
inc
dptr
jnz
c1
ret
command:
mov
p0,a
clr
p2.0
clr
p2.1
setb
p2.2
acall
delay
acall
delay
clr
p2.2
ret
display:
acall
delay
mov
p0,a
setb
p2.0
clr
p2.1
setb
p2.2
acall
delay
acall
delay
acall
delay
clr
p2.2
ret
clk1:acall clk
ret
anclk1:acall anclk
ret
delay: mov
r7,#250
h1: mov
r6,#255
h2: mov
r5,#255
h: djnz
r6,h
djnz
r5,h2
djnz
r7,h1
ret
getkey: mov p3,#01fh
mov
dptr,#key
k1:
mov a,p3
anl a,#01fh
cjne a,#01fh,k1
acall
delay
k2:
mov a,p3
anl a,#01fh
cjne a,#01fh,over
sjmp k2
over:
acall delay
mov
a,p3
anl
a,#01fh
cjne
a,#01fh,over1
sjmp
k2
over1: mov
r1,#01h
mov r0,#0dfh
mov r3,#03h
ovr: mov
p3,r0
anl
a,r0
jnb acc.1,keydisp
inc dptr
jnb acc.2,keydisp
inc dptr
jnb acc.3,keydisp
inc dptr
jnb acc.4,keydisp
inc dptr
mov a,r0
rl a
mov r0,a
djnz r3,ovr
ljmp
k1
keydisp:clr a
movc a,@a+dptr
acall
disp
ret
clk:
sjmp rep1
rep1:
mov r3,#200
rep:
mov p1,#09h
acall delay
mov p1,#0ah
acall delay
mov p1,#06h
acall delay
mov
p1,#05h
acall delay
djnz r3,rep
djnz r2,rep1
ret
anclk:
sjmp rep3
rep3:
mov r3,#200d
rep2:
mov p1, #05
acall delay
mov p1,#06h
acall delay
mov p1,0ah
acall delay
mov p1,#09h
acall delay
djnz r3,rep2
djnz r2,rep3
ret
org 0300h
no1: db 'E','N','T','E','R',' ','L','E','N','G','T','H',':','0'
no2: db 'E','R','R','O','R','!','0'
no3: db '1','-','C','L','K','0'
no4: db
'2','-','A','N','T','I','C','l','K',':','0'
no5: db 'L','I','M','I','T','
','E','X','C','E','E','D','E','D','0'
no6: db 'E','N','T','E','R','0'
no7: db 'V','A','L','I','D','
','D','I','R','E','C','T','I','O','N','0'
key: db
'#','7','4','1','0','8','5','2','A','9','6','3'
comm: db 38h,0Eh,01h,06h,84h,0
end
0 comments:
Post a Comment