Table of contents
3.Introduction
4.Specification requirements
5.Solutions suggestions
6.The magnetic fields sensors
7.The inclination measurement system
8.The gyroscope
9.The data acquisition system
10.Communication system
11.The power supply
12.Realisation of the PCB
13.The embedded system
14.Static Library Util.a
15.ViewPort
16.Xcompass
17.Sensors controller commands
18.Test
19.Future improvements
20.Conclusion
21.References
The embedded system on the Smart Compass
controller is written in C-language. That program manages the different the
instrument compute the data received from the ADCs.
The main entry of the program is the file
‘main.c’. Three methods are implemented in this file:
'main ()' that is the entry point of the program
and realise the main routine. It initializes the different modules of the
system.
'welcome_msg ()' returns
information about the Smart Compass card and the program version, the date of
development, the authors and supervisor.
'version_exec ()' return the actual version of
the program.
'parse_command ()' execute
the instruction send by
Xcompass or viewport through the RS232 or RS485 connection. The command and the parameter available that composed this
instruction declared in the identical way in the driver.
When the microcontroller boot, it
initializes the different module and prints the welcome message. At that point,
it will wait until an instruction is addressed to the smart compass card.
The two
C-program ‘timer’ and ‘comm’ are inspired from the UAV embedded system. The
program ‘timer.c’ contains the different methods that manage the delay or the
different interrupt mode. We have reused these timer functions without
modifications.
The file ‘comm.c’ contains the different
method to communicate throw the serial or the SPI port. It contains in
particular the functions to initialize and to use the UART:
The printf() function is enabled by the
init and extra method have been implemented to directly send and receive the
instruction structure.
In addition, we have added three methods
that initialize and read values on the two different ADC: the function
‘adc_atmega32’ and ‘adc_max186’. These methods have been developed to work on
both the card. The number of the card is defined in the header of this program.
Any bit received by the RS232 (or RS485)
will raise an interrupt that will store the request. If the length of the
request corresponds to the length’s value given by the instruction, the command
is parsed.
If the command is one of the five modules
of the compass (MAGNETO, GYRO, ACC, REF_VOLTAGE, or COMPENSATION), the
parameter is redirected to the corresponding module application:
Figure 25
Note: The COMPENSATION module has been
included on the file ‘magneto’ as it concerns the compensation of the magneto
module and it does not require an independent file.
The other available commands are
considered like the informational command (VERSION, CARD, USAGE, and PING).
The different programs that process the
modules have the common method according to the available parameter (see
section 17.2.2):
Each module’s program has a method
'[ModuleName]_exec' that interpret the parameter’s value.
If this value corresponds to MODULE, the
method 'module_[ModuleName]' is executed. It returns all the output values
available for that module.
If the parameter’s value is ANGLE, the
calculated value of the azimuth is returned.
If the supply voltage is sufficient, the
second DC/DC converter can be switch off. On the first card, this is done by a
hardware control. However, on the second card, the control is soft. The
selection can be set on manual or automatic.
To this purpose, we have three available
modes that can be executed by the method ‘power_switch’:
ON: enable manually the DC/DC converter (SMR)
OFF: disable manually the DC/DC converter (MMR)
AUTO: enable automatically the converter if the
supply power is inferior to 18V
To realize a pulse command, we have to
generate first a SET and then a RESET signal. The pulse circuit is connected on
the port PC0 (SET) and PC1 (RESET) of the microcontroller. A pulse can be
generated by a software method (‘magneto_pulse’) with in argument the kind of
signal that we want to generate:
The magnitude of the field on each axis
is difference between the values read after a Set a Reset. This value can then
been pass to the method ‘magneto_get_north’ that will return the azimuth.
The module compensation can generate an
opposite magnetic field to eliminate the magnetic interference. This module
controls the value of the curser in the digital potentiometer, which drive the
compensated field.
Similarly to the other modules, when the
command COMPENSATION is executed, the method ‘compensation_exec’ switch the
first parameter. This last one corresponds to the axis of the magneto sensors
to compensate. The second parameter corresponds to the compensation’s value.
These two parameters are passed in argument on the function
‘magneto_compensation’ that realize this operation and returns the value VALID
to confirm the compensation. |