Trouble getting the L298N to work as intended

I have a 12v linear actuator that has two wires. If I connect wire A to 12V and wire B to ground, it extends and when I connect wire B to 12V and wire A to ground it retracts.

I would like to control this linear actuator using an Arduino. At first I was thinking about using two replays, but to avoid the clicking noise thought that I might be able to use a L298N module which I originally bought to control a dc motor.
From my understanding the L298N is essentially an H-Bridge.

I have it hooked up like this:

actuator.png

And this is my code:

#define IN1 12
#define IN2 13

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
}

void loop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  delay(3000);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  delay(3000);
}

Now when I measure the voltage between out1 and out2, I get 12v for 3 seconds, then I get 0v for 3 seconds and then 12v again etc... What I wanted was to get 12v, then -12v, then 12v again etc.

What am I doing wrong?

It looks like you are connected to the Motor 2 or Motor B side of the board and using IN3 and IN4 which is fine. What I don't understand is when you mention:

Now when I measure the voltage between out1 and out2, I get 12v for 3 seconds, then I get 0v for 3 seconds and then 12v again etc... What I wanted was to get 12v, then -12v, then 12v again etc.

Depending on the board as they label things differently but OUT 1 should be two terminals as should be OUT 2. That is the way your picture shows things connected.

The code is fine and on the OUT 2 or MOT 2 or whatever they call it on your board the polarity should reverse every 3 seconds.

"when I measure the voltage between out1 and out2" I don't understand your reference to Out1 and Out2?

Ron

I cannot tell from the frizy drawing if it is connected correctly. Consider using the TB6612FNG H-Bridge you will get much better performance. You are losing over 3 volts with the driver you are using.

out1+out2 are the pins for the terminal corresponding to in1+in2.
out3+out4 are the currently unused pins that i could use for a second motor.

So I guess my L298N module must be broken... :confused:

@gilshultz
If I'm losing 3v then how do you explain that I'm still measuring 12v at the output and not 9v?
Can the TB6612FNG handle 4-5A of current?
If you download the image it's less distorted btw. But I can export it at a higher resolution tomorrow if it would help.

Your drawing (cartoon) clearly shows you connected to the Motor B side? The B side or Motor 2 is controlled by the Input 3 and Input 4 terminals. That is how I see what you posted anyway. The module can drive two motors and the output for each motor has two terminals. We really need to work on the terminology. Since each set of terminals can have the polarity reversed there is no (+) and (-) labeled on the board. The board I have is labeled MOT1 and MOT2.

Worst case you can try the other side and move your control lines over.

Ron

I’m connected to the Motor A side. I think you just got confused because the image is flipped.

I’ll try to take some photos with my horrible photography skills and attach them. Maybe that will make it clearer.

edit: In case you’re wondering, the black tape on the Arduino is just there so I don’t get blinded from the insanely bright LEDs. And the input terminal of the L298N didn’t melt, I just used a screwdriver that was a little too thick.

"I'm connected to the Motor A side. I think you just got confused because the image is flipped".

Now you tell me. I was going by the image and facing the board the second motor out is on the right. :slight_smile: OK, MOT 1 is inputs 1 and 2.

Ron

Turns out the wire from pin13 to in2 was faulty…
Man I hate these jumper wires. I wish they would make non-shit versions of them with proper amounts of copper and silicone insulations.

I use single-core copper hook-up wire with conductor diameter of 0.6mm, which fits dupont sockets and breadboard well, and can carry several amps. Not as flexible, but you just cut to the right length for
neat wiring, and it works out a lot cheaper eventually.

MarkT:
I use single-core copper hook-up wire with conductor diameter of 0.6mm, which fits dupont sockets and breadboard well, and can carry several amps. Not as flexible, but you just cut to the right length for
neat wiring, and it works out a lot cheaper eventually.

That! I just order rolls from Amazon or actually leave my wife emails on what I want. Amazon is her world. :slight_smile: I got tired of buying new jumper wires and eventually remembered how I did bread boards before retirement. :slight_smile:

Ron

You're probably talking about wires like these, right? I use these quite often actually, but only for breadboard-to-breadboard connections. For off-breadboard connections they tend to bend and misbehave too easily.
I also need female duponts way too often and I hate crimping them myself because it takes forever if you need as many as I do.
You also lose the nice benifit of having a ribbon.

female-female dupont adapters would be nice.

But I wish they'd just sfell silicone ribbons like this, but in color and with male/female dupont connectors in whatever length you want.
Or an affordable device that can crimp a whole ribbon at a time without having to manually strip every wire. I mean I can crimp a rock-solid IDE cable with like 40 pins in 1 second. Surely with smarter designed duponts that would be possible as well.