Example Code

Two Stepper Motor Control with One Arduino and Adafruit Motor Shield

Code and Documents

Attachment

Overview

This example lets you control the Speed and #Steps of two stepper motors using one arduino and adafruit motor shield.

Description

For those of you who have worked with 1 stepper motor control using Labview and not knowing how to use a second stepper with the same arduino, this is how it is. I'm using adafruit motor driver shield with my arduino UNO R3. This is a code modified using the 'Stepper motor Example.vi' proveided by LIFA (You must have come across this vi already)

The acceleration control has been disabled, which can be re-initialised if required by converting the now set constant node into a control node.


Steps to Implement or Execute Code

  1. Just download and run the code
  2. Dont forget to configure you're motor driver pins to the motors and arduino com port.
  3. Have fun

Requirements

Software

Labview 2009 or higher

Labview Interface For Arduino

VISA

Hardware

Arduino UNO R3

Adafruit Motor Shield

Additional Images or Video



Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
akapoor5
Member
Member
on

Thank you for sharing this program. I recently used this program for running my XY stage and it works (after minor modifications) but the problem now is that it is only causing the stage axes to move in one direction. I tried also by putting a negative sign into the # of steps to move but it still does not move in both directions. Could you please help me get the stage working in both directions ?

akapoor5
Member
Member
on

Using a negative sign in Y number of steps reverses the direction but it does not work for the X direction. Any ideas about why it is happening ? 

akapoor5
Member
Member
on

Just wanted to update that my query has been resolved. The problem was that in the block diagram you can see a 0 or 1 paired with stepper pin numbers which are connected to the stepper motor driver and replacing 0 with 1 or vice versa, reverses the order of pins from 3,4 to 4, 3 which actually defines the direction of movement of that particular stage axis connected to that particular stepper motor. The error was that changing 0 to 1 was not reversing the pins corresponding to the X- direction and that is why putting a negative sign in the number of X steps was not reversing the direction of movement of X.

Thank you.

z2sam
Member
Member
on

Hi, I have some problems with this program, mainly that my stepper motors is both decelerating. For example if one motor is running at 400 step/sec and should go 16000 steps, and then the other one go at 200 step/sec and should go 32000 steps. You can hear also the frequency is changing, but yeah in the end both motors doesn't stop at the same time, the motor which runs slower is stopping many seconds behind. The only difference is that I use Mega 2560. (could that be the problem?!) EDIT: (Oh forgot I don't use the adafruit motor shield, maybe this is the reason )

Jacquesnaude1
Member
Member
on

Hi All, can someone please help.  I cannot get ANY movement from my stepper motor.  I know the hardware is ok because if I run the script in Arduino, it works.  What firmware do I need to load on the arduino? I have used LIFA_Base and AFMotor.cpp and all the other ones but cannot get any movement from the motor.  I have also connected the stepper on M3 and M4 but nothing would move.  I dont understand what the pin settings should be.  i am using a Mega board instead of an UNO so I changed that as well as tjhe comms but left the rest alone.  Can someone please assist?

I dont have much Labview and Arduino background and I am just starting but I must be doing something completely stupid.........

Contributors