Skip to content

When the instrument doesn't exist, build it

Some checks need an instrument nobody sells, or one that costs too much to buy for every bench. Here one small single-board computer with an I/O board watches a thermostat's wires and also runs the test, so the bench needs no other computer. The last post put two instruments in one test, and the one before it swapped one for another; this one builds the instrument.

A check nobody sells an instrument for

Some of a device's behavior only shows up over time. This thermostat protects its compressor: after cooling stops, it holds off for four minutes before it cools again, even if the room warms up straight away.

Checking that by hand means watching a clock and a wire at the same time, calling for cooling, and noting when the wire closes. It's slow, it usually needs more than one try, and the answer is whatever the person watching wrote down. Off-the-shelf equipment can read a wire, but this check is a wire and a clock together, inside a test, and that combination is often what a bench is missing.

One small computer as test equipment and runner

The bench is a Wi-Fi thermostat as the device under test, and a small single-board computer with an I/O board wired to its heat, cool, and fan wires. The computer answers a small API that reports what it sees on each wire.

In Knilb, a plan declares named roles, and a deployment binds a participant to each one. The thermostat fills one role, and the computer is registered as test equipment and fills another, relay_monitor. Each step names the role it checks, so the test asks the thermostat what it reports and asks the computer what the wires did.

The same computer is also the client that runs the test. The Knilb CLI installs on it, and it is registered as a client like any other machine, so it sends the thermostat its commands and checks the wires itself.

Four minutes, checked at the wire

The test first waits long enough that no earlier protection is still holding, then calls for cooling. The computer confirms the cool wire closed and the fan wire closed with it, while the heat wire stayed open. After a minute of cooling, the test ends the call, then calls for cooling again at once.

Now the cool wire must stay open while the protection holds. Each step can wait before its request, so the test checks the wire once a minute, and the computer finds it open at all three checks. Once the four minutes are up, the same check finds the wire closed. The computer also counted three changes on the cool wire, closed, open, and closed again, so the cooling call never came early.

The run took about fifteen minutes on the bench, and the long waits are sped up in the video. What it shows is specific: one small computer, one thermostat, and one test, with the computer as both the test equipment and the runner.

The answer comes from the wire

The result keeps every step and the device that answered it, so each check inside the four minutes is there to read. It also freezes the deployment as it was cast, with the address of the device in each role, so it's clear the computer answered every wire check.

The thermostat said when it was cooling. The wire said when it actually called the compressor, and that is the answer the test relies on.

Build the one your bench needs

When the instrument a bench needs doesn't exist, a small computer with the right inputs can be built to answer the test, and Knilb runs it as one more role in the plan. Two public examples show the pattern: the thermostat relay monitor used here, and a web relay stand-in built on the same hardware. They are examples to read and rebuild for your own bench, not a kit.

The bench story shows this bench in context beside the others.

If your tests depend on timing, or on an instrument you can't buy, tell us what you're building, and we'll work through it with you as a design partner.

Become a design partner