Пример #1
0
import time  #タイムカウントに使用するライブラリ
from datetime import datetime  #タイムスタンプに使用するライブラリ
import numpy as np  #配列計算、FFT化する時に使用するライブラリ
import pandas as  pd  #数式、配列を操作するライブラリ
import csv  #csvを作成するライブラリ
import matplotlib.pyplot as plt
import sys  #ファイルを読み出したい時に使用するライブラリ
sys.path.append('/home/pi/Documents/adxl355/')
from adxl355 import ADXL355  # pylint: disable=wrong-import-position
device = ADXL355()            # pylint: disable=invalid-name
#t0 = time.time()

Temperature_Response = device.read_data(0x06) <<8 | device.read_data(0x07)
Temperature = (Temperature_Response - 1852) / (-9.05) + 25
print("Temperature[degC]", int(Temperature))

device.write_data(0x28, 0x02)  #LowPass-filter #0x02:ODR1kHz/LPF250Hz
#print("filter_setting", device.read_data(0x28))

#しきい値を指定
threshold_value_MAX = -0.55
#threshold_value_MIN = 0.009

#グラフのレンジ指定
x_axis_range_min = 0
x_axis_range_max = 400
y_axis_range_min = 0
y_axis_range_max = 100

def data_collection():
    global t1
Пример #2
0
import time
import datetime
import sys
from defined_functions import *
from adxl355 import ADXL355
# Open file
filename = '{0:%Y%m%d-%H.%M.txt}'.format(datetime.datetime.now())
output_file = open(filename, 'w')
print(filename)
# Constants
temp_scale = -9.05  # LSB/oC
temp_bias = 1852  # LSB

# Start sensor
sensor = ADXL355()
time.sleep(0.2)

# Reset all settings
sensor.reset_settings()
time.sleep(0.2)

# Set measure mode
sensor.set_measure_mode(drdy_off=1, temp_off=0, standby=0)

# Set settings
f_s = 3  # [Hz]
dt = 1 / f_s  # [s]

range_g = 0x01  # 2g range
sensor._set_measure_range(range_g)  #Set range
odr_lpf = 0xA  # ODR: 3.906Hz, LPF:
import numpy as np
import csv
import pandas as pd

t00=time.time()
#print(sys.path)

sys.path.append('/home/pi/Documents/')

#print(sys.path)

#time.sleep(1)

from adxl355 import ADXL355

device = ADXL355()


loop_num = 4096
loop_int = 0.00007 #可変

'''
x = []
y = []
z = []
'''

time.sleep(0.1)
print('start')

index=1
Пример #4
0
from time import sleep
from adxl355 import ADXL355, ADXL355Range

adxl = ADXL355()

if adxl.isRunning:
    adxl.end()

adxl.range = ADXL355Range.range2G

adxl.begin()

print "Current temperature is %fC" % (adxl.temperature)
print
print "Press Ctrl-C to exit"

try:
    while True:
        axes = adxl.axes
        print "x = %d\ty = %d\tz = %d" % (axes['x'], axes['y'], axes['z'])
        sleep(1.0)
except KeyboardInterrupt:
    # Assumes nothing external fiddles with this register
    print "Ctrl-C seen - exiting"
    adxl.end()