Stepper motor issues with L297/8

Hello folks,

I am having an issue with my stepper motor when operating with 12V on my breadboarded L297/L298.
After uploading the GRBL to my Arduino, I am able to step in both directions easily (using Grbl Controller software) when my VDD is 5 V (see schematic).

But when I switch it over to 12 V, the stepper motor makes a squealing sound and does not move and the L298 heats up pretty quickly (I have a small piece of metal as a heatsink).

I have tried it with the following code, it steps every half second. When on 5V, its ok but when it's 12V, the motor still squeals, but steps forward and backward one step at a time, sometimes it doesn't step at all.

#define stepPin 2
#define dirPin 5

void setup()
{
  Serial.begin(9600);
  Serial.println("Starting stepper exerciser.");

  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);

  digitalWrite(dirPin, HIGH);
  digitalWrite(stepPin, LOW);
}

void loop()
{
        digitalWrite(stepPin, HIGH);
        delayMicroseconds(2);
        digitalWrite(stepPin, LOW);
        delayMicroseconds(1300);
        delay(500);
}

Specs:
Motor: 17HS4402, (1.3A, 2.5Ohm, 12-24V) from here
PSU: Generic ATX, 25A on 5V rail, 19A on 12V rail

Schematic:
Please see attached

I have looked around on many forums and have tried the following:
-Put pin 19 High/Low > result: when it's High the stepper seems less erratic on 12V
-Put pin 11 High/Low> result same as above.
-Adjust the current given by vref> I have tried 10k/1.7k, 10k/10k, and the current 33k/10k.
-Reverse the stepper motor wires to one coil> no difference in result

At idle, Vref sits at:
1.02V with VDD = 5V
1.12V with VDD = 0V
1.07V with VDD = 12V

So I know I am not starving the motors.

Any ideas?
Thanks.

The L298 can't handle the current required by that low voltage, high current motor, so it is overheating and shutting down.

That type of motor is intended for chopper style motor drivers. This one will work Pololu - DRV8825 Stepper Motor Driver Carrier, High Current
but you will need to set the current limit to 1.3A. Follow the Pololu documentation closely.

Actually, the L297/L298 combo -is- a chopper stepper driver. The L298 is rated for 2A, but you MUST use a heat sink to get anywhere close to that.

With 5V in, the L298 drops out a few volts. So the 2.5 ohm coil resistance plus the 1 ohm sense resistor is probably limiting current below 1A without chopper action. Without a heat sink, the L298 may remain cool. But boost the voltage, current goes up, L298 overheats.

This is a chopper driver circuit, so the current should be being limited to about 1.2A
by the L297 and current sense feedback. 1.2A is rather high for the L298 though.

It sounds like something is misconnected - but I'd first try bring Vref down to a
much lower value like 0.3V or so and see if chopper action is working then.

There may be layout issues if this is on a breadboard, remember the high current
parts of the circuitry needs to be kept away from the rest of the circuit. Heavy
decoupling throughout is mandatory with this kind of circuit.

So I measured the sense voltages while executing this code

VSense1
5V: Alternates from 0V to 0.5V depending on the step
12V: Alternates from 0V to 2.46V (!)

VSense2
5V: Alternates from 0.5V to 0V (with respect to above 5V sequence)
12V: Stays at around 0.6V

Then changed the two Vref resistors to 20k and 2k2 resulting in a Vref of 0.48V.

VSense1
5V: Alternates from 0V to 0.5V depending on the step
12V: Alternates from 0V to 2.56V (!)

VSense2
5V: Alternates from 0.5V to 0V
12V: Stays at around 0.25V

I also measured both coils on the motor, both are around 3 ohms.

MarkT:
1.2A is rather high for the L298 though.

The L298 can support up to 2A by specs (ofc practically around maybe 1.5-1.7A), 1A to 1.2A should be enough, right?

MarkT:
It sounds like something is misconnected - but I'd first try bring Vref down to a
much lower value like 0.3V or so and see if chopper action is working then.

Can we tell if the chopper is working by measuring the Vsense voltage (as measured above)

MarkT:
There may be layout issues if this is on a breadboard, remember the high current
parts of the circuitry needs to be kept away from the rest of the circuit. Heavy
decoupling throughout is mandatory with this kind of circuit.

Where in the circuit are the ideal places to decouple? On inputs?

So it seems to me that VSense1 is not operating at the expected levels, or is it Vsense2?
Could it be the chopper not working on the VSense1?

Photo of the layout?

Heatsink?

Power supply ratings?

Below are my pictures

I do know that my circuit is pretty messed up, but doubt thats causing the issue since Vsense2 stays at constant voltage on 12V, I doubt extra noise or interference can cause that.

The heatsink I know is quite small, if even a heatsink at all. Every time I try it, I only turn the 12V on for less than 30 seconds, so it only gets warm.

The PSU is from a computer, ATX.

http://imgur.com/idw8i1t,hD3CbFc,jUUCmaI#0
http://imgur.com/idw8i1t,hD3CbFc,jUUCmaI#1
http://imgur.com/idw8i1t,hD3CbFc,jUUCmaI#2

(sorry, pics too big for attach and don't resize with img tags)

Well... first thing, a protoboard is not reliable for those kinds of currents.

I strongly suggest wiring up the L297/298 on a soldered breadboard. That is really required for those kinds of current levels.

There are just too many wires for me to sort it out in a picture.

Decoupling goes on every voltage rail to ground - never on the inputs!!

Grumpy Mike's tutorial:
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Ok, thanks

I will see if I can make this on a breakout board (or whatever they're called)

Thing is, I dont really want to solder the L298 into the board and it doesn't fit in sockets really well