Expand description
A course’s Teensy data logger: one sensor’s reading a line, each line opening with the sensor’s tag and the logger’s clock in microseconds, in two layouts.
The Harvey Mudd College advanced rocketry course flies a data logger it builds around a Teensy
board, and publishes its flights’ files on its Flight Data page, which lists two kinds of
.TXT file, “Teensy Data Logger” and “New Teensy Data Logger”, read by the course’s own
scripts. No document describes either layout, so this reader takes them from the files, and
the sample logs’ survey (cargo xtask logs) holds each part of the reading that isn’t stated
to a physical check (ADR-274).
The tab-separated layout (LogFormat::TeensyTabs) writes a tag, the clock, then the
values, each field after a tab, shown here as spaces:
A 2000 0.25 -0.50 9.75
G 2000 1.50 0.50 -2.00
M 2000 20.10 -3.40 17.80
Alt 3100 P 95000 MSL 540.42
HG 3600 0.4788 -0.9577 10.5337
ADC Pin-35 3700 0.0120000000
ADC Pin-36 3800 0.0150000000No line states a unit. Three of the values are read in SI, each held by the survey to the files:
| Values | Read as | Held to |
|---|---|---|
A’s three | Quantity::Acceleration, m/s², as written | their magnitude on the pad, the 5 s ending 1 s before liftoff, and over the last 2 s, after landing, each within 3 % of standard gravity |
Alt’s P | Quantity::Pressure, Pa, as written | MSL worked out from it, below |
Alt’s MSL | Quantity::AltitudeMsl, m, as written | on every line, 44,330 × (1 − (P / 101,325)^(1/5.255)), the altitude formula of the Bosch BMP180 barometer’s data sheet (BST-BMP180-DS000, §3.6), to within 0.0103 m: its half step, 0.005 m, as it is written to the hundredth, and an allowance of 44,330 × 2⁻²³ m for the logger’s own rounding of the formula, whose form no document gives |
The MSL is so a pressure altitude, above where the pressure would be 101,325 Pa, not a
height above the sea. The rest is kept as written, Quantity::Unrecognized, as nothing
states its unit and no check settles one: the gyroscope (G), the magnetometer (M), a
quantity HPR Sim doesn’t hold, the high-g accelerometer (HG), whose magnitude during the
boost, while A reads from 3 g to 90 % of its greatest, is 1.37 to 2.39 times A’s in the
sample logs where both are read as m/s², and the two analog inputs. A
value is named by its tag and its place, counted from 1, such as A 1 or HG 3, or by its tag
and the name the line gives it, such as Alt P.
The layout with named fields (LogFormat::TeensyNamed) opens with a line for each
sensor stating its units, then writes a tag, t, the clock, and name–value pairs, comma
separated:
ICM data in us, milli-g, deg/s, milli-T, deg C
MS5 data in us, deg C, Pa
ICM, t, 500000500, xa, 12.20, ya, -20.50, za, 998.40, xg, 0.18, yg, -0.12, zg, 0.06, xm, 30.15, ym, 4.20, zm, -18.75, T, 24.50
MS5, t, 500001000, T, 24.10, P, 95000The first unit is the clock’s, and must be us. The others go to the fields by their names:
a name less a leading x, y or z is its group, so xa, ya and za are one, and the
units go to the groups in the order the first line of the tag names them; one unit stated goes to
every field if no name carries an axis’s x, y or z, as T1 and T2 don’t, or if all are
one group. A tag whose units don’t fit its groups so, or with no units line, such as a VOL line
the sample file writes, is kept as written, and a note says so. The units read are milli-g and
g, to m/s², deg/s, deg C, to kelvins, and Pa; any other is kept as written, as is
milli-T, a magnetic field. The survey holds two of the stated units to the files: the
milli-g accelerometer’s magnitude on the pad and over the file’s last 2 s, after landing,
within 3 % of 1,000 milli-g, as for A, and the Pa pressure on the pad between 50 and 110
kPa, as no launch site’s is outside it. The others rest on the file’s statement: in the sample
file, the high-g accelerometer read in its stated g is 0.996 times the milli-g one over the
boost, which the survey reports. A value
is named by its tag and its name, such as ICM xa.
The clock, in both layouts, is the logger’s count of microseconds, a whole number, read as seconds from the logger’s own zero. The named layout states its unit; the tab-separated one doesn’t, and the survey holds the reading to the flights: the time from liftoff to apogee, by the clock so read, is within a factor of 2 of √(2h/g) for the apogee’s height h, a coarse check (the burn adds time and drag takes some away), where a clock read wrongly by a power of ten is 10 or more times off. Each tag is a channel set on its own clock, as each sensor is read at its own rate.
What refuses the file. A line that isn’t a tag, a whole-number clock and values, or whose
tag’s layout (its count of values, or its names) differs from the tag’s first line, or whose
clock doesn’t increase from the tag’s line before (LogError::Syntax, naming its line). A
logger’s clock of this kind runs over after 2³² microseconds, 71.6 minutes, so a longer
recording is refused there. A file’s last line, if the file ends with no line end and the
line can’t be read, is a line the logger was writing when it stopped: it is dropped, and a
note says so. At most MAX_TAGS tags, MAX_VALUES values on a line and names of
MAX_NAME_BYTES: a file past them isn’t a logger’s.
The record has no barometric track, as neither layout writes an altitude above the pad:
FlightLog::time_s and FlightLog::altitude_m are empty, and every value is a channel.
Constants§
- MAX_
NAME_ BYTES - The longest a tag, a value’s name or a unit may be, bytes, three times the sample logs’
longest,
ADC Pin-35. - MAX_
TAGS - The most tags a file may hold, over four times the sample logs’ seven.
- MAX_
VALUES - The most values a line may hold, over six times the sample logs’ ten.
Functions§
- read
- Reads the tab-separated layout.
- read_
named - Reads the layout with named fields.
- recognizes_
named - Whether the text is the named layout: its first line that isn’t blank states a tag’s units,
the clock’s
usfirst, and one of its first 100 is a line of name–value pairs. - recognizes_
tabs - Whether the text is the tab-separated layout: its first line that isn’t blank is a tag, a
clock and values by tabs, and one of its first 100 is an
Altline,Alt, the clock,Pand a pressure,MSLand an altitude.