Figure 8 :: I2C Interface Connections - Lightware SF11/C Product Manual

Laser altimeter
Table of Contents

Advertisement

I2C interface
The I2C interface on the main connector can be used to output a value that represents the altitude in centimetres. This interface
operates in "slave" mode and uses 3.3 V logic levels. The I2C address can be set through the USB menu system. The host controller
acts as the I2C "master" and sends the address to the SF11 as an 8 bit value (7 address bits plus 1 read/write bit). The SF11 then
returns the altitude as a 16 bit integer. The maximum delay between receiving the address and returning the altitude is 25 ms.
The I2C bus also has a binary coded command set that can be used to retrieve or change values. Distance values are always in
centimetres and signed values are permitted where used. The main I2C address can only be set through the USB menu and cannot be
change accidentally through the I2C port.
Values in the SF11 are held at specific locations and once a value has been read or written the location remains active until changed.
This is useful to simplify the code needed for the continuous monitoring of a value. For example, to update the distance
continuously, set the distance location once then read the value in a loop like the Arduino code below:
float distance;
byte a, b;
void setup()
{
Wire.beginTransmission(0x66);
Wire.write(0);
Wire.endTransmission();
}
void loop()
{
delay(50);
Wire.requestFrom(0x66, 2);
while(Wire.available())
{
a = Wire.read();
b = Wire.read();
}
distance = (float)(a * 256 + b)/100;
}
Writing new values also makes the new location active so it needs to be changed back again if you want to monitor something else.
In this example the zero datum offset value is updated then the distance is read continuously:
float zero_offset = 0.34;
a = (byte)(zero_offset * 100 >> 8);
b = (byte)(zero_offset * 100 && 0xff);
void setup()
{
Wire.beginTransmission(0x66);
Wire.write(7);
Wire.write(a);
Wire.write(b);
Wire.endTransmission();
Wire.beginTransmission(0x66);
Wire.write(0);
Wire.endTransmission();
}
Caution
Ensure that a unique I2C address is assigned to the SF11 and that no other devices share this address.
SF11 Laser altimeter - Product manual - Revision 10
// Distance will be in meters
// Bytes read by the I2C port
// One time setup
// Enable transmission to the I2C address
// Write the distance location -> 0
// End the transmission
// The output registers are now configured to send the distance
// Main loop
// Delay or user code here
// Request 2 bytes from the SF11
// Make sure the SF11 sends the required number of bytes
// Fetch the high byte of the distance
// Fetch the low byte of the distance
// Convert to a floating point value in meters
// Start with a new zero datum value in meters
// Convert to cm and fetch the high byte
// Fetch the low byte
// One time setup
// Enable transmission to the I2C address
// Write the zero datum offset location -> 7
// Write the high byte of the zero datum
// Write the low byte of the zero datum
// End the transmission
// The zero datum location is still active but is not needed
// Enable transmission to the I2C address
// Write the distance location -> 0
// End the transmission - the distance location is now active

Figure 8 :: I2C interface connections

|
|
8
of
20
© LightWare Optoelectronics (Pty) Ltd, 2021
SF11 Laser altimeter
Product manual
|
www.lightwarelidar.com

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sf11 seriesSf11/bSf11Sf10Sf11-c

Table of Contents