trying to control a stepper motor with a L298N {motor epson Em 257}

hello for a project im trying to controll a stepper motor using the L298N driver.

the motor im using is the same as in this video: {epson EM 257}

https://www.youtube.com/watch?v=GFKohtByprc datasheet/other forum for this motor: http://forum.arduino.cc/index.php?topic=91016.0

i tried various different code for this controller.

the "arduino" i use is a Atmega pro mini 328P {clone revision}

https://www.diymore.cc/collections/free-shipping-1/products/diymore-pro-mini-3-3v-8mhz-board-atmega328-microcontroller-module-for-arduino-mini-atmega328p-with-i-o-pins

i already tested and the arduino is functioning {tested it by using a simple program that blinks a led}

i connected a 12V 3A psu to the L298N

the code i tried using: {the page where i found the code}

https://coeleveld.com/arduino-stepper-l298n/

does anybody know what im doing wrong {i did change the code from the page to match the stepper motor im using}

Can you provide the script with the changes you made? And what is the problem? What is it doing and what is it that you expect it to be doing?

An L298 is a poor choice for driving a stepper motor.

These links may help Stepper Motor Basics Simple Stepper Code

...R

Robin2:
An L298 is a poor choice for driving a stepper motor.

Worth pointing out though that it was actually designed to do exactly that. My first foray into the use of steppers used an L298 and some steppers out of a copier or printer over 25 years ago.

More correct to say it’s a poor choice for driving modern steppers, since back in the day, the L298 was the exact right choice for contemporary steppers.

ardy_guy: Worth pointing out though that it was actually designed to do exactly that.

I'm not convinced. I suspect the marketing guys got their hands on that text :)

Because it can handle inductive loads it can drive a stepper motor. You can also paint the outside walls of a house with a 1 inch paintbrush.

...R

Robin2:
I’m not convinced. I suspect the marketing guys got their hands on that text

It’s the impedance of the windings that makes the difference if my memory serves: L298’s contemporary steppers were suited to the L298.

A pretty standard way of driving a stepper then was the pairing of L298 with L297. The L297 took as input the required direction on one pin, and a pulse per step on another. Its output was to walk the stepper by managing the L298’s input, just as one might do now with digital pins on an Arduino.

I wonder if the marketing guys got their hands on this actual circuit application from the L298 datasheet too?

L298 with L297 from L298 datasheet.GIF

The L298 I used 25y ago came out of a copier with the stepper motor it had driven in production manufacture by the (then) world’s largest copier manufacturer. They were convinced that the L298 could drive steppers, and the L298 does drive steppers, provided they are the L298’s contemporary steppers not today’s.

ardy_guy: It's the impedance of the windings that makes the difference if my memory serves:

I have no argument with your technical analysis.

What I said in Reply #2 was aimed at making life simple for a beginner.

...R

for those wanting to know why i choose this particular stepper motor driver,

yes i do know that its not the best stepper motor driver out there but:

i only choose it because it was the only one where i found that someone got working with the motor i have.

{i bought the driver on ebay for 2.49$ {2pcs}} {so its not like i spend 10$ on a driver module}

and for those asking yes the motor is recycled out of a old printer/label maker.

another motor i have is the: ""Minebea 16PU-M202-G1ST""

which im planning to use for the exact same idea

i will post the script tomorrow. {i only tried using the script to test the motor itself to see if i can get it spinning, so there is not much changed} {the only change i made was so the steps where matching to the specified motor}


the problem is that the motor axle is not spinning, when holding it i can feel that the coils are powering the axle since there is a noticeable torque holding the axle in place.

i will also try to use different wiring layouts on the motor/driver to see if this makes any difference.

i will also put up a picture of the idea, so you guys can give better help/support.

this is a rough scematic/ layout of what im planning to make: (not all wires are connected in the diagram, so ports can be changed if needed)

|500x454

as for the question of the code i did not change anything except the step-count, {so that it matched my specified motor}

i also did a test using a led and the motor to see if the coils where bad and this was not the case

(small update)

by using the stepper motor default script of the arduino interface

i got the motor spinning successfully.

current pinout:

digital pin 1-6 (LCD display)
digital Pin 8-11 motor

both codes are stock arduino codes i use for testing:

the hello world LCD display code
and the stepper motor code under: example/stepper/onestep revolution

the plan is to use the motor with 2 endstops and a timer sensor so the motor wil spin for X minutes at time X
the same is at time Y.

the endstops are used so that if the motor spins further than needed it will stop
the display only has to show the current time, and active program/code
like
time: 16:06
program active 1
the 2 extra buttons are overide buttons so i can toggle program/code X or Y when needed.
the leds are just for show

the current code: {combination of hello world and motor driver}
{im using a arduino uno for testing purposes {since its easier to program due not having a usb compiler for the arduino mini}}

// include the library code:
#include <LiquidCrystal.h>
#include <Stepper.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 5, en = 6, d4 = 1, d5 = 2, d6 = 3, d7 = 4;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
// put your setup code here, to run once:
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“hello, world!”);
}

void loop() {
// put your main code here, to run repeatedly:

// step one revolution in one direction:
Serial.println(“clockwise”);
myStepper.step(stepsPerRevolution);
delay(500);

// step one revolution in the other direction:
Serial.println(“counterclockwise”);
myStepper.step(-stepsPerRevolution);
delay(500);

// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis() / 1000);
}

ps:

what type of time sensor do you guys recommend?
DS3231??
DS1302??
41F6 DC5V AR I2C?
a different one?

i still have 4 digital pins left.
and i need to connect at least 4 buttons {2 of which are end-stops}
and if possible 3 leds {look at given image for more information}

for some reason after updating the IDE the code is now broken???

