フィルターのクリア

Stepper motor programming on arduino using drv8825 on MATLAB

10 ビュー (過去 30 日間)
Rajbir Singh
Rajbir Singh 2020 年 2 月 20 日
コメント済み: Conner Carriere 2021 年 2 月 17 日
I am facing a problem while programming a stepper motor on arduino using drv8825 on MATLAB. The results are not same while programming on these 2 platforms.
On Arduino IDE its working as expected using the following code:
# define dirpin 2
# define stepPin 3
# define stepsPerRevolution 200
void setup() {
// Declare pins as output:
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}
void loop() {
// Set the spinning direction clockwise:
digitalWrite(dirPin, HIGH);
// Spin the stepper motor 1 revolution slowly:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(600);
digitalWrite(stepPin, LOW);
delayMicroseconds(600);
}
delay(600);
// Set the spinning direction counterclockwise:
digitalWrite(dirPin, LOW);
//Spin the stepper motor 5 revolutions fast:
for (int i = 0; i < stepsPerRevolution; i++) {
// These four lines result in 1 step:
digitalWrite(stepPin, HIGH);
delayMicroseconds(600);
digitalWrite(stepPin, LOW);
delayMicroseconds(600);
}
delay(600);
}
On MATLAB I have tried to program the same but results are not same as shown on Arduino, using the following code:
clear a
% Arduino Declaration
a = arduino('COM4', 'Uno');
StepPerRevolution = 200;
% Pin Configuration
configurePin(a,'D2','DigitalOutput'); %D2 = Direction pin
configurePin(a,'D3','DigitalOutput'); %D3 = Step pin
while true
writeDigitalPin(a,'D2',1);
for i = 0:StepPerRevolution
writeDigitalPin(a,'D3',1);
pause(0.0006);
writeDigitalPin(a,'D3',0);
pause(0.0006);
end
writeDigitalPin(a,'D2',0);
for i = 0:StepPerRevolution
writeDigitalPin(a,'D3',1);
pause(0.0006);
writeDigitalPin(a,'D3',0);
pause(0.0006);
end
end
Please help
  1 件のコメント
Conner Carriere
Conner Carriere 2021 年 2 月 17 日
Did you figure anything out, having issues also?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by