No changes between revisions
/Modules/Mechanical/WINDGAUGE01A/SW/Data_analyser.ipynb
0,0 → 1,88
{
"metadata": {
"name": "",
"signature": "sha256:c35f5f2963a30c62e2bc2437fc0d2422404aec0dbc3c5526df0be8cecdef27ee"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import h5py\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"file = h5py.File('test_rps.hdf5', 'r') # 'r' means that hdf5 file is open in read-only mode\n",
"dataset = file['RPS01']"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"print dataset.value[:,1]"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"[ 1.45415117e+09 1.45415117e+09 1.45415117e+09 ..., 1.45415168e+09\n",
" 1.45415168e+09 1.45415168e+09]\n"
]
}
],
"prompt_number": 20
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plt.plot(dataset.value[:,1], dataset.value[:,2], color = 'r')"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 22,
"text": [
"[<matplotlib.lines.Line2D at 0x7f9d48ecac50>]"
]
}
],
"prompt_number": 22
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
/Modules/Mechanical/WINDGAUGE01A/SW/test_rps.hdf5
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Modules/Mechanical/WINDGAUGE01A/SW/test_rps.log.hdf5
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/Modules/Mechanical/WINDGAUGE01A/SW/wind_gauge.py
0,0 → 1,87
#!/usr/bin/python
 
# Python library for RPS01A MLAB module with AS5048B I2C Magnetic position sensor.
 
#uncomment for debbug purposes
#import logging
#logging.basicConfig(level=logging.DEBUG)
 
import time
import datetime
import sys
from pymlab import config
 
#### Script Arguments ###############################################
 
if len(sys.argv) != 2:
sys.stderr.write("Invalid number of arguments.\n")
sys.stderr.write("Usage: %s PORT ADDRESS\n" % (sys.argv[0], ))
sys.exit(1)
 
port = eval(sys.argv[1])
#### Sensor Configuration ###########################################
 
''''
cfg = config.Config(
i2c = {
"port": port,
},
 
bus = [
{
"type": "i2chub",
"address": 0x72,
"children": [
{"name": "encoder", "type": "rps01", "channel": 1, }
],
},
],
)
 
'''
cfg = config.Config(
i2c = {
"port": port,
},
bus = [
{
"name": "encoder",
"type": "rps01",
},
],
)
 
 
cfg.initialize()
 
print "RPS01A magnetic position sensor RPS01 readout example \r\n"
sensor = cfg.get_device("encoder")
 
print sensor.get_address()
print sensor.get_zero_position()
 
#### Data Logging ###################################################
 
try:
while True:
# for i in range(10):
angle1 = sensor.get_angle(verify = False)
time.sleep(0.1)
angle2 = sensor.get_angle(verify = False)
time.sleep(0.1)
angle3 = sensor.get_angle(verify = False)
if (angle1 < angle2):
speed = (angle2 - angle1)/0.01
else:
speed = (360 - angle1 + angle2)/0.01
sys.stdout.write("Speed: " + str(speed) +"\t"+ str(angle1) +"\t"+ str(angle2) + "\t\tMagnitude: " + str(sensor.get_magnitude())
+ "\tAGC Value: " + str(sensor.get_agc_value()) + "\tDiagnostics: " + str(sensor.get_diagnostics()) + "\r\n")
sys.stdout.flush()
time.sleep(0.01)
except KeyboardInterrupt:
sys.exit(0)