Closed daniviga closed 2 years ago
Thanks for the detailed report and after a quick review I think your analysis is correct. It is incorrectly scaling to Amps rather than tracking fully in mA.
For the PROG track, can you check the serial output and ensure it is not timing out or throwing another type of error? I'll do some digging on this and see if I can reproduce it as well.
The commit should fix the readings but keeping this open until we narrow down the issues with the PROG track.
I can no longer reproduce this issue with v2.0 code.
First of all I would thank you for this great project, it's really a nice way to learn an play with DCC and the ESP32.
I'm however facing an issue with current readings/reportings.
Setup
CONFIG_GPIO_OUTPUTS
andCONFIG_GPIO_SENSORS
), I'm not using themIssues
OPS is working fine, I can command my DCC engines (H0n3, H0n30 and 0n30), however I always get
[OPS] 0 mA / 2000 mA
even when there's a load (engine on track running); shortages are properly spotted:[OPS] Shutdown threshold breached 2.00 mA (raw: 4095 / 4080)
, but only 2.00 mA are reported instead of 2000 mA.Digging into the code I've found the following:
https://github.com/atanisoft/ESP32CommandStation/blob/c52c483c61801dd48c22efe2ac033279c716be46/components/DCCSignalGenerator/private_include/MonitoredHBridge.h#L95-L102
That formula actually returns a value that looks reasonable for mA, i.e.
((50 * 2000) / 4096 = 24)
However, when
getUsage()
is called, the value returned is dived by 1000, like if it was returning Amps and not mA, i.e.: https://github.com/atanisoft/ESP32CommandStation/blob/c52c483c61801dd48c22efe2ac033279c716be46/components/DCCSignalGenerator/MonitoredHBridge.cpp#L263-L265As a quick and dirty test I've changed
getUsage()
to return A and not mA (multiplying by 1000, so I can change only one point in the code) and now returned values do make sense:I get back
Is this a bug or it's a peculiarity of my setup (maybe the L298)? I'm also unable to read CV on PROG, not sure if this could be related or it's a different issue.
As a reference the same Shield works fine (readings too) with an Arduino Uno R3 and the BaseStation-EX (via JMRI).