Stepper eratic when arudino plugged into USB

I am using a L298N Controller Board to control a stepper motor via a Ardunino Uno (also tried a Duemilanove) The L298N board takes 12volts(or more) and steps it down to 5vs which can be used to power the arduino (and this works fine) The problem comes when the Arduino is plugged into USB, at which point the motor starts spinning erratically and stuttering. As soon as I unplug the usb it goes back to working fine again.

I have the ground shared between the 12v supply and the arduino, and the 5v from the l298 plugged into the VIn on the arduino.

I want the ardunino plugged into the computer because I want to be able to use the serial to control the stepper.

Has anyone seen this before? I'm assuming the 5v usb power is interfering with something, i'm just not sure how to stop it without also killing the serial link to the computer.

(attached basic schematic of what i'm doing)

Thanks,
matt

Unplugg the 5 volt from the L298 board before connecting USB.

analog:
and the 5v from the l298 plugged into the VIn on the arduino.

The 5v from the L298 should connect to the 5v pin of the Arduino. And probably should be disconnected when the Arduino is powered from the USB cable.

...R

Unplugging the 5volts running from the L298 to the arduino and just running from usb power causes the same problem (erratic movement)

Also, running the wire from the 5volts on the L298 to the 5v on the arduino also causes the same issue.

thanks,
matt

analog:
Also, running the wire from the 5volts on the L298 to the 5v on the arduino also causes the same issue.

Does that mean that you get erratic behaviour when the L298 is connected to the 5v pin on the Arduino AND the Arduino is disconnected from the USB cable?

The Arduino Vin pin is the same as the barrel jack and requires a voltage in excess of 6v, 7v is the recommended minimum so if you have a regulated 5v supply it should always be connected to the 5v pin.

Do you have a spare L298 that you could try?

...R

Hi,
Can you post a complete circuit diagram please?

Showing all your connections to the UNO and the L298.

Thanks.. Tom... :slight_smile:

Better still post your complete code and circuit like is expected in this forum and explained in the "how
to post" sticky threads. Here means at least two versions of the circuit, since they are behaving
different. You should also post the datasheet or similar for both the motor and the power supply.

The USB thing may be a red-herring, its best to check everything, so we need to see everything.

Attached is the circuit, it's pretty basic, I've tried it connecting to both the Vin and 5v, both with the same result.

I've also tried switching out the controller board (yay they came in a 5pack, then again they could all be bad too.)

the code for this is the sample arduino stepper code:

#include <Stepper.h>

const int stepsPerRevolution = 200;  
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  myStepper.setSpeed(200);

}

void loop() {
  myStepper.step(stepsPerRevolution);
  delay(500);
}

I think this is the closest to a datasheet i've found on the board: https://www.vanallesenmeer.nl/Files/2/38000/38789/Attachments/Product/19R532a99t89o082381327649Z60XBnK.pdf

thanks,
matt

Image from Reply #7 so we don't have to download it. See this Simple Image Posting Guide

...R