Upload
abhijit-karnik
View
1.055
Download
3
Embed Size (px)
DESCRIPTION
Project report for 7th Semester title "Surveillance Robot with Remote Control and End Effectors"
Citation preview
CERTIFICATE
IRMA ISTITUTE OF TECHOLOGY
AHMEDABAD
I hereby certify that the following students of B.E. IV, Semester VII,
Instrumentation and Control have satisfactorily completed their project on
‘SURVEILLANCE ROBOT WITH REMOTE CONTROL AND END EF‘SURVEILLANCE ROBOT WITH REMOTE CONTROL AND END EF‘SURVEILLANCE ROBOT WITH REMOTE CONTROL AND END EF‘SURVEILLANCE ROBOT WITH REMOTE CONTROL AND END EFFECTOR’FECTOR’FECTOR’FECTOR’
atatatat
ARRAYCOM INDIA LTD.ARRAYCOM INDIA LTD.ARRAYCOM INDIA LTD.ARRAYCOM INDIA LTD.
SR. NO. NAME ROLL NO.
1 ABHIJIT KARNIK 00IC28
2 NISHANT KAUSHIK 00IC29
3 HARSH SATYAPANTHI 00IC44
(Prof. J.B. Patel) (Dr. M.D. Desai)
ITERAL GUIDE HEAD OF THE ELECTRICAL
EGIEERIG DEPARTMET
DATE:
ProjecProjecProjecProject Report t Report t Report t Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TechnologyNirma Institute of TechnologyNirma Institute of TechnologyNirma Institute of Technology
XABREXABREXABREXABRE
ACKOWLEDGEMET:
As students of the final year of engineering (Instrumentation & Control), we are
required to undertake a project for the 7th and 8
th semesters. Our project is titled
“SURVEILLANCE ROBOT WITH REMOTE CONTROL AND END EFFECTORS”.
Herewith is encapsulated a report of the same.
In our attempt, we have come to realize that robotics is a field which is not just an
isolated field on its own. It is the fusion of a number of concepts from all the major
engineering fields. Hence our journey has had a number of guides, each one from a
different field. In submitting this report, we, the undersigned, would like to take the
opportunity to thank all these people, without whose help our modest endeavour would
never have seen the light of the day.
Thereby we take immense pleasure in thanking Mr. Kedar Thanki and Mr. S.J.
Dhru (Arraycom (I) Limited) who were our External guides, Dr. M.D. Desai (HOD,
Electrical Dept.), Prof. J.B. Patel(Asst. Prof., IC Dept., & Internal Guide), Prof. B.B.
Kadam (Prof., Electrical Dept.), Mr. H.K. Patel (Lecturer, IC Dept.), Prof. Y... Trivedi
(Asst. Prof., EC Dept.), Ms. Gauri Mudaliar (Lecturer, Mechanical Dept.), Mr. Sudhir
Raval (DI. Engg. Ltd) and Mr. Purendere (Syntronics Pvt. Ltd.)
We would also like to acknowledge the enthusiastic support that was given to us
by the faculty of I.C. Dept., who not only gave us moral support but were actively
interested in our project through all its ups and downs.
Last but not the least; we would like to acknowledge the unquestioning and
untiring support from our families.
Abhijit Karnik (00IC28)
ishant Kaushik (00IC29)
Harsh Satyapanthi (00IC44)
ProjecProjecProjecProject Report t Report t Report t Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TechnologyNirma Institute of TechnologyNirma Institute of TechnologyNirma Institute of Technology
XABREXABREXABREXABRE
FOREWORD:
The word robot was coined by the Czech writer Kapek in his play ‘Rossum's
Universal Robots’. Since then countless devices have been created and have been
associated with the word ‘Robot’. The works of Isaac Asimov have laid the foundation of
sociology pertaining to the use of robots instead of humans and the word ‘Robotics’ was
also coined by him. In today’s world, work on robots, that resemble and look almost
human, and others which don’t resemble humans in any way, progresses in leaps and
bounds. The world has forerunners in this technology like MIT, CMU, Sony, Honda etc.
In this world of ASIMO, AIBO, Packbot etc., we have made an attempt to create a device
which we dare call ‘Robot’.
Perhaps the most important work of Isaac Asimov could be considered to be the
coining of the 4 Laws of Robotics. One of the fundamental concepts of robots made
famous by the Zeroth Law of Robotics by Asimov: “A robot may not injure humanity, or,
through inaction, allow humanity to come to harm.” We have tried to create a system
which will allow safeguarding of life. We plan to achieve this by way of allowing the
robot to take the place of humans in situations which hold a potential threat to human life.
Our attempt was to provide a tool to the enforcers of law and order that could allow them
to access and assess a situation which could hold avoidable threat to human life.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
ITRODUCTIO:
This report is the documentation of all the efforts that went into the making
of Xabre. The title of the project was coined as:
‘Surveillance Robot with Remote Control & End Effectors’,
shortened to Sabre, (a type of sword) and going with the spirit of prototypes having
an ‘X’ in their name, we arrived at ‘Xabre’. Xabre is targeted to be a ‘Technology
Demonstrator’ prototype, wherein an attempt has been made such that the presently
available systems are integrated in a particular fashion, to accomplish a specific task.
This report is divided into 6 sections. Each section deals with the project
from a different viewpoint. The first section deals with the purpose of the robot, the
features it has and the system block diagram. The second section deals with the
operational description of the different modules of the robot which thereby allow the
proper functioning of the features that we have planned to implement on the robot.
The third section is the hardware and software section wherein the mind and the
nerve control of the robot is explained. The fourth section deals with the mechanical
design of the system. The fifth section contains the summary of different
technological fundamentals that were considered for use in the system as well as the
selection of the integrated circuit chips used in the project. The last section is the
annexure containing the selected sections of the datasheets of the electronic
components used in our project, bibliography, information about the sources of the
system’s components and the future development or design modifications that we
can implement but couldn’t due to various constraints..
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SECTIO 1
PROJECT OBJECTIVES:
The features that we have planned to implement on the robot are as follows:
1. Locomotion
2. Camera vision
3. Pan/Tilt motions for camera
4. Self-righting mechanism
5. Gripper mechanism
6. Extension operations
7. Path Illumination
Locomotion is the fundamental feature of the system since the system is a
mobile one. An easily maneuverable system implementing a differential tank-style
drive has been thought of. The differential drive also has a multi-speed operation
facility too.
The surveillance objective requires a camera to be mounted on the system. The
video information that is acquired by the camera has to be transmitted to the base
controller (called Zeus from now on) The HMI part of Zeus displays the video to the
human operator.
The additional requirement is that the camera should be able to cover the
maximum space around it, without the mobile robot (called Xabre from now on)
being required to rotate or move. This facility is provided by Pan/Tilt feature. This
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
allows the human controller to change the Point of View (POV) of the camera
easily.
The self-righting feature provides for a very versatile operation of the robot over
uneven terrain. In case during navigation, Xabre turns upside down, we can actually
flip it to right side up without the intervention of the human controller. This is done
automatically by the self-righting feature.
The gripper feature is the small object manipulator provided on Xabre to allow it
to physically interact with its environment and place or retrieve small objects into
the target location. The gripper has a single Degree of Freedom (DoF) apart from the
gripping action.
Xabre is targeted to be deployed into environments wherein, it may be loaded
with other tools that are required for it to perform desired tasks. Since it would be
improper to not provide the facility for the direct control of such tools without
additional overhead of hardware, we have already provided for the extension tools.
As of now a minimum of 5 such tools can be controlled by Zeus.
At times, Xabre may have to venture into areas where there is minimal light. In
such cases, since we can’t implement IR vision systems (reason being cost
constraints); we have the path illumination feature. This allows the camera to be able
to see the region ahead of it, after being illuminated.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
TARGET APPLICATIOS:
The target applications are surveillance and object retrieval purposes, basically
where it is practically difficult for humans to venture. The need to have a system like
the one we have designed is commonly felt in certain cases very frequently. One of
such target applications, for which this project was designed, is the case of hostage
situation. Another situation being a criminal is hiding in a house. In either situation,
the law enforcement officials would find it very convenient to not risk any human
life by sending someone inside. Instead, if Xabre is sent in, it can peruse the
surroundings and communicate, to the officials outside, the scene inside through
Zeus.
Xabre can also be used to approach and investigate any suspicious object which
could be hazardous. For this purpose, the gripper mechanism which has the ability to
grasp and extricate small objects, can actually manipulate or extract such objects
which are accessible to it. Since the beginning of the project, we have tried to design
a system which can easily be upgraded with the minimum effort. As a result of this,
the present design allows for the implementation of system upgrades in form of
extension operation tools. The extension operations make the Xabre versatile and
upgradeable. It can be fitted with upto 5 tools that can perform remotely controllable
tasks. For e.g. when equipped with a miniaturized metal detector, Xabre can also be
used for detection of personnel landmines which have some metallic structure.
Additionally Xabre can be used to navigate into ducts or small places that are not
easily accessible by humans and investigate faults in equipment placed there.
Project Report
Project Report
Project Report
Project Report
7 777th ththth Sem
I.C.
Sem I.C.
Sem I.C.
Sem I.C.
Nirma Institute of Te
Nirma Institute of Te
Nirma Institute of Te
Nirma Institute of Technology
chnology
chnology
chnology
XABRE
XABRE
XABRE
XABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SYSTEM BLOCK DIAGRAM (explanation)
The stated target is to implement a robotic vehicle which can be manually
controlled using a wireless link and perform specific functions. The application of
the device as a mobile surveillance system and a small object manipulator requires
the presence of vision and a small gripper system onboard the vehicle. The vehicle
also incorporates a feature called self-righting. The additional features to be
implemented in the system are the pan/tilt operation of the camera & path lighting.
For further development and tool addition, provision for 5 extension operation tools
is also provided. The whole project is hence broadly divided into the following
modules:
Module List
M01. PC Control Module (Human Machine Interface or HMI)
M02. Locomotion Module
M03. Self-Righting Module
M04. Pan/Tilt Module
M05. Gripper Tool Module
M06. Extension Tools Module
M07. System Controller & Power Module
M08. Control Communication
M09. Camera Module (Video Acquisition, Transmission and Reception)
M10. Light Module
The modules are present over both the Zeus control and Xabre bot. The
module definition basically separates out sets of hardware doing a specific common
objective task.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
The above modules can be broadly divided into 2 parts by way of location:
1. Zeus (The Control) : The immobile PC side systems including modules:
M01, M08 (partially) & M09 (partially)
2. Xabre (Bot): The actual robot including modules: M02, M03, M04, M05,
M06, M07, M08 (partially), M09 (partially) & M10
The system block diagram shows how the operation of the Xabre is carried out.
The human controller determines an action to be carried out. Then he/she gives the
corresponding directive to the Human Machine Interface (HMI) which is a VB form
object present on the PC monitor screen. The HMI does the required processing of
the directive and generates a bit pattern which is basically a command that the µC on
Xabre can understand. It sends the directive to the Transmitter module on Zeus
through the COM port. The Transmitter module then transmits the command to
Xabre.
The receiver module on Xabre receives the command and sends it to the C
through its Serial UART 0. The µC then processes the command and detects as to
for which module the command is for, based on the bit pattern. It then actuates the
module as required. Some modules have their own feedbacks to the µC. These are
basically limit indicators and for these modules, the µC checks for limit status before
actuating the module.
The Camera module is kept entirely isolated from this control scheme. This
module being a fully separate and ‘plug n play’ system, has its own communication
system. It sends back the video data to Zeus, wherein the receiver o/p is converted to
PC display compatible form and displayed onto the PC monitor screen. The pan/tilt
operation of the camera is listed separately because it is under direct control of the
µC and is a separate entity than the Camera module.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
TARGETS FOR 7TH
SEMESTER
The project development requires the generation of mechanical structure,
controller circuitry and operating software for the system. The 7th semester
objectives were hence:
1. Complete Design and Analysis: The whole system, its objectives,
architecture of the hardware, mechanical systems and finally the software
architecture was to be complete on paper so as to serve as a reference for the
further steps in development.
2. Mechanical Systems: Piecewise testing of the whole system would prove
unsatisfactory in a project as this one, where the electronics play an equal
and important role as the mechanical assembly. Hence the most important
objective was to have a fully functional mechanical system.
3. Preliminary system integration: We plan to complete the operational
integration of the system so that its basic locomotory function can be
activated.
4. HMI Software and PC side controller: The system’s HMI that allows
commands to be sent to Xabre along with the camera output display on the
PC screen. Hence the targeted controller for Xabre also features in the targets
for 7th semester.
Ground Reality
The projected targets have been somewhat satisfactorily met after a number
of obstacles. The whole mechanical design has been carried out by us, without any
external help, using AutoCAD 2000i software. The system architecture and the
software design for the µC has been completed. The software implementation for the
µC for some of the modules has been completed for this semester.
The delays caused due to availability of motors, mechanical structure
manufacturing etc were the main obstacles in the achievement of the objectives.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SECTIO 2
Function Description:
The modules are controlled remotely or otherwise by way of functions, each
of which is defined for a specific module. The function defines the activities of the
module based on the commands or external input received by the module. These
functions are normally executed when either a command is received or any interrupt
is received from the interrupt i/ps. The general program then performs the task of
continually ascertaining if the control communication link is still active or not. All
the actuatory actions are only executed as responses to interrupts. The functions are
explained below:
Functions:
1. Locomotion (Ref M02):
Class: Manual Control
Description: The robot works on the tank-style drive. The differential motion
generated by the 2 motors gives the required direction navigation and
maneuverability. The magnitude and the direction are specified in the
commands. The driver IC (the LMD18200T) accepts PWM input only. For this
purpose, we are using Timer 0 in mode 1 to generate the PWM output for both
the drives simultaneously. The locomotion motors on the right and left of the
system are driven by 2 bit signals each. 1 bit determines the direction and the
other bit provides PWM o/p. The port P0’s lower nibble is utilized for this
purpose. This is the only module under the control of the µC that doesn’t use the
system bus (viz. Port P1 as the data bus and bits of Port P2 used for the device
select)
Sensors: none
Inputs: none
Command Bytes: 2 (10Y-Di-MMMM)
Internal Status Bytes: Locomotion Byte (Loc_Byte)
External Port Bytes: 4 bits (RDRPWM-LDLPWM)
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
2. Self Righting Auto
Class: Auto Control
Description: When the system overturns, this function detects the overturning
and carries out actions to make sure that the system flips over back to upside up
position. This is carried out by first rotating the arms CW until the system flips
over properly. When the system has flipped upright, the SR arms are brought
back to lock-in position by rotating the Sr arms ACW. Additionally a manual
override for the command is also provided. This is obtained by the SR disable
command. System carries out the sequence of righting the system if it flips over
while disabling locomotion during operation. It also restarts locomotion after
sequence is over. Self righting has 2 steps. First, on detection of flip-over
through sensor, initiate ‘OPEN’ action of self-righting arms. Second, on
detection of flip-right through sensor, initiate ‘CLOSE’ action and continue it till
sensor indicates lock-in of arms.
Sensors: 1 tilt sensor, 3 IR LED-PXTOR pairs
Inputs: 4 bits, interrupt driven
Command Bytes: X1 (1 bit)
Internal Status Bytes: SR Status Byte (SR_Stat_Byte)
External Port Bytes: 2 bits (SRMSRD)
3. Self Righting Manual
Class: Manual Control with auto trip
Description: In some cases the operation of the SR arms is required to raise the
front end of the robot. For this manual operation is implemented to either open
the SR arms outwards or inwards as per command issued. Also the limiting
position is determined by either the stop command or the lock-in/extremity
position being achieved. Hence on receiving Zeus command and if lock-in is
true, C initiates ‘M_OPEN’ action of self-righting arms. Stop opening when
‘M_OPEN’ limit is reached. OR On Zeus command, if lock-in is true, initiate
‘M_CLOSE’ action. Stop closing when ‘M_CLOSE’ limit is reached. If lock-in
is not true for either close command continue till lock-in is true. If new Zeus
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
command is received before the end of the previous Zeus command, the older
one is discarded. These commands are scrapped if the Self Righting Auto action
is triggered.
Sensors: 3 IR LED-PXTOR pairs (Same as Self Righting Auto)
Inputs: 3 bits, interrupt driven.
Command Bytes: 2 bits (XY)
Internal Status Bytes: SR Status Byte (SR_Stat_Byte) [Same as Self Righting
Auto]
External Port Bytes: 2 bits (Same as Self Righting Auto)
4. Gripper Operation.
Class: Manual Control with auto trip
Description: This function pertains to the micro-manipulator implemented on
Xabre used to grip and lift (if required) small objects (size < 10 cm). The
implemented system has a total of 4 functions to perform. The first 2 pertain to
the direct gripping action. These are namely: Gripper Open and Gripper Close.
They are limited by Gripper Open Limit Switch and the Gripper Close Limit
Switch. The Gripper Open Limit Switch prevents damage to either motor or
gripper if we try to open it beyond its limit. The Gripper Close Limit Switch
prevents damage to motor or gripped object when gripper is closing. The
additional system functions are namely: Lift and Drop. The Lift function allows
the Gripper to rise up by 300o after gripping object, such that the object is lifted
off the ground. This allows Xabre to move, after having picked up the object and
ensuring that the object is not dragged while Xabre is moving. Drop function is
required to place the object back on ground after returning to the base station.
Sensors: 4 microswitches
Inputs: 4 bits, interrupt driven.
Command Bytes: 4 bits (AB UV)
Internal Status Bytes: Gripper Status Byte (G_Stat_Byte)
External Port Bytes: 2 bits (G1G2 G3G4)
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
5. Pan/Tilt of Camera.
Class: Manual Control with auto trip
Description: The camera module is independent in its operation of image
acquisition and data transmission. However the system is not equipped with the
ability to change its POV on its own. This requires a setup to physically rotate
the camera so as to move its POV Camera panning or tilting is carried out as per
the Zeus commands sent to it. The panning action is limited to 300o by limit
switches on either extremities and the tilting action is limited to 135o by limit
switches on either extremities. The action is continued until one of the
microswitches is tripped or Zeus command orders a stop.
Sensors: 4 microswitches.
Inputs: 4 bits, interrupt mode
Command Bytes: 1 byte (110- _ - CD - EF)
Internal Status Bytes: P/T Status Byte (PT_Stat_Byte)
External Port Bytes: 4 bits (TDTM - PDPM)
6. Light Operation
Class: Manual
Description: The light function is manually controlled and lights up only when
the system is asked to switch it on. This is essential for surveillance as Xabre
should let its presence known only when there is explicit need for the same.
Light is turned on after receiving ‘Turn_On’ command from Zeus. On receiving
‘Turn_Off’ command from Zeus, the light is turned off. Light provides only
forward path lighting only presently. The light system can be attached to the PT
System to allow it to have the same POV as the camera.
Sensors: none
Inputs: none
Command Bytes: 1 bit (G)
Internal Status Bytes: l (SR_Stat_Byte)
External Port Bytes: 1 bit (L)
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
7. Extension Operations 1
Class: Manual with no processing
Description: Used for allowing additional tools to be added to the system.
Extension Ops 1 carries the 3 bit command and a 1 bit command for the
extension tools.
Sensors: none
Inputs: none
Command Bytes: 111 - 0 – E31E32E33 – E41
Internal Status Bytes: Higher order nibble of Extension Byte (Extn_Byte)
External Port Bytes: 4 bits (HIJK)
8. Extension Operations 2
Class: Manual with no processing
Description: Used for allowing additional tools to be added to the system.
Extension Ops 2 carries the 2 bit command and two 1 bit commands for the
extension tools.
Sensors: none
Inputs: none
Command Bytes: 111 - 1 - E21E22 – E11 – E51
Internal Status Bytes: Lower order nibble of Extension Byte (Extn_Byte)
External Port Bytes: 4 bits (NOQR) (same byte as Ext Ops 1)
9. Reset Operation
This operation sets Xabre to initial operative stage loading default values for the
system.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Zeus Command Byte Definitions:
The µC is configured to accept commands over the wireless link from Zeus. These
commands are hence called Zeus Commands. The command structure of the same is
shown below:
Brief definitions
Core
Class
Information Indicated Functions
D4 D3 D2 D1 D0
000 1 1 0 0 0 Reset
010 1 0 0 1 1 Test Command 1
011 1 0 1 0 1 Test Command 2
001 0 A B V U Gripper 1 and 2 Command
001 1 X Y 1 X1 SRM & SR Auto Override Command
100 Di M3 M2 M1 M0 Left Drive Command
101 Di M3 M2 M1 M0 Right Drive Command
110 G C D E F Light and Pan/Tilt Command
111 0 E31 E32 E33 E41 Extension Ops 1
111 1 E21 E22 E11 E51 Extension Ops 2
Detailed explanation:
I. Two bit commands
Bit
Pattern
SRM Pan Tilt Gripper 1 Gripper 2
XY CD EF AB UV
00 Do Nothing Do Nothing Do Nothing Do Nothing Do Nothing
01 Stop Stop Stop Stop Stop
10 Open CW* Pan Left Tilt Up Open Lift Up
11 Open ACW* Pan Right Tilt Down Close Drop Down
*CW opening is also implemented for SR Auto in the initial phase. To bring the SR
arms back into the lock-in position, ACW rotation is applied.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
II. Locomotion commands
D4 bit defines the direction. If 1 then rotate motor to generate forward motion. If 0
then rotate motor to generate reverse motion. M3-0 determines magnitude. The
locomotion magnitudes are converted to values which are used as Timer0 High load
values so that the single timer can be used to generate two PWM signal for both
drive motors.
III. Extension Operations:
The bits are output as sent by Zeus. A single byte is output and the related nibble is
set as per the commands.
Inputs & Sensors:
Two ports are used for the inputs. The inputs are from the sensors on the Xabre
system and bring in specific information about the system status. The most
important information is the overturning detection. For this a tilt sensor is used. This
sensor gives a ‘1’ signal for normal state and when the system flips over, the sensor
gives a ‘0’ as input. The microswitches used for the remaining inputs give ‘0’ for
normal states and for the tripped state gives ‘1’. The photo-transistor systems are
arranged as a PXTOR on one side of a disc with 3 holes and the IR LEDs on the
other side of the disc. The photo-transistor systems give ‘1’ output for hole and for
blank, give ‘0’. During normal operation only the PXTOR for the lock-in indication
gives 1 and the remaining two extremity detectors give 0 as output. The arrangement
is such that only one system in front of a hole will give output 1 and for the
remaining times none of the 3 systems will give output 1.
The input port 1, being used for gripper microswitches, is common to the SR inputs.
This port is interrupt driven, i.e. when there is any change of state of any of the 8
inputs, an interrupt is generated by the debouncing IC and sent to INT0 of Thor.
Then Thor can read in the states of the 8 switches.
The input port 2, being used for the Pan/Tilt microswitches, is also an interrupt
driven port. The inputs from this port are read in and two steps are carried out by
Thor. First, it saves the trip status to the P/T status byte and then writes stop
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
commands to the tripped system (Pan or Tilt for which microswitch has tripped) if
the on bits for the same are set.
External Port Bytes:
Port
P2.x
Information Indicated Functions/Port names
D7 D6 D5 D4 D3 D2 D1 D0
P0.x# x X x x RD RPW
M LD
LPW
M
Locomotion Port
000b SRT SRLI SRC SRA 0 0 1 1 I/P PORT, int. driven
010b SRD SRM 0 0 1 1 1 L SR & Light Port
011b G1M G1D G2M G2D TM TD PM PD Gripper & Pan/Tilt
Port
100b TUL TDL PRL PLL GUL GDL GCL GOL I/P PORT, int. driven
101b H I J K N O Q R Extension ops. Port
#Only the locomotion commands don’t use the P1 data bus and P2.x address select
system.
I. Inputs:
Interrupt Driven Inputs -1
SRT: SR Tilt sensor. SRLI: SR Lock-in sensor.
SRC: SR CW limit sensor. SRA: SR ACW limit sensor.
Interrupt Driven Inputs -2
GUL: Gripper Up limit sensor. GDL: Gripper Down limit sensor.
GCL: Gripper Close limit sensor. GOL: Gripper Open limit sensor.
PLL: Pan Left limit sensor. PRL: Pan Right limit sensor.
TDL: Tilt Down limit sensor. TUL: Tilt Up limit sensor.
II. Outputs:
Locomotion
LD Left or Right Direction
1=Forward; 0=Reverse
LPWM Drive PWM signal.
1=ON ; 0=OFF RD RPWM
SR/Gripper 1-2/Pan/Tilt
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SRD Direction determining bit.
1 indicates CW / Open / Lift /
Tilt Up / Pan Left
0 indicates ACW / Close / Drop /
Tilt Down / Pan Right
SRM
ON/OFF determining bit. If the
bit is 1, the motor runs else it
doesn’t run.
G1D G1M
G2D G2M
TD TM
PD PM
Light/Extension Operations
L, H, I, J, K, N, O, Q, R 1 indicates ON; 0 indicates OFF
Internal Status Bytes:
Byte Name Information Indicated
D7 D6 D5 D4 D3 D2 D1 D0
Loc_Byte LD LM3 LM2 LM1 RD RM3 RM2 RM1
SR_Stat_Byte SRT SRLI SRC SRA SR On SR Cw Aut_O L
G_Stat_Byte G1D G1M G2D G2M GUL GDL GCL GOL
PT_Stat_Byte TUL TDL PRL PLL TD TM PD PM
Extn_Byte H I J K N O Q R
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SECTIO 3
SOFTWARE
HMI:
The interface is a form object coded in VB6 Enterprise Edition,
incorporating Microsoft Communication Control Toolbox ver 6. The HMI is an
intuitively designed interface which allows the user to easily control Xabre by using
the k/b and a joystick. The interface is shown
below:
The joystick interface needs to be calibrated for different PCs and for
different temperature regions, since this tends to affect the potentiometers which are
integral to the construction of the joystick. To compensate for change in the
potentiometer resistance and allow the proper operation, we use the joystick
calibration form called Calib as a child form of the main Zeus form. This form is
shown below:
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Since we are using RS-232 serial output port viz. Com1 or any other
available Com port (usually Com 2), the satisfactory operation of the Com port has
to be verified before starting communication with Xabre. For this we use the ‘Serial
Settings Select’ form. This form is shown below:
The code for the same consists of 2 .bas modules and 3 form objects. The
code listing for the same is as follows next.
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
ZEUS Form Object
VERSION 5.00
Object = "648A5603-2C6E-101B-82B6-
000000000014#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Zeus
BorderStyle = 1 'Fixed Single
Caption = "Zeus"
ClientHeight = 2490
ClientLeft = 1575
ClientTop = 2400
ClientWidth = 9765
FillColor = &H00C0FFFF&
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
Moveable = 0 'False
ScaleHeight = 2490
ScaleWidth = 9765
Begin MSCommLib.MSComm MSComm1
Left = 0
Top = 960
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = 0 'False
NullDiscard = -1 'True
RThreshold = 1
InputMode = 1
End
Begin VB.Frame Ext_Ops_frame
BorderStyle = 0 'None
Height = 1095
Left = 3480
TabIndex = 17
Top = 1320
Width = 2535
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 5
Left = 0
Picture = "Xabre 161003.frx":0000
ScaleHeight = 315
ScaleWidth = 480
TabIndex = 24
Top = 600
Width = 540
End
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 7
Left = 1440
Picture = "Xabre 161003.frx":03ED
ScaleHeight = 315
ScaleWidth = 480
TabIndex = 23
Top = 600
Width = 540
End
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 6
Left = 720
Picture = "Xabre 161003.frx":07DA
ScaleHeight = 315
ScaleWidth = 480
TabIndex = 22
Top = 600
Width = 540
End
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 1
Left = 0
Picture = "Xabre 161003.frx":0BC8
ScaleHeight = 315
ScaleWidth = 480
TabIndex = 21
Top = 0
Width = 540
End
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 4
Left = 1680
Picture = "Xabre 161003.frx":0FB6
ScaleHeight = 315
ScaleWidth = 240
TabIndex = 20
Top = 0
Width = 300
End
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 3
Left = 1080
Picture = "Xabre 161003.frx":1050
ScaleHeight = 315
ScaleWidth = 480
TabIndex = 19
Top = 0
Width = 540
End
Begin VB.PictureBox Ext_op_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 375
Index = 2
Left = 600
Picture = "Xabre 161003.frx":143E
ScaleHeight = 315
ScaleWidth = 240
TabIndex = 18
Top = 0
Width = 300
End
End
Begin VB.PictureBox Light_Pic
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 840
Left = 4440
Picture = "Xabre 161003.frx":14D8
ScaleHeight = 780
ScaleWidth = 540
TabIndex = 16
Top = 120
Width = 600
End
Begin VB.Frame Keyboard_Controlled_Frame
BorderStyle = 0 'None
Height = 2295
Left = 6480
TabIndex = 8
Top = 120
Width = 2295
Begin VB.PictureBox Kb_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 810
Index = 0
Left = 720
Picture = "Xabre 161003.frx":2B0A
ScaleHeight = 750
ScaleWidth = 750
TabIndex = 13
Top = 720
Width = 810
End
Begin VB.CommandButton Kb_Button
DownPicture = "Xabre 161003.frx":48FC
Height = 405
Index = 1
Left = 720
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":57B2
Style = 1 'Graphical
TabIndex = 12
Top = 120
UseMaskColor = -1 'True
Width = 810
End
Begin VB.CommandButton Kb_Button
DownPicture = "Xabre 161003.frx":66CC
Height = 810
Index = 4
Left = 1680
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":759A
Style = 1 'Graphical
TabIndex = 11
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Top = 720
UseMaskColor = -1 'True
Width = 405
End
Begin VB.CommandButton Kb_Button
DownPicture = "Xabre 161003.frx":84B4
Height = 405
Index = 2
Left = 720
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":93CE
Style = 1 'Graphical
TabIndex = 10
Top = 1680
UseMaskColor = -1 'True
Width = 810
End
Begin VB.CommandButton Kb_Button
DownPicture = "Xabre 161003.frx":A2E8
Height = 810
Index = 3
Left = 120
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":B1B6
Style = 1 'Graphical
TabIndex = 9
Top = 720
UseMaskColor = -1 'True
Width = 405
End
Begin VB.Label Label4
Caption = "Keyboard Buttons"
Height = 375
Left = 0
TabIndex = 15
Top = 0
Width = 735
End
End
Begin VB.Frame Joystick_Controlled_frame
BorderStyle = 0 'None
Height = 2295
Left = 960
TabIndex = 2
Top = 120
Width = 2295
Begin VB.CommandButton Joy_Button
DownPicture = "Xabre 161003.frx":C0D0
Height = 810
Index = 3
Left = 120
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":CF9E
Style = 1 'Graphical
TabIndex = 7
Top = 720
UseMaskColor = -1 'True
Width = 405
End
Begin VB.CommandButton Joy_Button
DownPicture = "Xabre 161003.frx":DEB8
Height = 405
Index = 2
Left = 720
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":EDD2
Style = 1 'Graphical
TabIndex = 6
Top = 1680
UseMaskColor = -1 'True
Width = 810
End
Begin VB.CommandButton Joy_Button
Appearance = 0 'Flat
DownPicture = "Xabre 161003.frx":FCEC
Height = 810
Index = 4
Left = 1680
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":10BBA
Style = 1 'Graphical
TabIndex = 5
Top = 720
UseMaskColor = -1 'True
Width = 405
End
Begin VB.CommandButton Joy_Button
Default = -1 'True
DownPicture = "Xabre 161003.frx":11AD4
Height = 405
Index = 1
Left = 720
MaskColor = &H8000000F&
Picture = "Xabre 161003.frx":1298A
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Style = 1 'Graphical
TabIndex = 4
Top = 120
UseMaskColor = -1 'True
Width = 810
End
Begin VB.PictureBox Joy_pics
AutoRedraw = -1 'True
AutoSize = -1 'True
Height = 810
Index = 0
Left = 720
Picture = "Xabre 161003.frx":138A4
ScaleHeight = 750
ScaleWidth = 750
TabIndex = 3
Top = 720
Width = 810
End
Begin VB.Label Label3
Caption = "Joystick Buttons"
Height = 375
Left = 0
TabIndex = 14
Top = 120
Width = 615
End
End
Begin VB.Timer Op_Mode_Timer
Enabled = 0 'False
Interval = 100
Left = 10
Top = 1560
End
Begin VB.Label TX_label
AutoSize = -1 'True
BackColor = &H000000FF&
BorderStyle = 1 'Fixed Single
Caption = "TX"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 255
Left = 4560
TabIndex = 25
Top = 960
Width = 315
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Right"
Height = 195
Left = 0
TabIndex = 1
Top = 2280
Width = 375
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Left"
Height = 195
Left = 0
TabIndex = 0
Top = 2040
Width = 270
End
End
Attribute VB_Name = "Zeus"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'>>> VARIABLE DECLARATIONS <<<'
Private X() As Integer
Private Y() As Integer
Private ari As Integer
Private joyb_states(4) As Boolean
Private joyb_pressed(4) As Boolean
Private kbb_states(4) As Boolean
Private light_status As Boolean
Private alternate_drive As Boolean
Private ext_ops_status(5) As Integer
Dim JoyInfo As tJoyInfo
Dim OP_vals As JoyVariables
Dim l_drive_matrix(30, 30) As Byte
Dim r_drive_matrix(30, 30) As Byte
Dim r_drive As Byte
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Dim l_drive As Byte
Private TX_on As Boolean
'>>> SUBROUTINES <<<'
Private Sub Form_Load()
'>>> Setup form position on the screen <<<'
Call relocate_form
'>>> Initialization ops <<<'
Call init
End Sub
Private Sub init()
'>>> Shutoff TX for main form <<<'
TX_on = False
'>>> Stick Control Array Init <<<'
ReDim X(10)
ReDim Y(10)
'>>> Stick Control Array Position Indicator <<<'
ari = 0
'>>> Initialise drive alternation variable <<<'
alternate_drive = True
'>>> Init Op_vals structure <<<'
Call set_Op_vals
'>>> Set frame positions and current kb controlled
module <<<'
Call set_Frames
'>>> Set Ext Ops Frame <<<'
Call set_ext_ops_frame
'>>> Initialise state value arrays <<<'
Call set_button_states
'>>> Light status init <<<"
Call light_setup
'>>> Initialise the drive matrices <<<'
Call init_l_drive
Call init_r_drive
r_drive = 0
l_drive = 0
Zeus.Show
Zeus.Enabled = False
Load Calib_Form
End Sub
Private Sub set_Op_vals()
OP_vals.XCntr = 32767
OP_vals.YCntr = 32767
OP_vals.Xmax = 65535
OP_vals.Xmin = 0
OP_vals.Ymax = 65535
OP_vals.Ymin = 0
OP_vals.X_Lower_Range = OP_vals.XCntr -
OP_vals.Xmin
OP_vals.X_Upper_Range = OP_vals.Xmax -
OP_vals.XCntr
OP_vals.Y_Lower_Range = OP_vals.YCntr -
OP_vals.Ymin
OP_vals.Y_Upper_Range = OP_vals.Ymax -
OP_vals.YCntr
OP_vals.X_Upper_Scale = OP_vals.X_Upper_Range /
15
OP_vals.X_Lower_Scale = OP_vals.X_Lower_Range /
15
OP_vals.Y_Upper_Scale = OP_vals.Y_Upper_Range /
15
OP_vals.Y_Lower_Scale = OP_vals.Y_Lower_Range /
15
OP_vals.Set_val = False
End Sub
Private Sub set_button_states()
'>>> Set values for joystick buttons as false<<<'
For i = 1 To 4
joyb_states(i) = False
joyb_pressed(i) = False
kbb_states(i) = False
Next i
End Sub
Private Sub init_l_drive()
Dim m As Byte
m = 16
For i = 0 To 15
m = m - 1
seed = m
For j = 0 To 30
'>>> Update seed <<<'
seed = seed + 1
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
'>>> Change if required <<<'
If seed = 32 Then seed = 31
If seed < 16 Then
l_drive_matrix(i, j) = 16 - seed
Else
l_drive_matrix(i, j) = seed
End If
Next j
Next i
m = 16
For i = 30 To 16 Step -1
m = m + 1
seed = m
For j = 30 To 0 Step -1
'>>> Change if required <<<'
If seed = 0 Then seed = 1
'>>> Update seed <<<'
seed = seed - 1
If seed < 16 Then
l_drive_matrix(i, j) = 16 - seed
If l_drive_matrix(i, j) = 16 Then l_drive_matrix(i,
j) = 15
Else
l_drive_matrix(i, j) = seed
End If
Next j
Next i
'>>> Desensitize Central Paths <<<'
For i = 14 To 16
For j = 0 To 30
l_drive_matrix(i, j) = l_drive_matrix(15, j)
Next j
Next i
For j = 14 To 16
For i = 0 To 30
l_drive_matrix(i, j) = l_drive_matrix(i, 15)
Next i
Next j
'>>> Desensitized Forward Extremities <<<'
For i = 1 To 3
For j = 1 To 30
If j > i Then l_drive_matrix(i, j) = l_drive_matrix(0,
j)
Next j
Next i
For i = 27 To 29
For j = 1 To 30
If j < i Then l_drive_matrix(i, j) =
l_drive_matrix(30, j)
Next j
Next i
End Sub
Private Sub init_r_drive()
Dim m As Byte
m = 16
For i = 0 To 15
m = m - 1
seed = m
For j = 30 To 0 Step -1
'>>> Update seed <<<'
seed = seed + 1
'>>> Change if required <<<'
If seed = 32 Then seed = 31
If seed < 16 Then
r_drive_matrix(i, j) = 16 - seed
Else
r_drive_matrix(i, j) = seed
End If
Next j
Next i
m = 16
For i = 30 To 16 Step -1
m = m + 1
seed = m
For j = 0 To 30
'>>> Change if required <<<'
If seed = 0 Then seed = 1
'>>> Update seed <<<'
seed = seed - 1
If seed < 16 Then
r_drive_matrix(i, j) = 16 - seed
If r_drive_matrix(i, j) = 16 Then r_drive_matrix(i,
j) = 15
Else
r_drive_matrix(i, j) = seed
End If
Next j
Next i
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
'>>> Desensitize Central Paths <<<'
For i = 14 To 16
For j = 0 To 30
r_drive_matrix(i, j) = r_drive_matrix(15, j)
Next j
Next i
For j = 14 To 16
For i = 0 To 30
r_drive_matrix(i, j) = r_drive_matrix(i, 15)
Next i
Next j
'>>> Desensitized Forward Extremities <<<'
For i = 1 To 3
For j = 1 To 30
If j < 30 - i Then r_drive_matrix(i, j) =
r_drive_matrix(0, j)
Next j
Next i
For i = 27 To 29
For j = 1 To 30
If j > 30 - i Then r_drive_matrix(i, j) =
r_drive_matrix(30, j)
Next j
Next i
End Sub
Private Sub Form_GotFocus()
Zeus.Joy_Button(1).SetFocus
End Sub
Public Sub xfer_calib()
If OP_tf_vals.Set_val Then OP_vals = OP_tf_vals
End Sub
'>>> Test code <<<'
Private Sub MSComm1_OnComm()
eventid = MSComm1.CommEvent
Select Case eventid
Case comEvReceive:
Call display_received '>>>DEBUG DATA: If event
not being triggered <<<'
End Select
End Sub
Private Sub display_received()
Dim Instring As Variant
Dim bytes As Variant
Dim RX_string As String
RX_string = ""
Instring = MSComm1.Input
bytes = Instring
Debug.Print CInt(bytes(0))
'MsgBox (RX_string)
End Sub
Private Sub Op_Mode_Timer_Timer()
If gSerial_Settings_Sel_loaded Or gCalib_form_loaded
Then Op_Mode_Timer.Enabled = False
If Not gSerial_first_init And Not gCalib_form_loaded
Then
Zeus.Enabled = False
Op_Mode_Timer.Enabled = False
Load Serial_Settings_Sel
GoTo out_of_timer
End If
Call CTSHolding_check
Call Joyread
Call show_joy_buttons_pressed
out_of_timer:
End Sub
Private Sub CTSHolding_check()
If MSComm1.PortOpen = False Then
MSComm1.commport = gPortNumber
TX_label.ToolTipText = "COM" +
CStr(MSComm1.commport)
If MSComm1.CTSHolding Then
TX_label.Caption = "LP"
TX_label.BackColor = vbBlue
TX_label.ForeColor = vbRed
TX_label.ToolTipText = "Make sure Green LED is
ON"
Else
TX_label.Caption = "TX"
If Not TX_on Then
TX_label.BackColor = vbRed
TX_label.ForeColor = vbWhite
If MSComm1.PortOpen = True Then
MSComm1.PortOpen = False
Else
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
TX_label.BackColor = vbGreen
TX_label.ForeColor = vbBlack
If MSComm1.PortOpen = False Then
MSComm1.PortOpen = True
End If
End If
End Sub
Private Sub Joyread()
Dim state_changed(4) As Boolean
Dim msg1 As String
Dim msg2 As String
Dim frwd As Integer
Dim side As Integer
Dim run_locomotion_command As Boolean
run_locomotion_command = True
rc = GetJoystickPos(JOYSTICK1, JoyInfo)
If rc = 0 Then
'>>> Process Button changes <<<'
'>>> Transfer Button pressed info from joyinfo to array
<<<'
For i = 1 To 4
If JoyInfo.ButtonDown(i) Then
joyb_pressed(i) = True
Else
joyb_pressed(i) = False
End If
Next i
'>>> Filter the array for opposite button pressed
conflicts <<<'
For i = 1 To 4
If joyb_pressed(i) Then
If Not joyb_states(4 - (i + 1) Mod 4) Then
joyb_pressed(i) = True
Else
joyb_pressed(i) = False
End If
End If
Next i
'>>> Check for change in state <<<'
state_changed(1) = joyb_pressed(1) Xor joyb_states(1)
state_changed(2) = joyb_pressed(2) Xor joyb_states(2)
state_changed(3) = joyb_pressed(3) Xor joyb_states(3)
state_changed(4) = joyb_pressed(4) Xor joyb_states(4)
'>>> Save Button states <<<'
For i = 1 To 4
joyb_states(i) = joyb_pressed(i)
Next i
'>>> if state has changed, options are"
' 1. both off
' 2. u on
' 3. d on
' 4. both on is not possible
If state_changed(1) Or state_changed(2) Then
If Not joyb_states(1) And Not joyb_states(2) Then
msg1 = "STOP"
If joyb_states(1) And Not joyb_states(2) Then msg1
= "UP"
If Not joyb_states(1) And joyb_states(2) Then msg1
= "DOWN"
Else
msg1 = "DO NOTHING"
End If
If state_changed(3) Or state_changed(4) Then
If Not joyb_states(3) And Not joyb_states(4) Then
msg2 = "STOP"
If joyb_states(3) And Not joyb_states(4) Then msg2
= "LEFT"
If Not joyb_states(3) And joyb_states(4) Then msg2
= "RIGHT"
Else
msg2 = "DO NOTHING"
End If
If state_changed(1) Or state_changed(2) Or
state_changed(3) Or state_changed(4) Then
Call joy_command(msg1, msg2)
run_locomotion_command = False
End If
End If
ari = (ari) Mod 10 + 1
If JoyInfo.X >= OP_vals.XCntr Then
X(ari) = (JoyInfo.X - OP_vals.XCntr) /
OP_vals.X_Upper_Scale + 15
Else
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
X(ari) = (JoyInfo.X - OP_vals.Xmin) /
OP_vals.X_Lower_Scale
End If
If JoyInfo.Y >= OP_vals.YCntr Then
Y(ari) = (JoyInfo.Y - OP_vals.YCntr) /
OP_vals.Y_Upper_Scale + 15
Else
Y(ari) = (JoyInfo.Y - OP_vals.Ymin) /
OP_vals.Y_Lower_Scale
End If
'>>> Joystick's X is Sideways <<<'
'>>> Joystick's Y is Forward <<<'
side = integrator(X)
frwd = integrator(Y)
If run_locomotion_command Then
frwd = Fix(frwd / 10)
side = Fix(side / 10)
Call locomotion_command(frwd, side)
End If
End Sub
Private Function integrator(fn() As Integer) As Long
Dim val As Double
Dim i As Integer
val = 0
For i = 1 To 10
val = val + fn(i)
Next i
integrator = val
End Function
'>>> Divert the command to the proper destination
subroutine <<<'
'>>> This performs check as to which module is being
controlled by joystk <<<'
'>>> It accordingly calls the relevant module's command
subroutine <<<'
Private Sub joy_command(msg1 As String, msg2 As
String)
If joy_control = "Camera" Then Call camera(msg1,
msg2)
If joy_control = "Gripper" Then
If msg1 = "UP" Then msg1 = "CLOSE"
If msg1 = "DOWN" Then msg1 = "OPEN"
If msg2 = "LEFT" Then msg2 = "LIFT"
If msg2 = "RIGHT" Then msg2 = "DROP"
Call gripper(msg1, msg2)
End If
End Sub
'>>> Module subroutines <<<'
'>>> MODULE LOCOMOTION <<<'
'>>> Locomotion command subroutine <<<'
'>>> Byte format is 10Y-Di-MMMM <<<'
'>>> Drive matrices give direct values for Di-MMMM
<<<'
'>>> Y=0 => Left locomotion command (128) <<<'
'>>> Y=1 => Right locomotion command (160)<<<'
Private Sub locomotion_command(frwd As Integer, side
As Integer)
Dim r_old As Byte
Dim r_new As Byte
Dim l_old As Byte
Dim l_new As Byte
Dim command As Byte
'>>> To prevent access of a array element outside array
size <<<'
'>>> Both drive arrays are of same size <<<'
'>>> So singular check will do <<<'
If frwd > UBound(l_drive_matrix, 1) Then frwd =
UBound(l_drive_matrix, 1)
If side > UBound(l_drive_matrix, 2) Then frwd =
UBound(l_drive_matrix, 2)
l_new = l_drive_matrix(frwd, side)
r_new = r_drive_matrix(frwd, side)
l_old = l_drive
r_old = r_drive
'>>> Send LDRV Command if it is its turn <<<'
If (l_new Xor l_old) <> 0 And alternate_drive Then
l_drive = l_new
command = 128 + l_drive
Label1.Caption = "Left: " + CStr(l_drive)
'>>> Presentation test code <<<'
Zeus.Caption = "Zeus: Command => " +
CStr(command)
'>>> Next drive command has to be Right drive
command <<<'
alternate_drive = False
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
'>>> Prevent 2 commands being sent simultaneously
<<<'
GoTo loco_out
End If
If (r_new Xor r_old) <> 0 And Not alternate_drive Then
r_drive = r_new
command = 160 + r_drive
Label2.Caption = "Right: " + CStr(r_drive)
Zeus.Caption = "Zeus: Command => " +
CStr(command)
alternate_drive = True
'>>> Prevent 2 commands being sent simultaneously
<<<'
GoTo loco_out
End If
loco_out:
If TX_on Then Call TX_write(command)
End Sub
'>>> MODULE LIGHT<<<'
'>>> Light module command subroutine <<<'
'>>> Byte format is 110-light-pan-tilt <<<'
'>>> Light_status 0 => Command =192 <<<'
'>>> Light status 1 => Command =208 <<<'
'>>> P/T: 00=> DO NOTHING for Pan/Tilt <<<'
Private Sub light_toggle()
Dim command As Byte
If TX_on And Not MSComm1.CTSHolding = True Then
If light_status Then
light_status = False
Light_Pic.Picture = LoadPicture(App.Path + "\Light
off.bmp")
command = 192
Else
light_status = True
Light_Pic.Picture = LoadPicture(App.Path + "\Light
on.bmp")
command = 208
End If
'Debug.Print command
Call TX_write(command)
Zeus.Caption = "Zeus: Command => " +
CStr(command)
End If
End Sub
'>>> MODULE PAN/TILT<<<'
'>>> P/T module command subroutines <<<'
'>>> Byte format is 110-light-pan-tilt <<<'
'>>> Light_status 0 => base Command =192 <<<'
'>>> Light status 1 => base Command =208 <<<'
'>>> Pan/tilt 00 => Do nothing; 01 => Stop (P:4 ; T:1);
<<<'
'>>> 10 => PL/TU (P:8 ; T:2) ; 11 => PR/TD (P:12 ; T:3)
<<<'
Private Sub camera(msg1 As String, msg2 As String)
Dim command As Byte
If TX_on And Not MSComm1.CTSHolding = True Then
command = 192
If light_status Then command = command + 16
'>>>MSG1 carries the Up/Down strings <<<"
If msg1 = "STOP" Then command = command + 1
If msg1 = "UP" Then command = command + 2
If msg1 = "DOWN" Then command = command + 3
If msg1 = "DO NOTHING" Then command =
command + 0
'>>>MSG2 carries the Left/Right strings <<<"
If msg2 = "STOP" Then command = command + 4
If msg2 = "LEFT" Then command = command + 8
If msg2 = "RIGHT" Then command = command + 12
If msg2 = "DO NOTHING" Then command =
command + 0
'Debug.Print command
Call TX_write(command)
Zeus.Caption = "Zeus: Command => " +
CStr(command)
End If
End Sub
'>>> MODULE GRIPPER <<<'
'>>> Gripper module command subroutines <<<'
'>>> Byte format is 001-0-G1-G2 <<<'
'>>> G1/G2 00 => Do nothing; 01 => Stop (G1:4 ; G2:1);
<<<'
'>>> 10 => G1_Open/G2_Lift (G1:8 ; G2:2) ; 11 =>
G1_Close/G2_Drop (G1:12 ; G2:3) <<<'
Private Sub gripper(msg1 As String, msg2 As String)
Dim command As Byte
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
If TX_on And Not MSComm1.CTSHolding = True Then
command = 32
'>>>MSG1 carries the G1 related strings <<<"
If msg1 = "STOP" Then command = command + 4
If msg1 = "CLOSE" Then command = command + 12
If msg1 = "OPEN" Then command = command + 8
If msg1 = "DO NOTHING" Then command =
command + 0
'>>>MSG2 carries the G2 related strings <<<"
If msg2 = "STOP" Then command = command + 1
If msg2 = "LIFT" Then command = command + 2
If msg2 = "DROP" Then command = command + 3
If msg2 = "DO NOTHING" Then command =
command + 0
'Debug.Print command
Call TX_write(command)
Zeus.Caption = "Zeus: Command => " +
CStr(command)
End If
End Sub
'>>> MODULE EXTENSION OPS 1&2<<<'
'>>> Extension ops module command subroutines <<<'
'>>> Byte format 1: 111 - 0 - E31E32E33 - E41
(Command 224+) <<<'
'>>> Byte format 2: 111 - 1 - E21E22 - E11 - E51
(Command 240+) <<<'
Private Sub ext_ops_event(KeyCode As Integer, Shift As
Integer, toggle As Boolean)
Dim command As Byte
If TX_on And Not MSComm1.CTSHolding = True Then
If Not toggle Then
If Shift = 0 Then '>>> Ext ops 1, Extension Tool 3
command <<<'
'>>> Key 1 to 7 or Tilde Key (~) representing
zero <<<'
If KeyCode < vbKey8 And KeyCode > vbKey0
Or KeyCode = 192 Then
If KeyCode = 192 Then KeyCode = 48
Ext_op_pics(4).Picture =
LoadPicture(App.Path + "\img" + CStr(KeyCode - 48) +
".gif")
ext_ops_status(3) = KeyCode - 48
command = 224 + ext_ops_status(3) * 2 +
ext_ops_status(4)
End If
Else '>>> Ext ops 2, Extension Tool 2
command <<<'
If KeyCode < vbKey4 And KeyCode > vbKey0
Or KeyCode = 192 Then
If KeyCode = 192 Then KeyCode = 48
Ext_op_pics(2).Picture =
LoadPicture(App.Path + "\img" + CStr(KeyCode - 48) +
".gif")
ext_ops_status(2) = KeyCode - 48
command = 240 + ext_ops_status(2) * 4 +
ext_ops_status(1) * 2 + ext_ops_status(5)
Else
GoTo jump_out
End If
End If
Else
ext_ops_status(KeyCode) =
(ext_ops_status(KeyCode) + 1) Mod 2
Ext_op_pics(Shift).Picture = LoadPicture(App.Path
+ "\E" + CStr(KeyCode) +
CStr(ext_ops_status(KeyCode)) + ".gif")
If KeyCode = 4 Then '>>>Ext ops 1, Extension Tool
4 command <<<'
command = 224 + ext_ops_status(3) * 2 +
ext_ops_status(4)
Else '>>>Ext ops 2, Extension Tool 1 OR 5
command <<<'
command = 240 + ext_ops_status(2) * 4 +
ext_ops_status(1) * 2 + ext_ops_status(5)
End If
End If
'Debug.Print command
Zeus.Caption = "Zeus: Command => " +
CStr(command)
Call TX_write(command)
jump_out: '>>> Jump out since EOps2 can have a max
value of 3 and not any more <<<'
End If
End Sub
'>>> Incomplete CODE FINISH THIS <<<'
'>>> MODULE SRM <<<'
'>>> SRM module command subroutines <<<'
'>>> Byte format 001-1-XY-1-X1 <<<'
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
'>>> EO INcomplete code list <<<'
'>>> TX Label <<<'
Private Sub TX_label_Click()
If Not MSComm1.CTSHolding Then
If TX_on Then
TX_label.BackColor = vbRed
TX_label.ForeColor = vbWhite
MSComm1.PortOpen = False
TX_on = False
Else
TX_label.BackColor = vbGreen
TX_label.ForeColor = vbBlack
MSComm1.PortOpen = True
TX_on = True
End If
End If
End Sub
'>>> BYTE COMMAND WRITER SUB <<<'
Private Sub TX_write(command As Byte)
Dim bytes(1) As Byte
Dim tx_buf As Variant
bytes(1) = command
tx_buf = bytes
If TX_on Then
tx_buf(1) = command
MSComm1.Output = tx_buf
End If
End Sub
Private Sub kb_frame_event(key As Integer)
'>>> For keyboard keys: E,S,D,X <<<'
'>>> Key = 1 to 4 => key pressed event <<<'
'>>> Key = 5 to 8 => key released event <<<'
Dim msg1 As String
Dim msg2 As String
If key < 5 Then
'IF key pressed conflicts with previously pressed key
so do nothing
If key = 1 And kbb_states(2) Then GoTo l_jump
If key = 2 And kbb_states(1) Then GoTo l_jump
If key = 3 And kbb_states(4) Then GoTo l_jump
If key = 4 And kbb_states(3) Then GoTo l_jump
'If the key is already pressed then do nothing
If key = 1 And kbb_states(1) Then GoTo l_jump
If key = 2 And kbb_states(2) Then GoTo l_jump
If key = 3 And kbb_states(3) Then GoTo l_jump
If key = 4 And kbb_states(4) Then GoTo l_jump
'Key pressed passes above two test so is a valid
keypress
kbb_states(key) = True
Kb_Button(key).Picture = LoadPicture(App.Path +
"\k" + CStr(key) + "on.bmp")
Else
'Event is a keyup event
'Keyup is a key conflicting with previously pressed key
so do nothing
If key = 5 And kbb_states(2) Then GoTo l_jump
If key = 6 And kbb_states(1) Then GoTo l_jump
If key = 7 And kbb_states(4) Then GoTo l_jump
If key = 8 And kbb_states(3) Then GoTo l_jump
kbb_states(key - 4) = False
Kb_Button(key - 4).Picture = LoadPicture(App.Path +
"\k" + CStr(key - 4) + "off.bmp")
End If
'>>> Read the stored states and determine required action
<<<'
If kbb_states(1) Then
msg1 = "UP"
Else
If kbb_states(2) Then
msg1 = "DOWN"
Else
If Not kbb_states(1) And Not kbb_states(2) And
(key = 5 Or key = 6) Then
msg1 = "STOP"
Else
msg1 = "DO NOTHING"
End If
End If
End If
If kbb_states(3) Then
msg2 = "LEFT"
Else
If kbb_states(4) Then
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
msg2 = "RIGHT"
Else
If Not kbb_states(3) And Not kbb_states(4) And
(key = 7 Or key = 8) Then
msg2 = "STOP"
Else
msg2 = "DO NOTHING"
End If
End If
End If
Call kb_command(msg1, msg2)
l_jump:
End Sub
Private Sub toggle_frames()
'Debug.Print "Toggle Called"
'Debug.Print joy_control
If joy_control = "Camera" Then
joy_control = "Gripper"
Joy_pics(0).Picture = Kb_pics(0).Picture
Kb_pics(0).Picture = LoadPicture(App.Path +
"\Camview.bmp")
Else
joy_control = "Camera"
Joy_pics(0).Picture = Kb_pics(0).Picture
Kb_pics(0).Picture = LoadPicture(App.Path +
"\Gripper.bmp")
End If
Zeus.Caption = "Zeus: Current Joystick Control is " +
CStr(joy_control)
End Sub
Private Sub kb_command(msg1 As String, msg2 As
String)
If joy_control = "Camera" Then
If msg1 = "UP" Then msg1 = "CLOSE"
If msg1 = "DOWN" Then msg1 = "OPEN"
If msg2 = "LEFT" Then msg2 = "LIFT"
If msg2 = "RIGHT" Then msg2 = "DROP"
Call gripper(msg1, msg2)
End If
If joy_control = "Gripper" Then Call camera(msg1,
msg2)
End Sub
'>>> KEYBOARD KEY EVENTS PROCESSORS <<<'
'>>> Total Controls having key events on Form = 6 <<<'
'>>> KEYDOWN EVENT Handlers <<<'
'>>> Keydown Handler 1 <<<'
Private Sub Joy_pics_KeyDown(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Keydown Handler 2 <<<'
Private Sub Joy_Button_KeyDown(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Keydown Handler 3 <<<'
Private Sub Kb_pics_KeyDown(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Keydown Handler 4 <<<'
Private Sub Kb_Button_KeyDown(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Keydown Handler 5 <<<'
Private Sub Light_Pic_KeyDown(KeyCode As Integer,
Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Keydown Handler 6 <<<'
Private Sub ext_op_pics_KeyDown(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> KEYUP EVENT Handlers <<<'
'>>> Keyup Handler 1 <<<'
Private Sub Joy_pics_KeyUp(Index As Integer, KeyCode
As Integer, Shift As Integer)
Call Form_KeyUp(KeyCode, Shift)
End Sub
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
'>>> KeyUp Handler 2 <<<'
Private Sub Joy_Button_KeyUp(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyUp(KeyCode, Shift)
End Sub
'>>> KeyUp Handler 3 <<<'
Private Sub Kb_pics_KeyUp(Index As Integer, KeyCode
As Integer, Shift As Integer)
Call Form_KeyUp(KeyCode, Shift)
End Sub
'>>> KeyUp Handler 4 <<<'
Private Sub Kb_Button_KeyUp(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyUp(KeyCode, Shift)
End Sub
'>>> KeyUp Handler 5 <<<'
Private Sub Light_Pic_KeyUp(KeyCode As Integer, Shift
As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> KeyUp Handler 6 <<<'
Private Sub ext_op_pics_KeyUp(Index As Integer,
KeyCode As Integer, Shift As Integer)
Call Form_KeyDown(KeyCode, Shift)
End Sub
'>>> Form KeyUp Event Handler <<<'
Private Sub Form_KeyUp(KeyCode As Integer, Shift As
Integer)
'>>> Required to send stop signal to <<<'
'>>> the currently active kb-controlled <<<'
'>>> module subsystem <<<'
Select Case KeyCode
'>>> Check which key has been released <<<'
Case vbKeyE: ' ^ '
Call kb_frame_event(5)
Case vbKeyX: ' v '
Call kb_frame_event(6)
Case vbKeyS: ' < '
Call kb_frame_event(7)
Case vbKeyD: ' > '
Call kb_frame_event(8)
End Select
End Sub
'>>> Form KeyDown Event Handle <<<'
Private Sub Form_KeyDown(KeyCode As Integer, Shift
As Integer)
Select Case KeyCode
'>>> Cases for normal kb keys <<<'
'>>> KB Frame Control Keys <<<'
Case vbKeyE: ' ^ '
Call kb_frame_event(1)
Case vbKeyX: ' v '
Call kb_frame_event(2)
Case vbKeyS: ' < '
Call kb_frame_event(3)
Case vbKeyD: ' > '
Call kb_frame_event(4)
Case vbKey1 To vbKey7, 192:
Call ext_ops_event(KeyCode, Shift, False)
'>>> Light Control Key <<<"
Case vbKeyL:
Call light_toggle
'>>> Cases for Function Keys <<<'
'>>> Extension Ops Toggles E1, E4 and E5 <<<'
'>>> Ext_Op# passed byVal to Keycode <<<'
'>>> Ext_Picture# passed byVal to Shift <<<'
'>>> Toggle operation is true as passed byVal to Toggle
<<<'
Case vbKeyF2:
Call ext_ops_event(1, 5, True)
Case vbKeyF3:
Call ext_ops_event(4, 6, True)
Case vbKeyF4:
Call ext_ops_event(5, 7, True)
'>>> User asks to shutdown Zeus <<<'
Case vbKeyF10:
'Set confirm and then unload code here'
If Not gCalib_form_loaded And Not
gSerial_Settings_Sel_loaded Then
'>>> Ensure shutdown(=reset) command is fired and only
then shutdown
Debug.Print "Fire shutdown command"
Unload_Check:
If check_buffer_empty() Then
Unload Me
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Else:
GoTo Unload_Check
End If
Else:
If gCalib_form_loaded Then Calib_Form.SetFocus
If gSerial_Settings_Sel_loaded Then
Serial_Settings_Sel.SetFocus
End If
'>>> User asks to transfer current kb controlled module to
joystick <<<'
Case vbKeyF5:
Call toggle_frames
'>>> User wants to re-calibrate locomotion controller
<<<'
Case vbKeyF9:
Zeus.Op_Mode_Timer = False
Zeus.Enabled = False
Calib_Form.SetFocus
Load Calib_Form
If OP_tf_vals.Set_val Then OP_vals = OP_tf_vals
End Select
End Sub
'>>> Cosmetics <<<'
Private Sub relocate_form()
Me.Width = (Screen.Width * 0.95)
Me.Move (Screen.Width * 0.05) / 2, (0.95 *
Screen.Height - Me.Height)
End Sub
Private Sub set_Frames()
Joystick_Controlled_frame.Left = (Zeus.Width -
Joystick_Controlled_frame.Width) * 0.1
Keyboard_Controlled_Frame.Left = (Zeus.Width -
Keyboard_Controlled_Frame.Width) * 0.9
joy_control = "Camera"
End Sub
Private Sub set_ext_ops_frame()
'>>> Init the ext_ops_status array <<<'
For i = 1 To 5
ext_ops_status(i) = 0
Next i
'>>> Load Default Pictures to the Ext_Ops Frame <<<'
Ext_op_pics(1).Picture = LoadPicture(App.Path +
"\E2.gif")
Ext_op_pics(2).Picture = LoadPicture(App.Path + "\img"
+ CStr(ext_ops_status(2)) + ".gif")
Ext_op_pics(3).Picture = LoadPicture(App.Path +
"\E3.gif")
Ext_op_pics(4).Picture = LoadPicture(App.Path + "\img"
+ CStr(ext_ops_status(3)) + ".gif")
Ext_op_pics(5).Picture = LoadPicture(App.Path + "\E1"
+ CStr(ext_ops_status(1)) + ".gif")
Ext_op_pics(6).Picture = LoadPicture(App.Path + "\E4"
+ CStr(ext_ops_status(4)) + ".gif")
Ext_op_pics(7).Picture = LoadPicture(App.Path + "\E5"
+ CStr(ext_ops_status(5)) + ".gif")
'>>> Position Pictures in Ext_Ops Frame <<<'
Ext_Ops_frame.Width = 4 * (50 +
Ext_op_pics(1).Width)
Ext_op_pics(1).Left = (Ext_Ops_frame.Width -
Ext_op_pics(1).Width) * 0.05
Ext_op_pics(2).Left = ((Ext_Ops_frame.Width * 0.45 -
Ext_op_pics(2).Width)) * 0.95
Ext_op_pics(3).Left = Ext_Ops_frame.Width * 0.55 +
(Ext_Ops_frame.Width * 0.5 - Ext_op_pics(3).Width) *
0.05
Ext_op_pics(4).Left = (Ext_Ops_frame.Width -
Ext_op_pics(4).Width) * 0.95
Ext_op_pics(5).Left = (Ext_Ops_frame.Width -
Ext_op_pics(5).Width) * 0.05
Ext_op_pics(6).Left = (Ext_Ops_frame.Width -
Ext_op_pics(6).Width) * 0.5
Ext_op_pics(7).Left = (Ext_Ops_frame.Width -
Ext_op_pics(7).Width) * 0.95
Ext_Ops_frame.Left = (Zeus.Width -
Ext_Ops_frame.Width) / 2
TX_label.Left = Ext_Ops_frame.Left
End Sub
Private Sub light_setup()
light_status = False
Light_Pic.Left = (Zeus.Width - Light_Pic.Width) / 2
Light_Pic.Top = Joystick_Controlled_frame.Top
End Sub
Private Sub show_joy_buttons_pressed()
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
For i = 1 To 4
If joyb_pressed(i) Then
Joy_Button(i).Picture = LoadPicture(App.Path + "\j"
+ CStr(i) + "on.bmp")
joyb_states(i) = True
Else
Joy_Button(i).Picture = LoadPicture(App.Path + "\j"
+ CStr(i) + "off.bmp")
joyb_states(i) = False
End If
Next i
End Sub
End Sub
The Vbjoy32.bas module takes care of reading the joystick’s potentiometers using
the Windows API called winmm.dll. The code listing for the same is as follows:
' Joystick Capabilities
Const MAXPNAMELEN = 32
Const MAXOEMVXD = 128
Type tJoyCaps
Mid As Integer
Pid As Integer
Pname As String * MAXPNAMELEN
Xmin As Long
Xmax As Long
Ymin As Long
Ymax As Long
Zmin As Long
Zmax As Long
NumButtons As Long
PeriodMin As Long
PeriodMax As Long
wRmin As Long
wRmax As Long
wUmin As Long
wUmax As Long
wVmin As Long
wVmax As Long
wCaps As Long
wMaxAxes As Long
wNumAxes As Long
wMaxButtons As Long
szRegKey As String * MAXPNAMELEN
szOEMVxD As String * MAXOEMVXD
End Type
Global JoyCaps As tJoyCaps
' Joystick API Calls
Declare Function joyGetDevCaps Lib "winmm.dll" Alias
"joyGetDevCapsA" (ByVal IDDevice As Integer, JCaps
As tJoyCaps, ByVal CapSize As Integer) As Integer
Declare Function joyGetPos Lib "winmm.dll" (ByVal
IDDevice As Integer, JPos As tJoyInfo) As Integer
Function GetJoystickPos(IDDevice As Long, JoyInfo As
tJoyInfo) As Integer
'-------------------------------------------------------
' This function is a wrapper around the joyGetPos API
' call. That call returns coordinates as unsigned
' long integers, which VB doesn't support. We move
' these coordinates into long values so that they
' can be easily evaluated.
'-------------------------------------------------------
Dim rc As Integer
Static NotFirstTime As Integer
If Not NotFirstTime Then
NotFirstTime = False
rc = joyGetDevCaps(IDDevice, JoyCaps,
Len(JoyCaps))
If rc <> 0 Then
GetJoystickPos = rc
Exit Function
End If
End If
rc = joyGetPos(IDDevice, JoyInfo)
GetJoystickPos = rc
If rc <> 0 Then Exit Function
JoyInfo.ButtonDown(1) = (JoyInfo.ButtonStates And
JOY_BUTTON1) = JOY_BUTTON1
JoyInfo.ButtonDown(2) = (JoyInfo.ButtonStates And
JOY_BUTTON2) = JOY_BUTTON2
JoyInfo.ButtonDown(3) = (JoyInfo.ButtonStates And
JOY_BUTTON3) = JOY_BUTTON3
JoyInfo.ButtonDown(4) = (JoyInfo.ButtonStates And
JOY_BUTTON4) = JOY_BUTTON4
End Function
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
The global declarations of variables accessed all over the program are declared in
globalvariables.bas as shown below:
Attribute VB_Name = "Module2"
Public Type JoyVariables
Xmin As Long
Xmax As Long
Ymin As Long
Ymax As Long
XCntr As Long
YCntr As Long
X_Upper_Range As Long
X_Lower_Range As Long
Y_Upper_Range As Long
Y_Lower_Range As Long
X_Upper_Scale As Long
X_Lower_Scale As Long
Y_Upper_Scale As Long
Y_Lower_Scale As Long
Set_val As Boolean
End Type
Public OP_tf_vals As JoyVariables
Global gCalib_form_loaded As Boolean
Global gSerial_Settings_Sel_loaded As Boolean
Global gSerial_first_init As Boolean
Global joy_control As String
The serial port settings are done through the Serial port settings form object which
has the following code listing
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
µC Operations Flowcharts and Algorithms:
Some of the flowcharts & algorithms used for the development of the µC
software are shown below:
Function Algorithms 1. SRM Auto: IF tilt_sw = open ‘indicates overturning, sensed thru interrupt. SET Sr_History=true; ‘Indicate SR Action is going on ROTATE acw; ‘acw wrt to Xabre’s upright left view REPEAT TILL tilt_sw = close; ‘Xabre is upright now, ‘sensed thru interrupt END IF IF Sr_History=true; Indicates that previous action was SR Action ROTATE cw; ‘cw wrt to Xabre’s upright left view REPEAT TILL lock_in = close; ‘SR arm is locked-in SET Sr_History=false; ‘Indicate SR Action completed 2. SRM Manual IF Command=Open_CW_manual ROTATE cw; ROTATE TILL Command = Stop_Rotation; IF Command=Open_ACW_manual ROTATE acw; ROTATE TILL Command = Stop_Rotation; IF Command=Open_CW_auto ROTATE cw; ROTATE TILL lock_in = close; ‘SR arm is locked-in IF Command=Open_ACW_auto ROTATE acw; ROTATE TILL lock_in = close; ‘SR arm is locked-in; 3. P/T Operation a. Command Operation IF PLL = open ON PL_Command: Pan Left; IF PRL = open ON PR_Command: Pan Right; IF TUL = open ON TU_Command: Tilt Up; IF TDL = open ON TD_Command: Tilt Down; b. Limit switch actuation Recognize Switch IF Switch = closed STOP Motion;
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
4. Light Operation: ON Light_ON_Command: Light = ON; ON Ligth_OFF_Command: Light = OFF; Function flowcharts:
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
HARDWARE
A PCB for the implementation of the circuit was manufactured. The
schematic design was prepared in Orcad V9.0 and the final layout was generated
using Protel V3.0.
This sub section includes the PCB layout diagrams.
5
5
4
4
3
3
2
2
1
1
D D
C C
B B
A A
PRIMARY CONTROL CARD
G2 MOTOR
TRANSMITTER CARD
G1 MOTOR
(On PC Side)
PAN MOTOR
TILT MOTOR
LDRV MOTOR RDRV MOTOR
SRM MOTOR
SRM LATCH
EOPs LATCH
G-PT LATCH
RECEIVER CARD
to variousLIMITSENSORS
to SRMLIMITSENSORS
1 1
XABRE HARDWARE
1 1Thursday, December 11, 2003
Title
Size Document Number Rev
Date: Sheet of
CTS TTLCTS TTL
CTS TTLCTS TTL
RXD TTL
CTS
TXD
RXD TTLRXD TTLRXD
12V
EXT 12V
5V
Ant
GND
RM1RM2LM1LM2PM1PM2G2M1G2M2G1M1G1M2SRM1SRM2TM1TM2
PM1
SRM1
RM2
G1M1
RM1
G2M1
TM1
G2M2
LM2
PM2
TM2
SRM2
G1M2
LM1
VCC
5V
12V
12V
12V
5V
12V
12V
12V
12V
12V
12V
5V
VCC
5V
5V
5V
5V
VCC
5V
5V
5V
5V
5V
5V
5V
5V
5V
5V
5V
5V
0
0
5V
GND
12V
12V
12V
12V
12V
12V
12V
C261uF
R2 R
C32 0.1uF
E1
ANTENNA
C35 0.1uF
J13
HEADER 15
123456789
101112131415
U1
DS89C420
2122232425262728
17
16
2930
11
10
31
1918
9
3938373635343332
12345678
1213
1415
P2.0P2.1P2.2P2.3P2.4P2.5P2.6P2.7
RD
WR
PSENALE/P
TXD
RXD
EA/VP
X1X2
RST
P0.0P0.1P0.2P0.3P0.4P0.5P0.6P0.7
P1.0/T2P1.1/T2X
P1.2P1.3P1.4P1.5P1.6P1.7
INT0INT1
T0T1
R6100E
C810nF
U6
74LS373
3478
13141718
111
256912151619
D0D1D2D3D4D5D6D7
OELE
Q0Q1Q2Q3Q4Q5Q6Q7
U9 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
U12 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
R216K8
U2
MAX6818
20
11
1918171615141312
1
10
23456789
Vcc
CH
OUT1OUT2OUT3OUT4OUT5OUT6OUT7OUT8
EN
GND
IN1IN2IN3IN4IN5IN6IN7IN8
C1710nF
C13
C282.2uF
R224K7
U5
74LS373
3478
13141718
111
256912151619
D0D1D2D3D4D5D6D7
OELE
Q0Q1Q2Q3Q4Q5Q6Q7
C1110nF
R1610K
C2010nF
J9
HEADER 4
1234
U4
74LS373
3478
13141718
111
256912151619
D0D1D2D3D4D5D6D7
OELE
Q0Q1Q2Q3Q4Q5Q6Q7
LS1RELAY DPDT
34
5
68
712
C330pF
C22
C272.2uF
D10LED
U10 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
R3 R
D14 DIODE
330ER8
C15100uFD2
1N4007
C510uF
R196K8
J8 RLP916F Conn.
1234
C6100uF
R2010K
11.0592 MhzXTAL
C1410nF
U13 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
R2410K
R10 10K
C210uF
U18 TLP916F
1 32 4
GN
D
VC
C
DA
TA
IN
AN
T
J5
HEADER 14
123456789
1011121314
D17
1N4007
R156K8
R11 6K8
C9100uF
C18100uF
SW1SW DPDT
Q3
2N2222
J1
HEADER 2
12
C430pF
D5LED
R4 R
C2310nF
R1210K
D7LED
J12JUMPER1
1 2
C34 0.1uF
U3
MAX6818
20
11
1918171615141312
1
10
23456789
Vcc
CH
OUT1OUT2OUT3OUT4OUT5OUT6OUT7OUT8
EN
GND
IN1IN2IN3IN4IN5IN6IN7IN8
R1810K
RS1RESISTOR SIP 10 5K
12 3 4 5 6 7 8 9 1
0
C31 0.1uF
U14
LM317/TO220
3
1
2VIN
ADJ
VOUT
R2310K
R136K8
C30 0.1uF
Q1
2N2222
D12
1N4007
Q2
2N2222
C29
C
U11 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
RS3RESISTOR SIP 10 5K 1
2 3 4 5 6 7 8 9 10
C12100uF
C33 0.1uF
SW2 SW DPDT
D3LED
D13
LED
U7 7805/TO1 3
2
VIN VOUT
GN
D
R1410K
D6LED
R9 1K
D1
1N4007
D9LED
C21100uF
U16 7805
1 3
2
VIN VOUT
GN
D
LS2RELAY DPDT
34
5
68
712
U15 RLP916F
4 56 712
8
3
Vcc
Vcc
Gn
dG
nd
Gn
d
DO
ut Ant
LO
ut
D15LED
J11
HEADER 10
12345678910
J4
HEADER 6
123456
R7VAR R
C251uF
R1 R
J7
HEADER 4
1234
C7
J3
HEADER 2
12
C16
C240.1uF
U17 HIN232
12
14710
11
15
16
138 9
13
45
26
R1OUT
T1OUTT2OUTT2IN
T1IN
GN
D
VC
C
R1INR2IN R2OUT
C1+C1-
C2+C2-
V+V-
D11
1N4007
C110uF
C10
D8LED
PB
C19
U8 LMD18200T2
11
9
1
10
8
6
7
354
OUT1
OUT2
TH OUT
BS1
BS2
CS OUT VC
C
GN
D
DIRPWMBRAKE
R176K8
D16LED
R510K
D4LED
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
SECTIO 5
Dual PWM Generation
This is required to control the driving of the two locomotion motors which have speed control implement in them by way of use of the H-bridge IC.
Drv_bit2=1 =>Drive magnitudes equal (Drv_bit1=0 then) Drv_bit1=1 =>LD lesser than RD (Drv_bit2=0 then) Drv_bit1=0 =>RD lesser than LD (Drv_bit2=0 then)
Phase_bits 3,2,1 Phase_bit3 for phase 3 Phase_bit2 for phase 2 Phase_bit1 for phase 1 1 indicates currently active phase, while rest of the bits will be zero Port Bits (Hardware defined) P0.0: Left Drv PWM Bit P0.1: Left Drv Direction Bit P0.2: Right Drv PWM Bit P0.3: Right Drv Direction Bit Phases Phase 1: Delay part of the whole time period. Value equal to 255-Small_val-Diff Load 255-40 Phase 3 indicated by 100 If 100 stop both On overflow set 255-50 Phase 2 indicated by 010 If 010 stop LD else stop RD On overflow set 255-6F Phase 1 indicated by 001 Both Drives off On LD command Save value to Left Locomotion Reg. M4M3M2M1-D-000 Call Set_Timer
Big_Val
FFh
Delay
Phase 3
Phase 2
Phase 1
Small_Val Diff
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
On RD command Save value to Right Locomotion Reg. M4M3M2M1-D-000 Call Set_Timer Set_Timer: Load L magnitude to temp1 Load R magnitude to temp2 Compare both magnitudes If L_Mag=R_Mag Set Drv_bit2 Clr Drv_bit1 Small_val=L_mag Big_val=R_mag Diff=01h Delay=255-Big_val If L_Mag<R_Mag Clr Drv_bit2 Set Drv_bit1 Small_val=255-L_mag Big_val=R_mag Diff=Small_val-Big_val)
Delay=255-Big_val If L_Mag>R_Mag Clr Drv_bit2 Clr Drv_bit1 Small_val=255-R_mag Big_val=L_mag Diff=Small_val-Big_val)
Delay=255-Big_val
On overflow ;At µC’s ISR for TF0 Goto PWM_sub; ;Jump to prog’s ISR PWM_sub: ;Prog’s ISR Stop Timer0; ;Stop the timer0 If Phase_bit3 set ;Indicates end of phase 3 Set Phase_bit2; ;Set start of phase 2 Clr Phase_bit3; ;Reset bit to show end of phase 3 Load Diff to TL0 ;Phase 2 counts for Diff period Goto PWM_writer; ;Perform PWM toggling Else If Phase_bit2 set ;Indicates end of phase 2 Set Phase_bit1; ;Set start of phase 1
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
Clr Phase_bit2; ;Reset bit to show end of phase 2 Load Delay to TL0 ;Phase 1 counts for Delay period Goto PWM_writer; Else ;Indicates end of phase 1 Set Phase_bit3; ;Set start of phase 3 Clr Phase_bit1; ;Reset bit to show end of phase 1 Load Small_val to TL0; ;Phase 3 counts for Small val period Goto PWM_writer; ;Perform PWM toggling PWM_writer Start Timer0; If Phase_bit3 set ;Phase 3 ON, so both drives ON P0.1 = 1; ;Turn ON LD P0.2 = 1; ;Turn ON RD Write Mag_bits; ;Magnitude bits are also set Else If Phase_bit2 set ;Phase 2 ON so lesser drive OFF If Drv_bit2set ;Both drives equal, turn ‘em OFF P0.1 = 0; ;Turn OFF LD P0.2 = 0; ;Turn OFF RD Else If Drv_bit1 set ;Drv_bits=01 so LD is less, so OFF P0.1 = 0; ;Turn OFF LD Else ;Drv_bits=00 so RD is less, so OFF P0.0 = 0; ;Turn OFF RD Else If Phase_bit1 set ;Phase 1 ON so both drive OFF P0.1 = 0; ;Turn OFF LD P0.2 = 0; ;Turn OFF RD
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
H-Bridge Logic (Extracted from Mag I.C. ’03, the annual magazine of IC Dept irma Institute of
Technology. Authored by Abhijit Karnik.)
There’s this nice idea you have floating about in your mind about a tank style robot you would like to build. All goes well till you decide to have the ability to reverse and there you have a nice pitfall. You can’t find a way to make your motor to get voltage in the reverse direction except use cumbersome relays with a number of switches. If you have been using a digital logic operation mode then again even relays are difficult to use. So what do you do? The answer lies in the H-bridge. The H-Bridge is basically a configuration which allows you to run the D.C. motor in any direction you want. The D.C. motor has 2 terminals. If one of the terminals is given positive D.C and the second terminal is grounded, the motor rotates in one direction. If the connections are reversed then, the motor rotates in the other direction. Now this means we need a circuit which allows either terminal to be connected to positive supply and the other one to ground as per our wish. As in figure 1 we have path A indicating connection for CCW motion, and path B for CW
motion and arrangement that at a time only one path is active, then the resulting configuration is the basic H-bridge. The blocks marked 1, 1’, 2 and 2’ in the figure are devices which allow the above requirement to be fulfilled.
The simplest option would be to use n-channel MOSFETs, as the blocks, which have the adequate power rating. The gate signal would be delivered from a logic gate that turns ON FETs 1 and 1’ while FETs 2 and 2’ would be OFF. This can be achieved by connecting the gates of FETs 1 and 1’ directly to gate output while the gates of FETs 2 and 2’ are connected to the inverted output of the same gate.
The operation of the H-Bridge is then as follows: If the gate output is high, FETs 1 and 1’ are ON and FETs 2 and 2’ are OFF. Path A is open while path B is closed and we have CCW motion. When the gate output is low, FETs 2 and 2’ are ON and FETs 1 and 1’ are OFF. Path B is open while path A is closed and we have CW motion. This arrangement is seemingly quite simple and easy to setup. So there should be some problems too. The 2 most basic problems in this arrangement are speed control and switching transients. For the first problem, we see that the H-bridge has no arrangements for controlling the speed of the motor. Either the motor is rotating CCW or CW at full power. The solution to this problem lies in pulse width modulation or PWM method. In short this method varies the operational duty cycle, i.e. the on time of the motor. The average DC delivered to the motor is varied by providing to the gate, pulses of variable time duration, ensuring that the motor speed is controlled. If we ‘AND’ the output of the control gate before it is supplied to any of the FET gate terminals, with a variable pulse width generator, PWM input is available to the FET gate terminals. The variable pulse width generator can be an IC555 in monostable mode with the time constant being varied by a pot and another IC555 in astable mode providing trigger input. The duty cycle can be varied from nearly 0% to ~99% of the frequency
Figure 1
Project Report Project Report Project Report Project Report
7777thththth Sem I.C.Sem I.C.Sem I.C.Sem I.C.
Nirma Institute of TeNirma Institute of TeNirma Institute of TeNirma Institute of Technologychnologychnologychnology
XABREXABREXABREXABRE
of the astable IC555. Accordingly the motor speed varies from 0 rpm to full rated value. The second problem (which is a bigger problem) is the switching transients. The motor coil can be considered to be an inductor. An inductor tries to oppose changes in current magnitude flowing through it. Abruptly switching off the current supply induces large transient spikes in voltage due to the collapsing magnetic field in the motor coil. This transient voltage and current can fry your FETs if they are not built to handle the voltages. Another possible source of transient current is known as ‘free wheeling’. Due to motor inertia, the rotation of the motor may not stop immediately. During this time the motor can act as a generator sourcing large current values. These problems are more complicated and need more control circuitry that keep both FETs 1’ and 2’ ON during switching and allow transients to run to ground. Another option would be to use zener diodes with knee voltage greater than supply and with enough power dissipation ratings connected between ground and both terminals (Cathodes towards motor). In any case the FETs tend to dissipate a lot of heat while switching, which needs to be diverted to a sink properly. Another solution to this problem is using one of the H-bridge ICs that are available. These ICs come with internal arrangements for transient protection and thermal shutdown. There is simple arrangement for direction control and speed control in form of separate pins. Normally you would find a pin labeled PWM input and another labeled direction. Their limitations are in terms of peak voltages and current ratings. Another limitation is cost. They are a trifle bit too expensive. One of the H-bridge ICs is LMD18200T from National Semiconductor. I have mentioned this IC since it allows 3A and 55V and best of all, National sends free samples (it costs $8.5) so experiments are easier to conduct. Texas Instruments also has similar ICs. Specific part numbers of FETs are not mentioned since it depends on your motor and supply and mostly because I haven’t used any. I learnt about the existence of H-bridge and directly headed for National’s website to search for a related IC and found the LMD18200T. The H-bridge is a very good solution for speed-direction control of a DC motor and if your motor is not going to take large currents, even FETs without arrangements for transient bypassing can do the job satisfactorily. With the H-Bridge, direction and speed control should never come in way of realizing the dream of your very own bot!
1 of 47 REV: 102203
Note: Some revisions of this device may incorporate deviations from published specifications known as errata. Multiple revisions of any device may be simultaneously available through various sales channels. For information about device errata, click here: www.maxim-ic.com/errata.
-
GENERAL DESCRIPTION The DS89C420 offers the highest performance available in 8051-compatible microcontrollers. It features a redesigned processor core that executes every 8051 instruction (depending on the instruction type) up to 12 times faster than the original for the same crystal speed. Typical applications see a speed improvement of 10 times using the same code and crystal. The DS89C420 offers a maximum crystal speed of 33MHz, achieving execution rates up to 33 million instructions per second (MIPS). APPLICATIONS Data Logging Vending Automotive Test Equipment Motor Control Magstripe Reader/Scanner Consumer Electronics Gaming Equipment Appliances (Washers, Microwaves, etc.) Telephones HVAC Building Security and Door Access Control Building Energy Control and Management Uninterruptible Power Supplies Programmable Logic Controllers Industrial Control and Automation ORDERING INFORMATION
PART TEMP RANGE MAX
CLOCK SPEED (MHz)
PIN-PACKAGE
DS89C420-MNG -40°C to +85°C 25 40 PDIP DS89C420-QNG -40°C to +85°C 25 44 PLCC DS89C420-ENG -40°C to +85°C 25 44 TQFP DS89C420-MCL 0°C to +70°C 33 40 PDIP DS89C420-QCL 0°C to +70°C 33 44 PLCC DS89C420-ECL 0°C to +70°C 33 44 TQFP DS89C420-MNL -40°C to +85°C 33 40 PDIP DS89C420-QNL -40°C to +85°C 33 44 PLCC DS89C420-ENL -40°C to +85°C 33 44 TQFP
Pin Configurations appear at end of data sheet.
FEATURES 80C52 Compatible
8051 Pin- and Instruction-Set Compatible Four Bidirectional I/O Ports Three 16-Bit Timer Counters 256 Bytes Scratchpad RAM
On-Chip Memory 16kB Flash Memory In-System Programmable through Serial Port 1kB SRAM for MOVX
ROMSIZE Feature Selects Internal Program Memory Size from
0 to 16k Allows Access to Entire External Memory Map Dynamically Adjustable by Software
High-Speed Architecture 1 Clock-Per-Machine Cycle DC to 33MHz Operation Single-Cycle Instruction in 30ns Optional Variable Length MOVX to Access
Fast/Slow Peripherals Dual Data Pointers with Auto
Increment/Decrement and Toggle Select Supports Four Paged Modes
Power Management Mode Programmable Clock Divider Automatic Hardware and Software Exit
Two Full-Duplex Serial Ports Programmable Watchdog Timer 13 Interrupt Sources (Six External) Five Levels of Interrupt Priority Power-Fail Reset Early Warning Power-Fail Interrupt
www.maxim-ic.com
DS89C420Ultra-High-Speed Microcontroller
DS89C420 Ultra-High-Speed Microcontroller
46 of 47
PIN CONFIGURATIONS
6 1 40
18 28
7 39
17 29
Dallas Semiconductor
DS89C420
TOP VIEW
PLCC
33 23
1 11
34 22
44 12
Dallas Semiconductor
DS89C420
TOP VIEW
TQFP
P1.0/T2P1.1/T2EXP1.2/RXD1P1.3/TXD1P1.4/INT2P1.5/INT3P1.6/INT4P1.7/INT5
RSTP3.0/RXD0P3.1/TXD0P3.2/INT0P3.3/INT1
P3.4/T0P3.5/T1
P3.6/WRP3.7/RD
XTAL2XTAL1
VSS
VCC P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 EA/VPP ALE/PROGPSEN P2.7 P2.6 P2.5 P2.4 P2.3 P2.2 P2.1 P2.0
40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21
123456789
1011121314151617181920
DS89C420
DIP
TOP VIEW
Ultra-High-Speed FlashMicrocontroller User’s Guide
53 _____________________________________________________________________________________________
UHSM UHSM 8051 8051 UHSM vs.
HEX CLOCK TIME CLOCK TIME 8051 SPEED
INSTRUCTION CODE CYCLES @ 25MHz CYCLES @ 25MHz ADVANTAGE
CJNE A, #data, rel B4 4 160 ns 24 960 ns 6
CJNE Rn, #data, rel B8..BF 4 160 ns 24 960 ns 6
CJNE @Ri, #data, rel B6..B7 5 200 ns 24 960 ns 4.8
DJNZ Rn, rel D8..DF 4 160 ns 24 960 ns 6
DJNZ direct, rel D5 5 200 ns 24 960 ns 4.8
NOP 00 1 40 ns 12 480 ns 12
Table 5-2. INSTRUCTION SPEED SUMMARY
SECTION 6: MEMORY ACCESSThe DS89C420 ultra-high-speed microcontroller supports the memory interface convention established for the industry standard80C51, but also implements two new page mode memory interfaces needed to support ultra-high-speed external operation. Theseexternal page mode interfaces are described later in this section.
INSTRUCTION CATEGORY SPEEDADVANTAGE QUANTITY
Total instructions: 1 byte 4.0 24.8 15.3 16.0 128.0 512.0 2724.0 1
Total instructions: 2 byte 4.0 16.0 278.0 512.0 13
Total instructions: 3 byte 4.8 36.0 58.0 8
Average across all instructions 8.5 111
OPCODE CATEGORYSPEED
ADVANTAGE QUANTITY
Total opcodes: 1 byte 4.0 44.8 15.3 16.0 358.0 512.0 9324.0 1
Total opcodes: two byte 4.0 16.0 428.0 512.0 43
Total opcodes: three byte 4.8 46.0 128.0 8
Average across all opcodes 9.4 255
Ultra-High-Speed FlashMicrocontroller User’s Guide
_____________________________________________________________________________________________ 56
the watchdog reset function automatically. Other bits of this register are undefined and are at logic 1 when read. The value of this reg-ister can be read at address FCh in parallel programming mode or by executing the verify option control register instruction in ROMLoader or in-application programming mode.
INTERNAL SRAM MEMORYThe DS89C420 ultra-high-speed microcontroller incorporates an internal 1kB SRAM that is usable as data, program, or merged pro-gram/data memory. Upon a power-on reset, the internal 1kB memory is disabled and transparent to both program and data memorymaps.
When used for data, the memory is addressed through MOVX commands, and is in addition to the 256 bytes of scratchpad memory.To enable the 1kB SRAM as internal data memory, software must set the DME0 bit (PMR.0). After setting this bit, all MOVX accesseswithin the first 1kB (0000h–03FFh) is directed to the internal SRAM. Any data memory accesses outside of this range are still directedto the expanded bus. One advantage of using the internal data memory is that MOVX operations automatically default to the fastestaccess possible. Note that the DME0 bit is cleared after any reset, so access to the internal data memory is prohibited until this bit ismodified. The contents of the internal data memory are not affected by the changing of the data memory enable (DME0) bit. Table 6-3 shows how the DME1, DME0 bits affect the data memory map.
ExternalData
Memory
8kB x 8
Flash Memory
(Program)
1kB x 8SRAM
Data ORprog mem addr from 400–7FF
128 BytesIndirect
Addressing
Bit Addressable
Bank 3Bank 2Bank 1Bank 000
1F202F
7F80
128 Bytes SFR
FF
0000
1FFF
2000
3FFF
INTERNALMEMORY
03FF
0000
FFFF FFFF
4000
00000000
03FF
ExternalProgramMemoryINTERNAL
REGISTERS
8kB x 8Flash
Memory(Program)
SCRATCHPAD
Note: The hatched areas shown on the internal and external memory are disabled on power-up (Default)
Non-usable if Internal SRAM is activated
Figure 6-1. Memory Map
Ultra-High-Speed FlashMicrocontroller User’s Guide
Mode 1Mode 1 is asynchronous and full duplex, using a total of 10 bits. The 10 bits consist of a start bit (logic 0), 8 data bits, and 1 stop bit(logic 1) as illustrated in Figure 12-2. The data is transferred LSb first. As described above, the baud rates for mode 1 are generatedby either a divide-by-16 of timer 1 rollover, a divide-by-16 of the timer 2 rollover, or a divide-by-32 of timer 1 rollover. The UART beginstransmission after the first rollover of the divide-by-16 counter following a software write to SBUF. Transmission takes place on the TXDpin. It begins by the start bit being placed on the pin. Data is then shifted out onto the pin, LSb first. The stop bit follows. The TI bit isset by hardware after the stop bit is placed on the pin. All bits are shifted out at the rate determined by the baud-rate generator.
Once the baud-rate generator is active, reception can begin at any time. The REN bit (SCON0.4 or SCON1.4) must be set to a logic 1to allow reception. The falling edge of a start bit on the RXD pin begins the reception process. Data is shifted in at the selected baudrate. At the middle of the stop bit time, certain conditions must be met to load SBUF with the received data:
• RI must = 0, and either
• If SM2 = 0, the state of the stop bit does not matter, or
• If SM2 = 1, the state of the stop bit must = 1.
If these conditions are true, then SBUF (hex address 99h or C1h) is loaded with the received byte, the RB8 bit (SCON0.2 or SCON1.2)is loaded with the stop bit, and the RI bit (SCON0.0 or SCON1.0) is set. If these conditions are false, then the received data is lost(SBUF and RB8 not loaded) and RI is not set. Regardless of the receive word status, after the middle of the stop bit time, the receivergoes back to looking for a 1 to 0 transition on the RXD pin.
Each data bit received is sampled on the 7th, 8th, and 9th clock used by the divide-by-16 counter. Using majority voting, two equalsamples out of the three determine the logic level for each received bit. If the start bit was determined to be invalid ( = 1), then thereceiver goes back to looking for a 1 to 0 transition on the RXD pin in order to start the reception of data.
Mode 2Mode 2 uses a total of 11 bits in asynchronous full-duplex communication, as illustrated in Figure 12-3. The 11 bits consist of 1 startbit (a logic 0), 8 data bits, 1 programmable 9th bit, and one stop bit (a logic 1). Like mode 1, the transmissions occur on the TXD sig-nal pin and receptions on RXD. For transmission purposes, the 9th bit can be stuffed as a logic 0 or 1. A common use is to put the par-ity bit in this location. The 9th bit is transferred from the TB8 bit position in the SCON register (SCON0.3 or SCON1.3) during the writeto SBUF. Baud rates are generated as a fixed function of the crystal frequency, as described earlier in this section. Like mode 1, mode2’s transmission begins after the first rollover of the divide-by-16 counter following a software write to SBUF. It begins by the start bitbeing placed on the TXD pin. The data is then shifted out onto the pin LSb first, followed by the 9th bit, and finally the stop bit. The TIbit (SCON0.1 or SCON1.1) is set when the stop bit is placed on the pin.
Reception begins when a falling edge is detected as part of the incoming start bit on the RXD pin. The RXD pin is then sampled accord-ing to the baud-rate speed. The 9th bit is placed in the RB8 bit location in SCON (SCON0.2 or SCON1.2). When a stop bit has beenreceived, the data value is transferred to the SBUF receive register (hex address 99 or C1). The RI bit (SCON0.0 or SCON1.0) is set toindicate that a byte has been received. At this time, the UART can receive another byte.
Once the baud-rate generator is active, reception can begin at any time. The REN bit (SCON0.4 or SCON1.4) must be set to a logic 1to allow reception. The falling edge of a start bit on the RXD pin begins the reception process. Data must be shifted in at the selectedbaud rate. At the middle of the 9th bit time, certain conditions must be met to load SBUF with the received data.
• RI must = 0, and either
• If SM2 = 0, the state of the 9th bit does not matter, or
• If SM2 = 1, the state of the 9th bit must = 1.
If these conditions are true, then SBUF is loaded with the received byte, RB8 is loaded with the 9th bit, and RI is set. If these condi-tions are false, then the received data is lost (SBUF and RB8 not loaded) and RI is set. Regardless of the receive word status, after themiddle of the stop bit time, the receiver goes back to looking for a 1 to 0 transition on RXD.
Data is sampled in a similar fashion to mode 1 with the majority voting on three consecutive samples. Mode 2 uses the sample divide-by-16 counter with either the oscillator divided by 2 or 4.
____________________________________________________________________________________________ 114
Ultra-High-Speed FlashMicrocontroller User’s Guide
115 ____________________________________________________________________________________________
SBUF
DIVIDE-BY-2
D7LO
AD
CLO
CK
TRANSMIT SHIFT REGISTER
S0P3.1
LATCHTXDPIN
RECEIVE DATA BUFFER WRRD
CLO
CK
RECEIVE SHIFT REGISTER
SI
READSERIAL
BUFFERBAUDCLOCK
LOADSERIALBUFFER
LOAD
INT
S
SE
RIA
L I/
OC
ON
TR
OL
SHIFT
T1FLAG =
SCONx.1
RXDPIN
SERIALINTERRUPT
LDSBUFRDSBUF
ST
OP
ST
AR
T
1 0
ST
OP
ST
AR
T
RB8 =SCONx.2
R1FLAG =
SCONx.0
DIVIDE-BY-16
BITDETECTION
DATA BUS
SBUF
RESET
DIVIDE-BY-16
SMOD_0 =PCON.7ORSMOD_1 =WDCON.7
D6
D5
D4
D3
D2
D1
D0
D7
D5
D4
D3
D2
D1
D0
D6
TIMER 2OVERFLOWTIMER 1
OVERFLOWA
VA
ILA
BLE
TO
SE
RIA
LP
OR
T 0
ON
LY
10
10
10
TCLK =T2CON.4
RCLK =T2CON.5
RECEIVE TIMING
BIT DETECTORSAMPLING
SHIFT
RI
RXDD0 D1 D2 D3 D4 D5 D6 D7 STOPSTART
TRANSMIT TIMING
LDSBUF
SHIFT
TI
TXDD0 D1 D2 D3 D4 D5 D6 D7 STOPSTART
Figure 12-2. Serial Port Mode 1
Ultra-High-Speed FlashMicrocontroller User’s Guide
127 ____________________________________________________________________________________________
SECTION 15: PROGRAM LOADING INTRODUCTIONThe DS89C420 family has the ability to perform program loading or reloading in a number of ways. First, ROM loader mode can beinvoked to create a serial communication channel, which permits in-system program/erase of the internal and external program mem-ory. Secondly, parallel programming mode allows programming and erasure of the internal flash memory using industry-standardEPROM or flash parallel programmers. Finally, user code in-application programming allows the capability to in-application erase andreprogram the upper 8kb block of flash memory through a special function register interface.
Note: The terms ROM loader, serial loader, and bootstrap loader are used interchangeably in this section and refer to the same func-tional entity.
ROM LOADER MODEThe DS89C420 defaults to the normal operating (nonloader) mode without external hardware. ROM loader mode can be invoked atany time, as described later in this section. Once the loader session is complete, the device performs a hardware reset and beginoperation. This is identical to an external reset, except that the ROM loader during the loader session may modify locations in scratch-pad RAM in order to execute properly. The Table 15-1 shows which areas of scratchpad RAM are guaranteed preserved and whichones are of indeterminate state after exiting the loader.
Table 15-1. Preserved and Indeterminate Scratchpad Memory
The guaranteed preserved locations are areas in scratchpad RAM that are be changed by the bootstrap loader. The indeterminatearea contains various stacks and buffers used by the loader, and a given byte in this area may or may not be modified by the loader.As such, the user should not rely on the loader preserving any data in this area.
It should also be noted that the loader, upon being invoked, clears the EWT bit (WDCON.1) so that the watchdog timer is preventedfrom generating an internal reset during the loader session.
Invoking the ROM Loader Mode The ROM loader mode is invoked by simultaneously applying a logic 1 to the RST pin, a logic 0 to the EA pin, and driving the PSENpin to a logic 0 level. If power were to cycle while the required input stimuli were present, the loader would be invoked on power-up.When the ROM loader mode is invoked, the device awaits an incoming <CR> character (0Dh) on serial port 0 at a baud rate that canbe detected by the autobaud routine. The autobaud routine is described later in this section. The autobaud routine receives and trans-mits data only on serial port 0, ignoring activity on serial port 1. Upon successful baud-rate detection, the bootstrap loader transmitsa banner similar to the one shown below, signaling to the host that loader mode has successfully been invoked. The banner is followedby a “>” prompt, which indicates the device is ready to receive a command. The command set recognizable by the ROM loader is alsodetailed later in this section. The flow of these conditions is shown in Figure 15-1.
Exiting the LoaderIn order to exit ROM loader mode on the DS89C420 device, first float the PSEN signal, and then float or drive the RST pin low. The RSTpin has an internal pulldown. The PSEN signal is an output and drives itself high. When the loader stimulus is removed, the processorperforms a hardware reset and begin execution at location 0000h. Note that both of these conditions must occur, or the loader is exit-ed. The flow of these conditions is shown in Figure 15-1.
DS89C420SCRATCHPAD MEMORY
Guaranteed Preserved 80h–FFhIndeterminate 00h–7Fh
Ultra-High-Speed FlashMicrocontroller User’s Guide
____________________________________________________________________________________________ 128
PROGRAM EXECUTION
INTERNAL MEMORY DISABLED EA\ =0
INTERNAL MEMORY ENABLED EA\ =1
PSEN\TOGGLED 0 1
RST = 1
EA\ = 0
PSEN\ = 0
POWER-ONRESET
AUTOBAUD ROUTINEAWAITING <CR> CHARACTER ON RXD OF SERIAL PORT 0
SERIAL COMMUNICATION WITH THE ROM LOADER CANPROCEED AS ESTABLISHED ON SERIAL PORT 0
DEVICE IN RESET(INTERNAL MEMORY DISABLED)
DEVICE IN RESET(INTERNAL MEMORY ENABLED)
N
N
N
N Y
Y
Y
Y
Y
N
Figure 15-1. Invoking and Exiting the Loader on the DS89C420
Ultra-High-Speed FlashMicrocontroller User’s Guide
129 ____________________________________________________________________________________________
Serial Program Load OperationProgram loading through a serial port is a convenient method of loading application software into the flash memory or external mem-ory. Communication is performed over a standard, asynchronous serial communications port using a terminal emulator program with8-N-1 (8 data bits, no parity, 1 stop bit) protocol settings. A typical application would use a simple RS-232 serial interface to in-systemprogram the device as part of a final production procedure.
The hardware configuration for the serial program load operation is illustrated in Figure 15-2. A variety of crystals can be used to pro-duce standard baud rates. The serial loader is designed to operate across a 3-wire interface from a standard UART. The receive, trans-mit, and ground wires are all that are necessary to establish communication with the device.
The serial loader implements an easy-to-use command line interface, which allows an Intel hex file to be loaded and read back fromthe device. Intel hex is the standard format output by 8051 cross-assemblers.
AUTOBAUD-RATE DETECTIONThe serial bootstrap loader can automatically detect, within certain limits, the external baud rate and configure itself to that speed. Theloader controls serial port 0 in mode 1 (asynchronous, 1 start bit, 8 data bits, no parity, 1 stop bit, full duplex), using timer 1 in 8-bitautoreload mode with the serial port 0 doubler bit (PCON.7) set. For these settings, an equation to calculate possible serial loaderbaud rates is provided as a function of crystal frequency and timer reload value. Table 15-1 shows baud rates generated using theequation:
** Timer reload values attempted by the loader:
FF, FE, FD, FC, FB, FA, F8, F6, F5, F4, F3, F0, EC, EA, E8,
E6, E0, DD, D8, D4, D0, CC, C0, BA, B0, A8, A0, 98, 80, 60, 40
When communicating with a PC COM port having a standard 8250/16450 UART, attempt to match the loader baud rate and PC COMport baud rate within 3% in order to maintain a reliable communication channel. If baud rates cannot be matched exactly, it is suggest-ed configuring the loader to the faster baud rate to avoid the possibility of overflowing the DS89C420 serial input buffer.
)(x192
Crystal Frequency
256-Timer ReloadSerial Loader_Baud rate =
TO PC
ROIN
TD
HC/AC125
TOOUTRD
R1IN
DTR
ROOUT
VCC
TOIN
R1OUT
DS232A
DS89C420
T1OUT
RXDO
TXDO
RST
EA
PSEN
T1IN
Figure 15-2. Serial Load Hardware Configuration
LMD182003A, 55V H-BridgeGeneral DescriptionThe LMD18200 is a 3A H-Bridge designed for motion controlapplications. The device is built using a multi-technology pro-cess which combines bipolar and CMOS control circuitrywith DMOS power devices on the same monolithic structure.Ideal for driving DC and stepper motors; the LMD18200 ac-commodates peak output currents up to 6A. An innovativecircuit which facilitates low-loss sensing of the output currenthas been implemented.
Featuresn Delivers up to 3A continuous outputn Operates at supply voltages up to 55Vn Low RDS(ON) typically 0.3Ω per switchn TTL and CMOS compatible inputs
n No “shoot-through” currentn Thermal warning flag output at 145˚Cn Thermal shutdown (outputs off) at 170˚Cn Internal clamp diodesn Shorted load protectionn Internal charge pump with external bootstrap capability
Applicationsn DC and stepper motor drivesn Position and velocity servomechanismsn Factory automation robotsn Numerically controlled machineryn Computer printers and plotters
Functional Diagram
DS010568-1
FIGURE 1. Functional Block Diagram of LMD18200
December 1999
LMD
182003A
,55VH
-Bridge
© 1999 National Semiconductor Corporation DS010568 www.national.com
Connection Diagrams and Ordering Information
DS010568-2
11-Lead TO-220 PackageTop View
Order Number LMD18200TSee NS Package TA11B
DS010568-25
24-Lead Dual-in-Line PackageTop View
Order Number LMD18200-2D-QV5962-9232501VXALMD18200-2D/8835962-9232501MXA
See NS Package DA24B
LMD
1820
0
www.national.com 2
Electrical Characteristics NotesNote 1: Absolute Maximum Ratings indicate limits beyond which damage to the device may occur. DC and AC electrical specifications do not apply when op-erating the device beyond its rated operating conditions.
Note 2: See Application Information for details regarding current limiting.
Note 3: The maximum power dissipation must be derated at elevated temperatures and is a function of TJ(max), θJA, and TA. The maximum allowable power dis-sipation at any temperature is PD(max) = (TJ(max) − TA)/θJA, or the number given in the Absolute Ratings, whichever is lower. The typical thermal resistance from junc-tion to case (θJC) is 1.0˚C/W and from junction to ambient (θJA) is 30˚C/W. For guaranteed operation TJ(max) = 125˚C.
Note 4: Human-body model, 100 pF discharged through a 1.5 kΩ resistor. Except Bootstrap pins (pins 1 and 11) which are protected to 1000V of ESD.
Note 5: All limits are 100% production tested at 25˚C. Temperature extreme limits are guaranteed via correlation using accepted SQC (Statistical Quality Control)methods. All limits are used to calculate AOQL, (Average Outgoing Quality Level).
Note 6: Output currents are pulsed (tW < 2 ms, Duty Cycle < 5%).
Note 7: Regulation is calculated relative to the current sense output value with a 1A load.
Note 8: Selections for tighter tolerance are available. Contact factory.
Typical Performance Characteristics
VSAT vs Flag Current
DS010568-16
RDS(ON) vs Temperature
DS010568-17
RDS(ON) vsSupply Voltage
DS010568-18
Supply Current vsSupply Voltage
DS010568-19
Supply Current vsFrequency (V S = 42V)
DS010568-20
Supply Current vsTemperature (V S = 42V)
DS010568-21
Current Sense Outputvs Load Current
DS010568-22
Current SenseOperating Region
DS010568-23
LMD
1820
0
www.national.com 4
Test Circuit
Switching Time Definitions
Pinout Description (See Connection Diagram)
Pin 1, BOOTSTRAP 1 Input: Bootstrap capacitor pin for halfH-bridge number 1. The recommended capacitor (10 nF) isconnected between pins 1 and 2.
Pin 2, OUTPUT 1: Half H-bridge number 1 output.
Pin 3, DIRECTION Input: See Table 1. This input controlsthe direction of current flow between OUTPUT 1 and OUT-PUT 2 (pins 2 and 10) and, therefore, the direction of rotationof a motor load.
Pin 4, BRAKE Input: See Table 1. This input is used tobrake a motor by effectively shorting its terminals. Whenbraking is desired, this input is taken to a logic high level and
it is also necessary to apply logic high to PWM input, pin 5.The drivers that short the motor are determined by the logiclevel at the DIRECTION input (Pin 3): with Pin 3 logic high,both current sourcing output transistors are ON; with Pin 3logic low, both current sinking output transistors are ON. Alloutput transistors can be turned OFF by applying a logic highto Pin 4 and a logic low to PWM input Pin 5; in this case onlya small bias current (approximately −1.5 mA) exists at eachoutput pin.
Pin 5, PWM Input: See Table 1. How this input (and DIREC-TION input, Pin 3) is used is determined by the format of thePWM Signal.
DS010568-8
DS010568-9
LMD
18200
www.national.com5
Pinout Description(See Connection Diagram) (Continued)
Pin 6, VS Power Supply
Pin 7, GROUND Connection: This pin is the ground return,and is internally connected to the mounting tab.
Pin 8, CURRENT SENSE Output: This pin provides thesourcing current sensing output signal, which is typically377 µA/A.
Pin 9, THERMAL FLAG Output: This pin provides the ther-mal warning flag output signal. Pin 9 becomes active-low at145˚C (junction temperature). However the chip will not shutitself down until 170˚C is reached at the junction.
Pin 10, OUTPUT 2: Half H-bridge number 2 output.
Pin 11, BOOTSTRAP 2 Input: Bootstrap capacitor pin forHalf H-bridge number 2. The recommended capacitor(10 nF) is connected between pins 10 and 11.
TABLE 1. Logic Truth Table
PWM Dir Brake Active Output Drivers
H H L Source 1, Sink 2
H L L Sink 1, Source 2
L X L Source 1, Source 2
H H H Source 1, Source 2
H L H Sink 1, Sink 2
L X H NONE
Application Information
TYPES OF PWM SIGNALS
The LMD18200 readily interfaces with different forms ofPWM signals. Use of the part with two of the more popularforms of PWM is described in the following paragraphs.
Simple, locked anti-phase PWM consists of a single, vari-able duty-cycle signal in which is encoded both direction andamplitude information (see Figure 2). A 50% duty-cyclePWM signal represents zero drive, since the net value ofvoltage (integrated over one period) delivered to the load iszero. For the LMD18200, the PWM signal drives the direc-tion input (pin 3) and the PWM input (pin 5) is tied to logichigh.
Sign/magnitude PWM consists of separate direction (sign)and amplitude (magnitude) signals (see Figure 3). The (ab-solute) magnitude signal is duty-cycle modulated, and theabsence of a pulse signal (a continuous logic low level) rep-resents zero drive. Current delivered to the load is propor-tional to pulse width. For the LMD18200, the DIRECTION in-put (pin 3) is driven by the sign signal and the PWM input(pin 5) is driven by the magnitude signal.
SIGNAL TRANSITION REQUIREMENTS
To ensure proper internal logic performance, it is good prac-tice to avoid aligning the falling and rising edges of input sig-nals. A delay of at least 1 µsec should be incorporated be-tween transitions of the Direction, Brake, and/or PWM inputsignals. A conservative approach is be sure there is at least500ns delay between the end of the first transition and thebeginning of the second transition. See Figure 4.
DS010568-4
FIGURE 2. Locked Anti-Phase PWM Control
DS010568-5
FIGURE 3. Sign/Magnitude PWM Control
LMD
1820
0
www.national.com 6
General DescriptionThe MAX6816/MAX6817/MAX6818 are single, dual, andoctal switch debouncers that provide clean interfacingof mechanical switches to digital systems. They acceptone or more bouncing inputs from a mechanical switchand produce a clean digital output after a short, presetqualification delay. Both the switch opening bounceand the switch closing bounce are removed. Robustswitch inputs handle ±25V levels and are ±15kV ESD-protected for use in harsh industrial environments. Theyfeature single-supply operation from +2.7V to +5.5V.Undervoltage lockout circuitry ensures the output is inthe correct state upon power-up.
The single MAX6816 and dual MAX6817 are offered inSOT packages and require no external components.Their low supply current makes them ideal for use inportable equipment.
The MAX6818 octal switch debouncer is designed fordata-bus interfacing. The MAX6818 monitors switchesand provides a switch change-of-state output (CH),simplifying microprocessor (µP) polling and interrupts.Additionally, the MAX6818 has three-state outputs con-trolled by an enable (EN) pin, and is pin-compatiblewith the ‘LS573 octal latch (except for the CH pin),allowing easy interfacing to a digital data bus.
ApplicationsµP Switch Interfacing
Industrial Instruments
PC-Based Instruments
Portable Instruments
Automotive Applications
Membrane Keypads
Features♦ Robust Inputs can Exceed Power Supplies
up to ±25V
♦ ESD Protection for Input Pins±15kV—Human Body Model±8kV—IEC 1000-4-2, Contact Discharge±15kV—IEC 1000-4-2, Air-Gap Discharge
♦ Small SOT Packages (4 and 6 pins)
♦ Single-Supply Operation from +2.7V to +5.5V
♦ Single (MAX6816), Dual (MAX6817), and Octal(MAX6818) Versions Available
♦ No External Components Required
♦ 6µA Supply Current
♦ Three-State Outputs for Directly InterfacingSwitches to µP Data Bus (MAX6818)
♦ Switch Change-of-State Output Simplifies Polling and Interrupts (MAX6818)
♦ Pin-Compatible with ’LS573 (MAX6818)
MA
X6
81
6/M
AX
68
17
/MA
X6
81
8
±15kV ESD-Protected, Single/Dual/Octal,CMOS Switch Debouncers
________________________________________________________________ Maxim Integrated Products 1
1
2
4
3
VCC
OUTIN
GND
MAX6816
SOT143
TOP VIEW
IN
MECHANICALSWITCH
RESET
GNDDEBOUNCED
OUTPUT
VCC
µP
0.1µF
OUT
MAX6816
Typical Operating Circuit
19-4770; Rev 1; 1/99
PART
MAX6816EUS-T
MAX6817EUT-T
MAX6818EAP -40°C to +85°C
-40°C to +85°C
-40°C to +85°C
TEMP. RANGEPIN-PACKAGE
4 SOT143
6 SOT23-6
20 SSOPNote: There is a minimum order increment of 2500 pieces forSOT packages.
Pin Configurations
Ordering InformationSOT
TOP MARK
KABA
AAAU
—
Pin Configurations continued at end of data sheet.
For free samples & the latest literature: http://www.maxim-ic.com, or phone 1-800-998-8800.For small orders, phone 1-800-835-8769.
_______________Detailed DescriptionTheory of Operation
The MAX6816/MAX6817/MAX6818 are designed toeliminate the extraneous level changes that result frominterfacing with mechanical switches (switch bounce).Virtually all mechanical switches bounce upon openingor closing. These switch debouncers remove bouncewhen a switch opens or closes by requiring thatsequentially clocked inputs remain in the same state fora number of sampling periods. The output does notchange until the input is stable for a duration of 40ms.
The circuit block diagram (Figure 1) shows the func-tional blocks consisting of an on-chip oscillator,counter, exclusive-NOR gate, and D flip-flop. When the
input does not equal the output, the XNOR gate issuesa counter reset. When the switch input state is stablefor the full qualification period, the counter clocks theflip-flop, updating the output. Figure 2 shows the typicalopening and closing switch debounce operation. Onthe MAX6818, the change output (CH) is updatedsimultaneously with the switch outputs.
Undervoltage LockoutThe undervoltage lockout circuitry ensures that the out-puts are at the correct state on power-up. While the sup-ply voltage is below the undervoltage threshold(typically 1.9V), the debounce circuitry remains trans-parent. Switch states are present at the logic outputswithout delay.
MA
X6
81
6/M
AX
68
17
/MA
X6
81
8
±15kV ESD-Protected, Single/Dual/Octal,CMOS Switch Debouncers
4 _______________________________________________________________________________________
PIN
2 — —
— 1, 3 —
— — 12–19
— 4, 6 —
3 — —
— — 2–9
— — 11
— — 1
4 5 20
Pin Description
FUNCTION
Switch Input
Switch Inputs
CMOS Debounced Outputs
CMOS Debounced Outputs
CMOS Debounced Output
Switch Inputs
Change-of-State Output. Goes low on switch input change ofstate. Resets on EN. Leave unconnected if not used.
Active-Low, Three-State Enable Input for outputs. Resets CH.Tie to GND to “always enable” outputs.
+2.7V to +5.5V Supply Voltage
NAME
IN
IN1, IN2
OUT8–OUT1
OUT2, OUT1
OUT
IN1–IN8
CH
EN
VCC
VCC
VCC
VCC
RPU
D Q
R
QDCOUNTER LOAD
OUT
IN
ESDPROTECTION
UNDER-VOLTAGELOCKOUT
OSC.
MAX6816MAX6817MAX6818
Figure 1. Block Diagram
1 2 10 GroundGND
MAX6816 MAX6817 MAX6818
Robust Switch InputsThe switch inputs on the MAX6816/MAX6817/MAX6818have overvoltage clamping diodes to protect againstdamaging fault conditions. Switch input voltages can safely swing ±25V to ground (Figure 3). ProprietaryESD-protection structures protect against high ESD encountered in harsh industrial environments,membrane keypads, and portable applications. They are designed to withstand ±15kV per theIEC1000-4-2 Air Gap Discharge Test and ±8kV per theIEC1000-4-2 Contact Discharge Test.
Since there are 63kΩ (typical) pull-up resistors con-nected to each input, driving an input to -25V will draw
approximately 0.5mA (up to 4mA for eight inputs) fromthe VCC supply. Driving an input to +25V will causeapproximately 0.32mA of current (up to 2.6mA for eightinputs) to flow back into the VCC supply. If the total sys-tem VCC supply current is less than the current flowingback into the VCC supply, VCC will rise above normallevels. In some low-current systems, a zener diode onVCC may be required.
±15kV ESD ProtectionAs with all Maxim devices, ESD-protection structuresare incorporated on all pins to protect against electro-static discharges encountered during handling andassembly. The MAX6816/MAX6817/MAX6818 haveextra protection against static electricity. Maxim's engi-neers have developed state-of-the-art structures to pro-tect against ESD of ±15kV at the switch inputs without
MA
X6
81
6/M
AX
68
17
/MA
X6
81
8
±15kV ESD-Protected, Single/Dual/Octal,CMOS Switch Debouncers
_______________________________________________________________________________________ 5
tDP
IN1
OUT1
IN2
OUT2
CH
MAX6818 ONLY
20ms/div
20V
0
-20V
4V
OUT(2V/div)
IN(20V/div)
0
tEN
OUT NORMALLYLOW
OUT NORMALLYHIGH
OUT1–OUT8
1/2 VCC 1/2 VCC
1/2 VCC
1/2 VCC
1/2 VCC
EN
tPE tPD
tPD
VOL + 0.5V
VOH - 0.5VtPE
tPC
OUT1–OUT8
CH
Figure 2. Input Characteristics
Figure 3. Switch Input ±25V Fault Tolerance
Figure 4. MAX6818 µP-Interface Timing Diagram
IN1
SW1
SW8IN8
+VCC
+VCC
µP
0.1µF
OUT1
OUT8
EN I/O
IRQ
D0
D7
CH
MAX6818
Figure 5. MAX6818 Typical µP Interfacing Circuit
MA
X6
81
6/M
AX
68
17
/MA
X6
81
8
±15kV ESD-Protected, Single/Dual/Octal,CMOS Switch Debouncers
_______________________________________________________________________________________ 7
meets Level 4 (the highest level) of IEC1000-4-2, with-out the need for additional ESD-protection compo-nents.
The major difference between tests done using theHuman Body Model and IEC1000-4-2 is higher peakcurrent in IEC1000-4-2, because series resistance islower in the IEC1000-4-2 model. Hence, the ESD with-stand voltage measured to IEC1000-4-2 is generallylower than that measured using the Human BodyModel. Figure 7a shows the IEC1000-4-2 model andFigure 7b shows the current waveform for the 8kV, IEC1000-4-2, Level 4, ESD Contact-Discharge test.
The Air-Gap test involves approaching the device with a charged probe. The Contact-Discharge method connects the probe to the device before the probe isenergized.
Machine Model The Machine Model for ESD tests all pins using a200pF storage capacitor and zero discharge resis-tance. Its objective is to emulate the stress caused bycontact that occurs with handling and assembly duringmanufacturing.
MAX6818 µP Interfacing The MAX6818 has an output enable (EN) input thatallows switch outputs to be three-stated on the µP databus until polled by the µP. Also, state changes at theswitch inputs are detected, and an output (CH) goes lowafter the debounce period to signal the µP. Figure 4shows the timing diagram for enabling outputs and read-ing data. If the output enable is not used, tie EN to GNDto “always enable’’ the switch outputs. If EN is low, CH isalways high. If a change of state is not required, leaveCH unconnected.
Pin Configurations (continued)
20
19
18
17
16
15
14
13
1
2
3
4
5
6
7
8
VCC
OUT1
OUT2
OUT3IN3
IN2
IN1
EN
TOP VIEW
OUT4
OUT5
OUT6
OUT7IN7
IN6
IN5
IN4
12
11
9
10
OUT8
CHGND
IN8
MAX6818
SSOP
GND
OUT2IN2
1 6 OUT1
5 VCC
IN1
MAX6817
SOT23-6
2
3 4
MAX6816 TRANSISTOR COUNT: 284
MAX6817 TRANSISTOR COUNT: 497
MAX6818 TRANSISTOR COUNT: 2130
SUBSTRATE CONNECTED TO GND
___________________Chip Information
SN54LS373, SN54LS374, SN54S373, SN54S374,SN74LS373, SN74LS374, SN74S373, SN74S374
OCTAL D-TYPE TRANSPARENT LATCHES AND EDGE-TRIGGERED FLIP-FLOPS
SDLS165B – OCTOBER 1975 – REVISED AUGUST 2002
1POST OFFICE BOX 655303 • DALLAS, TEXAS 75265
Choice of Eight Latches or Eight D-TypeFlip-Flops in a Single Package
3-State Bus-Driving Outputs
Full Parallel Access for Loading
Buffered Control Inputs
Clock-Enable Input Has Hysteresis toImprove Noise Rejection (’S373 and ’S374)
P-N-P Inputs Reduce DC Loading on DataLines (’S373 and ’S374)
description
These 8-bit registers feature 3-state outputsdesigned specifically for driving highly capacitiveor relatively low-impedance loads. Thehigh-impedance 3-state and increasedhigh-logic-level drive provide these registers withthe capability of being connected directly to anddriving the bus lines in a bus-organized systemwithout need for interface or pullup components.These devices are particularly attractive forimplementing buffer registers, I/O ports,bidirectional bus drivers, and working registers.
The eight latches of the ’LS373 and ’S373 aretransparent D-type latches, meaning that whilethe enable (C or CLK) input is high, the Q outputsfollow the data (D) inputs. When C or CLK is takenlow, the output is latched at the level of the datathat was set up.
The eight flip-flops of the ’LS374 and ’S374 areedge-triggered D-type flip-flops. On the positivetransition of the clock, the Q outputs are set to thelogic states that were set up at the D inputs.
Schmitt-trigger buffered inputs at the enable/clock lines of the ’S373 and ’S374 devices simplify system designas ac and dc noise rejection is improved by typically 400 mV due to the input hysteresis. A bufferedoutput-control (OC) input can be used to place the eight outputs in either a normal logic state (high or low logiclevels) or the high-impedance state. In the high-impedance state, the outputs neither load nor drive the bus linessignificantly.
OC does not affect the internal operation of the latches or flip-flops. That is, the old data can be retained or newdata can be entered, even while the outputs are off.
Copyright 2002, Texas Instruments Incorporated
Please be aware that an important notice concerning availability, standard warranty, and use in critical applications ofTexas Instruments semiconductor products and disclaimers thereto appears at the end of this data sheet.
SN54LS373,
SN74LS373 . . . DW, N, OR NS PACKAGE
SN74S373 . . . DW OR N PACKAGE(TOP VIEW)
3 2 1 20 19
9 10 11 12 13
4
5
6
7
8
18
17
16
15
14
8D7D7Q6Q6D
2D2Q3Q3D4D
SN54LS373, SN54S373,. . . FK PACKAGE
(TOP VIEW)
1D 1Q OC
5Q 5D8Q
4QG
ND C
V CC
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
OC1Q1D2D2Q3Q3D4D4Q
GND
VCC8Q8D7D7Q6Q6D5D5QC
C for ’LS373 and ’S373;
C for ’LS373 and ’S373;
PRODUCTION DATA information is current as of publication date.Products conform to specifications per the terms of Texas Instrumentsstandard warranty. Production processing does not necessarily includetesting of all parameters.
On products compliant to MIL-PRF-38535, all parameters are testedunless otherwise noted. On all other products, productionprocessing does not necessarily include testing of all parameters.
SN54LS373, SN54LS374, SN54S373, SN54S374,SN74LS373, SN74LS374, SN74S373, SN74S374
OCTAL D-TYPE TRANSPARENT LATCHES AND EDGE-TRIGGERED FLIP-FLOPS
SDLS165B – OCTOBER 1975 – REVISED AUGUST 2002
3POST OFFICE BOX 655303 • DALLAS, TEXAS 75265
Function Tables
’LS373, ’S373(each latch)
INPUTS OUTPUTOC C D Q
L H H H
L H L L
L L X Q0
H X X Z
SN54LS373, SN54LS374, SN54S373, SN54S374,SN74LS373, SN74LS374, SN74S373, SN74S374OCTAL D-TYPE TRANSPARENT LATCHES AND EDGE-TRIGGERED FLIP-FLOPS
SDLS165B – OCTOBER 1975 – REVISED AUGUST 2002
4 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265
logic diagrams (positive logic)
OC
for ’S373 Only
1
11
32
C
1D
C1
1D1Q
45
2D
C1
1D2Q
76
3D
C1
1D3Q
89
4D
C1
1D4Q
1312
5D
C1
1D5Q
1415
6D
C1
1D6Q
1716
7D
C1
1D7Q
1819
8D
C1
1D8Q
Pin numbers shown are for DB, DW, J, N, NS, and W packages.
OC
for ’S374 Only
1
11
32
CLK
1D
C1
1D1Q
45
2D 1D2Q
76
3D 1D3Q
89
4D 1D4Q
1312
5D 1D5Q
1415
6D 1D6Q
1716
7D 1D7Q
1819
8D 1D8Q
’LS373, ’S373Transparent Latches
’LS374, ’S374Positive-Edge-Triggered Flip-Flops
C1
C1
C1
C1
C1
C1
C1
µA7800 SERIESPOSITIVE-VOLTAGE REGULATORS
SLVS056G – MAY 1976 – REVISED OCTOBER 2001
1POST OFFICE BOX 655303 • DALLAS, TEXAS 75265
3-Terminal Regulators
Output Current up to 1.5 A
Internal Thermal-Overload Protection
High Power-Dissipation Capability
Internal Short-Circuit Current Limiting
Output Transistor Safe-Area Compensation
Direct Replacements for Fairchild µA7800Series
description
This series of fixed-voltage monolithicintegrated-circuit voltage regulators is designedfor a wide range of applications. Theseapplications include on-card regulation forelimination of noise and distribution problemsassociated with single-point regulation. Each ofthese regulators can deliver up to 1.5 A of outputcurrent. The internal current-limiting andthermal-shutdown features of these regulatorsessentially make them immune to overload. Inaddition to use as fixed-voltage regulators, thesedevices can be used with external components toobtain adjustable output voltages and currents,and also can be used as the power-pass elementin precision regulators.
The µA7800C series is characterized foroperation over the virtual junction temperaturerange of 0°C to 125°C.
AVAILABLE OPTIONS
PACKAGED DEVICES
TJVO(NOM)
(V)PLASTIC
FLANGE MOUNT(KC)
HEAT-SINKMOUNTED
(KTE)
5 µA7805CKC µA7805CKTE
8 µA7808CKC µA7808CKTE
0°C to 125°C10 µA7810CKC µA7810CKTE
0°C to 125°C12 µA7812CKC µA7812CKTE
15 µA7815CKC µA7815CKTE
24 µA7824CKC µA7824CKTE
The KTE package is only available taped and reeled. Add the suffix R to thedevice type (e.g., µA7805CKTER).
Please be aware that an important notice concerning availability, standard warranty, and use in critical applications ofTexas Instruments semiconductor products and disclaimers thereto appears at the end of this data sheet.
Copyright 2001, Texas Instruments IncorporatedPRODUCTION DATA information is current as of publication date.Products conform to specifications per the terms of Texas Instrumentsstandard warranty. Production processing does not necessarily includetesting of all parameters.
KC PACKAGE(TOP VIEW)
The COMMON terminal is in electricalcontact with the mounting base.
TO-220AB
OUTPUTCOMMONINPUT
KTE PACKAGE(TOP VIEW)
The COMMON terminal is inelectrical contact with the mountingbase.
OC
I
OUTPUT
COMMON
INPUT
OC
I
µA7800 SERIESPOSITIVE-VOLTAGE REGULATORS
SLVS056G – MAY 1976 – REVISED OCTOBER 2001
6 POST OFFICE BOX 655303 • DALLAS, TEXAS 75265
APPLICATION INFORMATION
+VO+V
0.1 µF0.33 µF
µA78xx
Figure 1. Fixed-Output Regulator
OUTING
–VO
COM
+
–
VI IL
µA78xx
Figure 2. Positive Regulator in Negative Configuration (VI Must Float)
R1
0.33 µF
Input OutputµA78xx
0.1 µF
IO
R2
VO Vxx Vxx
R1 IQR2
NOTE A: The following formula is used when Vxx is the nominal output voltage (output to common) of the fixed regulator:
Figure 3. Adjustable-Output Regulator
VO(Reg)R1
Input
IO
IO = (VO/R1) + IO Bias Current
0.33 µF
µA78xx
Output
Figure 4. Current Regulator
1
®
HIN232, HIN236, HIN237,HIN238,HIN239, HIN240, HIN241
FN3138.13Data Sheet June 2003+5V Powered RS-232 Transmitters/ReceiversThe HIN232-HIN241 family of RS-232 transmitters/receivers interface circuits meet all ElA RS-232E and V.28 specifications, and are particularly suited for those applications where ±12V is not available. They require a single +5V power supply (except HIN239) and feature onboard charge pump voltage converters which generate +10V and -10V supplies from the 5V supply. The family of devices offer a wide variety of RS-232 transmitter/receiver combinations to accommodate various applications (see Selection Table).
The drivers feature true TTL/CMOS input compatibility, slew-rate-limited output, and 300Ω power-off source impedance. The receivers can handle up to ±30V, and have a 3kΩ to 7kΩ input impedance. The receivers also feature hysteresis to greatly improve noise rejection.
Features• Meets All RS-232E and V.28 Specifications
• Requires Only Single +5V Power Supply- (+5V and +12V - HIN239)
• High Data Rate. . . . . . . . . . . . . . . . . . . . . . . . . . . 120kbps
• Onboard Voltage Doubler/Inverter
• Low Power Consumption
• Low Power Shutdown Function
• Three-State TTL/CMOS Receiver Outputs
• Multiple Drivers
- ±10V Output Swing for 5V lnput
- 300Ω Power-Off Source Impedance- Output Current Limiting
- TTL/CMOS Compatible
- 30V/µs Maximum Slew Rate
• Multiple Receivers
- ±30V Input Voltage Range- 3kΩ to 7kΩ Input Impedance
- 0.5V Hysteresis to Improve Noise Rejection
Applications
• Any System Requiring RS-232 Communication Ports- Computer - Portable, Mainframe, Laptop
- Peripheral - Printers and Terminals
- Instrumentation- Modems
Selection Table
PARTNUMBER
POWER SUPPLYVOLTAGE
NUMBER OF RS-232
DRIVERS
NUMBER OF RS-232
RECEIVERSEXTERNAL
COMPONENTS
LOW POWERSHUTDOWN/TTL THREE-STATE
NUMBER OF LEADS
HIN232 +5V 2 2 4 Capacitors No/No 16
HIN236 +5V 4 3 4 Capacitors Yes/Yes 24
HIN237 +5V 5 3 4 Capacitors No/No 24
HIN238 +5V 4 4 4 Capacitors No/No 24
HIN239 +5V and +7.5V to 13.2V 3 5 2 Capacitors No/Yes 24
HIN240 +5V 5 5 4 Capacitors Yes/Yes 44
HIN241 +5V 4 5 4 Capacitors Yes/Yes 28
CAUTION: These devices are sensitive to electrostatic discharge; follow proper IC Handling Procedures.1-888-INTERSIL or 321-724-7143 | Intersil (and design) is a registered trademark of Intersil Americas Inc.
Copyright © Intersil Americas Inc. 2003. All Rights Reserved.All other trademarks mentioned are the property of their respective owners.
HIN232, HIN236, HIN237, HIN238, HIN239, HIN240, HIN241
Pin Descriptions
PIN FUNCTION
VCC Power Supply Input 5V ±10%.
V+ Internally generated positive supply (+10V nominal), HIN239 requires +7.5V to +13.2V.
V- Internally generated negative supply (-10V nominal).
GND Ground lead. Connect to 0V.
C1+ External capacitor (+ terminal) is connected to this lead.
C1- External capacitor (- terminal) is connected to this lead.
C2+ External capacitor (+ terminal) is connected to this lead.
C2- External capacitor (- terminal) is connected to this lead.
TIN Transmitter Inputs. These leads accept TTL/CMOS levels. An internal 400kΩ pull-up resistor to VCC is connected to each lead.
TOUT Transmitter Outputs. These are RS-232 levels (nominally ±10V).
RIN Receiver Inputs. These inputs accept RS-232 input levels. An internal 5kΩ pull-down resistor to GND is connected to each input.
ROUT Receiver Outputs. These are TTL/CMOS levels.
EN Enable input. This is an active low input which enables the receiver outputs. With EN = 5V, the receiver outputs are placedin a high impedance state.
SD Shutdown Input. With SD = 5V, the charge pump is disabled, the receiver outputs are in a high impedance state and thetransmitters are shut off.
NC No Connect. No connections are made to these leads.
Ordering InformationPART
NUMBERTEMP.
RANGE (oC) PACKAGE PKG. DWG. #
HIN232CB 0 to 70 16 Ld SOIC M16.3
HIN232CB-T 0 to 70 Tape and Reel
HIN232CP 0 to 70 16 Ld PDIP E16.3
HIN232IB -40 to 85 16 Ld SOIC M16.3
HIN232IP -40 to 85 16 Ld PDIP E16.3
HIN236CB 0 to 70 24 Ld SOIC M24.3
HIN236IB -40 to 85 24 Ld SOIC M24.3
HIN237CB 0 to 70 24 Ld SOIC M24.3
HIN237CB-T 0 to 70 Tape and Reel
HIN238CB 0 to 70 24 Ld SOIC M24.3
HIN238CB-T 0 to 70 Tape and Reel
HIN238CP 0 to 70 24 Ld PDIP E24.3
HIN238IB -40 to 85 24 Ld SOIC M24.3
HIN239CB 0 to 70 24 Ld SOIC M24.3
HIN239CB-T 0 to 70 Tape and Reel
HIN239CP 0 to 70 24 Ld PDIP E24.3
HIN240CN 0 to 70 44 Ld MQFP Q44.10X10
HIN241CA 0 to 70 28 Ld SSOP M28.209
HIN241CB 0 to 70 28 Ld SOIC M28.3
HIN241IB -40 to 85 28 Ld SOIC M28.3
2
HIN232, HIN236, HIN237, HIN238, HIN239, HIN240, HIN241
Pinouts HIN232 (PDIP, SOIC)
TOP VIEW HIN236 (SOIC)
TOP VIEW
14
15
16
9
13
12
11
10
1
2
3
4
5
7
6
8
C1+
V+
C1-
C2+
C2-
R2IN
T2OUT
VCC
T1OUT
R1IN
R1OUT
T1IN
T2IN
R2OUT
GND
V-
T3OUT
T1OUT
T2OUT
R1IN
R1OUT
T2IN
T1IN
GND
VCC
C1+
V+
C1-
T4OUT
R2OUT
SD
EN
T4IN
R3OUT
V-
C2-
C2+
R2IN
T3IN
R3IN
1
2
3
4
5
6
7
8
9
10
11
12
16
17
18
19
20
21
22
23
24
15
14
13
VCC
+5V
2V+
16
T1OUT
T2OUT
T1IN
T2IN
T1
T2
11
10
14
7+5V
400kΩ
+5V400kΩ
R1OUT R1IN
R1
1312
5kΩ
R2OUT R2IN
R2
89
5kΩ
+10V TO -10VVOLTAGE INVERTER
NOTE 1
6 V-C2+
C2-
+NOTE 1
4
5
+5V TO 10VVOLTAGE DOUBLER
C1+
C1-
+NOTE 1
1
3+
NOTE 1
+
+1µF
15
NOTE:
1. Either 0.1µF or 1µF capacitors may be used. The V+ capacitor may be terminated to VCC or to GND.
9
VCC
+5V TO 10VVOLTAGE DOUBLER
+10V TO -10VVOLTAGE INVERTER
T1OUT
T2OUT
T3OUT
T4OUTT4IN
T1IN
T2IN
T3IN
T1
T2
T3
T4
+5V
+1µF
+1µF
+1µF
7
6
2
3
18 1
19 24
10
1211
15
V+
V-
C1+
C1-
C2+
C2-
+5V400kΩ
+5V400kΩ
+5V400kΩ
+5V400kΩ
+1µF
13
14
R1OUT R1IN
R1
45
5kΩ
R2OUT R2IN
R2
2322
5kΩ
R3OUT R3IN
R3
1617
5kΩ
EN20 21
SD
8
3
HIN232, HIN236, HIN237, HIN238, HIN239, HIN240, HIN241
Detailed DescriptionThe HIN232 thru HIN241 family of RS-232 transmitters/receivers are powered by a single +5V power supply (except HIN239), feature low power consumption, and meet all ElA RS-232C and V.28 specifications. The circuit is divided into three sections: The charge pump, transmitter, and receiver.
Charge PumpAn equivalent circuit of the charge pump is illustrated in Figure 1. The charge pump contains two sections: the voltage doubler and the voltage inverter. Each section is driven by a two phase, internally generated clock to generate +10V and -10V. The nominal clock frequency is 16kHz. During phase one of the clock, capacitor C1 is charged to VCC. During phase two, the voltage on C1 is added to VCC, producing a signal across C3 equal to twice VCC. During phase one, C2 is also charged to 2VCC, and then during phase two, it is inverted with respect to ground to produce a signal across C4 equal to -2VCC. The charge pump accepts input voltages up
to 5.5V. The output impedance of the voltage doubler section (V+) is approximately 200Ω, and the output impedance of the voltage inverter section (V-) is approximately 450Ω. A typical application uses 1µF capacitors for C1-C4, however, the value is not critical. Increasing the values of C1 and C2 will lower the output impedance of the voltage doubler and inverter, increasing the values of the reservoir capacitors, C3 and C4, lowers the ripple on the V+ and V- supplies.
During shutdown mode (HIN236, HIN240 and HIN241), SHUTDOWN control line set to logic “1”, the charge pump is turned off, V+ is pulled down to VCC, V- is pulled up to GND, and the supply current is reduced to less than 10µA. The transmitter outputs are disabled and the receiver outputs are placed in the high impedance state.
TIMING CHARACTERISTICS
Baud Rate (1 Transmitter Switching) RL = 3kΩ 120 - - kbps
Output Enable Time, tEN HIN236, HIN239, HIN240, HIN241 - 400 - ns
Output Disable Time, tDIS HIN236, HIN239, HIN240, HIN241 - 250 - ns
Propagation Delay, tPD RS-232 to TTL - 0.5 - µs
Instantaneous Slew Rate SR CL = 10pF, RL = 3kΩ , TA = 25oC (Note 4) - - 30 V/µs
Transition Region Slew Rate, SRT RL = 3kΩ , CL = 2500pF Measured from +3V to -3V or -3V to +3V, 1 Transmitter Switching
- 3 - V/µs
TRANSMITTER OUTPUTS
Output Voltage Swing, TOUT Transmitter Outputs, 3kΩ to Ground ±5 ±9 ±10 V
Output Resistance, TOUT VCC = V+ = V- = 0V, VOUT = ±2V 300 - - Ω
RS-232 Output Short Circuit Current, ISC TOUT shorted to GND - ±10 - mA
NOTE:
4. Guaranteed by design.
Electrical Specifications Test Conditions: VCC = +5V ±10%, TA = Operating Temperature Range (Continued)
PARAMETER TEST CONDITIONS MIN TYP MAX UNITS
+
-C1
+
-C3
+
-C2
+
-C4
S1 S2 S5 S6
S3 S4 S7 S8VCC GND
RCOSCILLATOR
VCC
GND
V+ = 2VCCGND
V- = -(V+)
C1+
C1- C2-
C2+
VOLTAGE INVERTERVOLTAGE DOUBLER
FIGURE 1. CHARGE PUMP
8
HIN232, HIN236, HIN237, HIN238, HIN239, HIN240, HIN241
TransmittersThe transmitters are TTL/CMOS compatible inverters which translate the inputs to RS-232 outputs. The input logic threshold is about 26% of VCC, or 1.3V for VCC = 5V. A logic 1 at the input results in a voltage of between -5V and V- at the output, and a logic 0 results in a voltage between +5V and (V+ -0.6V). Each transmitter input has an internal 400kΩ pullup resistor so any unused input can be left unconnected and its output remains in its low state. The output voltage swing meets the RS-232C specifications of ±5V minimum with the worst case conditions of: all transmitters driving 3kΩ minimum load impedance, VCC = 4.5V, and maximum allowable operating temperature. The transmitters have an internally limited output slew rate which is less than 30V/µs. The outputs are short circuit protected and can be shorted to ground indefinitely. The powered down output impedance is a minimum of 300Ω with ±2V applied to the outputs and VCC = 0V.
ReceiversThe receiver inputs accept up to ±30V while presenting the required 3kΩ to 7kΩ input impedance even if the power is off (VCC = 0V). The receivers have a typical input threshold of 1.3V which is within the ±3V limits, known as the transition region, of the RS-232 specifications. The receiver output is 0V to VCC. The output will be low whenever the input is greater than 2.4V and high whenever the input is floating or driven between +0.8V and -30V. The receivers feature 0.5V hysteresis to improve noise rejection. The receiver Enable line EN, when set to logic “1”, (HIN236, 239, 240, and 241) disables the receiver outputs, placing them in the high impedance mode. The receiver outputs are also placed in the high impedance state when in shutdown mode.
TOUT
V- < VTOUT < V+
300Ω400kΩ
TXIN
GND < TXIN < VCC
V-
V+
VCC
FIGURE 2. TRANSMITTER
ROUT
GND < VROUT < VCC5kΩ
RXIN
-30V < RXIN < +30V
GND
VCC
FIGURE 3. RECEIVER
TIN
VOL
VOLtPLHtPHL
Average Propagation Delay =tPHL + tPLH
2
ORRIN
TOUTOR
ROUT
FIGURE 4. PROPAGATION DELAY DEFINITION
9
HIN232, HIN236, HIN237, HIN238, HIN239, HIN240, HIN241
ApplicationsThe HIN2XX may be used for all RS-232 data terminal and communication links. It is particularly useful in applications where ±12V power supplies are not available for conventional RS-232 interface circuits. The applications presented represent typical interface configurations.
A simple duplex RS-232 port with CTS/RTS handshaking is illustrated in Figure 9. Fixed output signals such as DTR (data terminal ready) and DSRS (data signaling rate select) is generated by driving them through a 5kΩ resistor connected to V+.
In applications requiring four RS-232 inputs and outputs (Figure 10), note that each circuit requires two charge pump capacitors (C1 and C2) but can share common reservoir capacitors (C3 and C4). The benefit of sharing common reservoir capacitors is the elimination of two capacitors and the reduction of the charge pump source impedance which effectively increases the output swing of the transmitters.
-+
-+
-+
DTR (20) DATATERMINAL READYDSRS (24) DATASIGNALING RATE
RS-232INPUTS AND OUTPUTS
TD (2) TRANSMIT DATA
RTS (4) REQUEST TO SEND
RD (3) RECEIVE DATA
CTS (5) CLEAR TO SEND
SIGNAL GROUND (7)15
8
13
7
14
16
-+
6
R2 R1
T2
T1
9
12
10
11
4
5
3
1
HIN232
C11µF
C21µF
TD
RTS
RD
CTS
SELECT
+5V
INPUTS ANDOUTPUTS
TTL/CMOS
FIGURE 9. SIMPLE DUPLEX RS-232 PORT WITH CTS/RTS HANDSHAKING
2
FIGURE 10. COMBINING TWO HIN232s FOR 4 PAIRS OF RS-232 INPUTS AND OUTPUTS
-+
RS-232INPUTS AND OUTPUTS
DTR (20) DATA TERMINAL READY
DSRS (24) DATA SIGNALING RATE SELECT
DCD (8) DATA CARRIER DETECT
R1 (22) RING INDICATOR
SIGNAL GROUND (7)15
8
13
7
14
2
-+
4
R2 R1
T2
T1
9
12
10
11
3
1HIN232
C11µF
DTR
DSRS
DCD
R1
+5V
INPUTS ANDOUTPUTS
TTL/CMOS
-+
-+
TD (2) TRANSMIT DATA
RTS (4) REQUEST TO SEND
RD (3) RECEIVE DATA
CTS (5) CLEAR TO SEND8
13
7
14
15
R2 R1
T2
T1
9
12
10
11
4
53
1
HIN232C11µF
C21µF
TD
RTS
RD
CTS
INPUTS ANDOUTPUTS
TTL/CMOS
-+
5C21µF
16
C3
2µF6
26
V- V+-+
C4
2µF
16
11
Wireless Video Camera 208CV
LYD208CV (Wireless)
• Camera apparatus: 1/3, 1/4 picture sensor
• System: PAL/CCIR/NTSC/EIR ( Not multi system )
• Validity pixel: PAL: 628X582 or NTSC: 510X492
• Picture area: PAL:5.78X4.19mm or NTSC:4.69X3.45mm
• Horizontal definition: 380line
• Scan frequency: PAL/CCIR:50Hz or NTSC/EIA: 60Hz
• Miniumum illumination: 3LUX
• Sensitivity : +18DB=AGL NO-OFF
• Output power : 50MW / 300MB
• Output frequency : 0.9G / 1.2G
• Frequency control : adopt CPU frequency lock the wreath to control, with high
frequency stability.
• Transmission signal : Video Only
• Deliver the distance : 50-100M / 300-500M
• Voltage : DC+8V
• Current : 200mA
• Power consumption < or = 640MW
• Size : 25X35X15(mm)
Include Power Adapter 9V and 8V Input 110V or 220V
RC100
Manual-modulated receiver
• High receive sensitivity : +18DB
• Receive frequency : 0.9G/1.2G
• Receive signal : Video Only
• Voltage : DC 9V
• Current : 500mA
• Size : 115X60X20(mm)