SlideShare ist ein Scribd-Unternehmen logo
1 von 64
VISVESVARAYA TECHNOLOGICAL
UNIVERSITY
JnanaSangama, Belgaum-590014
A Project Report
On
“Closed Loop Motor Control using Attitude Heading Reference
System”
Submitted in Partial fulfillment of the Requirements for VIII semester
Bachelor of Engineering
in
Electronics & Communication Engineering
By
ESHAAN KUMAR 1AR09EC015
TEJAS S 1AR09EC043
SHILPA S 1AR09EC032
Under the Guidance of
Mrs. PADMAJA VIJAYKUMAR
Assistant Professor, Dept. of ECE
AIeMS
DEPARTMENT OF ELECTRONICS AND COMMUNICATION
ENGINEERING
AMRUTA INSTITUTE OF ENGINEERING &
MANAGEMENT SCIENCES
Near bidadi industrial Area, Bengaluru-562109
ACKNOWLEDGEMENT
“The satisfaction and euphoria that accompany the successful completion of any task would be
incomplete without the mention of the people who made it possible, whose constant guidance
and encouragement crowned my effort with success.”
I am extremely thankful to Aeronautical Development Establishment (ADE) and
Amruta Institute of Engineering & ManagementSciences (AIeMS) with its ideals and
inspirations for having provided me with the facilities, which made my project a success.
I earnestly thankMr. P.S.KRISHNAN, director, ADE and Dr.A.PRABHAKAR,
Principal, AIeMS, for providing me with congenial environment to work in, that helped in
completing this project.
I express my sincere thanks to Mr. A.M.G PILLAI Sc „F‟, Head, MST Division,
ADE and Mr. C.R.RAJAGOPAL, HOD, ECE, AIeMSfor their encouragement throughout
the demure of the project.
I express my heart full gratitude to my project guide Mr. R.SRINIVASANSc „F‟,
MST Division, ADE and college Internal guide Assit.Prof. PADMAJA VIJAYKUMAR,
ECE, AIeMS for their able guidance and valuable advice at every stage of my project, which
helped me in the successful completion of the project.
I express my gratitude to Mr. G.S.RAVINDRAN Sc „F‟, HRD, ADE for his
encouragement throughout the project.
I wish to express my solicit thanks to Mr. KASI.V.RaoSc ‟D‟, and Mrs. REVATHY
Sc‟D‟, MST Division, ADE for their guidance and important links.
I express my sincere thanks to Mrs. MAMATHA RANI and Mr.RAHUL RAI,
project co-ordinators, ECE, AIeMSfor their valuable guidance.
I am thankful to all the Staff of ADE, faculty members and non-teaching staff of ECE
Department, AIeMS for their kind co-operation.
I also wish to thank my friends for their encouragement. Last but not the least, I
would like to thank my parents and almighty for the support.
TEJAS.S (1AR09EC043)
B.V.V.Sangha‟s
AMRUTA INSTITUTE OF ENGINEERING AND
MANAGEMENT SCIENCES
Near Bidadi Industrial Area, Bengaluru– 562109
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING
CERTIFICATE
This is to Certify that the Project work entitled “Closed Loop Motor Control using Attitude
Heading Reference System”has been carried out by Tejas S (1AR09EC043)bonafide
student of Amruta Institute of Engineering & Management Sciences, in the partial
fulfillment of the requirements for the award of the degree in Bachelor of Engineering in
Electronics & communication Engineering under Visvesvaraya Technological
University, Belgaum during the academic year 2012-2013. It is certified that all
corrections/suggestions indicated for Internal Assessment have been incorporated in the
report deposited in the department library.
Mrs. PADMAJA VIJAY KUMAR Mr. C.R RAJAGOPAL
Dr.A.PRABHAKARAssistant Prof., Dept. of ECE Head of Department
Principal
AIeMS AIeMS AIeMS
Name of the Examiners: Signature and Date
1.
2.
ABSTRACT
State of art Attitude Heading Reference System (AHRS) using MEMS gyros are
being used worldwide to control UAV’s,using control actuators,the rudder,elevator etc. This
project deals with the design,development and demonstration of a closed loop actuation
system using AHRS and DC motor.
The system has been designed based on the AduC 7020 and external interfaces to
connect AHRS and a DC motor.AHRS software module have been validated using C.
Complete software code for the microcontroller including AHRS interface,realization of PI
controller etc have been written and validated.
The complete hardware has been realized and successfully demonstrated for the
closed loop performance which will be used for future projects of ADE.
TABLE OF CONTENTS
PAGE NO
1. INTRODUCTION 1
1.1 EVOLUTION 1
1.2 USER REQUIREMENTS 3
1.3 PROJECT OVERVIEW 4
2. ATTITUDE HEADING REFERENCE SYSTEM (AHRS) –
LITERATURE STUDY 5
2.1 SERIAL PORT CONFIGURATIONS 6
2.2 COMMUNICATIONS COMMANDS 6
2.3 PIN CONFIGURATION OF AHRS USED 7
2.4 DEVICE MODES 8
2.5 AHRS FORMAT IN SENDING THE SENSOR DATA 9
2.6 FLOATING POINT REPRESENTATION 9
2.7 FLOATING POINT CONVERSION EXAMPLE 10
3. AHRS CONFIGURATION 12
3.1 BAUD RATE SETTINGS 12
3.2 MODE SETTINGS 12
3.3 ROLL AND ANGULAR RATE COMMANDS 13
3.4 SUMMARY OF SETTING 14
4. HARDWARE DESIGN 15
4.1 HARDWARE DESIGN 15
4.2 CHOICE OF MICRO CONTROLLER 16
4.3 MICRO CONTROLLER SYSTEM DESIGN / AHRS CONTROL CARD 17
4.3.1 SYSTEM CLOCK 17
4.3.2 INPUT & OUTPUT PORTS 17
4.3.3 PARALLEL PORT 17
4.3.4 INTERRUPT SYSTEM 18
4.3.5 UART SERIAL INTERFACE AND RS232 DRIVER 18
4.3.6 POWER SUPPLY COMPATIBILITY FOR MICRO
CONTROLLER 19
4.3.7 ANALOG AND DIGITAL GROUND SCHEME 19
4.3.8 MONITORING POINTS 19
4.3.9 DAC 19
4.3.10 TERMINATION OF THE INPUTS AND OUTPUTS
FROM THE BOARD 19
4.4 SIGNAL CONDITIONER INTERFACE / LEVEL CONTROL CARD20
4.4.1 LEVEL SHIFTER DESIGN 20
4.4.2 VOLTAGE TO CURRENT AMPLIFIER DESIGN 21
4.4.3 MOTOR SELECTION 21
4.5 HARDWARE SUMMARY 22
5. SOFTWARE DESIGN 26
5.1 MICRO CONTROLLER REGISTER INITALIZATION 26
5.2 GENERAL PURPOSE IO PINS 26
5.3 BAUD RATE SETTING FOR UART SERIAL INTERFACE 27
5.3.1 SETTING OF DATA LENGTH 27
5.3.2 TRANSMISSION AND RECEPTION OF DATA 28
5.4 DAC SYSTEM 28
5.5 INTERRUPT SYSTEM 28
5.6 TIMERS 29
5.7 FLOATING POINT CONVERSION ALGORITHM 29
5.8 ANGLE REPRESENTATION FROM AHRS 33
5.9 READING THE PARALLEL PORT 33
5.10 PORTING DATA INTO DAC 34
5.10.1 COMPUTATION OF ERROR 34
5.10.2 SATURATION LOGIC 35
6. SOFTWARE FLOW CHART 36
6.1 OVERVIEW OF SOFTWARE PROGRAMMING 36
6.2 OVERALL FLOWCHART 37
7. RESULTS 41
7.1 RESULTS TAKEN DURING DEVELOPMENT 41
7.2 PROGRAPH OF THE HARDWARE SET UP 48
8. CONCLUSION AND FUTUREWORK 52
8.1 CONCLUSION 52
8.2 FUTURE WORK 52
REFERENCES
APPENDIX
LIST OF FIGURES
PAGE NO
Fig 1.1 Aircraft with variety of sensors 1
Fig1.2 Typical Mechanical Gyroscopes 2
Fig1.3 Principle axis of Rotation of an Aircraft 2
Fig1.4 Basic Block diagram arrived based on User Requirements 4
Fig2.1 Typical AHRS 5
Fig2.2 Pin configuration of AHRS 7
Fig4.1 Basic Block diagram based on User Requirements without using Microcontroller 15
Fig4.2 Basic Block diagram based on User Requirements using Microcontroller 15
Fig4.3 Basic Block diagram based on User Requirements using Microcontroller 16
Fig4.4 Level shifter circuit diagram 20
Fig4.5 V-I Converter circuit diagram 21
Fig4.6 The overall hardware structure 22
Fig4.7 The complete circuit diagram 23
Fig4.8 The detailed circuit diagram using DAC and SWITCH 24
Fig4.9 The circuit diagram of Level Shifter and VI converter 25
Fig5.1 Frame format 30
Fig5.2 Flowchart to find Sign bit 30
Fig5.3 Flowchart to find exponent part 31
Fig5.4 Flowchart to find mantissa part 32
Fig6.1 Overview of software programming 36
Fig6.2 Overall flowchart of project 38
Fig6.3 Flowchart of Call response mode routine 39
Fig6.4 Flowchart of AHRS read data routine 39
Fig6.5 Flowchart of Conversion routine 40
Fig6.6 Flowchart of PI controller routine K1 and K2 41
Fig7.1 Shows the AHRS o/p as seen on a DAC when it is manually rotated
from +/- 180 degrees. 42
Fig7.2 The update value from AHRS in every 10 msec 42
Fig7.3 The roll output of the AHRS on DAC. 43
Fig7.4 The output of the level shifter in the closed loop when seen on a oscilloscope 44
Fig7.5 The output of the Roll rate on DAC in the closed loop when seen
on a oscilloscope. 44
Fig7.6 The roll output of the AHRS on DAC for a step command of +90 deg 45
Fig7.7 The roll output of the AHRS on DAC for a step command of +157 deg 45
Fig7.8 The roll output of the AHRS on DAC for a step command of +45 deg 46
Fig7.9 The roll output of the AHRS on DAC for a step command of 0 deg 46
Fig7.10 The roll output of the AHRS on DAC for a step command of -45 deg 47
Fig7.11 The roll output of the AHRS on DAC for a step command of -90 deg 47
Fig7.12 The roll output of the AHRS on DAC for a step command of -157 deg 48
Fig7.13 The roll output of the AHRS on DAC for a step command of +67deg 48
Fig7.14 AHRS 3DM GX-25 49
Fig7.15 AHRS fitted along with the motor 49
Fig7.16 AHRS Control Card Design 49
Fig7.17 Level control card design 50
Fig7.18 Switch implementation on bread board 50
Fig7.19 Set up of the whole system and closed loop control 51
Fig7.20 Set up of the whole system and closed loop control 51
LIST OF TABLES
PAGE
NO
Table 2.1 Default serial port settings 6
Table 2.2 Command summary 7
Table 3.1 MODE Command 13
Table 3.2 EULER ANGLE Command 13
Table 3.3 EULER ANGLE and ANGULAR RATE Command 14
Table 4.1 Parallel port commands configuration 17
Table 5.1 Write sequence of PLLCON and POWCON 26
Table 5.2 GP1CON (Reading the parallel port1 data) 27
Table5.3 Values to be loaded in order to set baud rate of 115200 27
Table5.4 EULER ANGLES and ANGULAR RATES 29
Table 5.5 List of Commands 33
INTRODUCTION
1.1 EVOLUTION
Sensors and actuators are the basic hardware components that are essential in any
control systems. Sensors are used to sense or measure the state of the system, and actuators
are used to adjust the state of the system.
Fig 1.1 Aircraft with variety of sensors
An aircraft attitude determination and control system typically uses a variety of
sensors and actuator, because attitude is described by three or more attitude variables.
There are two basic classes of attitude sensors. The First class makes absolute measurements,
whereas the second class makes relative measurements.
Absolute measurement sensors are based on the fact that knowing the position of an
aircraft it is possible to compute the vector directions, these directions with respect to an
aircraft or body.
Relative measurement sensors belong to the class of gyroscopic instruments,
including the rate gyro and the integrating gyro. Classically, these instruments have been
implemented as spinning disks mounted on gimbals
Gyroscopes are physical sensors that detect and measure the angular motion of an
object relative to an inertial frame of reference. The term "Gyroscope" is attributed to the
mid-19th
century French physicist Leon Foucault who named his experimental apparatus for
Earth's rotation observation by joining two Greek roots: gyros - rotation and skopeein- to
see.The unique feature of gyroscopes is the ability to measure the absolute motion of an
object without any external infrastructure or reference signals. All gyroscopescan be divided
into two main categories, depending on whether the angular velocity or orientation is being
measured. Rate gyroscopesmeasure the angular velocity, or the rate of rotation of an object.
Angle gyroscopes also called Whole Angle or Rate Integratinggyroscopes, measure the
angular position, or orientation of an object directly.
Essentially all existing Micro-Electro-Mechanical-Systems (MEMS) gyroscopes are
of the rate measuring type and are typically employed for motion detection (for example, in
consumer electronics and automotive safety devices) and motion stabilization and control (for
example, in smart automotive steering and antenna/camera stabilization systems).
Gyroscopes allow untethered tracking of an object's angular motion and orientation
and enable standalone Heading Reference Systems (AHRS).
Fig 1.2 Typical Mechanical Gyroscopes
AHRS is a 3-axis Inertial Measurement Unit (IMU) combined with a 3-axis magnetic
sensor, and an onboard processor that creates a virtual 3-axis sensor capable of measuring
heading (yaw), pitch, and roll angles of an object moving in 3D space.
Fig 1.3 Principle axis of Rotation of an Aircraft
AHRS sensors were originally designed to replace the large traditional mechanical
gyroscopic aircraft flight instruments and provide better reliability and accuracy. Typically an
AHRS will consists of either a fiber optic (FOG) or MEMS 3-axis angular rate gyro triad, a
3-axis MEMS accelerometer, and a 3-axis magnetic sensor known as a magnetometer.
An Attitude & Heading Reference System (AHRS) is a self-contained system which
provides the pitch, roll and yaw angles as shown in figure 1.3
AHRS sensors are typically used in one of three ways. First of all they can be used as
an instrument to provide flight data recording of the orientation of the platform as a function
of time. Secondly an AHRS can be used for platform stabilization. The angular rate outputs
can be directly tied into a control loop to maintain platform stability. An AHRS can also be
used as an attitude control system. Aircraft, helicopters, quad-rotors, blimps, and even
underwater robotic vehicles all can benefit from the use of an AHRS to form a closed-loop
attitude control system. The angular rate outputs at a high bandwidth along with the estimated
orientation angles make it possible to command a platform directly with desired attitude
angles.
AHRS sensors are typically used in one of two ways. First of all they can be used as
an instrument to provide flight data recording of the orientation of the platform as a function
of time. Secondly an AHRS can be used for platform stabilization. The angular rate outputs
can be directly tied into a control loop to maintain platform stability.
The proposed project undertaken is to design, develop and demonstrate a closed loop
motor control using the AHRS sensor meeting the following user requirements.
1.2 USER REQUIREMENTS
The following are the requirements specified by the user
1. Hardware design based on ADuC 7020 microcontroller having the following
interfaces
a) UART port interface to AHRS the 3DM GX-25.
b) Parallel port interface to set different eight roll command inputs.
c) Analog output interface to control a motor.
2. Software using code to validate the working of AHRS for roll feedback and roll rate
feedback.
3. Microcontroller software to
a) Validate the working of AHRS.
b) Inclusion of PI controllers in inner and outer loops having provision to change
the proportional and integral time constant as desired.
c) Sample the data at an update rate of ~5msec.
4. Interface the motor including the design to the required voltage to current converter
and demonstrate the closed loop working of AHRS as a steering and stabilization
system.
1.3 PROJECT OVERVIEW
The project deals with design, development and demonstration of a closed loop
system using AHRS and DC motor.
Block schematic of the system is as shown in Figure-1.4
.
Fig 1.4 Basic Block diagram arrived based on User Requirements
The AHRS is capable of giving angle and rate outputs in roll axis, pitch axis and
heading. However, only roll angle and roll rate outputs from the AHRS is proposed to be
used to meet the user requirements.
ATTITUDE HEADING REFERENCE SYSTEM (AHRS)
– LITERATURE STUDY
AHRS is a 3-axis Inertial Measurement Unit (IMU) combined with a 3-axis magnetic
sensor, and an on-board processor that creates a virtual 3-axis sensor capable of measuring
heading (yaw), pitch, and roll angles of an object moving in 3D space. The user has indicated
the use of 3DM-GX3-25 AHRS. Literature study on this AHRS is given below.
The AHRS under study is from Micro strain. It has a fourth generation orientation
sensor core which has the following features.
1. 32-bit low power high performance processor
2. USB and serial UART host interface
3. 17 bit resolution on Gyros, Accelerometers, and Magnetometers
4. Full 1kHz Coning and Sculling integration
5. Cascaded adjustable FIR filters
6. Data rates of up to 1000Hz
7. Smallest and lightest full function 6-DOF orientation sensor
8. Fully calibrated and temperature compensated outputs
Fig 2.1 Typical AHRS
AHRS is an inertial sensor installation that outputs aircraft attitude, heading and flight
dynamics information to flight deck displays, flight controls, weather radar antenna platform
and other aircraft systems.
AHRS Comprises of Gyros, Accelerometers, and Magnetometers. Gyros are basically used to
measure the Rate of Rotation. Accelerometers are used to measure the Linear Acceleration.
Magnetometers are used to measure the Earth’s Magnetic Field.
2.1 SERIAL PORT CONFIGURATIONS
AHRS selected communicates with the external world [host computer] via an Rs232 serial
port having the following default serial port settings as given in Table2.1.
Baud Rate 115.2K
Parity None
Data Bits 8
Stop bits 1
RTS/CTS Disabled
Table 2.1 Default serial port settings
2.2 COMMUNICATIONS COMMANDS
AHRS can be controlled by the host computer controls by issuing one or more single
byte commands (in some cases, additional data bytes must follow the command byte). Most
commands will cause the AHRS to transmit a response of a fixed number of bytes.
AHRS can be commanded by Host computer in a continuous Mode so that AHRS
could continuously output a pre-selected data quantity without being prompted by the host.
AHRS can also be programmed to power-on directly into Continuous Mode without requiring
any host control.
Table 2.2 lists a summary of all commands available for the AHRS.
Table2.2 Command summary
2.3 PIN CONFIGURATION OF AHRS USED
Fig 2.2 Pin configuration of AHRS
RS 232 Pin 2
(Transmit)
RS 232 Pin 3 (
Receive)
RS232 Pin 5
(Ground) +5V
2.4 DEVICE MODES
AHRS operates in one of three modes Continuous, Active, or Idle.
ACTIVE MODE
In active mode, the AHRS has all sensors powered on and is performing continuous
sampling and data conditioning. The communications channel is open and the AHRS can
respond to any configuration, status, or data command. The host may issue any command at
any time. The sensor will not output unsolicited data records. The 3DM-GX3™ will respond
to data commands by outputting the corresponding data record. Multiple commands issued by
the host will be buffered on-board the device, with one being processed at the completion of
each successive sampling cycle.
CONTINUOUS MODE
In continuous mode, the AHRS will output a data record continuously with no further
action by the host. The data record output corresponds to the preset data command set by the
last call to Continuous Preset. The host computer must be capable of the buffering and
interpreting the data stream at sufficient speed to prevent loss of data.
Once continuous mode is set, it will remain in effect until it is terminated by issuing a
different Mode command or the power to the device is interrupted. An alternate single byte
command, Set Continuous Mode, can be used to start continuous mode. This command does
not change the continuous preset value.
An alternate single byte termination command, Stop Continuous Mode, may be used
to stop the continuous mode and put the sensor into active mode. The benefit of this
command is that it does not generate a response packet. This can be advantageous where the
introduction of a response packet in the middle of a data stream can cause a parser to get out
of sync with the stream.
Although the AHRS will still act on and respond to all other commands while in
continuous mode, it is better to change to active or idle mode before doing configuration
commands. This makes it easier for the host to parse the incoming stream of response
packets.
IDLE MODE
The idle mode is the same as the active mode in that the AHRS will respond to any
configuration, status, or data command. However, in the idle mode, the sensors are turned off
and data commands return invalid sensor data. For raw data, the values will just be
undetermined. This mode is useful when doing configuration on a battery powered system
and you need to minimize the power consumption. Idle mode draws approximately one half
of the current compared to active mode.
2.5 AHRS FORMAT IN SENDING THE SENSOR DATA
The sensor data say Roll angle and roll rate from AHRS is transmitted Euler angles which is
in the IEEE-754 floating point format. The IEEE – 754 format of representation is as follows.
The IEEE-754 format is aSingle precision floating point format in which a computer
number occupies 4 bytes (32 bits) in computer memory and represents a wide dynamic range
of values.
Single-precision binary floating-point is used due to its wider range over fixed point
(of the same bit-width), even if at the cost of precision.
This gives from 6 to 9 significant decimal digits precision (if a decimal string with at
most 6 significant decimal is converted to IEEE 754 single precision and then converted back
to the same number of significant decimal, then the final string should match the original; and
if an IEEE 754 single precision is converted to a decimal string with at least 9 significant
decimal and then converted back to single, then the final number must match the original)
2.6 FLOATING POINT REPRESENTATION
The IEEE 754 standard specifies a binary32 as having:
1. Sign Bit: 1 Bit.
2. Exponent Width: 8 Bits.
3. Mantissa/ Significant Precision: 23 Bits
Sign bit determines the sign of the number, which is the sign of the significant as well.
Exponent is either an 8 bit signed integer from −128 to 127 (2's Complement) or an 8 bit
Unsigned integer from 0 to 255 which is the accepted base forms in IEEE 754 32 bit
definition. For this case an exponent value of 127 represents the actual zero.
The true significant includes 23 fraction bits to the right of the binary point and an
implicit leading bit (to the left of the binary point) with value 1 unless the exponent is stored
with all zeros. Thus only 23 fraction bits of the significant appear in the memory format but
the total precision is 24 bits (equivalent to log10(224
) ≈ 7.225 decimal digits).
The bits are laid out as follows:
1 Bit 8 Bits 23 Bits
The data obtained from AHRS will be in IEEE-754 Format as shown above. Hence in
order to understand we convert this data in IEEE-754 Format to Decimal Format, Which is
done using the Conversion formula,
2.7 FLOATING POINT CONVERSION EXAMPLE
1Bit 8Bits 23Bits
SIGN
1. Here the value of Sign Bit S=0.
Hence the number is Positive.
2. Here the value of Exponent E is given by E = 01111110 b = 126 d
e = E -127 = -1
3. Fractional part of Mantissa M is given by
M = 10000000000000000000000 (23 bits) = 0.5 d
By substituting the values of S , E and M in the below equation, we get the converted
decimal value.
In the above example N= 0.75d
AHRS CONFIGURATION
The detailed description of the AHRS configuration used in the project is given below
3.1 BAUD RATE SETTINGS
Thefollowingbaud rate setting of the AHRS isused in the project to improve upon the
speed of transmission. Care has been taken in the choice of the baud rate to match with the
capability of the microcontroller suggested by the user
Baud rate 115.2K
Parity None
Data Bits 8
Stop Bits 1
3.2 MODE SETTINGS
AHRS operates in various modes i.e., in active, continuous, idle mode, hence it is
necessary to set the AHRS in particular mode for its proper operation. The default mode of
AHRS is Active mode; however the mode is set into Active mode by command to eliminate
the possibility in sensing wrong information from the AHRS. The command used to change
mode of operation of AHRS called as MODE command. This command packet is sent to the
AHRS from the Host PC.
MODE command is as shown in Table 3.1
The user has to transmit four bytes of commands to AHRS. The AHRS responds by a
response packet which is used to confirm that the mode is set in Active mode only.
Continuous mode is not opted in the particular application, as it is preferred to acquire
the particular data packet each time only when a packet of data has been requested i.e., at a
particular update rate/ predefined rate of 5m sec as per user requirements.
Check sum which is the sum of Byte1 and byte 2 is used to declare the correct
response for the command given.
Function: Putthe 3DM-GX3™ into new mode or read current mode.
Command:
Byte1 0xD4
Byte2 0xA3(Confirms user intent)
Byte3 0x47(Confirms user intent)
Byte4 Modeselector:
0:No mode change: just read current mode
1:Put in Active mode (default)
2:Put in Continuous mode (use Continuous Preset
first)
3:Put in Idle mode
4:Put in Sleep mode
5:Put in Deep Sleep mode
Response:
Byte1 0xD4
Byte2 Currentor new mode
Bytes3-4 Checksum
Table 3.1 MODE Command
3.3 ROLL AND ANGULAR RATE COMMANDS
AHRS provides the sensor information in EULER ANGLES by setting a command
0xCE or information of EULER ANGLES and ANGULAR RATES by setting up a
command 0xCF through the host PC. The response is the data packet sent from the AHRS.
Data format is as shown in Table 3.2
Euler Angles (0xCE)
Function: The3DM-GX3™ will output a data record containing Euler
Angles.
Command:
Byte1 0xCE
Function: The3DM-GX3™ will output a data record containing Euler
Angles.
Response:
Byte1 0Xce
Bytes2-5 Roll (IEEE-754Floating Point)
Bytes6-9 Pitch (IEEE-754Floating Point)
Bytes10-13 Yaw (IEEE-754Floating Point)
Bytes14-17 Timer
Bytes18-19 Checksum
Table 3.2 EULER ANGLE Command
A part of the requirement i.e. EULER ANGLES is only satisfied by this command,
hence not preferred.
EulerAngles and Angular Rates (0xCF)
Function: The3DM-GX3™ will output a data record containing Euler
Anglesand AngularRates.
Command:
Byte1 0xCF
Function: The3DM-GX3™ will output a data record containing Euler
Anglesand AngularRates.
Response:
Byte1 0xCF
Bytes2-5 Roll (IEEE-754Floating Point)
Bytes6-9 Pitch (IEEE-754Floating Point)
Bytes10-13 Yaw (IEEE-754Floating Point)
Bytes14-17 AngRateX (IEEE-754Floating Point)
Bytes18-21 AngRateY (IEEE-754Floating Point)
Bytes22-25 AngRateZ (IEEE-754Floating Point)
Bytes26-29 Timer
Bytes30-31 Checksum
Table 3.3 EULER ANGLE and ANGULAR RATE Command
As both the Angle and Angular rates are required from the AHRS, the command 0XCF is
initiated to obtain this information from the sensor. Check sum i.e. sum of byte1 to byte 29 is
used to check the correctness of the data received from AHRS. Roll angle and roll rate from
this command are used as per user requirements.
3.4 SUMMARY OF SETTING
1. The Baud rate set for AHRS is the default 115.2K baud rate.
2. During power ON, AHRS is set in Active Mode (by default) by sending four bytes
Command (0xd4, 0xA3, 0x47, 0x01). and ensure that the mode is set by checking its
response
3. Command of Command Euler angles and Angular Rates (0xCF) is used in order to
read the Roll angle and Roll rate every 5m sec update rate.
4. Data from AHRS to acquire roll angle and roll rate [Euler angles and Angular
Rates]is read once in every 5m sec
HARDWARE DESIGN
4.1 HARDWARE DESIGN:
The hardware design to design the system to meet the user requirements is given in this
section.
The block schematic of the system required to be implemented in the hardware is as shown in
Figure-4.1
Fig4.1 Basic Block diagram based on User Requirements without using Microcontroller
The modified block schematic highlights the blocks that could be implemented in the
hardware to meet the requirements given in Figure-4.2 given below.
Fig4.2 Basic Block diagram based on User Requirements using Microcontroller
Fig4.3 Basic Block diagram based on User Requirements using Microcontroller
4.2 CHOICE OF MICRO CONTROLLER
Micro controller is required to have the following interfaces
1. One Serial RS 232 interface to connect it to AHRS
2. 8 bit parallel port interface to set the roll command
3. DAC to convert the data into analog form to interface with a motor
Choice of the controller is also based on the processing capability / speed to execute the
compensators every 5m sec interval. Micro controller ADuC7020 from M/s Analog Devices
has been selected as it has all the interfaces required in the project and has the computational
speed capability as given by the user. More over the same micro controller IC is available in
the laboratory with all the support tools required, hence this micro controller is selected.
ADuc 7020 Micro controller has the following features:
1. The ADuC7020 devices operate from an on-chip oscillator and a PLL generating an
internal high frequency clock of 41.78MHz.
2. The micro-controller core is an ARM7TDMI, 16bit / 32bit RISC machine, which
offers up to 41MIPS per performance.
3. 8K bytes of SRAM and 62K bytes of non-volatile Flash/EE memory are provided on-
chip. Hence no external memory is needed for storing the program.
4. General Purpose Timer: Timer is general-purpose, 32bit timer with a programmable
prescale. The source can be the 32 KHz external crystal, the core clock frequency, or
an external GPIO, P1.0 or 0.6.
4.3 MICRO CONTROLLER SYSTEM DESIGN / AHRS
CONTROL CARD
4.3.1 SYSTEM CLOCK:
The system clock in the Micro controller is routed through a programmable clock
divider from which the MCU core clock operating is generated. An external clock of 32.768
KHz is connected to the micro controller which enables the micro controller to operate at a
core clock frequency of 41.78 MHz
4.3.2 INPUT & OUTPUT PORTS:
The ADuC720 provide 40 general purpose, bidirectional I/O (GPIO) pins. Many of
the GPIO pins have multiple functions. GIPO pins are used for synchronization of data in
serial communication. They are also use to control the display functions and give display
inputs.
4.3.3 PARALLEL PORT
Micro controller aduc7020 has 5 ports each of 8 bits which can be configured. IN the
present system design three input lines from Port 1 are used. The port is configured so that
the roll command can be switched to a particular value based on the switch position of Port
numbers 1.2, 1.3, 1.4 are used in the design. The following are the roll commands chosen
arbitrary based on the three bit positions
P(1.4) P(1.3) P(1.2) Angle(in degree)
0 0 0 157
0 0 1 90
0 1 0 45
0 1 1 0
1 0 0 -45
1 0 1 -90
1 1 0 -157
1 1 1 67
Table 4.1Parallel port commands configuration
4.3.4 INTERRUPT SYSTEM:
There are 23 interrupt sources on the ADuC7020, which are controlled by the
interrupt controller. Four additional interrupt sources are generated from external interrupt
request pins, IRQ0, IRQ1, IRQ2 and IRQ3.
In the present design no external interrupts are proposed to be used. Internal timer interrupts
and Serial communication transmitter and receiver interrupts are only to be used.
Timer-0 interrupt is used to interrupt the system in every 5 sec to acquire/ process and control
the motor using DAC.
The serial interrupts can be used to command the AHRS i,e, transmit serial interrupt can be
used when a command to AHRS to be sent i,e command AHRS to send Roll and roll rate
angles Receive serial interrupt can used to receive every byte of data sent by AHRS.
However this serial interrupt mechanism is not restored in the present design but polling
mechanism for the status bit is resorted to due to ease in its implementation Interrupt mode
option has been kept as an option if the job cannot be completed within the execution time of
5m sec.
4.3.5 UART SERIAL INTERFACE AND RS232 DRIVER:
ADUC 7020 micro controller has a single UART port. A UART peripheral is a full-
duplex, universal, asynchronous receiver/transmitter. It is fully compatible with the 16,450
serial port standards. The UART performs serial-to-parallel conversions on data characters
received from a peripheral device or modem, and parallel to serial conversions on data
characters received from the CPU
UART port is used to AHRS sensor. As the serial output from Micro controller is
LTLL 0 to 3.3V. A level translator is required to be used to make it compatible with RS 232
standards i.e m signal from +/- 12 V. Hence a Level translator IC has been used for this
purpose. Available ICADM3202ARNZ (U9) has been chosen and used for this purpose
which meets this requirement.
4.3.6 POWER SUPPLY COMPATIBILITY FOR MICRO
CONTROLLER:
The power input to the micro controller is + 5 V DC inputs. As the microcontroller
operates in 3.3 V, a voltage regular driver is required to be used. ADP3333-3.3RL7, voltage
regulator, which takes 5V-DC as input and provides an output of 3.3V-DC.ADuC720 has
been selected and used. Required decoupling capacitors for all the components are also used
in the design. A transient absorber is also used in the design to above the transients on the
5V line
4.3.7ANALOG AND DIGITAL GROUND SCHEME:
It is necessary to isolate the Digital ground of the digital peripherals with the analog
section. To isolate this inductor of the order of 10 µH is used.
4.3.8 MONITORING POINTS:
As AHRS is an important sensor used in the project, to monitor the functioning of the
AHRS on say an oscilloscope the outputs of AHRS are terminated on a Connector. Jumper
J1 FTSH-105-01-L-DV is used for this purpose.
4.3.9 DAC:
ADuC Microcontroller has internally four DAC with it. The signal level from this DAC is
from 0 to 2.5 V. Same DAC from the micro controller is proposed to be used.
The ADuC DAC outputs are terminated to the external world using a buffer. A four channel
analog Buffer IC is used to interface with the four DAC outputs from Micro controller.
Buffer AD8064 IC is used for this purpose.
4.3.10TERMINATION OF THE INPUTS AND OUTPUTS FROM THE
BOARD:
All the necessary Inputs and outputs that are required to control the motor / AHRS are
terminated on a 30 pin connector. Available connector TFM is used for this purpose.
4.4 SIGNAL CONDITIONER INTERFACE / LEVEL
CONTROL CARD
The ADUC microcontroller has DAC which provides signal in the voltage range of 0
to 2.5 V. The DAC is required to drive / control a motor in both directions in a closed
loop. Hence a suitable level shifter to swing the voltage from 0 to 2.5 V to +/- 5 V has
been designed.
4.4.1 LEVEL SHIFTER DESIGN:
An operation amplifier is used to shift the level. OPa 07 a low noise amplifier has
been selected in the design. Basically the level shifter is a summer opamp. Description is
given belw.
Fig 4.5 Level shifter circuit diagram
Applying KCL (Kirchoff’s Current Law) to the circuit shown below
+ = (1)
= - (2)
Proper choice of components such as resistors (R1, R2, Rf) to shift the output voltage level
from 0 to 2.5 V to +/- 5 V
Value of V2 has been fixed at -5 V and resistor Rf = 4KΩ, R1 = 4KΩ,R2 = 4KΩ.
This results in level shifted output of +/- 5V for input V1 varying from 0 to 2.5 V
4.4.2 VOLTAGE TO CURRENT AMPLIFIER DESIGN:
Motor requires controlled current to be driven at a required RPM. Voltage from the level
shifter is converted to appropriate current input to the motor using a V to I converter.
A V to I converter is designed using a power amplifier OPA 501. Typical V to I converter is
given below.
Fig 4.4V-I Converter circuit diagram
= (3)
I = I1 – I2 (4)
(5)
I = (6)
When both Level shifter and V to I converter are connected together then output of level
shifter is nothing but input to the V to I converter.
4.4.3 MOTOR SELECTION:
A geared motor having sufficient torque has been chosen in our application. Swiss make
Mini motor SA has been used. This motor selected requires a maximum current of 100mA
when operated from a voltage up to 5 V. V to I converter has been designed such that the
required current is supplied.
The resistance values chosen are R4 = 470Ω, R5 = 1KΩ, R6= 100Ω
A current limit is also required to be added in any V to I converter design. The current
limiting resistor value is chosen as per the equation Ilim= which works out to be
4.7Ω considering the max current requirement to the motor of 100mA.
4.5 HARDWARE SUMMARY
Block schematic with the interface of the designed cards are as shown in figure.
1. AHRS is connected to the AHRS control card via the J2 connector pin numbers
19[AHRS transmit/ Microcontroller receive], pin number 20[AHRS receive/
microcontroller transmit]and common ground pin number 3 on J2 connector.
2. Micro controller DAC 1 [ pin number 6 of J2 connector ] connected to T1 of the level
control card and ground[ J2 connector pin number 3 ] to T3
3. DAC2 [pin number 7 of J2 connector] to oscilloscope to observe any waveform if
any.
4. Motor between T3 and T4 of the level control card.
Fig 4.6 The Overall Hardware Structure
Fig 4.7The complete circuit diagram
Fig 4.8The detailed circuit diagram using DAC and SWITCH
Fig 4.9The circuit diagram of Level Shifter and VI converter
SOFTWARE DESIGN
5.1 MICRO CONTROLLER REGISTER INITALIZATION
During power on of the micro controller the following registers are required to be initialized
PLLKey1 followed by the PLLCON register and then followed by PLLKEY2
PLLCON (Programmable Loop Logic Control): Controls the operating mode (Active
mode)
POWCON (Power Control Register): Controls the core clock frequency and power down
mode.
PLLCON value has initialized to 0x21 there by setting the PLL in the default configuration.
In this configuration the internal clock is initialized
1. Next the POWCON key is initialized by POWKEY1 = 0x01, POWCON and
POWKEY2/POWCON register is used to control the mode and set the clock
frequency. (POWCON register is set in active mode and set a clock frequency of
41.78 MHz by setting POWCON register to 00)
2. To be precisePLLCON and POWCONare written using the sequence.
PLLCON POWCON
PLLKEY1 = 0xaa POWKEY1 = 0x01
PLLCON = 0x21 POWCON = 0x00
PLLKEY2 = 0x55 POWKEY2 = 0xF4
Table 5.1 Write sequence of PLLCON and POWCON
5.2 GENERAL PURPOSE IO PINS
The ADuC 7020 provides 40 General Purpose bi-directional I/O pins. Many of the
GPIO pins have multiple functions.
In the present application GP1CON control register is set to 0x0000001 which initialise the
following port pins as given below
PIN VALUE NAME REASON
P1.0 10 SIN Configure as serial input port [for microcontroller from AHRS ]
P1.1 10 SOUT Configure as serial output port [ for AHRS from microcontroller
P1.2 00 GPIO Configure as input port
P1.3 00 GPIO Configure as input port
P1.4 00 GPIO Configure as input port
Table 5.2 GP1CON (Reading the parallel port1 data)
The data from the parallel port1 is used to read the switch positions by reading the register
GP1DAT.
5.3 BAUD RATE SETTING FOR UART SERIAL INTERFACE
Micro controller is programmed such that the transmission and reception from /to AHRS is at
a baud rate of 115200. Micro controller is hence required to set registers COMCON0,
COMDIV0,COMDIVI and COMDIV2.It is required to generate the precise baud rate by
using modes termed as normal mode and fractional mode
COMCON0 0x80
COMDIV0 0x0B
COMDIV1 0x00
COMDIV2 0x883E
Table 5.3Values to be loaded in order to set baud rate of 115200
The following data has been initialized in the following registers to set the baud rate to
115200. The error has been reduced to 0% by using the fractional baud rate when compared
to 3 % if used only with normal baud rate.
5.3.1 SETTING OF DATA LENGTH
Data length is set by initialising the COMCON0 Register to design the size of the information
packets to be transmitted.
COMCON0 register has been initialised to a value of 0x83 which enables data transmission
of 8 bits, 1 start bit, one stop bit and no parity.
5.3.2 TRANSMISSION AND RECEPTION OF DATA
a. The data to be transmitted is loaded in the COMTX register so that data as initialized via
COMCON0 register can be transmitted [to AHRS].
b. The received data will be available in the COMRX register [from AHRS].
c. The next data to be transmitted is initiated by checking the status of THRE bit of the
COMSTAT0 register.
d. The data to be read is initiated by checking the status of DR(Data Ready) bit of the
COMSTAT0 register.
5.4 DAC SYSTEM
The ADuC 7020 incorporates four, 12 – bit voltage output resistor string DAC’s on-
chip. Each DAC has three selectable ranges: 0 V to VREF, 0 V to DACREF and 0 V to AVDD.
Each DAC is independently configurable through a control register (DACxCON) and
a data register (DACxDAT). The two registers are identical for the four DAC’s.
DAC1CON and DAC2CON control register used DAC which are set to value 0X12.
There by Enabling the DACto work in normal mode of operation and set the output voltage in
the range from 0 to 2.5V [VREF voltage].
Data to be load for DAC operation is loaded in the register DAC1DAT (bits 27 to 16)
for Output on DAC1
It is necessary to set the reference voltage to a reference valueie. VREF 2.5V, this is
accomplished by loading 0x01 in REFCON register.
5.5 INTERRUPT SYSTEM
No external interrupts are proposed to be used in the design. Only internal timer interrupt
(timer 0) is required to be initialized.
Before initializing any interrupt, the interrupt is initialized using IRQEN register. Timer 0
interrupt is enabled by loading the value of 0x 00000004 in IRQEN register
5.6 TIMERS
The ADuC7020 has four general purpose Timer/Counters:Timer0, Timer1, Timer2 or Wake-
up Timer. Only Timer 0 is used in the project.
1. Timer0 is configured in periodic mode where the counter
decrements/increments from the value in the Load Register (T0LD MMR)
until zero/full scale and starts again at the value stored in the Load Register. .
The value loaded in T0LD register for timer0 is 0x0330 considering the source
clock frequency of 41.78MHz and interval is 5m sec and pre scale chosen to
be 256.
2. The pre scale is set to 256 and timer 0 enable in periodic mode by loading
value of 0x 00C8 to the TCON register.
3. It is necessary to clear the timer 0 interrupt after each execution. This is
accomplished by writing any value say 0xFF in T0CLRI register.
Reading the AHRS data:
The AHRS is commanded in Active mode and the 32 bytes of data are read by the
microcontroller. The flow diagram is given in figure-
5.7 FLOATING POINT CONVERSION ALGORITHM
The AHRS gives a 32 byte of data which are IEEE- 754 floating point format.
Function: The3DM-GX3™ will output a data record containing Euler
Anglesand AngularRates.
Response:
Byte1 0xCF
Bytes2-5 Roll (IEEE-754Floating Point)
Bytes6-9 Pitch (IEEE-754Floating Point)
Bytes10-13 Yaw (IEEE-754Floating Point)
Bytes14-17 AngRateX (IEEE-754Floating Point)
Bytes18-21 AngRateY (IEEE-754Floating Point)
Bytes22-25 AngRateZ (IEEE-754Floating Point)
Bytes26-29 Timer
Bytes30-31 Checksum
TABLE 5.4 EULER ANGLES and ANGULAR RATES
As an example, let us consider there are four bytes say (2 to 5) i.e. 32 bits that is
received from AHRS which is in IEEE-754 format which consists of sign, exponent and
mantissa
Fig 5.1 Frame format
In order to convert the received data from AHRS that is in IEEE-754 format to normal
Decimal value four main steps are used. The first job is to separate the S E and M bits from
the 32 bit data received. Once these values are obtained, the angle information [say roll angle
from AHRS] is converted into decimal format by using the formula
(7)
STEP 1: TO FIND S
To find Sign bit(S), as only the MSB bit of array is required a[3], Masking is done by
for the remaining 7bits by multiplying a[3] with 0x80 and later shift by right shift by 7
position to get value of S
Flow diagram is as given below
a[3] a[1]a[2] a[0]
Fig 5.2Flowchart to find Sign bit
STEP2: TO FIND E
To get the exponent value, it is noted that the value is stored in 2 bytes, i.e. some part in a[3]
and some part in a[2].
In the array a[3], as only 7bits are required, masking is done by multiplying a[3] with
0x7F and later left shift it by 1bit position and stored as d1.
Similarly in order to get 1st
bit of a[2], the data is masked by multiplying a[2] with
0x80 and later right shift it by 7bit positions and stored as d2.
The two byte d1 and d2 available are combined together making it as a single byte to
get the value of exponent (e) by performing Logical OR operation.
Flow diagram is as given below
Fig 5.3Flowchart to find exponent part
Then we subtract exponent value e with 127 and store it as e.
STEP 3: TO FIND M and N
Flow diagram is as given below:
Fig 5.4Flowchart to find mantissa part
1. Only last 7 bits of a[2] is required. The data is obtained by masking a[2] with 0x7F.
This is stored in t.
2. To get the mantissa value after the decimal point the value if it is added with 0x80.
a. If e value is negative, then eis multiplied with -1 and again stored it in e. t
value is right shifted by e position and store it in fb.
b. Else if e value is positive, then the value of tis left shifted by e positions and
stored in fb. If the value of sign bit (s) is 1, then fb is multiplied with -1.
c. The value stored in fb is in decimal form. i.e., to convert the value into
decimal value in degrees, the fbvalue is multiplied with 57.3 and 0.087.
d. Here fb value is the N value [say roll angle data in degrees].
This may be noted that shift operation is performed instead of power operation as
given in equation 7.
5.8 ANGLE REPRESENTATION FROM AHRS
AHRS data obtained as fb from the AHRS is a 32 bit data which is equal to 0 to 360 degrees.
To be precise the value contained in hex is
FFFFF800 for -180 deg
00000000 for 0 deg
0000007FF for +180 deg
DAC provided on the microcontroller is a 12 bit DAC and has an o/p voltage range from 0 to
2.5 Volts.
Hence the 32 bit angular data is to be reduced to 12 bit data by shifting this data to right by
16 bits.
5.9 READING THE PARALLEL PORT
Input commands are read using Port 1 ie.,port 1.2, 1.3, 1.4 using GP1DAT register.
Based on the bit positions the following roll command angles are derived as follows.
P(1.4) P(1.3) P(1.2) Angle(in degree) Command
0 0 0 157 0x6FF
0 0 1 90 0x3FF
0 1 0 45 0x1FF
0 1 1 0 0
1 0 0 -45 0xFFFFFE03
1 0 1 -90 0xFFFFFBFF
1 1 0 -157 0xFFFFF900
1 1 1 67 0x2FF
Table5.5 List of Commands
Hex value for the command is matched to the roll angle value command as described in the
explained in section5.8.
5.10 PORTING DATA INTO DAC
It is necessary to read the roll value on a DAC port for monitoring purpose. For
monitoring, data is loaded on DAC2DAT register having a value ranging from 000 to FFF.
As the data coming from AHRS is having a negative value which cannot be loaded to the
DAC, the AHRS value is offset by a value of 0x7FFi.e., The value of Roll -180 would
become 0 and value of 0 deg angle becomes 7FF, and value +180deg becomes FFF.
The DAC loaded with a value of 0 gives 0 V and the DAC loaded with vale of FFF gives 2.5
V as discussed in the hardware sections. Hence an analog value of 0 volts corresponds to -
180 deg and DAC analog value of 2.5 corresponds to +180 degrees.
5.10.1 COMPUTATION OF ERROR
The roll command as determined based on the switch positions, is subtracted from the
feedback angle error [fb] to generate the roll error. The roll error is fed to the compensator
K1. The Compensator K1 assumed is only a gain of 0.2. The output of compensator k1 is
subtracted with the roll rate to generate the roll rate error. The roll rate error is fed to the
compensator K2. The compensator K2 is a PI controller having gain (P) of 0.02 and Integral
constant (I) of 0.76. However these constants are arbitrarily based on trial and error which
must be optimized.
The equation for integrator is given by
y[n]= y[n-1]+0.76 x[n] (8)
Where,
y[n] is the present integrated value
y[n-1] is previous 1 sample of y[n]
x[n] is the present output
5.10.2 SATURATION LOGIC
It is necessary to check for the overflow when any 2 values are summed or multiplied. Hence
saturation logic has been implemented. A subroutine is written such that the value in positive
is limited to +7FF and in negative direction by -7FF or 0xFFFFF801.
SOFTWARE FLOW CHART
6.1 OVERVIEW OF SOFTWARE PROGRAMMING
Fig 6.1 Overview of software programming
6.2 OVERALL FLOWCHART
Fig6.2 Overall flowchart of project
Fig 6.3Flowchart of Call response mode routine
Fig 6.4Flowchart of AHRS read data routine
Fig 6.5Flowchart of Conversion routine
PI Controller Routine K1& K2
Fig 6.6Flowchart of PI controller routine K1 and K2
fb from AHRS (ROLL angle) Read Cmd selected as on (from parallel port)
RESULTS
The hardware has been realized and softwarehas been written to demonstrate the closed loop
performance of the system using AHRS.
7.1 RESULTS TAKEN DURING DEVELOPMENT
1. AHRS OUTPUT ON DAC
Fig 7.1 shows the AHRS o/p as seen on a DAC when it is manually rotated from +/- 180
degrees.
It may be noted that for a rollangle of 100 deg a voltage equal to 0 is seen and for -180 deg
voltage is 2.5 V.
2. SAMPLING AT EVERY 10m sec
During the development stage timer 0 was loaded with a data equivalent to 10 msec to
check whether the system was capable of acquiring the data in every 10 msec.
Fig 7.2 The update value from AHRS in every 10m sec
3.WITHOUT ROLL RATE
The closed loop control without Roll rate was exercised during development
stage and using a PI controller in the loop. It may be observed from fig 7.3 that there
were more oscillations and it took more time to settle, given a step command of 180
degrees.
Fig 7.3 The roll output of the AHRS on DAC
Fig 7.4 The output of the level shifter in the closed loop when seen on a oscilloscope
4. WITH ROLL RATE
The closed loop control with Roll rate was exercised with the inclusion of PI
controller [K2] in the inner loop and a simple Gain controller in the outer loopand using
the roll rate during development stage. It may be observed that there were more
oscillations and it took more time to settle, given a step command of 180 degrees.
Fig 7.5 the output of the Roll rate on DAC in the closed loop when seen on a oscilloscope.
Fig 7.6: The roll output of the AHRS on DAC for a step command of +90 deg
Fig 7.7:The roll output of the AHRS on DAC for a step command of +157deg
Fig 7.8:The roll output of the AHRS on DAC for a step command of +45deg
Fig 7.9: The roll output of the AHRS on DAC for a step command of 0deg
Fig 7.10: The roll output of the AHRS on DAC for a step command of -45deg
Fig 7.11: The roll output of the AHRS on DAC for a step command of -90deg
Fig 7.12: The roll output of the AHRS on DAC for a step command of -157deg
Fig 7.13: The roll output of the AHRS on DAC for a step command of +90 deg
7.2 PHOTOGRAPH OF THE HARDWARE SET UP
1. AHRS used
Fig 7.14 AHRS 3DM GX-25
2. AHRS fitted along with the motor which is mechanically coupled
Fig 7.15AHRS fitted along with the motor
3. AHRS Control Card Designed
Fig 7.16AHRS Control Card Design
4.Level control card designed and developed
Fig 7.17Level control card design
5.Switch implementation on bread board
Fig 7.18Switch implementation on bread board
6. Set up of the whole system and closed loop control
Fig 7.19Set up of the whole system and closed loop control
Fig 7.20Set up of the whole system and closed loop control
CONCLUSION AND FUTURE WORK
8.1 CONCLUSION
A successful attempt was made to design a closed loop control system using available motor
with AHRS. AHRS is a miniaturized system which is proved to be a useful element to be
used in macro UAVs (Unmanned Aerial Vehicles). The update rate of the senor, possess
some limitation on the control system bandwidth. As reading the data from AHRS, convert it
to normal format from IEEE 754 and processing it using Micro controller could be achieved
only in every ~5ms.
This project has also demonstrated its performance in using in any steering and stabilization
system in inertial space which requires less control accuracies, because it has been observed
that the line of sight of motor remains the same irrespective of the rotating motor .
8.2 FUTURE WORK
The design of PI controller has not been optimized to get the best performance from
the output. It is envisaged that the control system can be optimized/tuned to get obtain a
settling within 50 m sec by proper control of proportional and integration constants..
The mechanical interface can be rugged enough to enable better control.
The system using AHRS can be used to control a 2 axis motion platform orthogonal to each
other, by providing necessary angle compensation algorithms which need to be devised.

Weitere ähnliche Inhalte

Ähnlich wie Project report

Embedded programming in RTOS VxWorks for PROFIBUS VME interface card
Embedded programming in RTOS VxWorks for PROFIBUS VME interface cardEmbedded programming in RTOS VxWorks for PROFIBUS VME interface card
Embedded programming in RTOS VxWorks for PROFIBUS VME interface cardRinku Chandolia
 
USB_Based_Closed_Loop_Digital_Control_System
USB_Based_Closed_Loop_Digital_Control_SystemUSB_Based_Closed_Loop_Digital_Control_System
USB_Based_Closed_Loop_Digital_Control_SystemAkshay Shah
 
Project Report-Design of a PLC System for health monitoring of DC drive throu...
Project Report-Design of a PLC System for health monitoring of DC drive throu...Project Report-Design of a PLC System for health monitoring of DC drive throu...
Project Report-Design of a PLC System for health monitoring of DC drive throu...Abhishek Sharma
 
AIR BAG CRASH USING MEMS
AIR BAG CRASH USING MEMS AIR BAG CRASH USING MEMS
AIR BAG CRASH USING MEMS Ganesh Gani
 
FPGA Based Speed Control of BLDC Motor
FPGA Based Speed Control of BLDC MotorFPGA Based Speed Control of BLDC Motor
FPGA Based Speed Control of BLDC MotorRajesh Pindoriya
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller systemVinny Chweety
 
Unmanned Aerial Vehicle for Surveillance
Unmanned Aerial Vehicle for Surveillance Unmanned Aerial Vehicle for Surveillance
Unmanned Aerial Vehicle for Surveillance Vedant Srivastava
 
Major project report
Major project reportMajor project report
Major project reportPraveen Singh
 
Minor_Project_Report
Minor_Project_ReportMinor_Project_Report
Minor_Project_ReportVansh Kumar
 
FLSmidth Report final
FLSmidth Report finalFLSmidth Report final
FLSmidth Report finalShahid Faizee
 
Fuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motorFuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motorSourav Chowdhury
 

Ähnlich wie Project report (20)

Embedded programming in RTOS VxWorks for PROFIBUS VME interface card
Embedded programming in RTOS VxWorks for PROFIBUS VME interface cardEmbedded programming in RTOS VxWorks for PROFIBUS VME interface card
Embedded programming in RTOS VxWorks for PROFIBUS VME interface card
 
USB_Based_Closed_Loop_Digital_Control_System
USB_Based_Closed_Loop_Digital_Control_SystemUSB_Based_Closed_Loop_Digital_Control_System
USB_Based_Closed_Loop_Digital_Control_System
 
Project Report-Design of a PLC System for health monitoring of DC drive throu...
Project Report-Design of a PLC System for health monitoring of DC drive throu...Project Report-Design of a PLC System for health monitoring of DC drive throu...
Project Report-Design of a PLC System for health monitoring of DC drive throu...
 
AIR BAG CRASH USING MEMS
AIR BAG CRASH USING MEMS AIR BAG CRASH USING MEMS
AIR BAG CRASH USING MEMS
 
FPGA Based Speed Control of BLDC Motor
FPGA Based Speed Control of BLDC MotorFPGA Based Speed Control of BLDC Motor
FPGA Based Speed Control of BLDC Motor
 
design of FPGA based traffic light controller system
design of FPGA based traffic light controller systemdesign of FPGA based traffic light controller system
design of FPGA based traffic light controller system
 
Unmanned Aerial Vehicle for Surveillance
Unmanned Aerial Vehicle for Surveillance Unmanned Aerial Vehicle for Surveillance
Unmanned Aerial Vehicle for Surveillance
 
Front Pages_pdf_format
Front Pages_pdf_formatFront Pages_pdf_format
Front Pages_pdf_format
 
Final
FinalFinal
Final
 
Final
FinalFinal
Final
 
MAJOR PROJECT
MAJOR PROJECTMAJOR PROJECT
MAJOR PROJECT
 
Main cerificate
Main cerificateMain cerificate
Main cerificate
 
final report
final reportfinal report
final report
 
A project report on
A project report onA project report on
A project report on
 
Major project report
Major project reportMajor project report
Major project report
 
Minor_Project_Report
Minor_Project_ReportMinor_Project_Report
Minor_Project_Report
 
My project
My projectMy project
My project
 
FLSmidth Report final
FLSmidth Report finalFLSmidth Report final
FLSmidth Report final
 
Alcohol report
Alcohol reportAlcohol report
Alcohol report
 
Fuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motorFuzzy logic control of brushless dc motor
Fuzzy logic control of brushless dc motor
 

Kürzlich hochgeladen

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Project report

  • 1. VISVESVARAYA TECHNOLOGICAL UNIVERSITY JnanaSangama, Belgaum-590014 A Project Report On “Closed Loop Motor Control using Attitude Heading Reference System” Submitted in Partial fulfillment of the Requirements for VIII semester Bachelor of Engineering in Electronics & Communication Engineering By ESHAAN KUMAR 1AR09EC015 TEJAS S 1AR09EC043 SHILPA S 1AR09EC032 Under the Guidance of Mrs. PADMAJA VIJAYKUMAR Assistant Professor, Dept. of ECE AIeMS DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING AMRUTA INSTITUTE OF ENGINEERING & MANAGEMENT SCIENCES Near bidadi industrial Area, Bengaluru-562109
  • 2. ACKNOWLEDGEMENT “The satisfaction and euphoria that accompany the successful completion of any task would be incomplete without the mention of the people who made it possible, whose constant guidance and encouragement crowned my effort with success.” I am extremely thankful to Aeronautical Development Establishment (ADE) and Amruta Institute of Engineering & ManagementSciences (AIeMS) with its ideals and inspirations for having provided me with the facilities, which made my project a success. I earnestly thankMr. P.S.KRISHNAN, director, ADE and Dr.A.PRABHAKAR, Principal, AIeMS, for providing me with congenial environment to work in, that helped in completing this project. I express my sincere thanks to Mr. A.M.G PILLAI Sc „F‟, Head, MST Division, ADE and Mr. C.R.RAJAGOPAL, HOD, ECE, AIeMSfor their encouragement throughout the demure of the project. I express my heart full gratitude to my project guide Mr. R.SRINIVASANSc „F‟, MST Division, ADE and college Internal guide Assit.Prof. PADMAJA VIJAYKUMAR, ECE, AIeMS for their able guidance and valuable advice at every stage of my project, which helped me in the successful completion of the project. I express my gratitude to Mr. G.S.RAVINDRAN Sc „F‟, HRD, ADE for his encouragement throughout the project. I wish to express my solicit thanks to Mr. KASI.V.RaoSc ‟D‟, and Mrs. REVATHY Sc‟D‟, MST Division, ADE for their guidance and important links. I express my sincere thanks to Mrs. MAMATHA RANI and Mr.RAHUL RAI, project co-ordinators, ECE, AIeMSfor their valuable guidance. I am thankful to all the Staff of ADE, faculty members and non-teaching staff of ECE Department, AIeMS for their kind co-operation. I also wish to thank my friends for their encouragement. Last but not the least, I would like to thank my parents and almighty for the support. TEJAS.S (1AR09EC043)
  • 3. B.V.V.Sangha‟s AMRUTA INSTITUTE OF ENGINEERING AND MANAGEMENT SCIENCES Near Bidadi Industrial Area, Bengaluru– 562109 DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING CERTIFICATE This is to Certify that the Project work entitled “Closed Loop Motor Control using Attitude Heading Reference System”has been carried out by Tejas S (1AR09EC043)bonafide student of Amruta Institute of Engineering & Management Sciences, in the partial fulfillment of the requirements for the award of the degree in Bachelor of Engineering in Electronics & communication Engineering under Visvesvaraya Technological University, Belgaum during the academic year 2012-2013. It is certified that all corrections/suggestions indicated for Internal Assessment have been incorporated in the report deposited in the department library. Mrs. PADMAJA VIJAY KUMAR Mr. C.R RAJAGOPAL Dr.A.PRABHAKARAssistant Prof., Dept. of ECE Head of Department Principal AIeMS AIeMS AIeMS Name of the Examiners: Signature and Date 1. 2.
  • 4. ABSTRACT State of art Attitude Heading Reference System (AHRS) using MEMS gyros are being used worldwide to control UAV’s,using control actuators,the rudder,elevator etc. This project deals with the design,development and demonstration of a closed loop actuation system using AHRS and DC motor. The system has been designed based on the AduC 7020 and external interfaces to connect AHRS and a DC motor.AHRS software module have been validated using C. Complete software code for the microcontroller including AHRS interface,realization of PI controller etc have been written and validated. The complete hardware has been realized and successfully demonstrated for the closed loop performance which will be used for future projects of ADE.
  • 5. TABLE OF CONTENTS PAGE NO 1. INTRODUCTION 1 1.1 EVOLUTION 1 1.2 USER REQUIREMENTS 3 1.3 PROJECT OVERVIEW 4 2. ATTITUDE HEADING REFERENCE SYSTEM (AHRS) – LITERATURE STUDY 5 2.1 SERIAL PORT CONFIGURATIONS 6 2.2 COMMUNICATIONS COMMANDS 6 2.3 PIN CONFIGURATION OF AHRS USED 7 2.4 DEVICE MODES 8 2.5 AHRS FORMAT IN SENDING THE SENSOR DATA 9 2.6 FLOATING POINT REPRESENTATION 9 2.7 FLOATING POINT CONVERSION EXAMPLE 10 3. AHRS CONFIGURATION 12 3.1 BAUD RATE SETTINGS 12 3.2 MODE SETTINGS 12 3.3 ROLL AND ANGULAR RATE COMMANDS 13 3.4 SUMMARY OF SETTING 14 4. HARDWARE DESIGN 15 4.1 HARDWARE DESIGN 15 4.2 CHOICE OF MICRO CONTROLLER 16 4.3 MICRO CONTROLLER SYSTEM DESIGN / AHRS CONTROL CARD 17 4.3.1 SYSTEM CLOCK 17
  • 6. 4.3.2 INPUT & OUTPUT PORTS 17 4.3.3 PARALLEL PORT 17 4.3.4 INTERRUPT SYSTEM 18 4.3.5 UART SERIAL INTERFACE AND RS232 DRIVER 18 4.3.6 POWER SUPPLY COMPATIBILITY FOR MICRO CONTROLLER 19 4.3.7 ANALOG AND DIGITAL GROUND SCHEME 19 4.3.8 MONITORING POINTS 19 4.3.9 DAC 19 4.3.10 TERMINATION OF THE INPUTS AND OUTPUTS FROM THE BOARD 19 4.4 SIGNAL CONDITIONER INTERFACE / LEVEL CONTROL CARD20 4.4.1 LEVEL SHIFTER DESIGN 20 4.4.2 VOLTAGE TO CURRENT AMPLIFIER DESIGN 21 4.4.3 MOTOR SELECTION 21 4.5 HARDWARE SUMMARY 22 5. SOFTWARE DESIGN 26 5.1 MICRO CONTROLLER REGISTER INITALIZATION 26 5.2 GENERAL PURPOSE IO PINS 26 5.3 BAUD RATE SETTING FOR UART SERIAL INTERFACE 27 5.3.1 SETTING OF DATA LENGTH 27 5.3.2 TRANSMISSION AND RECEPTION OF DATA 28 5.4 DAC SYSTEM 28 5.5 INTERRUPT SYSTEM 28 5.6 TIMERS 29 5.7 FLOATING POINT CONVERSION ALGORITHM 29 5.8 ANGLE REPRESENTATION FROM AHRS 33 5.9 READING THE PARALLEL PORT 33 5.10 PORTING DATA INTO DAC 34 5.10.1 COMPUTATION OF ERROR 34 5.10.2 SATURATION LOGIC 35
  • 7. 6. SOFTWARE FLOW CHART 36 6.1 OVERVIEW OF SOFTWARE PROGRAMMING 36 6.2 OVERALL FLOWCHART 37 7. RESULTS 41 7.1 RESULTS TAKEN DURING DEVELOPMENT 41 7.2 PROGRAPH OF THE HARDWARE SET UP 48 8. CONCLUSION AND FUTUREWORK 52 8.1 CONCLUSION 52 8.2 FUTURE WORK 52 REFERENCES APPENDIX
  • 8. LIST OF FIGURES PAGE NO Fig 1.1 Aircraft with variety of sensors 1 Fig1.2 Typical Mechanical Gyroscopes 2 Fig1.3 Principle axis of Rotation of an Aircraft 2 Fig1.4 Basic Block diagram arrived based on User Requirements 4 Fig2.1 Typical AHRS 5 Fig2.2 Pin configuration of AHRS 7 Fig4.1 Basic Block diagram based on User Requirements without using Microcontroller 15 Fig4.2 Basic Block diagram based on User Requirements using Microcontroller 15 Fig4.3 Basic Block diagram based on User Requirements using Microcontroller 16 Fig4.4 Level shifter circuit diagram 20 Fig4.5 V-I Converter circuit diagram 21 Fig4.6 The overall hardware structure 22 Fig4.7 The complete circuit diagram 23 Fig4.8 The detailed circuit diagram using DAC and SWITCH 24 Fig4.9 The circuit diagram of Level Shifter and VI converter 25 Fig5.1 Frame format 30 Fig5.2 Flowchart to find Sign bit 30 Fig5.3 Flowchart to find exponent part 31 Fig5.4 Flowchart to find mantissa part 32 Fig6.1 Overview of software programming 36
  • 9. Fig6.2 Overall flowchart of project 38 Fig6.3 Flowchart of Call response mode routine 39 Fig6.4 Flowchart of AHRS read data routine 39 Fig6.5 Flowchart of Conversion routine 40 Fig6.6 Flowchart of PI controller routine K1 and K2 41 Fig7.1 Shows the AHRS o/p as seen on a DAC when it is manually rotated from +/- 180 degrees. 42 Fig7.2 The update value from AHRS in every 10 msec 42 Fig7.3 The roll output of the AHRS on DAC. 43 Fig7.4 The output of the level shifter in the closed loop when seen on a oscilloscope 44 Fig7.5 The output of the Roll rate on DAC in the closed loop when seen on a oscilloscope. 44 Fig7.6 The roll output of the AHRS on DAC for a step command of +90 deg 45 Fig7.7 The roll output of the AHRS on DAC for a step command of +157 deg 45 Fig7.8 The roll output of the AHRS on DAC for a step command of +45 deg 46 Fig7.9 The roll output of the AHRS on DAC for a step command of 0 deg 46 Fig7.10 The roll output of the AHRS on DAC for a step command of -45 deg 47 Fig7.11 The roll output of the AHRS on DAC for a step command of -90 deg 47 Fig7.12 The roll output of the AHRS on DAC for a step command of -157 deg 48 Fig7.13 The roll output of the AHRS on DAC for a step command of +67deg 48 Fig7.14 AHRS 3DM GX-25 49 Fig7.15 AHRS fitted along with the motor 49 Fig7.16 AHRS Control Card Design 49
  • 10. Fig7.17 Level control card design 50 Fig7.18 Switch implementation on bread board 50 Fig7.19 Set up of the whole system and closed loop control 51 Fig7.20 Set up of the whole system and closed loop control 51
  • 11. LIST OF TABLES PAGE NO Table 2.1 Default serial port settings 6 Table 2.2 Command summary 7 Table 3.1 MODE Command 13 Table 3.2 EULER ANGLE Command 13 Table 3.3 EULER ANGLE and ANGULAR RATE Command 14 Table 4.1 Parallel port commands configuration 17 Table 5.1 Write sequence of PLLCON and POWCON 26 Table 5.2 GP1CON (Reading the parallel port1 data) 27 Table5.3 Values to be loaded in order to set baud rate of 115200 27 Table5.4 EULER ANGLES and ANGULAR RATES 29 Table 5.5 List of Commands 33 INTRODUCTION
  • 12. 1.1 EVOLUTION Sensors and actuators are the basic hardware components that are essential in any control systems. Sensors are used to sense or measure the state of the system, and actuators are used to adjust the state of the system. Fig 1.1 Aircraft with variety of sensors An aircraft attitude determination and control system typically uses a variety of sensors and actuator, because attitude is described by three or more attitude variables. There are two basic classes of attitude sensors. The First class makes absolute measurements, whereas the second class makes relative measurements. Absolute measurement sensors are based on the fact that knowing the position of an aircraft it is possible to compute the vector directions, these directions with respect to an aircraft or body. Relative measurement sensors belong to the class of gyroscopic instruments, including the rate gyro and the integrating gyro. Classically, these instruments have been implemented as spinning disks mounted on gimbals Gyroscopes are physical sensors that detect and measure the angular motion of an object relative to an inertial frame of reference. The term "Gyroscope" is attributed to the mid-19th century French physicist Leon Foucault who named his experimental apparatus for Earth's rotation observation by joining two Greek roots: gyros - rotation and skopeein- to see.The unique feature of gyroscopes is the ability to measure the absolute motion of an object without any external infrastructure or reference signals. All gyroscopescan be divided into two main categories, depending on whether the angular velocity or orientation is being measured. Rate gyroscopesmeasure the angular velocity, or the rate of rotation of an object. Angle gyroscopes also called Whole Angle or Rate Integratinggyroscopes, measure the angular position, or orientation of an object directly.
  • 13. Essentially all existing Micro-Electro-Mechanical-Systems (MEMS) gyroscopes are of the rate measuring type and are typically employed for motion detection (for example, in consumer electronics and automotive safety devices) and motion stabilization and control (for example, in smart automotive steering and antenna/camera stabilization systems). Gyroscopes allow untethered tracking of an object's angular motion and orientation and enable standalone Heading Reference Systems (AHRS). Fig 1.2 Typical Mechanical Gyroscopes AHRS is a 3-axis Inertial Measurement Unit (IMU) combined with a 3-axis magnetic sensor, and an onboard processor that creates a virtual 3-axis sensor capable of measuring heading (yaw), pitch, and roll angles of an object moving in 3D space. Fig 1.3 Principle axis of Rotation of an Aircraft AHRS sensors were originally designed to replace the large traditional mechanical gyroscopic aircraft flight instruments and provide better reliability and accuracy. Typically an AHRS will consists of either a fiber optic (FOG) or MEMS 3-axis angular rate gyro triad, a 3-axis MEMS accelerometer, and a 3-axis magnetic sensor known as a magnetometer. An Attitude & Heading Reference System (AHRS) is a self-contained system which provides the pitch, roll and yaw angles as shown in figure 1.3
  • 14. AHRS sensors are typically used in one of three ways. First of all they can be used as an instrument to provide flight data recording of the orientation of the platform as a function of time. Secondly an AHRS can be used for platform stabilization. The angular rate outputs can be directly tied into a control loop to maintain platform stability. An AHRS can also be used as an attitude control system. Aircraft, helicopters, quad-rotors, blimps, and even underwater robotic vehicles all can benefit from the use of an AHRS to form a closed-loop attitude control system. The angular rate outputs at a high bandwidth along with the estimated orientation angles make it possible to command a platform directly with desired attitude angles. AHRS sensors are typically used in one of two ways. First of all they can be used as an instrument to provide flight data recording of the orientation of the platform as a function of time. Secondly an AHRS can be used for platform stabilization. The angular rate outputs can be directly tied into a control loop to maintain platform stability. The proposed project undertaken is to design, develop and demonstrate a closed loop motor control using the AHRS sensor meeting the following user requirements. 1.2 USER REQUIREMENTS The following are the requirements specified by the user 1. Hardware design based on ADuC 7020 microcontroller having the following interfaces a) UART port interface to AHRS the 3DM GX-25. b) Parallel port interface to set different eight roll command inputs. c) Analog output interface to control a motor. 2. Software using code to validate the working of AHRS for roll feedback and roll rate feedback. 3. Microcontroller software to a) Validate the working of AHRS. b) Inclusion of PI controllers in inner and outer loops having provision to change the proportional and integral time constant as desired. c) Sample the data at an update rate of ~5msec.
  • 15. 4. Interface the motor including the design to the required voltage to current converter and demonstrate the closed loop working of AHRS as a steering and stabilization system. 1.3 PROJECT OVERVIEW The project deals with design, development and demonstration of a closed loop system using AHRS and DC motor. Block schematic of the system is as shown in Figure-1.4 . Fig 1.4 Basic Block diagram arrived based on User Requirements The AHRS is capable of giving angle and rate outputs in roll axis, pitch axis and heading. However, only roll angle and roll rate outputs from the AHRS is proposed to be used to meet the user requirements.
  • 16. ATTITUDE HEADING REFERENCE SYSTEM (AHRS) – LITERATURE STUDY AHRS is a 3-axis Inertial Measurement Unit (IMU) combined with a 3-axis magnetic sensor, and an on-board processor that creates a virtual 3-axis sensor capable of measuring heading (yaw), pitch, and roll angles of an object moving in 3D space. The user has indicated the use of 3DM-GX3-25 AHRS. Literature study on this AHRS is given below. The AHRS under study is from Micro strain. It has a fourth generation orientation sensor core which has the following features. 1. 32-bit low power high performance processor 2. USB and serial UART host interface 3. 17 bit resolution on Gyros, Accelerometers, and Magnetometers 4. Full 1kHz Coning and Sculling integration 5. Cascaded adjustable FIR filters 6. Data rates of up to 1000Hz 7. Smallest and lightest full function 6-DOF orientation sensor 8. Fully calibrated and temperature compensated outputs Fig 2.1 Typical AHRS AHRS is an inertial sensor installation that outputs aircraft attitude, heading and flight dynamics information to flight deck displays, flight controls, weather radar antenna platform and other aircraft systems. AHRS Comprises of Gyros, Accelerometers, and Magnetometers. Gyros are basically used to measure the Rate of Rotation. Accelerometers are used to measure the Linear Acceleration. Magnetometers are used to measure the Earth’s Magnetic Field.
  • 17. 2.1 SERIAL PORT CONFIGURATIONS AHRS selected communicates with the external world [host computer] via an Rs232 serial port having the following default serial port settings as given in Table2.1. Baud Rate 115.2K Parity None Data Bits 8 Stop bits 1 RTS/CTS Disabled Table 2.1 Default serial port settings 2.2 COMMUNICATIONS COMMANDS AHRS can be controlled by the host computer controls by issuing one or more single byte commands (in some cases, additional data bytes must follow the command byte). Most commands will cause the AHRS to transmit a response of a fixed number of bytes. AHRS can be commanded by Host computer in a continuous Mode so that AHRS could continuously output a pre-selected data quantity without being prompted by the host. AHRS can also be programmed to power-on directly into Continuous Mode without requiring any host control. Table 2.2 lists a summary of all commands available for the AHRS.
  • 18. Table2.2 Command summary 2.3 PIN CONFIGURATION OF AHRS USED Fig 2.2 Pin configuration of AHRS RS 232 Pin 2 (Transmit) RS 232 Pin 3 ( Receive) RS232 Pin 5 (Ground) +5V
  • 19. 2.4 DEVICE MODES AHRS operates in one of three modes Continuous, Active, or Idle. ACTIVE MODE In active mode, the AHRS has all sensors powered on and is performing continuous sampling and data conditioning. The communications channel is open and the AHRS can respond to any configuration, status, or data command. The host may issue any command at any time. The sensor will not output unsolicited data records. The 3DM-GX3™ will respond to data commands by outputting the corresponding data record. Multiple commands issued by the host will be buffered on-board the device, with one being processed at the completion of each successive sampling cycle. CONTINUOUS MODE In continuous mode, the AHRS will output a data record continuously with no further action by the host. The data record output corresponds to the preset data command set by the last call to Continuous Preset. The host computer must be capable of the buffering and interpreting the data stream at sufficient speed to prevent loss of data. Once continuous mode is set, it will remain in effect until it is terminated by issuing a different Mode command or the power to the device is interrupted. An alternate single byte command, Set Continuous Mode, can be used to start continuous mode. This command does not change the continuous preset value. An alternate single byte termination command, Stop Continuous Mode, may be used to stop the continuous mode and put the sensor into active mode. The benefit of this command is that it does not generate a response packet. This can be advantageous where the introduction of a response packet in the middle of a data stream can cause a parser to get out of sync with the stream. Although the AHRS will still act on and respond to all other commands while in continuous mode, it is better to change to active or idle mode before doing configuration commands. This makes it easier for the host to parse the incoming stream of response packets.
  • 20. IDLE MODE The idle mode is the same as the active mode in that the AHRS will respond to any configuration, status, or data command. However, in the idle mode, the sensors are turned off and data commands return invalid sensor data. For raw data, the values will just be undetermined. This mode is useful when doing configuration on a battery powered system and you need to minimize the power consumption. Idle mode draws approximately one half of the current compared to active mode. 2.5 AHRS FORMAT IN SENDING THE SENSOR DATA The sensor data say Roll angle and roll rate from AHRS is transmitted Euler angles which is in the IEEE-754 floating point format. The IEEE – 754 format of representation is as follows. The IEEE-754 format is aSingle precision floating point format in which a computer number occupies 4 bytes (32 bits) in computer memory and represents a wide dynamic range of values. Single-precision binary floating-point is used due to its wider range over fixed point (of the same bit-width), even if at the cost of precision. This gives from 6 to 9 significant decimal digits precision (if a decimal string with at most 6 significant decimal is converted to IEEE 754 single precision and then converted back to the same number of significant decimal, then the final string should match the original; and if an IEEE 754 single precision is converted to a decimal string with at least 9 significant decimal and then converted back to single, then the final number must match the original) 2.6 FLOATING POINT REPRESENTATION The IEEE 754 standard specifies a binary32 as having: 1. Sign Bit: 1 Bit. 2. Exponent Width: 8 Bits. 3. Mantissa/ Significant Precision: 23 Bits Sign bit determines the sign of the number, which is the sign of the significant as well. Exponent is either an 8 bit signed integer from −128 to 127 (2's Complement) or an 8 bit
  • 21. Unsigned integer from 0 to 255 which is the accepted base forms in IEEE 754 32 bit definition. For this case an exponent value of 127 represents the actual zero. The true significant includes 23 fraction bits to the right of the binary point and an implicit leading bit (to the left of the binary point) with value 1 unless the exponent is stored with all zeros. Thus only 23 fraction bits of the significant appear in the memory format but the total precision is 24 bits (equivalent to log10(224 ) ≈ 7.225 decimal digits). The bits are laid out as follows: 1 Bit 8 Bits 23 Bits The data obtained from AHRS will be in IEEE-754 Format as shown above. Hence in order to understand we convert this data in IEEE-754 Format to Decimal Format, Which is done using the Conversion formula, 2.7 FLOATING POINT CONVERSION EXAMPLE 1Bit 8Bits 23Bits SIGN
  • 22. 1. Here the value of Sign Bit S=0. Hence the number is Positive. 2. Here the value of Exponent E is given by E = 01111110 b = 126 d e = E -127 = -1 3. Fractional part of Mantissa M is given by M = 10000000000000000000000 (23 bits) = 0.5 d By substituting the values of S , E and M in the below equation, we get the converted decimal value. In the above example N= 0.75d AHRS CONFIGURATION
  • 23. The detailed description of the AHRS configuration used in the project is given below 3.1 BAUD RATE SETTINGS Thefollowingbaud rate setting of the AHRS isused in the project to improve upon the speed of transmission. Care has been taken in the choice of the baud rate to match with the capability of the microcontroller suggested by the user Baud rate 115.2K Parity None Data Bits 8 Stop Bits 1 3.2 MODE SETTINGS AHRS operates in various modes i.e., in active, continuous, idle mode, hence it is necessary to set the AHRS in particular mode for its proper operation. The default mode of AHRS is Active mode; however the mode is set into Active mode by command to eliminate the possibility in sensing wrong information from the AHRS. The command used to change mode of operation of AHRS called as MODE command. This command packet is sent to the AHRS from the Host PC. MODE command is as shown in Table 3.1 The user has to transmit four bytes of commands to AHRS. The AHRS responds by a response packet which is used to confirm that the mode is set in Active mode only. Continuous mode is not opted in the particular application, as it is preferred to acquire the particular data packet each time only when a packet of data has been requested i.e., at a particular update rate/ predefined rate of 5m sec as per user requirements. Check sum which is the sum of Byte1 and byte 2 is used to declare the correct response for the command given. Function: Putthe 3DM-GX3™ into new mode or read current mode. Command: Byte1 0xD4 Byte2 0xA3(Confirms user intent)
  • 24. Byte3 0x47(Confirms user intent) Byte4 Modeselector: 0:No mode change: just read current mode 1:Put in Active mode (default) 2:Put in Continuous mode (use Continuous Preset first) 3:Put in Idle mode 4:Put in Sleep mode 5:Put in Deep Sleep mode Response: Byte1 0xD4 Byte2 Currentor new mode Bytes3-4 Checksum Table 3.1 MODE Command 3.3 ROLL AND ANGULAR RATE COMMANDS AHRS provides the sensor information in EULER ANGLES by setting a command 0xCE or information of EULER ANGLES and ANGULAR RATES by setting up a command 0xCF through the host PC. The response is the data packet sent from the AHRS. Data format is as shown in Table 3.2 Euler Angles (0xCE) Function: The3DM-GX3™ will output a data record containing Euler Angles. Command: Byte1 0xCE Function: The3DM-GX3™ will output a data record containing Euler Angles. Response: Byte1 0Xce Bytes2-5 Roll (IEEE-754Floating Point) Bytes6-9 Pitch (IEEE-754Floating Point) Bytes10-13 Yaw (IEEE-754Floating Point) Bytes14-17 Timer Bytes18-19 Checksum Table 3.2 EULER ANGLE Command A part of the requirement i.e. EULER ANGLES is only satisfied by this command, hence not preferred.
  • 25. EulerAngles and Angular Rates (0xCF) Function: The3DM-GX3™ will output a data record containing Euler Anglesand AngularRates. Command: Byte1 0xCF Function: The3DM-GX3™ will output a data record containing Euler Anglesand AngularRates. Response: Byte1 0xCF Bytes2-5 Roll (IEEE-754Floating Point) Bytes6-9 Pitch (IEEE-754Floating Point) Bytes10-13 Yaw (IEEE-754Floating Point) Bytes14-17 AngRateX (IEEE-754Floating Point) Bytes18-21 AngRateY (IEEE-754Floating Point) Bytes22-25 AngRateZ (IEEE-754Floating Point) Bytes26-29 Timer Bytes30-31 Checksum Table 3.3 EULER ANGLE and ANGULAR RATE Command As both the Angle and Angular rates are required from the AHRS, the command 0XCF is initiated to obtain this information from the sensor. Check sum i.e. sum of byte1 to byte 29 is used to check the correctness of the data received from AHRS. Roll angle and roll rate from this command are used as per user requirements. 3.4 SUMMARY OF SETTING 1. The Baud rate set for AHRS is the default 115.2K baud rate. 2. During power ON, AHRS is set in Active Mode (by default) by sending four bytes Command (0xd4, 0xA3, 0x47, 0x01). and ensure that the mode is set by checking its response 3. Command of Command Euler angles and Angular Rates (0xCF) is used in order to read the Roll angle and Roll rate every 5m sec update rate. 4. Data from AHRS to acquire roll angle and roll rate [Euler angles and Angular Rates]is read once in every 5m sec HARDWARE DESIGN
  • 26. 4.1 HARDWARE DESIGN: The hardware design to design the system to meet the user requirements is given in this section. The block schematic of the system required to be implemented in the hardware is as shown in Figure-4.1 Fig4.1 Basic Block diagram based on User Requirements without using Microcontroller The modified block schematic highlights the blocks that could be implemented in the hardware to meet the requirements given in Figure-4.2 given below. Fig4.2 Basic Block diagram based on User Requirements using Microcontroller
  • 27. Fig4.3 Basic Block diagram based on User Requirements using Microcontroller 4.2 CHOICE OF MICRO CONTROLLER Micro controller is required to have the following interfaces 1. One Serial RS 232 interface to connect it to AHRS 2. 8 bit parallel port interface to set the roll command 3. DAC to convert the data into analog form to interface with a motor Choice of the controller is also based on the processing capability / speed to execute the compensators every 5m sec interval. Micro controller ADuC7020 from M/s Analog Devices has been selected as it has all the interfaces required in the project and has the computational speed capability as given by the user. More over the same micro controller IC is available in the laboratory with all the support tools required, hence this micro controller is selected. ADuc 7020 Micro controller has the following features: 1. The ADuC7020 devices operate from an on-chip oscillator and a PLL generating an internal high frequency clock of 41.78MHz. 2. The micro-controller core is an ARM7TDMI, 16bit / 32bit RISC machine, which offers up to 41MIPS per performance. 3. 8K bytes of SRAM and 62K bytes of non-volatile Flash/EE memory are provided on- chip. Hence no external memory is needed for storing the program. 4. General Purpose Timer: Timer is general-purpose, 32bit timer with a programmable prescale. The source can be the 32 KHz external crystal, the core clock frequency, or an external GPIO, P1.0 or 0.6.
  • 28. 4.3 MICRO CONTROLLER SYSTEM DESIGN / AHRS CONTROL CARD 4.3.1 SYSTEM CLOCK: The system clock in the Micro controller is routed through a programmable clock divider from which the MCU core clock operating is generated. An external clock of 32.768 KHz is connected to the micro controller which enables the micro controller to operate at a core clock frequency of 41.78 MHz 4.3.2 INPUT & OUTPUT PORTS: The ADuC720 provide 40 general purpose, bidirectional I/O (GPIO) pins. Many of the GPIO pins have multiple functions. GIPO pins are used for synchronization of data in serial communication. They are also use to control the display functions and give display inputs. 4.3.3 PARALLEL PORT Micro controller aduc7020 has 5 ports each of 8 bits which can be configured. IN the present system design three input lines from Port 1 are used. The port is configured so that the roll command can be switched to a particular value based on the switch position of Port numbers 1.2, 1.3, 1.4 are used in the design. The following are the roll commands chosen arbitrary based on the three bit positions P(1.4) P(1.3) P(1.2) Angle(in degree) 0 0 0 157 0 0 1 90 0 1 0 45 0 1 1 0 1 0 0 -45 1 0 1 -90 1 1 0 -157
  • 29. 1 1 1 67 Table 4.1Parallel port commands configuration 4.3.4 INTERRUPT SYSTEM: There are 23 interrupt sources on the ADuC7020, which are controlled by the interrupt controller. Four additional interrupt sources are generated from external interrupt request pins, IRQ0, IRQ1, IRQ2 and IRQ3. In the present design no external interrupts are proposed to be used. Internal timer interrupts and Serial communication transmitter and receiver interrupts are only to be used. Timer-0 interrupt is used to interrupt the system in every 5 sec to acquire/ process and control the motor using DAC. The serial interrupts can be used to command the AHRS i,e, transmit serial interrupt can be used when a command to AHRS to be sent i,e command AHRS to send Roll and roll rate angles Receive serial interrupt can used to receive every byte of data sent by AHRS. However this serial interrupt mechanism is not restored in the present design but polling mechanism for the status bit is resorted to due to ease in its implementation Interrupt mode option has been kept as an option if the job cannot be completed within the execution time of 5m sec. 4.3.5 UART SERIAL INTERFACE AND RS232 DRIVER: ADUC 7020 micro controller has a single UART port. A UART peripheral is a full- duplex, universal, asynchronous receiver/transmitter. It is fully compatible with the 16,450 serial port standards. The UART performs serial-to-parallel conversions on data characters received from a peripheral device or modem, and parallel to serial conversions on data characters received from the CPU UART port is used to AHRS sensor. As the serial output from Micro controller is LTLL 0 to 3.3V. A level translator is required to be used to make it compatible with RS 232 standards i.e m signal from +/- 12 V. Hence a Level translator IC has been used for this
  • 30. purpose. Available ICADM3202ARNZ (U9) has been chosen and used for this purpose which meets this requirement. 4.3.6 POWER SUPPLY COMPATIBILITY FOR MICRO CONTROLLER: The power input to the micro controller is + 5 V DC inputs. As the microcontroller operates in 3.3 V, a voltage regular driver is required to be used. ADP3333-3.3RL7, voltage regulator, which takes 5V-DC as input and provides an output of 3.3V-DC.ADuC720 has been selected and used. Required decoupling capacitors for all the components are also used in the design. A transient absorber is also used in the design to above the transients on the 5V line 4.3.7ANALOG AND DIGITAL GROUND SCHEME: It is necessary to isolate the Digital ground of the digital peripherals with the analog section. To isolate this inductor of the order of 10 µH is used. 4.3.8 MONITORING POINTS: As AHRS is an important sensor used in the project, to monitor the functioning of the AHRS on say an oscilloscope the outputs of AHRS are terminated on a Connector. Jumper J1 FTSH-105-01-L-DV is used for this purpose. 4.3.9 DAC: ADuC Microcontroller has internally four DAC with it. The signal level from this DAC is from 0 to 2.5 V. Same DAC from the micro controller is proposed to be used. The ADuC DAC outputs are terminated to the external world using a buffer. A four channel analog Buffer IC is used to interface with the four DAC outputs from Micro controller. Buffer AD8064 IC is used for this purpose. 4.3.10TERMINATION OF THE INPUTS AND OUTPUTS FROM THE BOARD:
  • 31. All the necessary Inputs and outputs that are required to control the motor / AHRS are terminated on a 30 pin connector. Available connector TFM is used for this purpose. 4.4 SIGNAL CONDITIONER INTERFACE / LEVEL CONTROL CARD The ADUC microcontroller has DAC which provides signal in the voltage range of 0 to 2.5 V. The DAC is required to drive / control a motor in both directions in a closed loop. Hence a suitable level shifter to swing the voltage from 0 to 2.5 V to +/- 5 V has been designed. 4.4.1 LEVEL SHIFTER DESIGN: An operation amplifier is used to shift the level. OPa 07 a low noise amplifier has been selected in the design. Basically the level shifter is a summer opamp. Description is given belw. Fig 4.5 Level shifter circuit diagram Applying KCL (Kirchoff’s Current Law) to the circuit shown below + = (1)
  • 32. = - (2) Proper choice of components such as resistors (R1, R2, Rf) to shift the output voltage level from 0 to 2.5 V to +/- 5 V Value of V2 has been fixed at -5 V and resistor Rf = 4KΩ, R1 = 4KΩ,R2 = 4KΩ. This results in level shifted output of +/- 5V for input V1 varying from 0 to 2.5 V 4.4.2 VOLTAGE TO CURRENT AMPLIFIER DESIGN: Motor requires controlled current to be driven at a required RPM. Voltage from the level shifter is converted to appropriate current input to the motor using a V to I converter. A V to I converter is designed using a power amplifier OPA 501. Typical V to I converter is given below. Fig 4.4V-I Converter circuit diagram = (3) I = I1 – I2 (4) (5) I = (6) When both Level shifter and V to I converter are connected together then output of level shifter is nothing but input to the V to I converter. 4.4.3 MOTOR SELECTION:
  • 33. A geared motor having sufficient torque has been chosen in our application. Swiss make Mini motor SA has been used. This motor selected requires a maximum current of 100mA when operated from a voltage up to 5 V. V to I converter has been designed such that the required current is supplied. The resistance values chosen are R4 = 470Ω, R5 = 1KΩ, R6= 100Ω A current limit is also required to be added in any V to I converter design. The current limiting resistor value is chosen as per the equation Ilim= which works out to be 4.7Ω considering the max current requirement to the motor of 100mA. 4.5 HARDWARE SUMMARY Block schematic with the interface of the designed cards are as shown in figure. 1. AHRS is connected to the AHRS control card via the J2 connector pin numbers 19[AHRS transmit/ Microcontroller receive], pin number 20[AHRS receive/ microcontroller transmit]and common ground pin number 3 on J2 connector. 2. Micro controller DAC 1 [ pin number 6 of J2 connector ] connected to T1 of the level control card and ground[ J2 connector pin number 3 ] to T3 3. DAC2 [pin number 7 of J2 connector] to oscilloscope to observe any waveform if any. 4. Motor between T3 and T4 of the level control card. Fig 4.6 The Overall Hardware Structure
  • 34. Fig 4.7The complete circuit diagram
  • 35. Fig 4.8The detailed circuit diagram using DAC and SWITCH
  • 36. Fig 4.9The circuit diagram of Level Shifter and VI converter SOFTWARE DESIGN
  • 37. 5.1 MICRO CONTROLLER REGISTER INITALIZATION During power on of the micro controller the following registers are required to be initialized PLLKey1 followed by the PLLCON register and then followed by PLLKEY2 PLLCON (Programmable Loop Logic Control): Controls the operating mode (Active mode) POWCON (Power Control Register): Controls the core clock frequency and power down mode. PLLCON value has initialized to 0x21 there by setting the PLL in the default configuration. In this configuration the internal clock is initialized 1. Next the POWCON key is initialized by POWKEY1 = 0x01, POWCON and POWKEY2/POWCON register is used to control the mode and set the clock frequency. (POWCON register is set in active mode and set a clock frequency of 41.78 MHz by setting POWCON register to 00) 2. To be precisePLLCON and POWCONare written using the sequence. PLLCON POWCON PLLKEY1 = 0xaa POWKEY1 = 0x01 PLLCON = 0x21 POWCON = 0x00 PLLKEY2 = 0x55 POWKEY2 = 0xF4 Table 5.1 Write sequence of PLLCON and POWCON 5.2 GENERAL PURPOSE IO PINS The ADuC 7020 provides 40 General Purpose bi-directional I/O pins. Many of the GPIO pins have multiple functions. In the present application GP1CON control register is set to 0x0000001 which initialise the following port pins as given below
  • 38. PIN VALUE NAME REASON P1.0 10 SIN Configure as serial input port [for microcontroller from AHRS ] P1.1 10 SOUT Configure as serial output port [ for AHRS from microcontroller P1.2 00 GPIO Configure as input port P1.3 00 GPIO Configure as input port P1.4 00 GPIO Configure as input port Table 5.2 GP1CON (Reading the parallel port1 data) The data from the parallel port1 is used to read the switch positions by reading the register GP1DAT. 5.3 BAUD RATE SETTING FOR UART SERIAL INTERFACE Micro controller is programmed such that the transmission and reception from /to AHRS is at a baud rate of 115200. Micro controller is hence required to set registers COMCON0, COMDIV0,COMDIVI and COMDIV2.It is required to generate the precise baud rate by using modes termed as normal mode and fractional mode COMCON0 0x80 COMDIV0 0x0B COMDIV1 0x00 COMDIV2 0x883E Table 5.3Values to be loaded in order to set baud rate of 115200 The following data has been initialized in the following registers to set the baud rate to 115200. The error has been reduced to 0% by using the fractional baud rate when compared to 3 % if used only with normal baud rate. 5.3.1 SETTING OF DATA LENGTH Data length is set by initialising the COMCON0 Register to design the size of the information packets to be transmitted.
  • 39. COMCON0 register has been initialised to a value of 0x83 which enables data transmission of 8 bits, 1 start bit, one stop bit and no parity. 5.3.2 TRANSMISSION AND RECEPTION OF DATA a. The data to be transmitted is loaded in the COMTX register so that data as initialized via COMCON0 register can be transmitted [to AHRS]. b. The received data will be available in the COMRX register [from AHRS]. c. The next data to be transmitted is initiated by checking the status of THRE bit of the COMSTAT0 register. d. The data to be read is initiated by checking the status of DR(Data Ready) bit of the COMSTAT0 register. 5.4 DAC SYSTEM The ADuC 7020 incorporates four, 12 – bit voltage output resistor string DAC’s on- chip. Each DAC has three selectable ranges: 0 V to VREF, 0 V to DACREF and 0 V to AVDD. Each DAC is independently configurable through a control register (DACxCON) and a data register (DACxDAT). The two registers are identical for the four DAC’s. DAC1CON and DAC2CON control register used DAC which are set to value 0X12. There by Enabling the DACto work in normal mode of operation and set the output voltage in the range from 0 to 2.5V [VREF voltage]. Data to be load for DAC operation is loaded in the register DAC1DAT (bits 27 to 16) for Output on DAC1 It is necessary to set the reference voltage to a reference valueie. VREF 2.5V, this is accomplished by loading 0x01 in REFCON register. 5.5 INTERRUPT SYSTEM No external interrupts are proposed to be used in the design. Only internal timer interrupt (timer 0) is required to be initialized.
  • 40. Before initializing any interrupt, the interrupt is initialized using IRQEN register. Timer 0 interrupt is enabled by loading the value of 0x 00000004 in IRQEN register 5.6 TIMERS The ADuC7020 has four general purpose Timer/Counters:Timer0, Timer1, Timer2 or Wake- up Timer. Only Timer 0 is used in the project. 1. Timer0 is configured in periodic mode where the counter decrements/increments from the value in the Load Register (T0LD MMR) until zero/full scale and starts again at the value stored in the Load Register. . The value loaded in T0LD register for timer0 is 0x0330 considering the source clock frequency of 41.78MHz and interval is 5m sec and pre scale chosen to be 256. 2. The pre scale is set to 256 and timer 0 enable in periodic mode by loading value of 0x 00C8 to the TCON register. 3. It is necessary to clear the timer 0 interrupt after each execution. This is accomplished by writing any value say 0xFF in T0CLRI register. Reading the AHRS data: The AHRS is commanded in Active mode and the 32 bytes of data are read by the microcontroller. The flow diagram is given in figure- 5.7 FLOATING POINT CONVERSION ALGORITHM The AHRS gives a 32 byte of data which are IEEE- 754 floating point format. Function: The3DM-GX3™ will output a data record containing Euler Anglesand AngularRates. Response: Byte1 0xCF Bytes2-5 Roll (IEEE-754Floating Point) Bytes6-9 Pitch (IEEE-754Floating Point) Bytes10-13 Yaw (IEEE-754Floating Point) Bytes14-17 AngRateX (IEEE-754Floating Point) Bytes18-21 AngRateY (IEEE-754Floating Point) Bytes22-25 AngRateZ (IEEE-754Floating Point)
  • 41. Bytes26-29 Timer Bytes30-31 Checksum TABLE 5.4 EULER ANGLES and ANGULAR RATES As an example, let us consider there are four bytes say (2 to 5) i.e. 32 bits that is received from AHRS which is in IEEE-754 format which consists of sign, exponent and mantissa Fig 5.1 Frame format In order to convert the received data from AHRS that is in IEEE-754 format to normal Decimal value four main steps are used. The first job is to separate the S E and M bits from the 32 bit data received. Once these values are obtained, the angle information [say roll angle from AHRS] is converted into decimal format by using the formula (7) STEP 1: TO FIND S To find Sign bit(S), as only the MSB bit of array is required a[3], Masking is done by for the remaining 7bits by multiplying a[3] with 0x80 and later shift by right shift by 7 position to get value of S Flow diagram is as given below a[3] a[1]a[2] a[0]
  • 42. Fig 5.2Flowchart to find Sign bit STEP2: TO FIND E To get the exponent value, it is noted that the value is stored in 2 bytes, i.e. some part in a[3] and some part in a[2]. In the array a[3], as only 7bits are required, masking is done by multiplying a[3] with 0x7F and later left shift it by 1bit position and stored as d1. Similarly in order to get 1st bit of a[2], the data is masked by multiplying a[2] with 0x80 and later right shift it by 7bit positions and stored as d2. The two byte d1 and d2 available are combined together making it as a single byte to get the value of exponent (e) by performing Logical OR operation. Flow diagram is as given below
  • 43. Fig 5.3Flowchart to find exponent part Then we subtract exponent value e with 127 and store it as e. STEP 3: TO FIND M and N Flow diagram is as given below:
  • 44. Fig 5.4Flowchart to find mantissa part 1. Only last 7 bits of a[2] is required. The data is obtained by masking a[2] with 0x7F. This is stored in t. 2. To get the mantissa value after the decimal point the value if it is added with 0x80. a. If e value is negative, then eis multiplied with -1 and again stored it in e. t value is right shifted by e position and store it in fb. b. Else if e value is positive, then the value of tis left shifted by e positions and stored in fb. If the value of sign bit (s) is 1, then fb is multiplied with -1.
  • 45. c. The value stored in fb is in decimal form. i.e., to convert the value into decimal value in degrees, the fbvalue is multiplied with 57.3 and 0.087. d. Here fb value is the N value [say roll angle data in degrees]. This may be noted that shift operation is performed instead of power operation as given in equation 7. 5.8 ANGLE REPRESENTATION FROM AHRS AHRS data obtained as fb from the AHRS is a 32 bit data which is equal to 0 to 360 degrees. To be precise the value contained in hex is FFFFF800 for -180 deg 00000000 for 0 deg 0000007FF for +180 deg DAC provided on the microcontroller is a 12 bit DAC and has an o/p voltage range from 0 to 2.5 Volts. Hence the 32 bit angular data is to be reduced to 12 bit data by shifting this data to right by 16 bits. 5.9 READING THE PARALLEL PORT Input commands are read using Port 1 ie.,port 1.2, 1.3, 1.4 using GP1DAT register. Based on the bit positions the following roll command angles are derived as follows. P(1.4) P(1.3) P(1.2) Angle(in degree) Command 0 0 0 157 0x6FF 0 0 1 90 0x3FF 0 1 0 45 0x1FF 0 1 1 0 0 1 0 0 -45 0xFFFFFE03 1 0 1 -90 0xFFFFFBFF
  • 46. 1 1 0 -157 0xFFFFF900 1 1 1 67 0x2FF Table5.5 List of Commands Hex value for the command is matched to the roll angle value command as described in the explained in section5.8. 5.10 PORTING DATA INTO DAC It is necessary to read the roll value on a DAC port for monitoring purpose. For monitoring, data is loaded on DAC2DAT register having a value ranging from 000 to FFF. As the data coming from AHRS is having a negative value which cannot be loaded to the DAC, the AHRS value is offset by a value of 0x7FFi.e., The value of Roll -180 would become 0 and value of 0 deg angle becomes 7FF, and value +180deg becomes FFF. The DAC loaded with a value of 0 gives 0 V and the DAC loaded with vale of FFF gives 2.5 V as discussed in the hardware sections. Hence an analog value of 0 volts corresponds to - 180 deg and DAC analog value of 2.5 corresponds to +180 degrees. 5.10.1 COMPUTATION OF ERROR The roll command as determined based on the switch positions, is subtracted from the feedback angle error [fb] to generate the roll error. The roll error is fed to the compensator K1. The Compensator K1 assumed is only a gain of 0.2. The output of compensator k1 is subtracted with the roll rate to generate the roll rate error. The roll rate error is fed to the compensator K2. The compensator K2 is a PI controller having gain (P) of 0.02 and Integral constant (I) of 0.76. However these constants are arbitrarily based on trial and error which must be optimized. The equation for integrator is given by y[n]= y[n-1]+0.76 x[n] (8) Where, y[n] is the present integrated value y[n-1] is previous 1 sample of y[n]
  • 47. x[n] is the present output 5.10.2 SATURATION LOGIC It is necessary to check for the overflow when any 2 values are summed or multiplied. Hence saturation logic has been implemented. A subroutine is written such that the value in positive is limited to +7FF and in negative direction by -7FF or 0xFFFFF801. SOFTWARE FLOW CHART
  • 48. 6.1 OVERVIEW OF SOFTWARE PROGRAMMING Fig 6.1 Overview of software programming 6.2 OVERALL FLOWCHART
  • 49.
  • 51. Fig 6.3Flowchart of Call response mode routine Fig 6.4Flowchart of AHRS read data routine
  • 52. Fig 6.5Flowchart of Conversion routine
  • 53. PI Controller Routine K1& K2 Fig 6.6Flowchart of PI controller routine K1 and K2 fb from AHRS (ROLL angle) Read Cmd selected as on (from parallel port)
  • 54. RESULTS The hardware has been realized and softwarehas been written to demonstrate the closed loop performance of the system using AHRS. 7.1 RESULTS TAKEN DURING DEVELOPMENT 1. AHRS OUTPUT ON DAC Fig 7.1 shows the AHRS o/p as seen on a DAC when it is manually rotated from +/- 180 degrees. It may be noted that for a rollangle of 100 deg a voltage equal to 0 is seen and for -180 deg voltage is 2.5 V. 2. SAMPLING AT EVERY 10m sec During the development stage timer 0 was loaded with a data equivalent to 10 msec to check whether the system was capable of acquiring the data in every 10 msec.
  • 55. Fig 7.2 The update value from AHRS in every 10m sec 3.WITHOUT ROLL RATE The closed loop control without Roll rate was exercised during development stage and using a PI controller in the loop. It may be observed from fig 7.3 that there were more oscillations and it took more time to settle, given a step command of 180 degrees. Fig 7.3 The roll output of the AHRS on DAC
  • 56. Fig 7.4 The output of the level shifter in the closed loop when seen on a oscilloscope 4. WITH ROLL RATE The closed loop control with Roll rate was exercised with the inclusion of PI controller [K2] in the inner loop and a simple Gain controller in the outer loopand using the roll rate during development stage. It may be observed that there were more oscillations and it took more time to settle, given a step command of 180 degrees. Fig 7.5 the output of the Roll rate on DAC in the closed loop when seen on a oscilloscope.
  • 57. Fig 7.6: The roll output of the AHRS on DAC for a step command of +90 deg Fig 7.7:The roll output of the AHRS on DAC for a step command of +157deg
  • 58. Fig 7.8:The roll output of the AHRS on DAC for a step command of +45deg Fig 7.9: The roll output of the AHRS on DAC for a step command of 0deg
  • 59. Fig 7.10: The roll output of the AHRS on DAC for a step command of -45deg Fig 7.11: The roll output of the AHRS on DAC for a step command of -90deg
  • 60. Fig 7.12: The roll output of the AHRS on DAC for a step command of -157deg Fig 7.13: The roll output of the AHRS on DAC for a step command of +90 deg
  • 61. 7.2 PHOTOGRAPH OF THE HARDWARE SET UP 1. AHRS used Fig 7.14 AHRS 3DM GX-25 2. AHRS fitted along with the motor which is mechanically coupled Fig 7.15AHRS fitted along with the motor 3. AHRS Control Card Designed Fig 7.16AHRS Control Card Design
  • 62. 4.Level control card designed and developed Fig 7.17Level control card design 5.Switch implementation on bread board Fig 7.18Switch implementation on bread board
  • 63. 6. Set up of the whole system and closed loop control Fig 7.19Set up of the whole system and closed loop control Fig 7.20Set up of the whole system and closed loop control
  • 64. CONCLUSION AND FUTURE WORK 8.1 CONCLUSION A successful attempt was made to design a closed loop control system using available motor with AHRS. AHRS is a miniaturized system which is proved to be a useful element to be used in macro UAVs (Unmanned Aerial Vehicles). The update rate of the senor, possess some limitation on the control system bandwidth. As reading the data from AHRS, convert it to normal format from IEEE 754 and processing it using Micro controller could be achieved only in every ~5ms. This project has also demonstrated its performance in using in any steering and stabilization system in inertial space which requires less control accuracies, because it has been observed that the line of sight of motor remains the same irrespective of the rotating motor . 8.2 FUTURE WORK The design of PI controller has not been optimized to get the best performance from the output. It is envisaged that the control system can be optimized/tuned to get obtain a settling within 50 m sec by proper control of proportional and integration constants.. The mechanical interface can be rugged enough to enable better control. The system using AHRS can be used to control a 2 axis motion platform orthogonal to each other, by providing necessary angle compensation algorithms which need to be devised.