Stepper motor driving with DFRobot motor shield

I have a L298N based Arduino motor shield DR10009 from DFRobot.

Driving two DC motors is ok, after a few adjustments (pull-down resistors to quiet the motors on startup ; driver corrections), but I am unable to use the alternative mode of this board: PLL control, intended to drive a two-phases stepper motor.

Could it be because the PWM signals should be delivered to pins 4 and 7, as it seems from the doc:

[quote]Arduino PLL Speed Control:

int E1 = 7;
int M1 = 6;
int E2 = 4;
int M2 = 5;
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 ); //PLL Speed Control 
    analogWrite( E2, value ); //PLL Speed Control
    delay(30);
  }
}

[/quote]

My board is FEZ Panda 2, it can deliver PWM on pins 5 and 6, but it can’t (at least natively) on 4 and 7.
Should I drive these pins entirely in a loop?

Does anyone have an experience on this?

Hello PFSB !

I had a look at the DRI0009 from dfrobot Arduino_Motor_Shield__L298N___SKU_DRI0009_-DFRobot
However I couldn’t quickly find shematics for it.

The code you sent is not intended to use for driving steppers motors.

You will be able to use this shield to drive a stepper motor, without using PWM. PWM is needed to control speed of regular motors only, or maybe to perform micro-stepping with steppers, which will be difficult to do with C# due to timing issues.

Is your stepper bipolar ?
You need to apply a stepping sequence on the “direction control” pins of your steppers, and make it change at each step.
Here is good information about steppers : Jones on Stepping Motor Types
Tutorials Archives - StepperWorld
The second documents also gives several possible stepping sequences : Wave-Drive, Hi-Torque, Half-step… depending on what you wish to do. There is a lot to learn about steppers :slight_smile: !

And some code I made for stepping motors on the adafruit motor shield :
http://code.tinyclr.com/project/323/adafruit-motor-shield-driver/
However, the data sent is serialized (not parallel like in your shield) and it is for 2 steppers.

If you can upload a schematics of your shield, I’ll have a look at it :wink:

Good luck and have fun !

Hi,

Stepper motors work differently.

Change your code to this:


int E1 = 7;
int M1 = 6;
int E2 = 4;
int M2 = 5;
void setup()
{
  pinMode(M1, OUTPUT);
  pinMode(M2, OUTPUT);
}
void loop()
{
  int value;
  analogWrite( E1, 255 ); //PLL Speed Control 
  analogWrite( E2, 255 ); //PLL Speed Control
  for ( value = 0 ; value <= 255; value+=5 )
  {
    digitalWrite( M1, LOW );
    digitalWrite( M2, LOW );
    delay(30);
    digitalWrite( M1, LOW );
    digitalWrite( M2, HIGH );
    delay(30);
    digitalWrite( M1, HIGH );
    digitalWrite( M2, LOW );
    delay(30);
    digitalWrite( M1, HIGH );
    digitalWrite( M2, HIGH );
    delay(30);
  }
}

I doubt that I have the sequence correct thus the motor might not turn and rather jump around.

Another good tutorial: http://www.ingeniumblog.net/2009/12/interfacing-a-cd-rom-stepper-motor/?instance=tml-1&action=register

Egad, thar be a sketch here…

thought I was in the wrong forum for a second :snooty:

I couldn’t find any schematics for this shield.

I use C# of course, the (Arduino? -)code example above is from the doc I refered to… but the principle is clear. As it is in your answer, Errol.

Then I will drive the pins directly in the loop, without PWM, as you show.

Thank you all for your fast answers.

Should probably rather be:


    digitalWrite( M1, LOW );
    digitalWrite( M2, LOW );
    delay(30);
    digitalWrite( M1, LOW );
    digitalWrite( M2, HIGH );
    delay(30);
    digitalWrite( M1, HIGH );
    digitalWrite( M2, HIGH );
    delay(30);
    digitalWrite( M1, HIGH );
    digitalWrite( M2, LOW );
    delay(30);