Help with flamingoeda L298N Shield.

I have been trying to find a documentation about this shield and how it behaves, but so far no luck.

http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=280530868792

The documentation to drive stepper with it...well...there is none.

For example, in the little source that is available, there are these "speedpins" in addition to the motorpins A+ A- B- B+.

Whats the purpose of these? Anybody have these and successfully driven a stepper with it..All I can do is to make the stepper buzz..

The motor I am trying to run is small bipolar motor.

Here is some source for the controller, this code is to run a normal dc motor i think.

// 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;
}
}
}

This is the code I tried, a combination of stepper class and this shields own.

#include <Stepper.h>

// change this to the number of steps on your motor
#define STEPS 100

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it’s
// attached to
Stepper stepper(STEPS, 8, 11, 12, 13);

// Coil A
int dir1PinA = 13;
int dir2PinA = 12;
int speedPinA = 10;

// Coil B

int dir1PinB = 11;
int dir2PinB = 8;
int speedPinB = 9;

int speed;

void setup() {

speed = 1000;
analogWrite(speedPinA, speed);
analogWrite(speedPinB, speed);

}

void loop() {

stepper.step(100);

}

Still speedpin is a mystery…is it a “delay” in milliseconds or what…? The smaller the speedpin value, dimmer the leds are…

Actually got it working..needed to add some delay. The "speedpin" was actually a voltage. 1000 being maximum value (or 1023)

// COIL A
int dir1PinA = 13;
int dir2PinA = 12;
int speedPinA = 10;

// COIL B
int dir1PinB = 11;
int dir2PinB = 8;
int speedPinB = 9;

int voltage;

void setup() {
pinMode(dir1PinA, OUTPUT);
pinMode(dir2PinA, OUTPUT);
pinMode(speedPinA, OUTPUT);
pinMode(dir1PinB, OUTPUT);
pinMode(dir2PinB, OUTPUT);
pinMode(speedPinB, OUTPUT);

voltage = 500;

}

void loop() {
analogWrite(speedPinA, voltage);
analogWrite(speedPinB, voltage);

digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinB, HIGH);
digitalWrite(dir2PinB, LOW);
delay(2);
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
digitalWrite(dir1PinB, HIGH);
digitalWrite(dir2PinB, LOW);
delay(2);
digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, HIGH);
digitalWrite(dir1PinB, LOW);
digitalWrite(dir2PinB, HIGH);
delay(2);
digitalWrite(dir1PinA, HIGH);
digitalWrite(dir2PinA, LOW);
digitalWrite(dir1PinB, LOW);
digitalWrite(dir2PinB, HIGH);
delay(2);

}

Still need to add LOW LOW sequences...i think.

I have a similar board and am using code like this:

// Motor A
int dir1PinA = 13;
int dir2PinA = 12;
int speedPinA = 10;

// Motor B
int dir1PinB = 11;
int dir2PinB = 8;
int speedPinB = 9;

int motorDisabled = 0;
int motorEnabled = 255;

int delayMillis = 5;

// N NE E SE S SW W NW
int stepperStates[8] = {
{ HIGH, HIGH, LOW, LOW, LOW, LOW, LOW, HIGH },
{ LOW, LOW, LOW, HIGH, HIGH, HIGH, LOW, LOW },
{ LOW, HIGH, HIGH, HIGH, LOW, LOW, LOW, LOW },
{ LOW, LOW, LOW, LOW, LOW, HIGH, HIGH, HIGH }
};

int stepperState = 0;

void setup() {
pinMode(dir1PinA, OUTPUT);
pinMode(dir2PinA, OUTPUT);
pinMode(speedPinA, OUTPUT);

pinMode(dir1PinB, OUTPUT);
pinMode(dir2PinB, OUTPUT);
pinMode(speedPinB, OUTPUT);

digitalWrite(dir1PinA, LOW);
digitalWrite(dir2PinA, LOW);
analogWrite(speedPinA, motorDisabled);

digitalWrite(dir1PinB, LOW);
digitalWrite(dir2PinB, LOW);
analogWrite(speedPinB, motorDisabled);

}

void loop() {

for (int i = 0; i < 8; ++i) {
analogWrite(speedPinA, motorDisabled);
analogWrite(speedPinB, motorDisabled);

digitalWrite(dir1PinA, stepperStates[0]);
_ digitalWrite(dir2PinA, stepperStates[1]);_

_ digitalWrite(dir1PinB, stepperStates[2]);
digitalWrite(dir2PinB, stepperStates[3]);_

* analogWrite(speedPinA, motorEnabled);*
* analogWrite(speedPinB, motorEnabled);*

* delay(delayMillis);*
* } *
}
[/font]
The speed pins actually use the PWM capabilities of the Arduino to control the speed of the motors attached to the shield. The L298 on there has an enable line that is connected to the speed pins, so the PWM activity of the Arduino board effectively controls the duty cycle of the motor…