Post Go back to editing

Category: Hardware

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

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('================================')
time.sleep(0.5)

• 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

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):