Skip to content

DEV-1067: decode an open circuit on gen-2 GSR range 3 as open - #305

Open
marknolan wants to merge 1 commit into
masterfrom
DEV-1067_gsr_range3_open_circuit_limit
Open

marknolan wants to merge 1 commit into
masterfrom
DEV-1067_gsr_range3_open_circuit_limit

Conversation

@marknolan

@marknolan marknolan commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

DEV-1067

Problem

SensorGSRVerisense.VERISENSE_PULSE_PLUS_GSR_UNCAL_LIMIT_RANGE3 raises every range-3 code below it to it before calibration, so that an open circuit reads as open. It was 1134. At the gen-2 front end's 1.8 V full scale that is below the 0.5 V that calibrateGsrDataToKOhmsUsingAmplifierEq divides by (0.5 V is code 1137.5). So codes 1134–1137, and everything clamped up to 1134, decode to a negative resistance. nudgeGsrResistance then pins it to the wrong end:

  • auto-range: floored at 8 kΩ, so an open circuit reads 125 µS, the highest conductance the device can report
  • fixed range 3: pinned to 680 kΩ, the bottom of the range, instead of 4.7 MΩ

This happens in real data. DEV-793's B6 recording (SR68-9, auto-range with open-circuit gaps; ASM_PC Test_056) has 4,629 range-3 open-circuit samples peaking at codes 1126–1136. 69% of them are ≤ 1137, and the committed Test_056 reference decodes every one as 125.000 µS.

Fix

The limit is now 1138, the first code above 0.5 V — the same rule as the Shimmer3's 683 at 3.0 V. 1134 came in with ASM-1736 (2021), replacing a TODO update value, with no derivation recorded. It is the last code below 0.4986 V, the reference the C# API and web SDK use for this front end.

Tests

API_00015_VerisenseGsrOpenCircuitLimit builds the sensor through VerisenseDevice and decodes codes 1134–1138 on range 3 with processDataCustom. It covers an SR68-9 and an SR61-5, in auto-range and on fixed range 3, and pins the limit to the first code above the reference.

Limit Result
1134 5/5 fail (8.0 kΩ auto-range, 680.0 kΩ fixed range 3)
1138 5/5 pass; the whole ShimmerDriver suite passes (108 tests)

CI builds only ShimmerDriverPC, so it will not run this test; it was run locally. The test is numbered 00015 because DEV-1047's branch already uses 00012–00014.

After merge

  • ASM_PC: bump this submodule and regenerate Test_056's reference. Its open-circuit samples change from 125.000 µS to ~0 µS, and any other gen-2 GSR reference with range-3 codes ≤ 1137 will move the same way.
  • Shimmer-MATLAB-ID: its vendored VerisenseFileParserPC.jar picks this up only when it is re-vendored.

Sibling PRs (same constant, same ticket)

🤖 Generated with Claude Code

Range-3 codes below VERISENSE_PULSE_PLUS_GSR_UNCAL_LIMIT_RANGE3 are raised
to it before calibration so that an open circuit reads as open. The limit
was 1134. At the second-generation front end's 1.8 V full scale that is
below the 0.5 V that calibrateGsrDataToKOhmsUsingAmplifierEq divides by,
which is code 1137.5. So codes 1134 to 1137, and every code clamped up to
1134, decoded to a negative resistance. nudgeGsrResistance then floored it
at 8 kOhm in auto-range, reading the open circuit as 125 uS, the highest
conductance the device can report. On fixed range 3 it pinned it to
680 kOhm, the bottom of the range.

It is not a corner case. With the electrodes open the amplifier output
sits on its reference, and the ADC reads either side of it. DEV-793's B6
recording (SR68-9, auto-range, open-circuit gaps; ASM_PC Test_056) has
4,629 range-3 samples between codes 1080 and 1250, peaking at 1126-1136,
and 3,205 of them are at or below 1137. The committed Test_056 reference
decodes every one of those as 125.000 uS.

The limit is now 1138, the first code above 0.5 V, as 683 is at the
Shimmer3's 3.0 V. 1134 came in with ASM-1736 in 2021, replacing a
"TODO update value" 683, with no derivation recorded. It is the last code
below 0.4986 V, the reference the C# API and web SDK use for this front
end, and it is wrong there too.

API_00015 decodes codes 1134-1138 on range 3 through VerisenseDevice and
processDataCustom, for an SR68-9 and an SR61-5, in auto-range and on fixed
range 3. It also pins the limit to the first code above the reference.
At 1134 all five tests fail (8.0 and 680.0 kOhm). At 1138 all five pass,
as does the rest of ShimmerDriver (108 tests).

It is numbered API_00015 because DEV-1047's branch already uses
00012-00014.

Downstream: ASM_PC has to bump this submodule and regenerate Test_056's
reference, whose open-circuit samples change from 125.000 uS to ~0 uS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant