LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Control DC stepper motors

I want to control DC stepper motor via labview and (EasyDriver           V4.4 or L298N) + arduino

It  just performance  stop and counter clockwise run  and clockwise run

But I just find  servo motor and step  motor example vi in labview

If I want to modify the models vi or use 3Dmicro Toolkit.

What can I do?

Do I have reprograming for arduino ?

My Attachments picture 1.2 is my method.

2 and 3 are labview program vi.

Thanks very much.

these arduino program

int E1 = 5;
int M1 = 4;
int E2 = 6;
int M2 = 7;

void setup()
{
pinMode(M1, OUTPUT);
pinMode(M2, OUTPUT);
}

void loop()
{
int value;
for(value = 0 ; value <= 255; value+=5)
{
digitalWrite(M1,HIGH);
digitalWrite(M2, HIGH);
analogWrite(E1, value); 
analogWrite(E2, value); 
delay(30);
}
}

Sample Code:

// motor A

int dir1PinA = 13;

int dir2PinA = 12;

int speedPinA = 10;

// motor B

// motor A

int dir1PinB = 11;

int dir2PinB = 8;

int speedPinB = 9;

unsigned long time;

int speed;

int dir;

void setup() {

  pinMode(dir1PinA, OUTPUT);

  pinMode(dir2PinA, OUTPUT);

  pinMode(speedPinA, OUTPUT);

  pinMode(dir1PinB, OUTPUT);

  pinMode(dir2PinB, OUTPUT);

  pinMode(speedPinB, OUTPUT);

  time = millis();

  speed = 0;

  dir = 1;

}

void loop() {

  analogWrite(speedPinA, speed);

  analogWrite(speedPinB, 255 - speed);

  // set direction

  if (1 == dir) {

    digitalWrite(dir1PinA, LOW);

    digitalWrite(dir2PinA, HIGH);

    digitalWrite(dir1PinB, HIGH);

    digitalWrite(dir2PinB, LOW);

  } else {

    digitalWrite(dir1PinA, HIGH);

    digitalWrite(dir2PinA, LOW);

    digitalWrite(dir1PinB, LOW);

    digitalWrite(dir2PinB, HIGH);

  }

  if (millis() - time > 5000)  {

    time = millis();

    speed += 20;

    if (speed > 255) {

      speed = 0;

    }

    if (1 == dir) {

      dir = 0;

    } else {

      dir =1;

    }

  }

}

another

01#include <Servo.h>
03 
04Servo myservo;
06int value = 0;
08 
09void setup()
10{
11  myservo.attach(9);
12}
13 
14void loop()
15{
16  if (value == 0)
17value = 180;
18  else
19value = 0;
20  
21  //myservo.write(0) 
              //myservo.write(180) 24
                    myservo.write(value);
25  delay(1500);

another

01
04
05#include <Servo.h>
06
07
08Servo myservo;
09 
10
11int potpin = 0;
12
13int val;
14 
15void setup()
16{
17  myservo.attach(9); 
18}
19 
20void loop()
21{
22  val = analogRead(potpin);       
23  val = map(val, 0, 1023, 0, 179);
24  myservo.write(val);           
25  delay(15);                     
26}
0 Kudos
Message 1 of 1
(2,982 Views)