DCC-EX / BaseStation-EX

Partial re-write of DCC++, maintained for historical purposes. Not actively bug-fixed or developed
https://dcc-ex.com
19 stars 8 forks source link

Frightrisk current mod #11

Closed FrightRisk closed 4 years ago

FrightRisk commented 4 years ago

Adding motor boards and changing current sense to use in human understandable milliAmps instead of just the raw pin reading. Some questions to ponder:

pin reading is always 0-1023, current can be anything like 0-20000 (for 20Amps). The current sense of the board gives us the reading and knowing either the datasheet milliVolts per pin increment or the measured value for tested boards will give us the conversion factor. Any unforeseen issues using computed actual current to trip the overcurrent protection?

JMRI gets the results of the command which is just the pin reading. It displays a current meter that only lists percentage. I believe it takes 0-1023 as it's range and so if it sees 511 for a reading, it will display 50%. We however, can know what the max current of the board is, the trip current we set, and the actual current in milliamps. We can change what we report to JMRI and issue a PR to JMRI to add that in the next version. What can we do with all this info? Should percentage still be just the pin reading to the max pin reading? Does this accurately represent the maximum current for the board? And is it more important to know the percentage of the trip current instead of max current of the board? Or both?

You can have a 2A board, but set the trip value to 1.5. So if you were at 90% of trip value, that is different than 90% of a value you think would max out the board. And things like max current and trip current could be static values that display on the current meter for reference.

Example: Board: Arduino Motor Shield Max Current: 2A, Trip Current: 1.5A, Actiual Current: .7A, percent of trip value: 50%, raw pin reading: 250

We would pass that to JMRI as <board, max_current, trip_current, current, pin_reading>. JMRI can compute the percentage from whatever value we decide just as it does now.

Ultimately, we may want to pull the trigger current out to the config file. More to think about there. Whatever people might need to tweak most should go into one file