1 Rev per hour

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
randwulf
 
Posts: 3
Joined: Mon Apr 16, 2012 11:38 pm

1 Rev per hour

Post by randwulf »

Anyone know how to get an accurate 1 rev per hour from the adafruit motor shield. What is the smallest increment the shield recognizes? Ive tried to get it to do 3.33 steps per minute but it doesnt work. Any suggestions?

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

Re: 1 Rev per hour

Post by adafruit_support_bill »

You can call "onestep()" every 18000 milliseconds.

Code: Select all

  uint8_t onestep(uint8_t dir, uint8_t style);

randwulf
 
Posts: 3
Joined: Mon Apr 16, 2012 11:38 pm

Re: 1 Rev per hour

Post by randwulf »

Im sorry, I'm a newbie at this and have had the shield for only a week. How would i implement the speed when using the one.step? I have scoured the internet and cannot find any examples on setting the speed for a one step. Please help.
As it stands now, this is the only code i have.



// AFMotor_MultiStepper.pde
// -*- mode: C++ -*-
//
// Control both Stepper motors at the same time with different speeds
// and accelerations.
// Requires the AFMotor library (https://github.com/adafruit/Adafruit-Mo ... ld-library)

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



The one step seems to be a possible answer to my question but i am unsure where you are supposed to put in the time increment between steps. I thought this should be a fairly basic problem but it seems there is no supporting documentation for it anywhere on the web.



AF_Stepper stepper1(200, 2);

// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {
stepper1.onestep(FORWARD, SINGLE);
}


void setup()
{
stepper1.setMaxSpeed(200.0);
stepper1.setAcceleration(100.0);
stepper1.moveTo(24);

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

Re: 1 Rev per hour

Post by adafruit_support_bill »

I have scoured the internet and cannot find any examples on setting the speed for a one step.
The function is "onestep". If you search these forums (or look at the library code) you will find examples of it.

You cannot set a speed for one-step. Because, as the name implies, it only steps once. You control the speed by how often you call it. To do one rev per hour with your motor, you want to call it once every 18000 milliseconds. The code below is the simplest implementation. Depending on what precision you need and what else you want to do in the loop, you may want to look into timers also.

Code: Select all

void loop()
{
   stepper1.onestep(FORWARD, SINGLE);
   delay(18000);
}

randwulf
 
Posts: 3
Joined: Mon Apr 16, 2012 11:38 pm

Re: 1 Rev per hour

Post by randwulf »

Thanks a million! That worked perfectly. Im going to try to work on counting /positioning and hopefully I will be able to figure this thing out.

Thanks again.

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

Return to “Arduino Shields from Adafruit”