Closed FrightRisk closed 4 years ago
So I would like to add a related to this. The current Sample Max is currently set manually in the Currentmonitor.h tab. I would like to make it a variable (instead of hardcoded number) that is defined for each motor shield. My initial recommendations would be to put it just below the motor shield rating (maybe 0.25 A) except in the super high power like 43A we would probably want to limit it at 10A or something like that or give a high and low power option. Concern is do you blow your power supply before your motor board
questions above #1 I think this is ready for testing now
When I was changing all my current code to deal with milliamps (but also keeping the raw pin reading) I saw that this code separately handles reading the current sense pin. Reading a CV, for example:
fills 8 registers by: taking ACK_BASE_COUNT number of readings averages them sends 3 reset packets, 5 verify packets and 6 idle packets (In DCC++ classic, the last one was 1 reset) takes ACK_SAMPLE_COUNT number of readings subtract the base reading to get the difference smooths it then sees if that value is greater than our ACK_SAMPLE Threshold If so, the decoder sent a current spike acknowledge, then does a bWrite
then repeats this all again to verify and at the end, we added one more reset packet
Does that look good now? Who can test?
How does this handle different motor controllers? If current sense device reports a different number of amps per millivolts on that pin, Don't the variables have to be tweaked experimentally for each board??
If I change this to actual current in milliamps, would that make the math better or worse? With pin values can be 11 or 12 for a BTS7960B at 5 Amps (I think). But we know the Uno is 300 means about 890mA. And we know programming needs to be 250ma or less or we are supposed to throw an overcurrent condition. Regardless of max current, we are always looking for a difference of some amount. What is that amount? And again, does that mean a table for every board?
Last, what about stay alive caps? Is DCC++ designed so that there is voltage on the track so the caps are charged or does it only pulse during the small time something is sent to the loco? That would mean we have to account for caps blocking us sensing the pulse since they may filter it.