
Knightscove (Customer) asked a question.
P1AM-200 intermittent "timed out" / "No Base Controller Activity" at idle with 24 V present: grounding recommendations?
I'm getting rare, intermittent base communication errors on a P1AM-200 field controller and would like advice on causes other than the external supply.
Setup:
- P1AM-200 on CircuitPython 10.2.1 with the P1AM library.
- P1-01DC fed from a 13.8 V battery-backed rail.
- 6 modules, including P1-08SIM, P1-08ADL-2, P1-16ND3, P1-16NE3 and P1-16TR.
- A Raspberry Pi is connected over USB for the serial console, so the CPU is also powered from USB 5 V.
Symptom:
- The library prints "timed out", then raises "Check External Supply Connection / No Base Controller Activity" on a single read.
- It happened 6 times in 10 days (11-04 to 11-13): at 04:04, 07:26, 13:42, 14:50, 16:29 and 18:29.
- Different modules were being read each time (the SIM, the ADL-2 and the 24 V check).
- It always happened at idle: no outputs switching, pump off, valves at rest.
- Most times the next read worked. Once, the inputs stayed frozen with no further errors until base.init() was run again.
What I've checked:
- The battery voltage read just before and after each event was steady at 13.22-13.25 V, with mains present.
- The Pi on the same rail logged no under-voltage.
- I tightened the base power terminals after the first cluster. Then there were none for 7 days, and one more came this morning on the coldest panel reading so far (about 52 F).
Questions:
- In the thread "P1AM losing connection to IO modules" (about every 27 h), grounding recommendations were sent by DM. Could you share them here?
- Besides the 24 V supply, what can make the base controller miss the 200 ms ready window: grounding, noise, backplane or CPU seating, or a marginal P1-01DC?
- Could the CPU being powered from USB 5 V alongside the base supply cause this? I'm planning a data-only USB cable.
- Is base.init() plus restarting the base watchdog the recommended recovery after this error?
Thanks!
One more detail on grounding, with a follow-up question.
The P1-01DC is wired as follows: +V and -V come from the 13.8 V battery-backed rail, G goes to the enclosure's single-point earth ground block, and LG is strapped to G with the factory metal jumper. The DC side (-V / the 13.8 V supply negative) is not bonded to earth anywhere in the panel; only the supply cases (G / FG) go to earth. The Raspberry Pi on the USB port is powered from the same negative rail as the P1-01DC -V.
Should -V be bonded to G (earth) at one point on a P1-01DC fed from a floating 13.8 V supply, or is leaving the DC side floating the recommended setup? Could a floating -V contribute to the base controller timeouts?
Possibly related: GitHub issue facts-engineering/P1AM #28, "readBlockData() sometimes times out after 200ms" (https://github.com/facts-engineering/P1AM/issues/28), is still open. It describes the same 200 ms miss on a P1AM-100 bench setup on mains power with nothing wired to the modules, and a FACTS developer reproduced it there. The CircuitPython library has the same 200 ms wait before printing "timed out" and raising "No Base Controller Activity".
Is there any progress on the root cause, or a recommended workaround? In particular, is it safe to simply retry the read once after a single timeout, or can a missed ready signal leave the base controller out of step so the next read returns stale data? Once, after this error, my inputs stayed frozen with no further errors until base.init() was run, which looked like that kind of desync.
Follow-up: root cause found. It was not the supply, the grounding or the base. Please disregard my grounding and power questions above; no answer is needed on those.
The intermittent "timed out" / "Check External Supply Connection / No Base Controller Activity" errors came from how the CircuitPython library times its 200 ms waits. Full details are in a GitHub issue: https://github.com/facts-engineering/CircuitPython_P1AM/issues/4
Setup: P1AM-200, CircuitPython 10.2.1, CircuitPython_P1AM 1.0.2, P1-01DC, six I/O modules. Faults happened only at idle.
Cause: _spi_timeout() and _data_sync() in P1AM.py time their waits with time.monotonic(). On CircuitPython, floats keep about 22 bits of precision, so time.monotonic() gets coarser with uptime. Once the board has been up more than 2^19 s (about 6.07 days) since a hard boot, it moves in 0.25 s steps. A wait that starts just before a step sees time.monotonic() - start jump from 0 to 0.25, which is more than 0.2, after only a few milliseconds. Then _spi_timeout() prints "timed out" and returns False, so read_block() raises "No Base Controller Activity" (and _wd_control() silently skips the reply), and _data_sync() lets single waits expire silently and raises when two expire in one call.
The base's unread reply can then be picked up by the next transaction, which can give junk values. We saw a 320 V reading on a 0-10 V input, and a temperature channel reading thousands of degrees.
A soft reload (Ctrl-D) doesn't reset time.monotonic(). Only a hard reset or power cycle does, which hides the problem for another 6 days.
Evidence:
(1) All 9 field faults over 3 weeks happened more than 6.07 days after the last hard boot, and none before.
(2) We timed every expired wait with supervisor.ticks_ms(). In one hour at 7.8 days uptime, with the library's own timing, there were 161 single _data_sync wait expiries, and every one really lasted under 50 ms. The ready line answered within 10 ms on all but one of ~32,800 transactions; the one exception was the base's start-up wait at boot. The false expiries are all short because the base answers in a few milliseconds, so a wait only "expires" when a 0.25 s clock step happens to land inside that short window.
(3) After changing only the timer, with no reset: 0 expiries in the first hour, and after 27 hours (8.9 days since hard boot) about 868,600 base transactions with no timeouts, no expired waits and no faults.
Fix we're running: we time the waits with supervisor.ticks_ms() (an integer count of milliseconds) instead of the float. The test becomes
((supervisor.ticks_ms() - start) & 0x1FFFFFFF) > 200
(the mask is needed because ticks_ms wraps at 2**29). We applied the same change to the three waits in _data_sync(), each with its own start time, and to Base.init()'s 5 s wait. For the library itself, adafruit_ticks would also work. These are the only uses of time.monotonic() in P1AM.py.
About GitHub issue #28 on the Arduino library (P1AM-100): that library times with integer millis(), so this float issue shouldn't apply there. It may have a different cause.
Happy to share logs or the diagnostic patch.
Hello Knightscove,
Thankyou for diving into this and creating a issue on the github site. I'll take a look into recreating the issue and testing the proposed fix.
Good to see the root cause was the library timing, but I want to add some practical notes on the grounding and power questions you raised, since they will matter the moment you scale this up beyond a bench.
On the USB 5V question: powering the CPU from the same negative rail as the P1-01DC is fine in principle, but the USB 5V line is a separate potential from the 24V DC rail. If the Pi and the P1AM share a common ground only at the enclosure ground block, any current flowing on that ground return can create a small offset that shows up as noise on the USB data lines. In practice, keep the USB ground path as short and thick as possible, and if you see marginal behaviour, try a USB isolator between the Pi and the P1AM.
For the 13.8V battery-backed rail: a 24V nominal rail that sags below about 19.8V (the P1AM-200 minimum) will drop modules off the bus. A 13.8V battery through a boost converter is workable, but check the converter output under full load with all six modules drawing current. A cheap bench DMM on the module power pins during a read cycle will tell you if you are dipping into the brown-out window.
On grounding: single-point star ground at the enclosure is correct. Just make sure the FG (chassis) and the signal ground (G) are bonded at one location only, and that the shield of any field cable is terminated at the controller end, not both ends.
Thanks for the detailed notes, appreciated.
Supply: We’re using the P1-01DC, which is rated 12–24 VDC (−10%/+20%) with under-voltage lockout below 9 V. The P1-01DC runs directly from our 13.8 V battery-backed rail, with no boost converter. Our battery-low alarm at 12.0 V fires well above the 10.8 V lower limit. I’ll still put a meter on the supply during an outage to confirm it holds up on battery.
USB: we’ve had no USB or serial data errors. All the faults turned out to be the library timing. We’re deliberately keeping the standard USB cable, so the CPU stays powered from the Pi even if the base loses power. The outputs are on the base, so they drop out safely anyway. With the CPU still running, the controller keeps logging and reporting the fault, instead of going silent. If USB noise ever shows up, an isolator is a good next step.
Grounding: agreed, it’s a single-point star ground at the enclosure. The transducer cables have no shield connected. If they turn out to have a drain wire, I’ll terminate it at the controller end only.