I am trying to use the Easy Driver with and Arduino Uno and a multiple Key LCD to control a syringe pump that someone else programmed based on other hardware. I used Example 1.6 to check the motor would move in two directions when different buttons were pressed and I got them to work. My motor has 200step/rev and a 360 degree revolution is 3200 microSteps of the stepper motor.
http://www.schmalzhaus.com/EasyDriver/E … mples.html
Now im trying to get the flowrates I need programmed by using the delay() for example I want the syringe to inject at 50 mL/min. My syringe is 300mL and has a barrel length of 155mm.
Since I don’t know how to code this I am following example 1.7 in the link above
I am trying to understand how to calculate the speed at which the stepper is moving the syringe. I realize the example is slightly different since it gives the RPM and what I am try to calculate is the RPM required for the flowrate but maybe if I can understand how the delay is calculated I can work backwards
I don’t understand how they got these two lines( not in correct order )
delayMicroseconds((MICROSECONDS_PER_MICROSTEP * 0.9)/2);
#define MICROSECONDS_PER_MICROSTEP (1000000/(STEPS_PER_REV * MICROSTEPS_PER_STEP)/(RPMS / 60))
thank you
Example1.7 code:
/* This example assumes a step/direction driver with Step on pin 9, Direction on pin 8
* And an input switch on pin 3. The switch is a switch to ground, with pin 3 pulled
* high with a pullup resistor. When the switch is turned on (closed, i.e. goes low)
* the the sepper motor steps at the rate specified (104 RPM in this code, with
* 1/8th microstepping of a 200 steps/rev motor)
*/
#define RPMS 104.0
#define STEP_PIN 9
#define DIRECTION_PIN 8
#define GO_PIN 3
#define STEPS_PER_REV 200
#define MICROSTEPS_PER_STEP 8
#define MICROSECONDS_PER_MICROSTEP (1000000/(STEPS_PER_REV * MICROSTEPS_PER_STEP)/(RPMS / 60))
uint32_t LastStepTime = 0;
uint32_t CurrentTime = 0;
void setup() {
pinMode(STEP_PIN, OUTPUT);
pinMode(DIRECTION_PIN, OUTPUT);
digitalWrite(STEP_PIN, LOW);
digitalWrite(DIRECTION_PIN, LOW);
pinMode(GO_PIN,INPUT);
}
void loop() {
if (digitalRead(GO_PIN) == LOW)
{
CurrentTime = micros();
if ((CurrentTime - LastStepTime) > MICROSECONDS_PER_MICROSTEP)
{
LastStepTime = CurrentTime;
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds((MICROSECONDS_PER_MICROSTEP * 0.9)/2);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds((MICROSECONDS_PER_MICROSTEP * 0.9)/2);
}
}
}