feat: autohold, persistent config (ext flash), a little cleanup? maybe

This commit is contained in:
2025-12-04 02:18:47 +06:00
parent 054bc38683
commit 526e657bee
8 changed files with 1362 additions and 705 deletions

146
README.md
View File

@@ -22,73 +22,111 @@ Extended features (Continuity, Temp, etc.) can be accessed using the SRQ button
4. **Sub-Menus:** Some modes (like Temp) have sub-menus for sensor type and 2W/4W mode. Same cycle logic to select these.
5. **Exit:** Press the SRQ button to exit back to initial mode (one we entered menu from).
## Extended Feature Modes
## Features
These can be triggered via the Menu or the serial commands below.
These can be triggered via the Menu or the serial commands below. Although sub-menu features probably don't work through GPIB commands.
Relative and Statistics depend on the mode you enter the menu from, i.e. if you enter relative from DCV it saves your state and you get relative voltage, from 2W relative 2W etc.
| Feature | Command | Description |
| :-------------- | :-------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Continuity** | `++cont` | Fast, latched continuity beeper (2W Ohm, R0: 30 Ohm Range, N3: 3.5 Digits) |
| **Temperature** | `++temp` | Supports **PT1000**, **Type K** (via shit CJC... because the AHT20 is near the transformer :)), and **Thermistors** (Generic 10k/50k/100k & YSI 44000 series) |
| **Relative** | `++rel` | Set NULL/0 offset |
| **dBm** | `++dbm` | Power measurement calculated against 50Ω reference |
| **Diode** | `++diode` | Diode test with 2.5V open circuit voltage and audible latch |
| **Ext Ohms** | `++xohm` | Measures high resistance (>30MΩ) by calculating against internal 10MΩ parallel resistance |
| **Statistics** | `++math` | Cycles display between Live / Min / Max / Avg |
| **Environment** | `++env` | Reads internal AHT20 sensor (Temp/Humidity) |
| **Display** | `++disp` | write custom string to LCD |
| **Normal** | `++norm` | Resets DMM to standard DC Volts state |
```
++help
## USB-GPIB Command Reference
HP3478A Internal USB-GPIB 1.2.0
Commands start with `++`. Any other text is sent directly to the GPIB bus.
[GPIB Setup]
++addr <0-30> Target Address
++auto <0-2> 0:Off, 1:Read-After-Write, 2:Query-Only
++read_tmo_ms <t> Timeout in ms
++eoi <0|1> Assert hardware EOI on write end
++eos <0-3> Write Term: 0:CRLF, 1:CR, 2:LF, 3:None
++eor <0-7> Read Stop: 0:CRLF ... 7:EOI-Only
++eot_enable <B> Append extra char to read output
++eot_char <dec> The char to append
### Controller Configuration
[System Configuration]
++config List all configurable parameters
++get <name> Get parameter value
++set <name> <v> Set parameter value
++savecfg Save config to flash
++ver Firmware Version
++rst System Reset
| Command | Arguments | Description |
| :--------------- | :-------- | :---------------------------------------------------- |
| `++ver` | | Get Firmware Version |
| `++help` / `++?` | | List available commands |
| `++rst` | | Reset the controller |
| `++addr` | `0-30` | Set target GPIB address (Default: 18) |
| `++tmo` | `ms` | Set USB-to-GPIB read timeout (alias: `++read_tmo_ms`) |
[GPIB Bus Operations]
++read Read from target
++write <data> Write to target
++trg Device Trigger (GET)
++clr Device Clear (SDC)
++dcl Universal Device Clear (DCL)
++ifc Interface Clear (Bus Reset)
++spoll [addr] Serial Poll
++srq Query SRQ Line (0=High/Idle, 1=Low/Active)
++loc Local (Drop REN)
++llo Local Lockout
there's also `++savecfg` and `++mode` to fake prologix compliance
[Internal HP3478A Features]
++cont, ++hold, ++rel, ++xohm
++dbm, ++diode, ++math, ++norm
++temp <l1> <l2> Temperature sensor mode ++env [temp|hum] Internal AHT20 Sensor
++disp <text> Write text to LCD
```
### Protocol & Formatting
There's also a configuration which can be saved using `++savecfg` if you want to make it persist (it's saved to v203's "undocumented" flash).
Also see [inc/config.h](./inc/config.h).
| Command | Arguments | Description |
| :------------- | :-------- | :------------------------------------------------------------------- |
| `++auto` | `0-2` | **0**: Off, **1**: Read-after-Write, **2**: Query-Only (ends in `?`) |
| `++eoi` | `0`\|`1` | Assert hardware EOI line on write end |
| `++eos` | `0-3` | Append to Write: 0:CRLF, 1:CR, 2:LF, 3:None |
| `++eor` | `0-7` | Stop Read on: 0:CRLF ... 7:EOI-Only |
| `++eot_enable` | `0`\|`1` | Append character to USB output stream? |
| `++eot_char` | `dec` | The decimal char to append (e.g., 10 for `\n`) |
```
++config
my_addr: 0
dmm_addr: 18
target_addr: 18
eot_char: 0
eot_enable: 0
eoi_assert: 1
eos_mode: 0
eor_mode: 0
auto_read: 0
gpib_timeout_ms: 1200
poll_interval_ms: 100
env_sensor_read_interval_ms: 1000
dmm_recovery_delay_ms: 1000
usb_debounce_connect_ms: 50
usb_debounce_disconnect_ms: 200
usb_timeout_target_ms: 5
menu_dot_interval_ms: 500
menu_commit_delay_ms: 2400
menu_sublayer_delay_ms: 500
menu_debounce_ms: 100
menu_lockout_ms: 1000
stats_cycle_time_ms: 3000
cont_disp_update_ms: 150
diode_stable_ms: 20
buzzer_chirp_hz: 3000
buzzer_chirp_ms: 75
buzzer_cont_hz: 2500
rtd_a: 0.003908
rtd_b: -0.000001
rtd_r0: 1000.000000
cjc_fallback_temp: 22.000000
cjc_self_heating_offset: 4.000000
type_k_scale: 24390.240000
dbm_ref_z: 50.000000
diode_th_short: 0.050000
diode_th_open: 2.500000
autohold_threshold: 1.000000
autohold_change_req: 2.000000
autohold_min_val: 0.050000
cont_threshold_ohms: 10.000000
autohold_stable_count: 3
rel_stable_count: 3
```
### Bus Management
i.e.
| Command | Description |
| :-------- | :------------------------------------------------ |
| `++read` | Read data from target immediately |
| `++write` | Write data to target manually |
| `++trg` | Issue Group Execute Trigger (GET) |
| `++clr` | Selected Device Clear (SDC) |
| `++dcl` | Universal Device Clear (resets entire bus) |
| `++spoll` | Serial Poll target (returns Status Byte) |
| `++srq` | Query SRQ Line status (0=Idle, 1=Active) |
| `++stat` | Print controller internal status (Addr, Tmo, etc) |
```
++set dbm_ref_z 60
++savecfg
```
### Lower Level Control
| Command | Description |
| :------ | :------------------------------------------ |
| `++loc` | Go To Local (Release Remote Lock) |
| `++gtl` | Send "Go To Local" GPIB message |
| `++llo` | Local Lockout (Disable front panel buttons) |
| `++ren` | Toggle Remote Enable line |
| `++ifc` | Interface Clear (Hard Bus Reset) |
Now your dBm feature will use 600 ohm ref instead of 50.
## Known Issues