Skip to content

Instantly share code, notes, and snippets.

@scspaeth
Last active June 3, 2019 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scspaeth/d376b3fb1b9626300fb3a132514cb06b to your computer and use it in GitHub Desktop.
Save scspaeth/d376b3fb1b9626300fb3a132514cb06b to your computer and use it in GitHub Desktop.
Fork of TI SensorTag Gyro; using CC2541 GyroUUIDs and Phyphox Accel params,
<phyphox version="1.7">
<title>Gyroscope</title>
<category>PocketLab One</category>
<description>Read the gyroscope of the PocketLab One and convert raw sensor readings to Angular Velocity in rad/s.</description>
<data-containers>
<container size="0">gyrXRaw</container>
<container size="0">gyrYRaw</container>
<container size="0">gyrZRaw</container>
<container size="0">gyrXCal</container>
<container size="0">gyrYCal</container>
<container size="0">gyrZCal</container>
<container size="0">t</container>
<container size="1">count</container>
<container size="1">tmax</container>
</data-containers>
<input>
<bluetooth name="MS-PL" mode="notification">
<config char="F000AA53-0451-4000-B000-000000000000" conversion="hexadecimal">0A</config> <!-- Measurement period n*10msec -->
<config char="F000AA52-0451-4000-B000-000000000000" conversion="hexadecimal">07</config> <!-- Axis select bit1:x bit2:y bit3:z -->
<output char="F000AA51-0451-4000-B000-000000000000" conversion="int16LittleEndian" offset="0">gyrXRaw</output>
<output char="F000AA51-0451-4000-B000-000000000000" conversion="int16LittleEndian" offset="2">gyrYRaw</output>
<output char="F000AA51-0451-4000-B000-000000000000" conversion="int16LittleEndian" offset="4">gyrZRaw</output>
</bluetooth>
</input>
<views>
<view label="Angular Velocity Data">
<graph label="Angular velocity X" labelX="t: time" unitX="s" labelY="gyrXCal: ω" unitY="rad/s" partialUpdate="true">
<input axis="x">t</input>
<input axis="y">gyrXCal</input>
</graph>
<graph label="Angular velocity Y" labelX="t: time" unitX="s" labelY="gyrYCal: ω" unitY="rad/s" partialUpdate="true">
<input axis="x">t</input>
<input axis="y">gyrYCal</input>
</graph>
<graph label="Angular velocity Z" labelX="t: time" unitX="s" labelY="gryZCal: ω" unitY="rad/s" partialUpdate="true">
<input axis="x">t</input>
<input axis="y">gyrZCal</input>
</graph>
</view>
</views>
<analysis optimization="true">
<multiply>
<input clear="false">gyrXRaw</input>
<input type="value">0.001065264</input> <!-- 2000 * 2*pi / 360 / 32768 -->
<output clear="true">gyrXCal</output>
</multiply>
<multiply>
<input clear="false">gyrYRaw</input>
<input type="value">0.001065264</input>
<output clear="true">gyrYCal</output>
</multiply>
<multiply>
<input clear="false">gyrZRaw</input>
<input type="value">0.001065264</input>
<output clear="true">gyrZCal</output>
</multiply>
<count>
<input clear="false">gyrXRaw</input>
<output>count</output>
</count>
<formula formula="([1]-1)*0.1">
<input clear="false">count</input>
<output>tmax</output>
</formula>
<ramp>
<input as="start" type="value">0</input>
<input as="stop">tmax</input>
<input as="length">count</input>
<output>t</output>
</ramp>
</analysis>
<export>
<set name="Gyroscope">
<data name="Time (s)">t</data>
<data name="Angular velocity x (rad/s)">gyrXCal</data>
<data name="Angular velocity y (rad/s)">gyrYCal</data>
<data name="Angular velocity z (rad/s)">gyrZCal</data>
</set>
</export>
</phyphox>
@scspaeth
Copy link
Author

scspaeth commented Jun 1, 2019

One can explore and connect the PocketLab One using the TI SensorTag app. The PL One mimics an earlier version of the TI SensorTag, the CC2541 (http://www.ti.com/tool/CC2541DK-SENSOR#3) which is now discontinued. This insight might help to design Phyphox experiments for the PL One.

@scspaeth
Copy link
Author

scspaeth commented Jun 1, 2019

Revision 8 connects with the PocketLab One and sends configuration data and receives raw gyro values but the output in graphs shows some similarity to gyro data but is non-sensical in other respects. The gyrX and gryY exhibit large changes in angular velocity (they shouldn't) and gryZ shows noisy and jittery patterns. I suspect that the problem may be an Endian mis-match with the gyroscope chip. The CC2650 uses an Invensense IMU and uses LittleEndian while the PocketLab One uses BigEndian. Try to switch.

@scspaeth
Copy link
Author

scspaeth commented Jun 1, 2019

Yes, the switch from Big to LittleEndian solved the weirdness in the Gyroscope output. gyrX and gyrY are now much smaller and the gyrZ axis shows a smooth damped harmonic oscillation when mounted on the unbalanced unicycle wheel.

@scspaeth
Copy link
Author

scspaeth commented Jun 2, 2019

When I forked this file, a some stage, I lost the 'ω' (omega) in the y-labels of the charts. So, I substituted the variable name for the formal physics representation. This has some utility because it helps users to know the variable names that are required to extract subsets of data using the Phyphox /get?xxx=full API requests. The API requires exact variable names including case matching and provides no results if the reference is not identical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment