Beruflich Dokumente
Kultur Dokumente
Pgina Principal
More
http://xavierstechno.blogspot.com/2012/02/easy-d...
Translate
Options
Next Blog
Create Blog
Sign In
Dupla
Etiquetes
Part I
(Maximum Stepper Speed)
Go to Part II (Adjust max Stepper Current)
Go to Part III (Sleep an Enable)
3D
Arduino
CNC
Click Here to see and download the design of a PCB implementing this circuit.
Easy
Driver
Fotografia
Links
Processing Programaci
Software
Stepper
An important thing to knwo about your stepper, is the maximum speed at witch it can be driven.
To know this, you can follow this LINK;
you need to knwo the specs of your stepper.
For my stepper:
Voltage:
Inductance:
Steps per revolution:
Current:
1 of 4
12v
46+-20% mH
Step Angle = 1.8
0.33 A
then i take 50
360 / 1.8 = 200 Steps/rev
i take 135 mA because with easy
driver you can adjust the maximun current
with the potenciometer
(i will explain this in a future post)
06/23/2015 08:05 PM
http://xavierstechno.blogspot.com/2012/02/easy-d...
To see this working copy the following code to Arduino IDE, set the proper value for this variables
microSteping
stepsPerRev
l
v
iMax
and run it.
This program also implements acceleration-desacceleration. You can change the amount of acceleration, changing the value of 'accelDuring' variable ( for example it accelerates during 10 steps the run at constant speed
and finaly it desaccelerates during 10 steps ).
If you don't want acceleration set it to 0 ( accepted values are 0 - 255 ).
//http://www.daycounter.com/Calculators/Stepper-Motor-Calculator.phtml
//Rev/sec = V/(L*2*Imax)/(steps/rev) (Imax en A, L en mili Herns) p.e. 12/(46*2*0.33)/200
//T = L*Imax*2/V (T miliSegons/step)
#define DIR_PIN 7
#define STEP_PIN 6
#define sbi(sfr,bit) ( sfr |=
_BV(bit) )
#define cbi(sfr,bit) ( sfr &= ~(_BV(bit)) )
// MS1 MS2 Resolution
// L
L
00 Full step (2 phase)
// H
L
10 Half step
// L
H
01 Quarter step
// H
H
11 Eighth step
//
// per defecte a la easy driver MS1 = MS2 = HIGH
float microStepping = 8;
long stepsPerRev = 200;
float l = 50;
float v = 12;
float iMax = 0.135;
//
//
//
//
//
//
float ocr2a;
int ocr2aIni;
//
//
//
//
long stepsLeft = 0;
boolean running = false;
void setup() {
unsigned int usDelay;
Serial.begin(115200);
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
usDelay = l * 2000 * iMax / v / microStepping;
ocr2a = ceil((float)usDelay / 8.0);
Serial.println(ocr2a);
if(accelDuring > 0){
accelDelta = (255 - int(ocr2a) ) / accelDuring;
Serial.println(accelDelta);
if(accelDelta<=0){
if(ocr2a < 255){
accelDelta =1;
ocr2aIni = 255;
accelDuring = 255 - ocr2a;
}else{
accelDelta = 0;
accelDuring = 0;
ocr2aIni = ocr2a;
}
}else
ocr2aIni = ocr2a + accelDelta * accelDuring;
}else
ocr2aIni = ocr2a;
Serial.println(ocr2aIni);
setTimer2(ocr2aIni);
Serial.print("Inter Step Delay: ");
Serial.print(usDelay);
Serial.println(" us");
Serial.print("Max Speed: ");
Serial.print( 60000000.0 / ((float)stepsPerRev * microStepping * (usDelay)) );
Serial.println(" RPM");
2 of 4
06/23/2015 08:05 PM
http://xavierstechno.blogspot.com/2012/02/easy-d...
long nVoltes = 1;
long nSteps = nVoltes * stepsPerRev * microStepping;
void loop(){
if(!running){
delay(1000);
driveStepper(nSteps);
nSteps = -nSteps;
}
}////
cbi(TCCR2A, COM2A0 );
cbi(TCCR2A, COM2A1 );
cbi(TCCR2A, WGM20
sbi(TCCR2A, WGM21
cbi(TCCR2B, WGM22
);
);
);
sbi(TCCR2B, CS22
cbi(TCCR2B, CS21
sbi(TCCR2B, CS20
);
);
);
sbi(TIMSK2, OCIE2A
);
cbi(ASSR, AS2);
OCR2A = lusDelay;
//
TCNT2 = 0;
sei();
}////
void stopTimer2() {
cbi(TIMSK2, OCIE2A
}////
// Enable Interrupts
);
ISR(TIMER2_COMPA_vect) {
3 of 4
06/23/2015 08:05 PM
downCounter--;
OCR2A += accelDelta;
}
else if(upCounter >0){
upCounter--;
OCR2A -= accelDelta;
}
digitalWrite(STEP_PIN, HIGH);
digitalWrite(STEP_PIN, LOW);
stepsLeft--;
}
else
running = false;
}////
http://xavierstechno.blogspot.com/2012/02/easy-d...
// incrementa el temps entre Steps en CS22:0 us (el proper Step es produir 8 us mes tard)
// ha d'accelerar
// decrementa el temps entre Steps en CS22:0 us (el proper Step es produir 8 us abans)
//
//
//
//
//
//
//
//
//
//
// para el motor
Newer Post
Home
Older Post
Powered by Blogger.
4 of 4
06/23/2015 08:05 PM