-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadis16210_example.py
61 lines (44 loc) · 1.66 KB
/
adis16210_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#Copyright (c) 2025 Analog Devices, Inc. All Rights Reserved.
#This software is proprietary to Analog Devices, Inc. and its licensors.
#
#Author: Alex Nolan
#requires pythonnet to be installed (pip install pythonnet)
import clr
from time import sleep
import os
#get path to resources folder and dll
topDir = os.path.join(os.getcwd(), '..\..\..')
#Load FX3 API Wrapper DLL
clr.AddReference(topDir + '\\resources\\FX3ApiWrapper.dll')
#Allows wrapper to be treated like standard python library
from FX3ApiWrapper import *
from System import Array
from System import String
#Create FX3 Wrapper and load ADIS16210 regmap
Dut = Wrapper(topDir + '\\resources\\', topDir + '\\regmaps\\ADIS16210_RegMap.csv',SensorType.StandardImu)
#Set SPI parameters per datasheet (830KHz sclk, 40us stall)
print("Configuring SPI settings")
Dut.SetSpiStallTime(40)
Dut.SetSCLKFreq(830000)
print("DUT reset")
Dut.ResetDut()
print(Dut.FX3.GetFirmwareVersion)
print("PROD_ID: " + str(Dut.ReadUnsigned("PROD_ID")))
Dut.UserLEDBlink(2.0)
#61ug per LSB
accel_scale = 61.0 / 10**6
#Create reg list
regs_py = ['XACCL_OUT','YACCL_OUT','ZACCL_OUT','TEMP_OUT']
regs = Array[String](regs_py)
data = []
#Enable data ready on DIO1 (0x0005)
Dut.WriteSigned("DIO_CTRL", 5)
print("Configuring decimation filter")
#Sample rate = 512/2^AVG_CNT
Dut.WriteSigned("AVG_CNT", 6)
print("Fs = " + str(Dut.MeasurePinFreq(1)) + "Hz") #DIO1 is data ready
Dut.SetDrActive(True)
while True:
data = Dut.ReadSigned(regs)
temp_c = (data[3] - 1331.0) * -0.47 #Zero C at 1331, -0.47C/LSB
print("XA: " + str(data[0] * accel_scale) + " YA: " + str(data[1] * accel_scale) + " ZA: " + str(data[2] * accel_scale) + " TEMP: " + str(temp_c))