Main Content

adis16505

Connect to ADIS16505 sensor on Arduino hardware SPI bus

Since R2024a

    Description

    The adis16505 object reads acceleration, angular velocity, and temperature using the ADIS16505 sensor connected to the SPI bus of the hardware. The ADIS16505 sensor is an inertial measurement unit (IMU) used to read acceleration and angular velocity in all three dimensions. The ADIS16505 sensor also has an embedded temperature sensor. Attach an ADIS16505 sensor to the SPI pins on the hardware. You can read the data from your sensor in MATLAB® using the object functions.

    Creation

    Description

    imu = adis16505(obj,'SPIChipSelectPin',chipSelectPin) creates a sensor object with default property values.

    Example: imu = adis16505(a,'SPIChipSelectPin','D10');.

    imu = adis16505(a,'SPIChipSelectPin',chipSelectPin,Name,Value) creates a sensor object with properties using one or more Name,Value pair arguments.

    Example: imu = adis16505(a,'SPIChipSelectPin',D10,'SampleRate',50);.

    Input Arguments

    expand all

    Arduino hardware connection created using arduino, specified as an object.

    Example: imu = adis16505(a,'SPIChipSelectPin',chipSelectPin) creates a connection to the ADIS16505 sensor on the hardware represented as an object, a.

    Name-Value Arguments

    Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Specifying SPIChipSelectPin is mandatory for Name-Value pair.

    Example: sensorObj = adis16505(a,'SPIChipSelectPin','D10','Name', Value, ...)

    10 is the SPIChipSelectPin number of the accelerometer and gyroscope of ADIS16505 connected to Arduino board.

    Properties

    expand all

    Note

    • All the properties except SamplesRead and SamplesAvailable can be set by specifying as name-value pair arguments while creating an adis16505 object.

    • The property SPIChipSelectPin is immutable (the property value is set during construction; you cannot change the value of an immutable property after the object is created).

    • The TimeFormat property is tunable, which means you can change the value anytime.

    • The SampleRate, SamplesPerRead, ReadMode, and OutputFormat properties are non-tunable, which means you cannot change their values once the object is locked. Objects are locked when you call the read function, and the release function unlocks them. If a property is tunable, you can change its value at any time.

    Enter the pin number on the Arduino® board to which the sensor chip select pin is connected. Press tab to view or identify the list of available pins.

    Specify the number of taps for Bartlett window filter. The default value is 1.

    The rate in samples/s at which data is read from the sensor.

    Data Types: double

    Number of samples read from the sensor in a single execution of the read function.

    Data Types: double

    Specify whether to return the latest or the oldest data samples. The number of samples depends on the SamplesPerRead value. The data read from the sensor is stored in the MATLAB buffer.

    • latest

      Provides the latest data samples available in the buffer. All previous data samples in the buffer are discarded. For example, if SamplesPerRead = 3, the latest three data samples read by the sensor are returned.

      The following figure illustrates how latest data samples are returned assuming S1 is the first sensor data stored in the buffer, S2 is the second data and so on and Sn is the last data stored in the buffer and SamplesPerRead property is set to 3 during sensor object creation.

    • oldest

      Provides the oldest data samples available in the buffer. In this case, no data samples are discarded. For example, if SamplesPerRead = 3, the first three data samples read are returned for the first read, the next three data samples are returned for the second read, and so on.

      The following figure illustrates how oldest data samples are returned assuming S1 is the first sensor data stored in the buffer, S2 is the second data and so on and Sn is the last data stored in the buffer and SamplesPerRead property is set to 3 during sensor object creation.

    Data Types: character vector | string

    This property is read-only.

    Samplesread property outputs the values of samples read so far by executing read function. Samplesread is set to 0, when the object is created or when you release the object.

    Data Types: double

    This property is read-only.

    Samples available in the host buffer. The data read from the sensor is stored in the MATLAB buffer.SamplesAvailable property shows the number of SamplesAvailable in this host buffer. When you release the object, SamplesAvailable is set to 0. When the ReadMode of sensor is set as latest, SamplesAvailable will always be 0.

    Data Types: double

    Set the output format of the data returned by executing the read function.

    When the OutputFormat is set to timetable, the data returned has the following fields:

    • Time — Time stamps in datetime or duration format

    • Acceleration — N-by-3 array in units of m/s2

    • AngularVelocity — N-by-3 array in units of rad/s

    • Temperature — N-by-1 array in units of degree Celsius

    When the OutputFormat is set to matrix, the data is returned as matrices of acceleration, angular velocity, and time stamps. The units for the sensor readings are the same as the timetable format.

    N is the number of samples per read specified by SamplesPerRead. The three columns of each field represent the measurements in x, y, and z axes.

    Data Types: character vector | string

    Set the format of the time displayed when the sensor data is read.

    • datetime — Displays the date and time at which the data is read.

    • duration — Displays the time elapsed in seconds after the sensor object is locked. The sensor object gets locked at the first call of the read function either after the object creation or after the execution of the release function.

    Data Types: character vector | string

    Object Functions

    readAccelerationRead one sample of acceleration from sensor
    readAngularVelocityRead one sample of angular velocity from sensor
    readTemperatureRead one sample of temperature from sensor
    readRead real-time sensor data at a specified rate
    releaseRelease the sensor object
    flushFlush the host buffer
    infoRead information related to sensor

    Examples

    Create Connection to ADIS16505 Sensor

    Create an arduino object with the SPI library.

    a = arduino('COM3','Uno','Libraries','SPI');

    Create the sensor object.

    imu = adis16505(a,'SPIChipSelectPin','D10');
    imu =
    
    adis16505 with properties:
    
        NumTapsBartlettFilter: 1
    
                    Interface: "SPI"
             SPIChipSelectPin: "D10"
                       SCLPin: "D13"
                       SDIPin: "D12"
                       SDOPin: "D11"
    
                   SampleRate: 110 (samples/s)
               SamplesPerRead: 10
                     ReadMode: "latest"
                  SamplesRead: 0
             SamplesAvailable: 0
    
    Show all properties, functions
    

    Create ADIS16505 Sensor Connection with Additional Name-Value Pair Arguments

    Create a sensor object with additional properties specified as name-value pair arguments.

    imu = adis16505(a,'SPIChipSelectPin','D10','SampleRate',110,'SamplesPerRead',3,'ReadMode','latest')
    imu =
    
      adis16505 with properties:
    
        NumTapsBartlettFilter: 1
    
                    Interface: "SPI"
             SPIChipSelectPin: "D10"
                       SCLPin: "D13"
                       SDIPin: "D12"
                       SDOPin: "D11"
    
                   SampleRate: 110 (samples/s)
               SamplesPerRead: 3
                     ReadMode: "latest"
                  SamplesRead: 0
             SamplesAvailable: 0
    
    Show all properties all functions

    More About

    expand all

    Version History

    Introduced in R2024a