
FLProg , , . , C . . , 1.10.3 . . , , . (, – ), . , , .
HMC5883L.
.
.
, . «» , . « »

. FBD, LAD Code. LAD FBD , «Code».

. (1), (2).

.

. , « ». – X, Y, Z. « ».

. , . Float – — . , ., . .

.

, . . : 0.88, 1.3, 1.9, 2.5, 4.0, 4.7, 5.6, 8.1
« » « ».

. Float, . , . .

. . , , .
. «». . « ».

.

, . , .

, , .
«» , , .. .
– «DeclareSection». , , . , .
Declare .
#include <Wire.h>
#include <HMC5883L.h>
HMC5883L compass;
int error = 0;
, . , . Loop. Declare.

Declare , .
#define.
:
typedef struct{
...
...}
test;
:
struct test{
...
...
};
extern. , .
«SetupSection». .
void setup()
{
// Initialize the serial port.
Serial.begin(9600);
Serial.println("Starting the I2C interface.");
Wire.begin(); // Start the I2C interface.
Serial.println("Constructing new HMC5883L");
compass = HMC5883L(); // Construct a new HMC5883 compass.
Serial.println("Setting scale to +/- 1.3 Ga");
error = compass.SetScale(1.3); // Set the scale of the compass.
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));
Serial.println("Setting measurement mode to continous.");
error = compass.SetMeasurementMode(Measurement_Continuous); // Set the measurement mode to Continuous
if(error != 0) // If there is an error, print it out.
Serial.println(compass.GetErrorText(error));
}
( ). . .

, «». , .
Loop.
void loop()
{
MagnetometerRaw raw = compass.ReadRawAxis();
MagnetometerScaled scaled = compass.ReadScaledAxis();
int MilliGauss_OnThe_XAxis = scaled.XAxis;
float heading = atan2(scaled.YAxis, scaled.XAxis);
float declinationAngle = 0.0457;
heading += declinationAngle;
if(heading < 0)
heading += 2*PI;
if(heading > 2*PI)
heading -= 2*PI;
float headingDegrees = heading * 180/M_PI;
Output(raw, scaled, heading, headingDegrees);
}
Setup . . Loop. , , .
:
Output (raw, scaled, heading, headingDegrees). , . «FunctionSection»
« ».

, .

.
void Output(MagnetometerRaw raw, MagnetometerScaled scaled, float heading, float headingDegrees)
{
Serial.print("Raw:\t");
Serial.print(raw.XAxis);
Serial.print(" ");
Serial.print(raw.YAxis);
Serial.print(" ");
Serial.print(raw.ZAxis);
Serial.print(" \tScaled:\t");
Serial.print(scaled.XAxis);
Serial.print(" ");
Serial.print(scaled.YAxis);
Serial.print(" ");
Serial.print(scaled.ZAxis);
Serial.print(" \tHeading:\t");
Serial.print(heading);
Serial.print(" Radians \t");
Serial.print(headingDegrees);
Serial.println(" Degrees \t");
}
, . . .

.
. , .

«».

.
— .