Hello everybody,
I'm customizing a sketch using two stepper motors with stepper.h library but varying the parameter Amot.setSpeed (100); the speed does not change: there is a limit of the rpm for steppers? is that the right parameter?
I'm using two Nema 17 1.8°step angle (200 steps/revolution) powered by a H-bridge driver L298N. Each phase draws current 0.4A at 12V, allowing for a holding torque of 26Ncm(36.8oz.in)
Thank you
Robin2
May 17, 2016, 10:57am
2
You need to post your program so we can understand what you are talking about.
And please use the code button </> so your code looks like thisand is easy to copy to a text editor
...R
Stepper Motor Basics
Sdroos,
How do you expect people to help you, if you don't give us all the details.
we need schematic and code...
Regards
Mel.
Robin2:
You need to post your program so we can understand what you are talking about.
And please use the code button </> so your code looks like thisand is easy to copy to a text editor
...R
Stepper Motor Basics
ok sorry, thinking that the info was enough
#include <MIDI.h>
#include <Stepper.h>
#include <Arduino.h>
int pin = 13; //midi in
byte Acounter = 0;
byte Bcounter = 0;
int AmotA = 9;
int AmotB = 10;
int AmotC = 11;
int AmotD = 12;
int BmotA = 5;
int BmotB = 6;
int BmotC = 7;
int BmotD = 8;
Stepper Amot(200, AmotA, AmotB, AmotC, AmotD);
Stepper Bmot(200, BmotA, BmotB, BmotC, BmotD);
MIDI_CREATE_DEFAULT_INSTANCE();
void HandleControlChange(byte channel, byte number, byte value)
{
if (channel == 1)
{
if (number == 20)
{
if (value < Acounter)
{
Amot.step(-5);
Acounter = value;
// serial.write(value);
digitalWrite(pin, HIGH);
}
else if (value > Acounter)
{
Amot.step(+5);
Acounter = value;
digitalWrite(pin, HIGH);
}
else if (value == Acounter)
{
Amot.step(0);
Acounter = value;
digitalWrite(pin, LOW);
}
}
else if (number == 21)
{
if (value < Bcounter)
{
Bmot.step(-10);
Bcounter = value;
digitalWrite(pin, HIGH);
}
else if (value > Bcounter)
{
Bmot.step(+10);
Bcounter = value;
digitalWrite(pin, HIGH);
}
else if (value == Bcounter)
{
Bmot.step(0);
Bcounter = value;
digitalWrite(pin, LOW);
}
}
}
else
{
digitalWrite(pin, LOW);
}
}
//-----------------------------------------------
void setup()
{
pinMode(pin, OUTPUT);
MIDI.setHandleControlChange(HandleControlChange);
MIDI.begin(MIDI_CHANNEL_OMNI);
Serial.begin(115200);
// Motor A
pinMode(AmotA, OUTPUT);
pinMode(AmotB, OUTPUT);
pinMode(AmotC, OUTPUT);
pinMode(AmotD, OUTPUT);
// Motor B
pinMode(BmotA, OUTPUT);
pinMode(BmotB, OUTPUT);
pinMode(BmotC, OUTPUT);
pinMode(BmotD, OUTPUT);
//Motorspeed
Amot.setSpeed(100); //5
Bmot.setSpeed(100); //4
}
void loop()
{
MIDI.read();
digitalWrite(pin, LOW);
}
Robin2
May 18, 2016, 10:17am
5
I am not familiar with creating music or with Midi. You need to explain how the program is intended to work.
...R
Hi Sdreoos,
Why does your code include a MIDI lib and Arduino.lib?? What L293 sheild are you using hope it's not this one: 0volts in M2, M3 using L293D and Uno - Motors, Mechanics, Power and CNC - Arduino Forum if so then you have to use their library?
I have just finished my first drawing bot using steppers and driver modules based on the A3967 chip and it works very well and is easy to control.
How are you powering the motors/sheild? A separate supply I hope, even if only batteries.
I can't see where you program starts with Loop void().
Regards
Mel.
If you use a specialized stepper motor driver board such as a Sparkfun Easydriver or a Pololu A4988 it will significantly reduce the computation load on the Arduino as well as controlling the motor more effectively.
Keep your L298 for your DC motor - that's what it is intended for.
...R
Stepper Motor Basics
Simple Stepper Code