this post was submitted on 04 Sep 2025
19 points (100.0% liked)

Ask Electronics

3838 readers
16 users here now

For questions about component-level electronic circuits, tools and equipment.

Rules

1: Be nice.

2: Be on-topic (eg: Electronic, not electrical).

3: No commercial stuff, buying, selling or valuations.

4: Be safe.


founded 2 years ago
MODERATORS
 

I am wiring this up, and I would like to limit the current being drawn from 18v DC/DC converter.

What would be the simplest way of doing this?

you are viewing a single comment's thread
view the rest of the comments
[–] litchralee@sh.itjust.works 4 points 2 weeks ago (18 children)

In that case, I would suggest looking at a different motor driver. The driver you've specified doesn't seem to have any provisions to detect a motor stall, which is something that other drivers can potentially do. Ideally, the driver would detect the back EMF from the stall and inform the microcontroller, which would then decide to stop movement.

An external current sensor might work, but that's adding to the part count and might not be as capable as built-in functionality within the motor driver. Plus, fancier motor drivers have some neat features that you could take advantage of as well. I think it would be more prudent to consider a different driver before adding additional parts.

[–] cmnybo@discuss.tchncs.de 4 points 2 weeks ago (12 children)

The L298 has two sense pins. Connect a current shunt between each sense pin and ground and you can measure the motor current. Use an op amp to amplify it and measure it with the ADC in the microcontroller. The microcontroller can stop the motor if the current gets too high.

[–] litchralee@sh.itjust.works 2 points 2 weeks ago* (last edited 2 weeks ago) (2 children)

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 instead 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 as an interrupt, 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. It also means software will not know the exact current level, other than that it's higher than the threshold set by the reference voltage.

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 points 2 weeks ago (1 children)

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 points 2 weeks ago

But could this comparison not be done with some hysteresis?

It can, but analog design is also not my forte.

The part count is not important as long as the parts aren't terribly expensive, since this is exclusively for my personal use

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.

load more comments (9 replies)
load more comments (14 replies)