Voltage drop across motor driver

Ok so I've been doing a project in which I have an automatic dispenser system. I have an arduino which powers an ultrasonic sensor. The arduino is also connected to an L289N motor driver which turns on and off a 12V DC motor. My code works and basically when the ultrasonic sensor senses a hand, the motor or in this case my peristaltic pump, turns on.The motor driver is powered by a 12V battery as well. However, I'm experiencing a voltage drop of 2V across my motor driver as when I measure the voltage across the pump when working, it is only 10V instead of 12V.
How can I make sure that my 12V DC motor pump is getting a full 12V instead of 10V and remove the voltage drop across the L289N?

Replace the L298N. That voltage drop is normal for L298N. It is a very old and inefficient design.

A more modern and efficient motor driver based on MOSFET technology will have a much lower voltage drop.

I can't recommend a model, some details of the current drawn by the pump would be needed, but you have only mentioned voltage.

Do you need a full H-bridge motor driver? If the pump only runs in one direction, an h-bridge is unnecessary. You need only a single MOSFET. IRL44Z might be suitable, for example.

(When I say "only a single MOSFET" I mean a much simpler component. You will additionaly need a couple of resistors and very importantly, a flyback diode.)

Here is my attempt at drawing a schematic view.
I'm not sure how I would go about replacing the L298N with a MOSFET considering the MOSFET only has 3 pins while the L298N has 6 wires going into it at different points?
Also the the current going into the L298N is 2.5 A but the current across the motor is 400mA

Hi, @davwarm
Welcome to the forum.

Something like this.

Tom.. :smiley: :+1: :coffee: :australia:

2 Likes

Thanks for that Tom
So the source pin goes to GND
Gate pin to Digital pin (from arduino)
Drain pin to the Motor.

Will this still work in conjunction with the sensor and code though?
And would I not maybe need a reverse diode to ensure the motor doesn't blow?

Yes, to ensure the MOSFET and Arduino don't get damaged.

Without seeing your code I can't comment, but you only need one output pin.
Looking at your schematic, good attempt by the way, D11 or D12, which ever goes HIGH when you want the motor to operate should do the trick.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like
const int trigPin = 9;
const int echoPin = 10;
const int motorPin1 = 5;
const int motorPin2 = 6;
const int motorEnable = 3;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorEnable, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
 

That's my code. Got some of the pins wrong on my schematic sorry. I'll have a look at the system with a MOSFET and then get back
Cheers

Also what circuit maker do you use? I usually use tinkercad because it's really easy to use but doesn't have a whole lot of components.

This may be easier to use. Available at many places on the internet

1 Like

Thanks Jim I'll have a look at that

Flyback diode!

2 Likes

There's a big chunk missing, I think!

2 Likes
const int trigPin = 9;
const int echoPin = 10;
const int motorPin1 = 5;
const int motorPin2 = 6;
const int motorEnable = 3;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(motorPin1, OUTPUT);
  pinMode(motorPin2, OUTPUT);
  pinMode(motorEnable, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  long duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;

  if (distance < 20) { // Adjust the distance threshold as needed
    digitalWrite(motorPin1, HIGH);
    digitalWrite(motorPin2, LOW);
    analogWrite(motorEnable, 255); // Full speed
  } else {
    digitalWrite(motorPin1, LOW);
    digitalWrite(motorPin2, LOW);
  }

  delay(100);
}

Yeah completely forgot the last part :joy:

@davwarm this module includes those resistors I mentioned, but not the flyback diode, so you will still need to add that.

Also, and this isn't obvious at first glance, the module internally connects the "signal ground" pins with the "DC- Power supply" screw terminal, which provides a common ground between the 12V and 5V parts of the circuit. So you won't have to do that.

1 Like

If you examine your code, you can see that motorPin2 is only ever LOW. So you didn't actually need to waste an Arduino pin for that, you could have connected (I assume) IN2 on the L298 to ground instead of to an Arduino pin.

If your code did write HIGH to motorPin2 and LOW to motorPin1, that would have thrown the pump's motor into reverse. With many types of pump, that might not make much difference, but with a peristaltic pump, it definitely would, and could result in contamination of the liquid you are pumping, because the pump will suck instead of push.

Similarly with motorEnable. You only ever write 255 to that pin, so you could have connected the EN to 5V and saved another Arduino pin there.

So in fact, only motorPin1 is doing anything useful, the other connections between Arduino pins and the L298 are redundant. (Except 5V and ground, of course).

Now I hope you understand why only one pin is needed with the MOSFET.

1 Like

Mosfet motor driver with flyback diode. Be sure to use a logic level MOSFET.

dc_motor_driver

3 Likes

This is my current setup
So I have to replace the motor driver with the MOSFET and add in resistors plus a flyback diode. I don't have the necessary amount of wires to do it yet but I'll get some more.



Did you see @jim-p 's suggestion from post #10 and my comments from post #15?

Yeah I need to get some more wires to make that happen. Will be getting them soon