I2C information for Stepper Motor Shield

Our weekly LIVE video chat. Every Wednesday at 8pm ET!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
orbitcoms
 
Posts: 20
Joined: Sun May 19, 2013 3:11 am

I2C information for Stepper Motor Shield

Post by orbitcoms »

I want to control a stepper motor from a different Host than the Arduino (to enable me to prototype a project before making a PCB layout).

I purchased several stepper motor boards and stepper motors and
need the I2C information (Slave address and functions). Also a schematic so I can see where the PWM signals go.

Thanks in advance.

Regards

David

User avatar
Franklin97355
 
Posts: 23940
Joined: Mon Apr 21, 2008 2:33 pm

Re: I2C information for Stepper Motor Shield

Post by Franklin97355 »

Take a look at the motor library for the codes sent to the shield https://github.com/adafruit/Adafruit-Mo ... ld-library

User avatar
orbitcoms
 
Posts: 20
Joined: Sun May 19, 2013 3:11 am

Re: I2C information for Stepper Motor Shield

Post by orbitcoms »

Which file contains the I2C slave address and functions? I am not up much on Arduino?

This is the code I found so far...

Code: Select all

#include <AccelStepper.h>
#include <AFMotor.h>

// two stepper motors one on each port
AF_Stepper motor1(200, 1);
AF_Stepper motor2(200, 2);

// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {  
  motor1.onestep(FORWARD, SINGLE);
}
void backwardstep1() {  
  motor1.onestep(BACKWARD, SINGLE);
}
// wrappers for the second motor!
void forwardstep2() {  
  motor2.onestep(FORWARD, SINGLE);
}
void backwardstep2() {  
  motor2.onestep(BACKWARD, SINGLE);
}

// Motor shield has two motor ports, now we'll wrap them in an AccelStepper object
AccelStepper stepper1(forwardstep1, backwardstep1);
AccelStepper stepper2(forwardstep2, backwardstep2);

void setup()
{  
    stepper1.setMaxSpeed(200.0);
    stepper1.setAcceleration(100.0);
    stepper1.moveTo(24);
    
    stepper2.setMaxSpeed(300.0);
    stepper2.setAcceleration(100.0);
    stepper2.moveTo(1000000);
    
}

void loop()
{
    // Change direction at the limits
    if (stepper1.distanceToGo() == 0)
	stepper1.moveTo(-stepper1.currentPosition());
    stepper1.run();
    stepper2.run();
}
Last edited by adafruit_support_bill on Sun Mar 01, 2015 8:34 am, edited 1 time in total.
Reason: please use the </> button when submitting code. press </>, then paste your code between the [code] [/code] tags.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C information for Stepper Motor Shield

Post by adafruit_support_bill »

That is the multi-stepper example code. The library code is in the link posted above:
https://github.com/adafruit/Adafruit_Mo ... V2_Library

User avatar
orbitcoms
 
Posts: 20
Joined: Sun May 19, 2013 3:11 am

Re: I2C information for Stepper Motor Shield

Post by orbitcoms »

I navigated to the site and downloaded the AFMotor_ConstantSpeed.pde under the MultiStepper examples but cannot see the I2C code in there?

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C information for Stepper Motor Shield

Post by adafruit_support_bill »

AF_Motor is for V1 shields. You want the V2 library:
https://github.com/adafruit/Adafruit_Mo ... V2_Library

User avatar
orbitcoms
 
Posts: 20
Joined: Sun May 19, 2013 3:11 am

Re: I2C information for Stepper Motor Shield

Post by orbitcoms »

That's where I went, which file to I download?

User avatar
Franklin97355
 
Posts: 23940
Joined: Mon Apr 21, 2008 2:33 pm

Re: I2C information for Stepper Motor Shield

Post by Franklin97355 »

Adafruit_MotorShield.cpp if all you want to do is look at the code. If you want the library download the zip file.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: I2C information for Stepper Motor Shield

Post by adafruit_support_bill »

That's where I went, which file to I download?
Really? There are no AF_Motor files or .pde files of any kind under that link. The files you want are the library files which are right there at the top level
Adafruit_MotorShield.cpp
and
Adafruit_MotorShield.h

Locked
Please be positive and constructive with your questions and comments.

Return to “Ask an Engineer! VIDEO CHAT (closed)”