Pen Decorator – Calibrating the motors

This was an eye opener for me. There are 4 modes for the motors to run with SINGLE, DOUBLE, INTERLEAVE and MICROSTEP. Double gives the most torque which is really important in making sure the cutter is tracking as expected. And Double also runs the roughest, jerking the cutter into each new position. MICROSTEP runs the smoothest, but may not have the torque (I still don’t know for sure). The Interleave is smoother than single, and I’m still playing with the torque experiments here.

When I ran the first set of calibrations I found out that the SINGLE and DOUBLE move the motor the same amount for the same number of steps. INTERLEAVE moved the motors only half the distance for the same number of steps – that made sense. What surprised me was that MICROSTEP actually traveled twice the distance for the same number of steps. Not sure at all why that is, but it’s factored into the code now :).

Another item that we’re playing with is the armature used on the servo for raising and lowering the drill platform. I’ve been using an open “U” shaped element made from wood. It tends to stick in some conditions, and when no power is applied to the motor, it allows the cutter head to drop all the way forward – and sometimes completely disengages from the support rod (upper rear most cross rod). Lee found a paint scraper at the store made of Ultra-High density plastic, which allows for a closed loop, and simply requires a 2nd screw to be used with the supplied servo arms to fasten the arm to the plastic. That keeps it from dropping off. The “U” shaped piece I was using was to drive the cutter down into the blank when cutting, but I found there was a limit to how deep I could push it on a pass. I’m probably going to fall back to the oval unit that Lee fashioned – we may use Lee’s CNC to fashion these units so they fit better.

Here’s the code I used for testing the motor, for those that are interested. It’s a modified version of the motor party sketch from Adafruit:

/* 
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control

For use with the Adafruit Motor Shield v2 
----> http://www.adafruit.com/products/1438

This sketch creates a fun motor party on your desk *whiirrr*
Connect a unipolar/bipolar stepper to M3/M4
Connect a DC motor to M1
Connect a hobby servo to SERVO1
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <Servo.h> 

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myStepper = AFMS.getStepper(200, 2);



void setup() {
 Serial.begin(9600); // set up Serial library at 9600 bps

 AFMS.begin(); // create with the default frequency 1.6KHz
 //AFMS.begin(1000); // OR with a different frequency, say 1KHz
 
 // setup the stepper
 myStepper->setSpeed(10); // 10 rpm 
}

int i;
int mode=0;

void loop() {
 mode = ((mode++) % 4) + 1;
 Serial.print("mode ");
 Serial.println(mode);
 for (i=0; i<100; i++) {
 myStepper->step(1, FORWARD, mode);
 delay(3);
 }
 
 for (i=100; i!=0; i--) {
 myStepper->step(1, BACKWARD, mode);
 delay(3);
 }
 
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s