← Back to the notebookPower meter
A working note

Keeping the scanner handy

The saved scanner repeats its question every five seconds. It resets the responding-device count, tries the addresses, prints the result and waits before starting again. That’s a useful small program even beside a larger meter sketch. It leaves out sensor calibration and power calculations deliberately. I like being able to say exactly what the program asks before interpreting its answer.

The useful thing about the scanner is what it leaves out. It doesn't try to calculate RMS, apply sensor calibration or combine voltage and current. That makes its result narrower, but it also makes the result easier to interpret. I can ask whether the controller is getting a response from a device instead of asking why a power value looks wrong. The full program contains more of the project. It doesn't automatically give me a better first question when I don't yet know which part has gone wrong.

I'm thinking of the small sketches as different views of the same circuit. The scanner looks at communication. A raw-sampling program lets me look at what a channel returns. A calculation sketch can help me follow the maths after the reading. These views don't have to compete. Their value comes from answering different questions. If I expect one of them to establish the whole measurement, I lose the reason I separated them. I want to know exactly which stage I have checked before relying on the next stage.

Imagine a later result that seems unreasonable. There are at least two broad possibilities to separate before changing constants. The controller might not be receiving the intended information reliably, or it might be interpreting information incorrectly. That division isn't a diagnosis, but it gives me somewhere to start. A device response can support the first communication step without clearing the analog path or the maths. A raw value can show that something is being read without proving that its scale is right. Each small answer has a boundary.

I find those boundaries helpful because the screen tends to hide them. The final program prints one result after several things have happened. If a value passes through a sensor relationship, an offset subtraction, a square and an average, the last number doesn't tell me where a mistake entered. Going back to a simpler sketch means I can remove some of those questions temporarily. That isn't abandoning the finished program. It’s giving myself a less crowded place to think about it.

The raw sampler adds a different view. It reads A0 and A1 in sequence, calls computeVolts and prints each input-voltage value beside its integer count. I can describe the two files by their jobs rather than call them unfinished versions of the same thing. One examines communication and the other exposes the data at the next stage. The final program depends on both kinds of relationship, but adding features does not remove the earlier questions.

The conditions of the check still matter. If I change the pin arrangement or configuration when I return to the scanner, I need to know what changed. Otherwise I might compare results from different arrangements as if they were repetitions of the same check. Keeping a simple sketch doesn't make the whole test simple by itself. The circuit and the program have to describe the same setup. That’s another reason not to keep only a message saying that the scan worked and forget everything around it.

I want the files to remain understandable too. A name that makes sense only while I'm working can become confusing later. What does this version ask? What result should I expect if communication is present? What does a missing response leave unresolved? Those are more useful descriptions than calling something final, because final doesn't tell me which part of the circuit the file tests. I don't need a large system for this. I need enough explanation that the next opening of the file doesn't feel like meeting somebody else's project.

There’s an advantage when asking for help as well. A smaller program can make a smaller question visible. Instead of handing over a full meter sketch and asking which of many things is wrong, I can show the part that requests a response or reads a channel. My mentor may still need the wider circuit to interpret it, but the relevant question is easier to find. That helps me follow the reasoning too. I don't want the explanation to disappear inside a large program simply because I brought every feature to the discussion at once.

The separate sketch also preserves a useful stopping point. I can leave the larger experiment unfinished without losing the smaller question. That makes the next session less dependent on remembering everything I was thinking when the whole program was open.

The small sketches preserve clear ways into the circuit. A reply, a channel value and a calculated physical quantity are different answers, and understanding the boundary between them makes each one more useful.

Leaving this here for next time.All the notes ↗