08-13-2012 02:08 PM
Hello!
I want to control DC motor via labview and L298N(+arduino)
It just performance stop and counter clockwise run and clockwise run
But I just find servo motor and step motor example for labview
And a example on labview.
If I want to modify the models vi.
What can I do?
Do I have to reprograming arduino?
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);
}
}
08-14-2012 03:17 AM - edited 08-14-2012 03:18 AM
There is DC motor in it.
I use arduino UNO and L298N to contol
L298N information on add
Picture is UNO and L298N + Mechanic
Thanks very much.
This is arduino program.
// 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;
}
}
}
08-14-2012 09:36 AM
Sorry I forgot saying.
My motor is DC stepper motor !
08-14-2012 03:37 PM
Hi little flower,
Sorry to inform you that the arduino hardware is not generally supported on the standard NI discussion Forums. However, if you go to www.ni.com/arduino and click on the “Discussions” tab under the “LabVIEW Interface for Arduino” header, you will be able to post your question there. Hopefully someone will be able to assist you from there.
Best,