Professional Documents
Culture Documents
Compass With Tilt Correction: Objective
Compass With Tilt Correction: Objective
Compass With Tilt Correction: Objective
Objective
The familiar compass with its magnetic north seeking needle has a digital
counter-part in the HoneywellHMC5883L three-axis compass at the heart of the
Digilent PmodCMPS pictured in the following Figure and it is included in the NI
myRIO Mechatronics Kit. The HMC5883L generates 12-bit measurements
delivered by I2C-bus serial communications at rates of up to 160 Hz and offers
multiple sensitivity ranges for compassing (finding the Earth’s magnetic north
pole) or to measure stronger magnetic fields up to 8 gauss.
1
This basic method requires that the compass be held parallel to the ground,
however, this may not always be convenient or even possible. A compass tilt
correction procedure exists provided that an accelerometer is available to
deter-mine the angle of the compass with respect to ground.
1 Experiment Setup
Wire the system as below. You only need to use the MXP Connector A.
2
Figure 1: Demonstration setup for compass connected to NImyRIOMXP Con-
nector A.
3
Figure 2: Demonstration setup for LCD character display connected to NI
myRIO MXP Connector A (Not B, even though it is shown for B). Remember
to set the mode jumpers as shown for UART serial communications.
4
Figure 3: Primary/Secondary Signals on MXP Connectors A and B
2 Steps
2.1 Detecting the Tilt
a. Click on the encircled button Create Project.
5
b. The new window with multiple options is shown in the figure below.
6
d. Select the myRIO Project from the right portion of the window.
e. The both of the above steps are shown in the figure below.
Just after pressing this button you will be able to see a new window on
your computers screen.
g. Select the Plugged into USB option and press Refresh button, your
attached myRIO device will be detected in this way.
IP address of the used NI myRIO is encircled in the below figure as 22.
11.2.
The newly opened window with a bit detail is shown in the figure below.
7
h. The destination of the le which is being created is shown in the figure
below.
i. Now, press the Finish button as highlighted in the figure shown below.
j. As you press this button a new window will again appear on your com-
puters screen.
k. Go to the \myRIO-1900 (xxx.xx.xx.x)"as encircled in the figure below.
8
l. Now double click on \Main.vi"
9
n. In the block diagram panel, right-click on the while loop and select \Re-
place with Timed-Loop", and configure it as below:
10
o. In the block diagram panel, drop a \MathScript" (Programming>>
Structures). By doing Right-Click on the left side, and by selecting \Add
Input", you can de ne the input variables. After writing the following
code, you can right-click on the right side, select \Add Output", and
choose the output variables as below
11
p. Drop \Negate"(Programming>>Numeric), \Or" (Programming>>Boolean),
\Complex to Re/Im"(Programming>>Numeric>>Complex), \bot-
ton"(myRio), \Select"(Programming>>Comparison), \Not"(Programming>>Boolean), and wire
the system partially as below:
12
\Array Constant" (Programming/Array), \True Constant" (Program-
ming/Boolean), \Reverse 1D Array" (Programming/Array), \Boolean Array
To Number" (Programming/Numeric/Conversion), \To Un-signed Byte
Integer"(Programming/Numeric/Conversion),\Build Ar-
ray"(Programming/Array), two \Numeric Constant"(Programming/Numeric/Conversion):
right click on them and select Representation/U8 and for one of them
only also right click and select Visible Items/Radix then click on it and
select \Hex", \I2C"(myRIO).
Configure and wire the program as below
13
14
r. Inside the loop, drop these items:
\Quotient & Remainder" (Programming/Numeric), \Equal To 0?"(Pro-
gramming/Comparison), \UART" \I2C" \Digital Input" (MyRIO), \Format Into
String" "(Programming/String), \Reset" (MyRIO/Device Management),
\Index Array"(Programming/Array),
\Join Numbers"(Programming/Numeric/Data Manipulation), \To
Word Integer"(Programming/Numeric/Conversion), \Build Array"(Programming/Array), \Case
Structure"(Programming/Structures)
Configure and Wire the system as below
15
16
17
18
19
s. when you connect the wires to the right side of the loop, by doing right
click on them and selecting \Replace with Shift Register", it can provide
the feedback to the loop
3 Report
3.1 Report sections*:
1. Introduction (literature survey-background information) ( 10%)
2. Definition of the experiment (diagrams, schematics, etc.) ( 10%)
20
3. Details of apparatus settings ( 5%)
4. Results and analysis and graphs presentation ( 40%)
5. Discussion, comments and reflections on the experiment ( 30%)
6. References ( 5%)
*Note: The percentages are solely marking indications and may vary.
c. On your phone, install a compass app and compare it with the one using
the myRIO compass. Which one gives more accurate results? Explain.