Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rotolevel

Measures the zero offset of a Murata SCL3300 inclinometer by rotary-table reversal.

A sensor cannot tell its own bias apart from a real tilt by measuring once. Measuring the same tilt twice, 180° apart, does separate them: the tilt flips sign between the two readings and the bias does not, so their average is the bias.

reading(0°)   =  tilt + offset
reading(180°) = -tilt + offset
offset        = (reading(0°) + reading(180°)) / 2

A Raspberry Pi drives a motorised table to 0°, 180° and 90°, samples the sensor over SPI at 10 Hz throughout, and writes CSV and XLSX reports. The 90° station is a cross-check: the tilt projects to nothing there, so the reading should equal the offset.

Try it without hardware

Every command takes --fake-hardware, which swaps the sensor and table for a simulator. Because the simulator injects a known offset, this doubles as a check that the maths is right — the reported offset should come back as the injected one.

pip install -e . && rotolevel init-db && rotolevel run --fake-hardware --calibration-time 2 --measurement-time 5

On the rig

pip install -e '.[pi,xlsx]' && rotolevel init-db && rotolevel run --iterations 3
Command Does
rotolevel init-db Create the database schema
rotolevel run Drive a full calibration and measurement run
rotolevel report Rebuild reports from data already stored
rotolevel monitor Print live sensor readings
rotolevel motor-demo Step the table through its stations, recording nothing

Hardware

  • Raspberry Pi with SPI enabled (dtparam=spi=on)
  • Murata SCL3300 inclinometer on SPI0, CE0
  • Rotary table with a two-bit direction input and a position sensor
Signal BCM pin
Position sensor (active low) 22
Direction bit 0 27
Direction bit 1 17

Wiring and the motor interface are in docs/hardware.md; the sensor protocol is in docs/scl3300.md; the method is in docs/measurement.md.

Configuration

Everything has a working default. Copy .env.example to .env to change anything — sampling rate, GPIO pins, report location, or the database backend. SQLite is the default and needs no server; MySQL/MariaDB is available with ROTOLEVEL_DB_BACKEND=mysql plus credentials.

Output

One directory per run under reports/, holding angle_x.csv and angle_y.csv (every sample), summary_x.csv and summary_y.csv (one row per iteration), and an XLSX workbook with charts. CSVs use ; separators and a decimal comma, which German-locale Excel opens directly.

Measurement rows have the offset subtracted; calibration rows do not, since the offset was derived from them.

Tests

pip install -e '.[dev,xlsx]' && pytest

The suite runs anywhere — no Raspberry Pi needed.

License

MIT — see LICENSE.

About

SCL3300 inclinometer zero-offset measurement by rotary-table reversal, on a Raspberry Pi.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages