A lot of project documentation stops at “here is how it works”,
without ever showing “here is the measured proof that it really works”. Yet
tests and their results are what separates a claim
from a proof.
Starting again from the success criteria
Your tests are not invented at the last minute: they follow directly
from the success criteria of the specification. See
Defining your need
and its table of functions. If the criterion is “sorting rate ≥ 80% over 20
trials”, the test literally consists of running the 20 trials and counting.
A simple test protocol
The docs/tests.md page of your template follows this structure: a
summary table at the top (criterion, expected value, measured value, validated or
not), then one section per test. Duplicate the example section for each
criterion of your specification.
Copy the protocol template (Markdown)
## Test: rate of correct sorting
**Target criterion:** ≥ 80% over 20 trials (see the specification)
**Method:** place 20 known items of waste (a mix of plastic/glass/metal)
one by one on the belt, and note the category detected by the robot.
**Conditions:** lighting of the Forum des Sciences (simulated with ...),
room temperature.
## Results
| Trial | Real waste | Detection | Correct? |
|---|---|---|---|
| 1 | Plastic | Plastic | ✅ |
| 2 | Glass | Metal | ❌ |
| ... | ... | ... | ... |
**Result:** 17/20 = 85%; criterion met.
Presenting the results clearly
A table for repeated measurements (as above).
A short video for dynamic behaviour (a mechanism that
moves, a system in operation): often more telling than a
written description.
A chart if you have continuous measurements (temperature over
time, speed against load). The template can plot one from
a CSV file (see just below).
Plotting a chart from a CSV file
Export your measurements as CSV (spreadsheet, serial monitor…) with a header
row: the first column is used as the X axis, each other column is a
curve, and the column names are used as the legend. Put the file in
docs/assets/data/, then in your page:
The type="bar" option plots a bar chart, type="scatter" points
only. A download link for the CSV is displayed below the chart. The
template contains a complete example in docs/tests.md, to be replaced by
your measurements.
Show the failures too
A test that fails (3 failed trials out of 20 in the example above) is not to be hidden. Note under what conditions it fails: that is information as useful as the success rate, and it ties in with the “Known limitations” section seen in Making your project transferable.
Proving by calculation, not only by measurement
A measured result only takes on its full meaning when compared with an expected
value. For anything to do with mechanics, electricity or
energy, that value is calculated in advance: this is the derivation.
It answers “why should it work?” before the test answers
“does it work?”.
When you compare the calculation and the measurement, three cases are possible:
They agree: you have solid proof, and the formula tells you
how far you can push (maximum load, battery life, speed…).
They differ a little: a gap is normal (friction, tolerances,
imperfect components), provided you quantify and explain it.
They differ a lot: one of your assumptions is wrong. That is
valuable information, to be documented as a failure (see the box
above).
A readable derivation always follows the same five steps:
Assumptions: what you assume (full battery, constant current,
friction neglected…).
Formula: the physical law or the relation used, with the meaning of
each symbol and its unit.
Symbolic calculation: isolate the quantity you are looking for before replacing
with numbers.
Numerical application: replace with the values, keeping the
units.
Comparison with the measurement: gap, explanation, conclusion.
A calculation is not a measurement
The calculation gives the value in an ideal world, the measurement gives that of your real prototype. Neither replaces the other: the calculation explains, the measurement confirms.
Writing a formula in a Markdown page
Markdown cannot write mathematics. Your project’s site
relies on MathJax, a library that reads a formula written in
LaTeX (the formula language of scientists) and draws it in the
browser. So you write only text, and the formatting is done
at display time. The route, from your file to the screen:
You write the formula in LaTeX, between two $$, in your
.md file.
Jekyll (the site generator) spots the $$ and sets the formula
aside, without applying the Markdown rules to it: the _ and *
of a formula therefore do not become italics.
MathJax, loaded in every page, spots these formulas and draws them.
Always two $$, never a single $. A single $ is not recognised:
the formula would be displayed as plain text, and Markdown could even
distort it (an *x* would become italic).
Depending on where you place the $$, the formula stays in the text or
stands apart, centred:
You want
You write
Result
A formula in a sentence
the $$ in the middle of a line of text
the formula stays in the line
A centred formula, set apart
the $$ alone on their line, with an empty line before and one after
the formula is centred, on its own line
The empty line is essential: without it, the formula stays attached to the
previous paragraph and becomes an “in the text” formula again.
Here is what you write in the file:
With a battery of capacity $$C = 2000\ \text{mAh}$$ and an average current
of $$I_{\text{avg}} = 570\ \text{mA}$$, the theoretical battery life is:
$$
t = \frac{C}{I_{\text{avg}}} = \frac{2000}{570} \approx 3.5\ \text{h}
$$
And here is what the reader sees:
With a battery of capacity $C = 2000\ \text{mAh}$ and an average current
of $I_{\text{avg}} = 570\ \text{mA}$, the theoretical battery life is:
$$
t = \frac{C}{I_{\text{avg}}} = \frac{2000}{570} \approx 3.5\ \text{h}
$$
The most useful commands
To write
You type
Result
A fraction
\frac{a}{b}
$\frac{a}{b}$
An exponent
x^{2}
$x^{2}$
A subscript
I_{\text{avg}}
$I_{\text{avg}}$
A square root
\sqrt{x}
$\sqrt{x}$
Multiply, approximately, compare
\times\approx\geq\leq
$\times\ \approx\ \geq\ \leq$
Greek letters
\tau\Omega\pi\Delta
$\tau\ \Omega\ \pi\ \Delta$
A value with its unit
2000\ \text{mAh}
$2000\ \text{mAh}$
A decimal comma (French notation)
3{,}5
$3{,}5$
A percentage
85\,\%
$85\,\%$
Three classic pitfalls:
The decimal comma, if you write your numbers the French way, is written {,}: with a
bare comma, LaTeX adds a space after it and 3,5 is displayed as “3, 5”.
The percentage is written \%: a bare % is taken for a
comment, and the rest of the line is ignored.
Words and units go in \text{...}: without it, mAh is
displayed in italics like a product of three variables m, A and h.
A space is written with a backslash followed by a space (as in
2000\ \text{mAh}) or with \, (thin space).
The formula is displayed as it is?
If you see the $$ and the \frac as plain text, MathJax is not loaded in your site. Check that the file docs/_includes/head_custom.html contains the line below (create it, along with the _includes folder, if it does not exist). If it already exists, add the line at the end without deleting anything.
Complete example: the battery life of the sorting robot
Let us take the criterion “battery life ≥ 4 h” and go through the five steps of the
derivation.
1. Assumptions. Full battery, constant average current for the whole
duration, usable capacity equal to the rated capacity (no loss).
2. Formula. The capacity of a battery is the electric charge it
can supply: it equals the current multiplied by the duration.
$$
C = I_{\text{avg}} \times t
$$
with $C$ the capacity (in mAh), $I_{\text{avg}}$ the average current (in mA) and
$t$ the duration (in h).
3. Symbolic calculation. We isolate $t$, the quantity we are looking for. The & align
the equals signs and \\ starts a new line:
$$
\begin{aligned}
C &= I_{\text{avg}} \times t \\
t &= \frac{C}{I_{\text{avg}}}
\end{aligned}
$$
$$
\begin{aligned}
C &= I_{\text{avg}} \times t \\
t &= \frac{C}{I_{\text{avg}}}
\end{aligned}
$$
4. Numerical application. We replace, units included:
$$
t = \frac{2000\ \text{mAh}}{570\ \text{mA}} \approx 3.5\ \text{h}
$$
The units do simplify to hours ($\text{mAh} / \text{mA} = \text{h}$):
it is a free check. If you get a unit other than the one
expected, the formula is wrong.
5. Comparison with the measurement. The test gives 3 h 30, that is $3.5\ \text{h}$:
the calculation and the measurement agree, the model is good. But the criterion of the
specification (≥ 4 h) is not met, and the same formula says what
to change:
So you need to bring the average consumption down from 570 mA to 500 mA (putting
the sensor to sleep between two items of waste, for example), or move to a battery
of at least 2280 mAh. It is this derivation, and not only the measured
figure, that makes your choice of solution credible.
Copy the derivation template (Markdown)
## Derivation: theoretical battery life
**Assumptions**: full battery, constant average current, no loss.
**Formula**:
$$
t = \frac{C}{I_{\text{avg}}}
$$
with $$C$$ the capacity (mAh), $$I_{\text{avg}}$$ the average current (mA) and
$$t$$ the duration (h).
**Numerical application**:
$$
t = \frac{... \text{ mAh}}{... \text{ mA}} \approx ...\ \text{h}
$$
**Measurement**: ... h. **Gap**: ... %. **Conclusion**: ...
Exercise
Choose a success criterion from your specification, write its
test protocol with the template above, actually run it, and
note the results, failures included.
If your criterion is numerical (a mass lifted, a current, a speed,
a duration…), first write the derivation that predicts the result, with
the formulas, then compare it with what you measured.