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 communication between the PC and the
robot consists to a set of commands and parameters. The PC sends different
instructions to the navigation’s system that interpret the command and the
parameter. Consequently, these instructions have been implemented both on the
microcontroller and on the driver.
The request sequence sent to the Atmega32
follows syntax:
Figure 37: command frame
It consists in two enumerations: command
and parameter.
We have the following correspondence
between the commands, the parameters and their numbers:
COMMANDS
|
PARAMETERS
|
NO_COMMAND
|
0x0
|
NO_PARAMETER
|
0x0
|
MAGNETO
|
0x1
|
VREF
|
0x1
|
GYRO
|
0x2
|
VCC
|
0x2
|
ACC
|
0x3
|
POWER_SUPPLY
|
0x3
|
REF_VOLTAGE
|
0x4
|
X_AXIS
|
0x4
|
COMPENSATION
|
0x5
|
Y_AXIS
|
0x5
|
GET_ALL_SENSORS
|
0x6
|
Z_AXIS
|
0x6
|
VERSION
|
0x7
|
PULSE
|
0x7
|
PING
|
0x8
|
TEMPERATURE
|
0x8
|
REBOOT
|
0x9
|
MODULE
|
0x9
|
USAGE
|
0xA
|
ANGLE
|
0xA
|
CARD
|
0xB
|
|
|
Table 13: The commands and parameters available
The first value off the enumeration
‘COMMAND’ and ‘PARAMETER’ are respectively ‘NO_COMMAND’ and ‘NO_PARAMETER’. Of
‘NO_COMMAND’ is never used on the program, but this declaration allows forbid
the utilisation of the value ‘0’ for the command. Therefore, it is always
interpreted like an error.
The main commands are the five next. They
are required to the calculation of the magnetic north.
The instruction set sends from the
computer to the Smart Compass card is composed by two bytes:
The headers are used to control the
request. When the system receives an instruction, it first checks if the
instruction is for it (with the device ID) and if the no loose of data occurs during
the transmission (with the length). If these two conditions are true, the
command is interpreted
According to the command and the
parameter received, it returned one or more values. To obtain these values the
commands and his parameter should belong to one of these combinations:
|
Commands
|
Parameters
|
Meanings
|
Data returned
|
NO_COMMAND
|
NO_PARAMETER
|
Error
|
ERROR_VALUE
|
MAGNETO
|
X_AXIS
|
X-axis magnetic field
|
X-axis value (voltage)
|
Y_AXIS
|
Y-axis magnetic field
|
Y-axis value (voltage)
|
Z_AXIS
|
Z-axis magnetic field
|
Z-axis value (voltage)
|
MODULE
|
Select the output available on the module
|
The three above values (voltage)
|
PULSE
|
Done a SET/RESET on the magneto
|
The values of each axis on the SET and
the values of each axis on the RESET (voltage)
|
ANGLE
|
North position calculated from the value
of the three axis
|
North position value (radians)
|
GYRO
|
Z_AXIS
|
Z-axis rotation’s speed
|
Z-axis value (voltage)
|
TEMPERATURE
|
Temperature inside the gyro
|
Gyro’s temperature (voltage)
|
MODULE
|
Select the output available on the module
|
The two above values (voltage)
|
ANGLE
|
Angle position of the robot
|
Position’s value (radians)
|
ACC
|
X_AXIS
|
X-axis acceleration
|
X-axis value (voltage)
|
Y_AXIS
|
Y-axis acceleration
|
Y-axis value (voltage)
|
TEMPERATURE
|
Temperature inside the accelerometer
|
Accelerometer ‘s temperature (voltage)
|
MODULE
|
Select the output available on the module
|
The three above values
|
REF_VOLTAGE
|
VREF
|
Reference voltage of the acquisition data
|
(voltage)
|
VCC
|
5V reference
|
(voltage)
|
POWER_SUPPLY
|
Power supply voltage
|
(voltage)
|
MODULE
|
Select the output available on the module
|
The three above values
|
COMPENSATION
|
X_AXIS
|
Compensate X-axis magneto
|
None
|
Y_AXIS
|
Compensate Y-axis of the magneto
|
None
|
Z_AXIS
|
Compensate Z-axis of the magneto
|
None
|
GET_ALL_SENSORS
|
NO_PARAMETER
|
Select all the modules
|
None
|
VERSION
|
NO_PARAMETER
|
Version of the program
|
Number’s version
|
PING
|
NO_PARAMETER
|
Test if the is connected
|
PONG
|
REBOOT
|
NO_PARAMETER
|
Restart the system
|
CONFIRM_REBOOT
|
USAGE
|
NO_PARAMETER
|
Usage of the program
|
The usage of the program
|
CARD
|
NO_PARAMETER
|
Define the card used
|
Card’s number
|
|
|
|
|
|
Table 14: instruction set
These previous instructions are available
for the two cards.
Except the two combination:
‘POWER_SUPPLY’ / ‘REF_VOLTAGE’ And ‘MAGNETO’ / ‘ANGLE’
In addition, the command ‘COMPENSATION’
has two parameters instead of one for the other command. Consequently the
length of this instruction is 3 bytes. The first parameter is used to select
the axis of the magneto to compensate and the second contains the value of the
compensation.
The command ‘GET_ALL_SENSORS’ is not
really a command because it is not directly sent to the MCU. It is just use to
address all the sensors.
The commands ‘VERSION’, ‘USAGE’ and
‘CARD’ are implemented to get information about the navigation’s system card.
To know the voltage value on
the magneto’s z-axis, you should send the following bytes:
0x2A 0x16
The hexadecimal value:
The response returned by the navigation
system match the structure on Figure 37.
The validity of the instruction is
indicated by the fourth byte: the return code. The different control values are
the following ones:
Name value
|
Value
|
Meaning
|
CONFIRM_REBOOT
|
0xFF (255)
|
Reboot confirmation
|
PONG
|
0xFF (255)
|
Connection confirmation
|
VALID
|
0x0F (15)
|
Validity code
|
ERROR_VALUE
|
0xF0 (240)
|
Internal error
|
ERROR_COMAND
|
0xF1 (241)
|
Invalid command
|
ERROR_PARAMETER
|
0xF2 (242)
|
Invalid parameter
|
ERROR_DEVICE
|
0xF3 (243)
|
Invalid device
|
ERROR_LENGTH
|
0xF4 (244)
|
Invalid length
|
ERROR_INSTRUCTION
|
0xF5 (245)
|
Invalid instruction
|
INTERNAL_ERROR
|
0xF6 (246)
|
Internal error
|
OVER_DELAY
|
0xF7 (247)
|
Delay expired
|
ERROR_MODE
|
0xF8 (248)
|
Unimplemented mode
|
ERROR_METHOD
|
0xF9 (249)
|
Unimplemented method
|
TOO_MANY_ERRORS
|
0xFA (250)
|
Too many errors occur during the
transmission
|
Table 15: Return Code
The three first
values on the Table 15 correspond to a valid value the
other means that an error happens. CONFIRM_REBOOT is returned in the data to
confirm the reboot and PONG that the connection with the system is established.
Except these two cases, if the fourth byte is different to VALID, we will have
one of the other possible values.
All the replied from the smart compass
are finished by the character “\0” that signify the end of the data. It allows
to check the length of the response and therefore if there were no loss during
the transmission. The device ID allows checking the source of the response.
Most of the data returned by the card are
in short format, except for the ANGLE and the VERSION, where the size is in
double format (4 octets).
The kind of response that we can obtain
for the request of the previous example could be:
0x06 0x0A 0x16 0x0F 0x07 0x0D
This will correspond to:
To send automatically a command to the
system you just use the command method in the CModule class. Still for the
previous example, you can do the following instruction:
unsigned short data = 0;
Navigation->commands(
MAGNETO, // module
Z_AXIS, // parameter
data, // pointer to receive the data
sizeof(data) // format of the waited data
);
All the types of format are accepted by
this method. You can pass for example the pointer on a structure of unsigned
short to receive more than one octet.
|