That sounds very cool - and way beyond my own understanding :-)
Is this something you could actually help with sketching out for me?
I found the datasheet for the L298 and I can see that for my use (I am using just out 1 and out 2) it should be pin 1 (Sense A) that should be relevant, right?
This looks like it is connected to gnd on the driver board (I can easily cut this connection).
Unfortunately I don’t understand what a current shunt is? :-)
It has me slightly worried that it says that pin 1 can go to -1v which I think would break the ADC input?
As far as I can tell the ADC input on the PICO accepts from 0 - 3.3v right?
Thanks a bunch for looking at this!
litchralee@sh.itjust.works 1 week ago
Ah, I entirely missed the sense pin when skimming the datasheet.
That said, using a shunt for an inductive load like a motor may have to contend with the corresponding spikes caused when switching the motor. This just means the thing doing the sensing needs to tolerate the spikes. Or mitigate them, with either a snubber or a flyback diode (is this actually doable with an H bridge?).
As for the op-amp and ADC, if we already accept the additional of the op-amp part, it is also feasible to use a comparator with a reference voltage set for the max safe current. The digital output of the comparator can then be fed directly to the microcontroller, providing fast reaction without the sampling time of an ADC. But this would be so quick that the spikes from earlier could get picked up, unless mitigated.
Still, these solutions are adding to the part count. If that’s a concern, then I’d look for a motor driver with this functionality built in.
boojumliussnark@lemmy.world 1 week ago
OK… I understand very little of this :( I am a software person. But could this comparison not be done with some hysteresis? The part count is not important as long as the parts aren’t terribly expensive, since this is exclusively for my personal use.
litchralee@sh.itjust.works 1 week ago
It can, but analog design is also not my forte.
In that case, the original suggestion of using an ADC and an op-amp would be the most flexible for software. You would, however, need to do some research on wiring an op-amp to amplify the sense voltage to something your microcontroller’s ADC is capable of resolving.