Hardware:
1. Arduino uno R3, your motor shield v2
2 your Stepper motor - NEMA-17 size -1.8 degre, 200 steps/rev, 12V 350mA
3 power is provide from a 12V 2 amp power adapter through the DC barrel jack
4 60cc syringe. Barrel lenght for the 50 ml volume is 75mm
5 threaded rod pitch is 1.25 mm/Rev
I have used another companies motor shield in the past for this pump and worked great but your shield would allow for a more secure installation and save me buying two different products to achieve the same thing. I was trying to use your a variation of your Stepper Test program to see if i could control the motor.
Based on my calculations:
A. Syringe_mL/Step= (Syringe_vol_mL/Syringe_Barrel_Lenght)*(thread_rod_Pitch_mm/Rev*Rev/200step)
Syringe_mL/Step= 0.004166667 cc/step
B. Speed in RPM= Rev/min (wanted speed in ml/min)* (steps/ml)*(Rev/200steps)
12 RPM
C. Steps for req volume
50ml= "=50ml*(1/.00417 ml/step)"
12000 steps
I have tried running the program as Microstep for the accuracy but cant seem to get an RPM that will work and there does not seem to be any logic to how the RPM correlates to the speed the syringe moves. In the end decided to use Double Coil with a variety of RPM's since the calculated RPM did not seem to work.
I annotated the code for the RPM, speed ml/min, volume cc for what i got.
// 12 rpm at double coil only 30 sec for 10cc;
// 06 rpm at double coil only 11 sec for 10cc;
// 25 rpm at double coil only 40 sec for 10cc;
// 35 rpm at double coil only 30 sec for 10cc;
// 28 rpm at double coil only 35 sec for 10cc;
// 20 rpm at double coil only 46 sec for 10cc;
// 18 rpm at double coil only 10 sec for 10cc;
// 20 rpm at microsteps over60 sec for 6cc;
// 50 rpm at microsteps 60 sec for 2cc cc;
// 5 rpm at microsteps 60 sec for 2c cc; not moving
// 10 rpm at microsteps 60 sec for 1ccc cc;
// 100 rpm at microsteps 60 sec for 4 cc;
// 200 rpm at microsteps 60 sec for 2 cc;
// 255 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm double coil steps 60 sec for 15cc;
// 10 rpm double coil steps 35 sec for 10cc;
// 3 rpm double coil steps 13 sec sec for 10cc;
Is this board not able to produce accurate speed? can someone catch what i may be doing wrong? thanks
Below is the code:
Code: Select all
/*
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
Prelim program to set calculations of RPM needed for 10ml min flow and 50cc volume collection
*/
#include <Wire.h>
#include <Adafruit_MotorShield.h>
//#include "utility/Adafruit_PWMServoDriver.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 *myMotor = AFMS.getStepper(200, 2);// for out 200 step per rev this stays at 200
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
while (!Serial);
Serial.println("Stepper test!");
if (!AFMS.begin()) { // create with the default frequency 1.6KHz
// if (!AFMS.begin(1000)) { // OR with a different frequency, say 1KHz
Serial.println("Could not find Motor Shield. Check wiring.");
while (1);
}
Serial.println("Motor Shield found.");
//note with usb motor moves slower than with than with the DC barrel as it has less power... make sure speed measure is done with the barrel 12V 2Ampp
//note per PDF setSpeed is a value between 0 and 255
myMotor->setSpeed(3); // 12 rpm at double coil only 30 sec for 10cc;
// 06 rpm at double coil only 11 sec for 10cc;
// 25 rpm at double coil only 40 sec for 10cc;
// 35 rpm at double coil only 30 sec for 10cc;
// 28 rpm at double coil only 35 sec for 10cc;
// 20 rpm at double coil only 46 sec for 10cc;
// 18 rpm at double coil only 10 sec for 10cc;
// 20 rpm at microsteps over60 sec for 6cc;
// 50 rpm at microsteps 60 sec for 2cc cc;
// 5 rpm at microsteps 60 sec for 2c cc; not moving
// 10 rpm at microsteps 60 sec for 1ccc cc;
// 100 rpm at microsteps 60 sec for 4 cc;
// 200 rpm at microsteps 60 sec for 2 cc;
// 255 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm at microsteps 60 sec for 2 cc; didnt move
// 5 rpm double coil steps 60 sec for 15cc;
// 10 rpm double coil steps 35 sec for 10cc;
// 3 rpm double coil steps 13 sec sec for 10cc;
}
void loop() {
// Serial.println("Single coil steps"); //noisy
// delay(1000);
// myMotor->step(11990, BACKWARD, SINGLE);//11990 for 50cc;5882 for 10cc (these values were miscalculated)
// delay(500);
// myMotor->step(11990, FORWARD, SINGLE);//push syringe
// delay(2000);
//------------------
//
Serial.println("Double coil steps");
delay(2000);
myMotor->step(12000,BACKWARD, DOUBLE);//
delay(500);
myMotor->step(12000, FORWARD, DOUBLE);
delay(2000);
//--------------------------
//
// Serial.println("Interleave coil steps");// did only 20 cc
// delay(2000);
// myMotor->step(11990, BACKWARD, INTERLEAVE);
// delay(500);
// myMotor->step(11990, FORWARD, INTERLEAVE);
// delay(2000);
//---------------------------
// Serial.println("Microstep steps");//
// delay(2000);
// myMotor->step(12000, BACKWARD, MICROSTEP);
// delay(500);
// myMotor->step(12000, FORWARD, MICROSTEP);// orig this was half steps of single coil so i half the steps for full syring
// delay(2000);
////
}