Post Go back to editing

Getting data from ADIS16470AMLZ

Category: Hardware
Product Number: ADIS16470AMLZ

Hi all,

I'm just starting in the embedded field and i need some help to reading the data from the ADIS16470AMLZ device to a Linux system.

Is there any example program to read and process these data?

Can someone point me in the right direction? Any help will be appreciated.

Regards,

Hareendran M G



Moved to MEMS Inertial Sensors forum and added tag.
[edited by: emassa at 3:59 PM (GMT -5) on 16 Dec 2022]
Parents
  • Here is a sample python program to read data from the senosr

    import spidev
    import time

    spi = spidev.SpiDev()
    spi.open(0, 0)
    spi.max_speed_hz = 100000
    spi.mode = 0b11
    spi.lsbfirst = False

    def read_x_gyro_out():
    return convert_deci_to_deg_per_sec(read_signed_decimal(0x07))

    def read_y_gyro_out():
    return convert_deci_to_deg_per_sec(read_signed_decimal(0x0B))

    def read_z_gyro_out():
    return convert_deci_to_deg_per_sec(read_signed_decimal(0x0F))

    def read_signed_decimal(address):
    decimal_list = spi.xfer([address, 0x00])
    if decimal_list is None or len(decimal_list) != 2:
    raise RuntimeError('Did not read expected number of bytes from device!')

    hex_list = [hex(x) for x in decimal_list]

    hex_int_1 = int(hex_list[0], 16)
    hex_int_2 = int(hex_list[1], 16)

    hex_16_bit = (hex_int_1 << 8 | hex_int_2)
    binary_string = bin(hex_16_bit)[2:].zfill(16)

    # Check if the binary number is negative (starts with 1)
    if binary_string[0] == '1':
    # Convert the binary number to an unsigned integer
    unsigned_decimal = int(binary_string, 2)
    # Subtract 65536 from the unsigned integer to get the signed decimal
    signed_decimal = unsigned_decimal - 65536

    return signed_decimal
    # If the binary number is not negative (starts with 0), simply convert it to an integer
    else:
    return int(binary_string, 2)


    def convert_deci_to_deg_per_sec(deci):
    return str((deci/10)) + ' deg/sec'


    while(True):
    print('x_gyro_out: ' + read_x_gyro_out())
    print('y_gyro_out: ' + read_y_gyro_out())
    print('z_gyro_out: ' + read_z_gyro_out())
    print('================================')
    time.sleep(0.5)

  • Thank you for sharing this with the forum! Good luck with your work on the ADIS16470.  We look forward to seeing future questions in this forum! 

Reply Children
No Data