darknessblade: for some reason after updating the IDE the code is now broken???

What exactly does that mean? if you are getting a compiler error then you need to post it along with the program that gave rise to the error.

Do you really need the newer version of the IDE?

You can have several versions of the IDE on the same PC.

...R

Robin2: What exactly does that mean? if you are getting a compiler error then you need to post it along with the program that gave rise to the error.

Do you really need the newer version of the IDE?

You can have several versions of the IDE on the same PC.

...R

Sketch uses 4192 bytes (12%) of program storage space. Maximum is 32256 bytes. Global variables use 280 bytes (13%) of dynamic memory, leaving 1768 bytes for local variables. Maximum is 2048 bytes. An error occurred while uploading the sketch

and when it does upload to the arduino the LCD does no longer print the message "hello world" {i did not change anything of the pinout}

Robin2: What exactly does that mean? if you are getting a compiler error then you need to post it along with the program that gave rise to the error.

Do you really need the newer version of the IDE?

You can have several versions of the IDE on the same PC.

...R

Sketch uses 4192 bytes (12%) of program storage space. Maximum is 32256 bytes. Global variables use 280 bytes (13%) of dynamic memory, leaving 1768 bytes for local variables. Maximum is 2048 bytes. An error occurred while uploading the sketch

and when it does upload to the arduino the LCD does no longer print the message "hello world" {i did not change anything of the pinout}

rebuilding the code from scratch wielded another result

now the screen shows the right message but it does not have the counter under hello world

i also need to know how i can have the motor run for X in direction W when time is Y. as given by the

DS3231 sensor i recently bought {on ebay}

it only needs to run 2 directions at 2+ given time programs.

i cant find anything online how i can easily build this

darknessblade: Sketch uses 4192 bytes (12%) of program storage space. Maximum is 32256 bytes. Global variables use 280 bytes (13%) of dynamic memory, leaving 1768 bytes for local variables. Maximum is 2048 bytes. An error occurred while uploading the sketch

That does not sound like a compiler error. Rather it seems to be an uploading error.

I am not familiar with the "Atmega pro mini 328P {clone revision}" so I don't know if it has specific requirements. Maybe the newer IDE is expecting a change in the boards.txt file, or maybe there are extra options to select from the tools/board menu before uploading.

Have you tried using the version of the IDE that worked previously?

...R

Robin2: That does not sound like a compiler error. Rather it seems to be an uploading error.

I am not familiar with the "Atmega pro mini 328P {clone revision}" so I don't know if it has specific requirements. Maybe the newer IDE is expecting a change in the boards.txt file, or maybe there are extra options to select from the tools/board menu before uploading.

Have you tried using the version of the IDE that worked previously?

...R

the clone version is exactly the same as every other atmega 328P arduino version im currently using a Uno version for testing purposes. since that model has a easier to use IO/power pinouts.

after some testing i was able to rebuild the working version from scratch. and now it works again. {hello world+ stepper test}

when i recieve the time sensor i will test to see if i can get that working with the display i use before working on the rest of the build, since that one is a essential part to get it working as i want even after a power outage so i do not have to rely on the arduino build in clock.

{the display is recycled of a old printer, since its format is smaller than most 2x16 display's its easier to make a casing around it}

i also have a button panel that can work either trough a IO expander {every button has its own IO} or i can use the analog port {every button has a resistor}

which one would you recommend.

it will be build in 2 "modules" {1 is the control/button array and display with the arduino} and the other will be the motor one {connected trough a cable that can handle 12V and has 6+ pins} so it does not really matter if i use a IO expander or not .{it just matters which one is easier to program}

darknessblade:
i also have a button panel that can work either trough a IO expander {every button has its own IO} or i can use the analog port {every button has a resistor}

which one would you recommend.

I don’t have a view - I would use the system that is most convenient so I would probably prefer the use of resistors as I have lots of them in stock. YMMV

…R

after disasembeling some old devices i found a

in74hct164an inside of it.

the board also contains a 7 segment display {4x 7 segment clock display} and a IR sensor. [i can also use the IR sensor with a remote control to replace the buttons} {which will be a option to replace the buttons for control of the {menu/ motor}}

after disasemblying another few printers, i got a few more nema17 stepper motors.

if i want to drive 2 motors per arduino what would be the best course of action?

get a reprap shield or keep using the L298N drivers?

so i can have 2 motors per arduino (2 curtains per window)

i also have a button array from a old brother mfc-8800dn which contains the following chip https://www.mouser.com/ProductDetail/Cypress-Semiconductor/MB90567PMC-G-137E1?qs=%2fha2pyFadujlAmPYfavc8TRKrOJek5ImnCNcOa4l9xDUm%2fdKZSRh4U7a9zxwNZ2u

now is my question. can i use this button array as a control panel for a smarthome system and send the signals using a ESP8266 enabled arduino board

{and have each button do a specific command like run code X or run code Y [left part of the panel 21 total custom program option] and use the right side of the panel for menu/setup options }

darknessblade:
get a reprap shield or keep using the L298N drivers?

You had my answer to that in Reply #2

A reprap shield is convenient but it is not essential for using A4988 or DRV8825 stepper drivers. They can be connected to an Arduino with wires.

…R

Robin2: You had my answer to that in Reply #2

A reprap shield is convenient but it is not essential for using A4988 or DRV8825 stepper drivers. They can be connected to an Arduino with wires.

...R

yes i looked at your 2nd post, i can see if im able to find other drivers cheaply {got a friend with a broken reprap 3d printer, who replaced the stepper drivers} maybe i can get those working again.

{not sure what model they are but they look similar to the "A4988"}

what about my question regarding the button array?/ chip on that board? {will it work or do i have to remove the chip and jump wire all the connections to a arduino/ IO expander}