Hello
I'm working at controling stepper motors with Labview and Arduino using "VISA" and Proteus simulation using the "virtual serial port driver"
As the first step, I made a simple code for control 3 servo motors instead stepper motors and it worked
#include <Servo.h>
//Initialization
Servo servoA,servoB,servoC;
byte servoA_angle=0,servoB_angle=0,servoC_angle=0;
void setup() {
servoA.attach(11,1000,2000);
servoB.attach(10,1000,2000);
servoC.attach(9,1000,2000);
Serial.begin(9600);
}
void loop() {
// Send Request to LabVIEW
Serial.write('r');
while(Serial.available()<3);
servoA.write(Serial.read());
servoB.write(Serial.read());
servoC.write(Serial.read());
Serial.flush();
delay(100);
}
The problem is when I change the code arduino for controling steppers. I hadn't changed the labview's code . It didn't work. I don't know where is the error.
#include <Stepper.h>
Stepper stepper1(200,2,3, 4, 5); // je pose que le moteur fait 200 pas par tour
Stepper stepper2(200,6, 7, 8, 9);
Stepper stepper3(200,10, 11,12,13);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode( 2, OUTPUT );
pinMode( 3, OUTPUT );
pinMode( 4, OUTPUT );
pinMode( 5, OUTPUT );
pinMode( 6, OUTPUT );
pinMode( 7, OUTPUT );
pinMode( 8, OUTPUT );
pinMode( 9, OUTPUT );
pinMode( 10, OUTPUT );
pinMode( 11, OUTPUT );
pinMode( 12, OUTPUT );
pinMode( 13, OUTPUT );
stepper1.setSpeed(30);
stepper2.setSpeed(30);
stepper3.setSpeed(30);
}
void loop() {
Serial.write('r');
while(Serial.available()<3);
stepper1.step(Serial.read());
stepper2.step(Serial.read());
stepper3.step(Serial.read());
Serial.flush();
delay(100);
}
I will be so grateful if someone can help me .
Thank you so much.