L298n, 24v motor and miss arduino

Hello

As an internet-educated electrician, i have last minute doubts on connecting my linear monitor (24v,2-3A) to the ardunio via l298n. my main doubt is about the connection of the motor supply (24v 7.5A) to the shared ground with the ardunio. which component should i put there to protect miss arduino?

An electrician friend is needed.

Thanks alot, Oori

Hey

they can share a ground, no problem. That is the proper way to do it. If you are concerned about noise that sometimes develops in a mess of ground wires, you can use the "star-grounding" technique. Do some Googling and you will find it: basically all grounds lead to one point. It's a good design approach to do it that way, but probably not a necessity for what you're doing.

For safety you can add a fuse (5A should do it) to the 24V supply. If you're really worried, double check your connections, and try things on a much smaller motor first.

The L298 dual driver is rated 2A per driver, so you will need to be using both drivers to get 4A capacity! They show how to do this on page 7 of the datasheet: pins2 & 14 drive one wire of the motor, while 3 & 13 drive the other wire. You will also really, really, really need a good heatsink on the l298.

D

:)

BTW Arduino is a guy ;)

Thanks.

I also see around people talking about adding (shottkey) fast recovery diode or a capacitor between the motor supply leads. any remarks on that?

Also, about the heat sink, you said: "realy, realy, realy" - so bad?, i mean: something like this: (conrad 188158 - 62) is not enough or with a small pc fan towards the heat sink? or am i far behind on this?

About sexuality and the pcb's recognition of the 'self' - next time...

Thanks alot. Ciao, Oori

I use a bypass diode every time I switch an inductive load. (anything with a coil of wire is probably going to be inductive.) The essence of an inductor is that once a current is flowng, it will try to keep the current flowing. If you try to stop if from flowing, then it will create a huge voltage trying to force the current to keep flowing. Those bypass diodes provide a safe, low voltage path for the current to quietly dissipate itself.

You can see the oscilloscope traces in my solenoid tutorial where my fairly small solenoid is making 250 volt spikes as I switch it off without the diode in place. http://www.arduino.cc/playground/Learning/SolenoidTutorial It probably would make bigger spikes, but at 250 volts it is forcing its way backwards through my drive transistor. Just the sort of thing you want to avoid.

For selecting the diode, you want it to have a reverse breakdown voltage larger than your system voltage and a forward current limit greater than the maxium current flowing in your inductive load. I wonder if being a fast diode is important. I don't think it is terribly important, but I haven't tested that. But if you have them around, faster is better.

Also, about the heat sink, you said: "realy, realy, realy" - so bad?

Yes you will need a good heat sink... if there are, say, four transistor junctions dropping voltage in the driver chip, that makes: P= V * I = (4 * .7V) * 2A = 5.6 Watts, which is a lot of heat to dissipate!

D

PS: a good schottky is a MUR260, but there are lots! Sometimes a diode manufacturer will send you samples.

Based on your answers - so, how about this one?

IC1 = L298N C1= 100nF D1-4 = BY500 / MUR360/??? trafo = 24v 7.5A Motor = Okin Linear motor (2-2.5A max, hopefully..) HeatSink = Rth 10 or lower , or an alu box...

Arduino9 = IN2 Arduino10 = Enable Arduino11 = IN1

Makes sense?

Thanks again. Ciao, Oori

hi Oori

looks good, just a few things missing.

  • You will need a .1Uf on the +5V logic supply to the motor driver. A 10Uf might be also a good idea, as motors make a lot of noise.
  • the L298 has a couple of pins (pins 1 & 15) for sensing motor current. I can't recall exactly how they work, but the schematic ( p6 of the datasheet) shows them tied together and connected to ground through a low-value resistor (say .5R, 3 watts). This is designed for external current sensing... in any case they have to connect to ground somehow, or you won't have a current path for the output transistors.

Have you started to build it yet? If you are worried about blowing things up, you could just substitute a 100R or 200R 1W resistor for the motor, to measure the voltages and see if the circuit is working properly. D

PS: You might want to read this thread..

Ok, back from outer space.. here's the (final?) diagram, i'll build it this weekend, hopefully..

Any last remarks, are most welcome (Daniel?)

cheers and thanks again, Oori

btw: should C2 be where it is, or between the gnd?

ah, and i forgot to say: R1 = 0.47ohm 5W

oori

hi

yes C2 should be from +5 to Gnd.

The shortcut to use one resistor instead of two on pins 1 & 15 might not work properly... best to use one for each pin. If both pins turn 'on', they will share the current, but if only one is on, it will get the full current. Might not be an issue coinsidering that one or the other always has to be on to make the motor go...

