Motor shield library

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

Moderators: adafruit_support_bill, adafruit

Motor shield library

Postby i-make-robots » Thu May 03, 2012 4:37 pm

1) In AFMotor.cpp, I notice...
Code: Select all
   delay(uspers/1000); // in ms
    steppingcounter += (uspers % 1000);
    if (steppingcounter >= 1000) {
      delay(1);
      steppingcounter -= 1000;
    }

Why do all this instead of delayMicroseconds(uspers); ?



2) The line in onestep()...

Code: Select all
// next determine what sort of stepping procedure we're up to


...is followed by some if else if for each style, but then it gets to microstepping and it looks like someone forgot to put the else in front of the if. Am I reading that right?



3) Can you please iluminate what's going on with the 4 PWMs and microstepping? There's no comment in the code to explain. I'd really like to free up a timer on the Arduino. I'm only using steppers in full step mode. Can I rip out all the microstepping and free one of the Arduino timers? I should still have use of the servo PWM, correct?



Thank you very much!
i-make-robots
 
Posts: 34
Joined: Sun Mar 11, 2012 12:52 pm
Location: Earth ...for now.

Re: Motor shield library

Postby adafruit_support_bill » Thu May 03, 2012 7:10 pm

At the time the library was written, delaymicroseconds disabled interrupts.

PWM is used to ramp the phases to create intermediate positions between the full-steps. If you don't need it, you can modify it for your needs.
User avatar
adafruit_support_bill
 
Posts: 15918
Joined: Sat Feb 07, 2009 9:11 am

Re: Motor shield library

Postby i-make-robots » Thu May 03, 2012 7:16 pm

Thank you! :)
i-make-robots
 
Posts: 34
Joined: Sun Mar 11, 2012 12:52 pm
Location: Earth ...for now.

Re: Motor shield library

Postby i-make-robots » Fri May 04, 2012 12:04 pm

Thanks again for all the help, Adafruit.

At the start of onestep() you calculate values a, b, c, & d based on which stepper is being used. These values are calculated every step, regardless of style and they require the use of an if(). If you move them to the constructor and there's a nice little per-step performance boost, as well as making release() cleaner.

Cheers!
i-make-robots
 
Posts: 34
Joined: Sun Mar 11, 2012 12:52 pm
Location: Earth ...for now.

Re: Motor shield library

Postby adafruit_support_bill » Fri May 04, 2012 12:21 pm

Thanks! It you post an issue in Github, we can look at that for the next rev of the library.
User avatar
adafruit_support_bill
 
Posts: 15918
Joined: Sat Feb 07, 2009 9:11 am


Return to Arduino Shields from Adafruit

Who is online

Users browsing this forum: Google [Bot], mibignistinly and 5 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[108]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[69]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]