Close

Let it Flow

darrin-bDarrin B wrote 02/09/2021 at 00:23 • 4 min read • Like

First, a question. Can anyone out there tell me how the water system in my home knows that it is late afternoon on Friday? Six of the eight times the system has failed, whether due to lightning, freezing or some other cause, it was within an hour of 5 p.m. on a Friday. As a consequence of the time, all of the area well service businesses have closed up shop for the weekend and I am facing a weekend of many inconveniences.

Here I am again, this time it is a frozen water line. That's the second time this winter. I believe that the culprit is the drain-back valve that is in the well shaft. Replacement must wait until spring, because large service trucks and steep, snow-covered driveways are not a good mix.

Part of my water pumping system is a monitoring device. Its' primary job is to shutdown the pump when the well runs dry. When things siezed up earlier this winter, I took note of an infra-red(IR) output built in to the monitor and the availability(for a price) of a device to display the output. Ooooh, time to dust off my reverse engineering skills.

An unknown IR signal, I'll start with a plain old phototransistor. A second transistor to make it a cascode, and a third to amplify the signal up to clipping. A few ideas later, I have a 3.3V digital signal piped straight in to my preferred micro-controller, the Z8. A digital storage scope would be nice, but it would spend most of its' time taking up space. Just a little bit of code and I have established the minimum and maximum pulse lengths that the well monitor is transmitting. A bit more code and the bits are on a timebase, guess I have a low-budget digital 'scope after all.

Staring at bits with GnuPlot (after processing with a bit of software) I identified a few interesting features, long break, short break, preamble and chunk. After modifying the code on the Z8 to start after the long break, the repeat cycle was found to be 16 chunks.

It's been a month, or so, since the last update. The input circuit has been modified a bit, it is now just the phototransistor and a PNP transistor. Using an IRDA port on another dev board, I was able to ascertain that my cobbled together system had no trouble detecting micorsecond duration IR pulses. Once I worked out how I could use the counter's gated mode with the DMA controller, I became able to measure the input signal in real-time. With a bit more code, I was sending a VCD file to Pulseview. Time to parse.

It was when I split the signal in to segments and then stacked those segments that a few interesting patterns emerged. Spliting the signal in to even smaller pieces, it became clear that it was a 32 bit value, without any encoding, was being transmitted.

Though I could take a software only approach to collecting the bits, using the SPI (Serial Peripheral Interface) port would likely have benefits. But where to get the clock signal? An on-chip timer should do nicely. Some re-wiring, new code, and a few terminal control characters later, I'm watching a grid of 32-bit values on my desktop. Thanks to a winter snow storm, I was able to determine that the bits were inverted. How is that possible? One of the values that the well monitor reports is line voltage, the snow storm caused the line voltage to drop a little. Late in the day the sun came out and all of the area grid-tied solar installs drove the line voltage higher. The value I suspected to be the voltage decreased. Inverting the bits and waiting for sunset to drive the voltage lower again, confirmed it. The line voltage is reported in tenths of a volt, 0x09AA -> 2474 -> 247.4 V which is well within 1% of the reading on my volt meter. 59 values to go...

Two, three really, values changed when the pump turned on while I watching the data stream from the control box. The voltage dropped by a few volts and two zero values changed to values of about 0x460. Could it be the real-time current reading? But two of them? Oh, right it is a two-phase, 240V system. Nice, the box monitors both phases. Because I had known that the pump would be running sometime soon, I had a clamp on ammeter clipped on to one of the phases. With the meter reading a bit over 11A, it seems to me that two more values are known. Two current values, scaled by 100, can be added to the list of knowns.

Reading TFM, there is an option to perform a complete reset on the controller. Be back in a few hours...

Then again, maybe not.

It took quite a bit of time to cram 10k bytes of code in to 8k of ROM. There is also a first draft of a PC board. Time to migrate this to project.

Like

Discussions