D

yo yo

I've set up the circuit (with the two small changes: C2 (5v-->gnd) and pin1,15 connected to ground, each one through a resistor) and with a resistor instead of the motor (for testing, aka "motor-resistor").

i've programmed the arduino to switch direction every two seconds, so i can measure voltages. a. when i measure the voltage on the "motor-resistor" or between out1 & out2 (for example) , i get nothing. b. when i measure the SEN_A or SEN_B - i get nothing. c. ALL the other measurements look perfect (arduino signals, Vs, etc...), all along the way (on the l298n pins, on the inputs, on the cross-connections (6/11, 5/12, 7/10) and so on..) d. if i measure between the "motor-resistor" and the gnd, i see the 2 sec switch, but the voltage changes from 0.1v to 0.38v - this gives me some kind of indication the 2 sec. switch "works/exists", although why should i see it between there and the gnd?? and with this strange voltage..

the arduino is programed simply:

int motor1Pin = 11;    // H-bridge leg 1 
int motor2Pin = 10;    // H-bridge leg 2 
int speedPin = 8;     // H-bridge enable pin 
int ledPin = 13;      //LED 


void setup() {

  beginSerial(19200);

  // set motor pins
  pinMode(motor1Pin, OUTPUT); 
  pinMode(motor2Pin, OUTPUT); 
  pinMode(speedPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

  
  digitalWrite(speedPin, HIGH);   // set the enables to high
  
  blink(ledPin, 5, 100);  
}


void loop() {

  blink(ledPin, 1, 100);

    digitalWrite(motor1Pin, LOW);   // set leg 1 of the H-bridge low
    digitalWrite(motor2Pin, HIGH);  // set leg 2 of the H-bridge high

  delay(2000);
  
  blink(ledPin, 2, 100);
      digitalWrite(motor1Pin, HIGH);  // set leg 1 of the H-bridge high
      digitalWrite(motor2Pin, LOW);   // set leg 2 of the H-bridge low

    delay(2000);
}

while trying to debug the circuit, i removed the protection diodes, and while testing the arduino died... i bring 2 other later today...

  1. as the speedPin (enable_a/b, 6/11) is high (5v) - i expect to measure 24v / -24v every two seconds between the "motor-resistor" pins, am i right?
  2. what should i expect to see between the SEN_A/B and gnd? (maybe this will help to solve this..)

Any advice?

Thanks again!! Oori

ok, brought another arduino... :)

when i measure the voltage between the "motor-resistor" pins i get the 2 sec. shift, but the voltages there is -0.05v and 0v (every 2 sec). i expect -24v & 24v, right....(?!)

cheers, oori

hi

double-check your wiring: is speedPin connected to pin 9 or pin 8?

D

speedPin connected to pin 8, just as a bypass, because pin9 gave me 2.5v on HIGH... not sure why, anyway, pin8 gives the needed 5v...

i've checked my wiring over and over... and now - i go to do it once more...

also, my circuit is 1-to-1 with the diagram, would you (daniel) please take a look at this again, just to verify.. cheers, oori

hi

your diagram matches what is in the datasheet schematic... You'll have to check your wiring (and soldering?) as this kind of problem when prototyping something is very common. Do you have the Arduino Gnd connected to the L298? that is a common error.

If you want to to troubleshoot, then disconnect the Arudino and use just the 5V/GND supply to power the L298. Then, tie the appropriate IN pins to +5 and Gnd, and connect the EN pin to +5 to see if the drivers works on its own.

D

ok, i sorted out the wiring, tested it with 5v trafo, worked nice, tested it with manually shifting the IN1/2, with the motor, 3-4 sec. each run, and it's ok.

when i connected it to the arduino, the arduino didn't fry up (which is good...), but in a matter of 4 sec. the l298n started to smoke, and in the 2 sec. it took me to reach the power switch, it went on fire.... was very nice... in 8 sec. you move from "cool! it works!" to "black stinking molded plastic.."

anyway, this was on the testing board, without any heatsink. could it be the the l298n burned so fast? if not - can it be that some short circuit has burned the l298n? if it matters, there's a chance the circuit was working in 33v insted of 24v at the time of the fire.. (although, as far as i've seen, this circuit should support this voltage..)

anyway, as i now know the wiring is correct, i will solder it all on a permanent board, and attach the l298n to the alu box, hope it's enough.. also, i'll make it easily replaceable with a connector...

cheers, oori

Hey oori,

You ever solve your problem? I seem to be having the same issue :-/

Best, Josh