Подключение пяти моторов 28byj-48
- Войдите на сайт для отправки комментариев
Ср, 19/12/2018 - 17:10
Стоит задача сделать ролеті на окна с управлением с ардуино. Ардуино уно. Так вот правильно ли будет такое подключение, или может что то подскажите
Библиотека CustomStepper
#include <CustomStepper.h>
//Full constructor, just the first 4 parameters are necessary, they are the pins connected to the motor,
//the others are optional, and default to the following below
//the 5th paramater is the steps sequence, where the 1st element of the array is the number of steps
//it can have a maximum of 8 steps
//the 6th parameter is the SPR (Steps Per Rotation)
//the 7th parameter is the RPM
//the 8th parameter is the rotation orientation
CustomStepper stepper(8, 9, 10, 11, (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 4075.7728395, 12, CW);
boolean rotate1 = false;
boolean rotatedeg = false;
boolean crotate = false;
CustomStepper stepper1(0, 1, 2, 3, (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 4075.7728395, 12, CW);
boolean rotate11 = false;
boolean rotatedeg1 = false;
boolean crotate1 = false;
CustomStepper stepper2(4, 5, 6, 7, (byte[]){8, B1000, B1100, B0100, B0110, B0010, B0011, B0001, B1001}, 4075.7728395, 12, CW);
boolean rotate12 = false;
boolean rotatedeg2 = false;
boolean crotate2 = false;
void setup()
{
//sets the RPM
stepper.setRPM(12);
//sets the Steps Per Rotation, in this case it is 64 * the 283712/4455 annoying ger ratio
//for my motor (it works with float to be able to deal with these non-integer gear ratios)
stepper.setSPR(4075.7728395);
}
void loop()
{
//when a command is finished it the isDone will return true, it is important to notice that
//you can't give one command just after another since they don't block the execution,
//which allows the program to control multiple motors
if (stepper.isDone() && rotate1 == false)
{
//this method sets the direction of rotation, has 3 allowed values (CW, CCW, and STOP)
//clockwise and counterclockwise for the first 2
stepper.setDirection(CCW);
//this method sets the motor to rotate a given number of times, if you don't specify it,
//the motor will rotate untilyou send another command or set the direction to STOP
stepper.rotate(2);
rotate1 = true;
}
if (stepper.isDone() && rotate1 == true && rotatedeg == false)
{
stepper.setDirection(CW);
//this method makes the motor rotate a given number of degrees, it works with float
//you can give angles like 90.5, but you can't give negative values, it rotates to the direction currently set
stepper.rotateDegrees(90);
rotatedeg = true;
}
if (stepper.isDone() && rotatedeg == true && crotate == false)
{
stepper.setDirection(CCW);
//this will rotate until you stop it with another comand or set the direction to STOP
stepper.rotate();
crotate = true;
}
//this is very important and must be placed in your loop, it is this that makes the motor steps
//when necessary
//222
//when a command is finished it the isDone will return true, it is important to notice that
//you can't give one command just after another since they don't block the execution,
//which allows the program to control multiple motors
if (stepper1.isDone() && rotate11 == false)
{
//this method sets the direction of rotation, has 3 allowed values (CW, CCW, and STOP)
//clockwise and counterclockwise for the first 2
stepper1.setDirection(CCW);
//this method sets the motor to rotate a given number of times, if you don't specify it,
//the motor will rotate untilyou send another command or set the direction to STOP
stepper1.rotate(2);
rotate11 = true;
}
if (stepper1.isDone() && rotate11 == true && rotatedeg1 == false)
{
stepper1.setDirection(CW);
//this method makes the motor rotate a given number of degrees, it works with float
//you can give angles like 90.5, but you can't give negative values, it rotates to the direction currently set
stepper1.rotateDegrees(90);
rotatedeg1 = true;
}
if (stepper1.isDone() && rotatedeg1 == true && crotate1 == false)
{
stepper1.setDirection(CCW);
//this will rotate until you stop it with another comand or set the direction to STOP
stepper1.rotate();
crotate1 = true;
}
//this is very important and must be placed in your loop, it is this that makes the motor steps
//when necessary
//333
//when a command is finished it the isDone will return true, it is important to notice that
//you can't give one command just after another since they don't block the execution,
//which allows the program to control multiple motors
if (stepper2.isDone() && rotate12 == false)
{
//this method sets the direction of rotation, has 3 allowed values (CW, CCW, and STOP)
//clockwise and counterclockwise for the first 2
stepper2.setDirection(CCW);
//this method sets the motor to rotate a given number of times, if you don't specify it,
//the motor will rotate untilyou send another command or set the direction to STOP
stepper2.rotate(2);
rotate12 = true;
}
if (stepper2.isDone() && rotate12 == true && rotatedeg2 == false)
{
stepper2.setDirection(CW);
//this method makes the motor rotate a given number of degrees, it works with float
//you can give angles like 90.5, but you can't give negative values, it rotates to the direction currently set
stepper2.rotateDegrees(90);
rotatedeg2 = true;
}
if (stepper2.isDone() && rotatedeg2 == true && crotate2 == false)
{
stepper2.setDirection(CCW);
//this will rotate until you stop it with another comand or set the direction to STOP
stepper2.rotate();
crotate2 = true;
}
//this is very important and must be placed in your loop, it is this that makes the motor steps
//when necessary
stepper.run();
stepper1.run();
stepper2.run();
}
Если работает, то правильное. Не работает - неправильное.
а можно подключить этот движок через 74HC595 сдвиговый регистр? так как на уно нехватает пинов для реализации
Теоретически - да. Но библиотек под такое извращение можете не найти. Придется разучивать всякие фокусы...
а можно подключить этот движок через 74HC595 сдвиговый регистр? так как на уно нехватает пинов для реализации
лучше купить драйвера типа A4498 - им на каждый мотор требуется всего два пина
Тогда мотор курочить придется - средние точки обмоток разъединять.
нашел схему подключения и на ней указан мотор с 4 выходами а на моторах 28byj-48 5 выходов как их подключить?
https://coeleveld.com/wp-content/uploads/2016/10/Modifying-a-28BYJ-48-st...
Последний пункт прочтите дважды.
А через i2c шаговый мотор нельзя подключить?
Можно. Но нужен контроллер шагового двигателя с управлением по I2C.
Можно купить готовый, а можно сделать из ардуино Нано например.