How to increase motor speed?
grbeltran
Posts: 6
Using the····· Stepper.java and stepperTest.java, listed very commonly in the forum, how do I increase the speed
of the motor?
I have decreased the delay in between each step to 1 or EVEN O ..
Example
public class stepperTest {
· public static void main() {
··· boolean x1 = true;
··· Stepper motor = new Stepper(CPU.pin4, CPU.pin5, CPU.pin6, CPU.pin7);
··· while(x1 = true) {
····· motor.stepFFwd(48, 0);·················· // one rev clockwise
····· CPU.delay(5000);························· // wait 1/2 second
····· motor.stepFRev(48, 0);·················· // one rev counter clockwise
····· CPU.delay(5000);························· // wait 1/2 second
··· }
· }
}
and it increases the speed but I need to increase the frequency somehow... or be able to change the delay(in between steps) to us...?
can anybody please help?
Thanks,
Gabe
of the motor?
I have decreased the delay in between each step to 1 or EVEN O ..
Example
public class stepperTest {
· public static void main() {
··· boolean x1 = true;
··· Stepper motor = new Stepper(CPU.pin4, CPU.pin5, CPU.pin6, CPU.pin7);
··· while(x1 = true) {
····· motor.stepFFwd(48, 0);·················· // one rev clockwise
····· CPU.delay(5000);························· // wait 1/2 second
····· motor.stepFRev(48, 0);·················· // one rev counter clockwise
····· CPU.delay(5000);························· // wait 1/2 second
··· }
· }
}
and it increases the speed but I need to increase the frequency somehow... or be able to change the delay(in between steps) to us...?
can anybody please help?
Thanks,
Gabe
Comments
or attach stepper.java. So we have not to search for it.
regards peter
Thanks,
Gabe
http://www.parallax.com/detail.asp?product_id=27964
public class stepperTest {
· public static void main() {
··· boolean x1 = true;
··· Stepper motor = new Stepper(CPU.pin4, CPU.pin5, CPU.pin6, CPU.pin7);
··· while (x1) {
····· motor.stepFFwd(48, 15);·················· // one rev clockwise
····· CPU.delay(5000);························· // wait 1/2 second
····· motor.stepFRev(48, 15);·················· // one rev counter clockwise
····· CPU.delay(5000);························· // wait 1/2 second
··· }
· }
}
You could try lowering the CPU.delay(5000)
so the stepper motors get updated more
frequently.
regards peter
Ex
step··step· step ·step ·step·<
(CPU.delay)·
> step· step ·step· step· step<
(CPU.delay)
> step etc.
right?
but what will·let me
stepstepstepstepstepstepstep· faster..
Thanks
Gabe·······
· /**
·· * Sets up phase inputs for step index
·· */
· private void setFullStep(int theStep) {
···· switch (theStep) {
······ case 0:
········ CPU.writePin(ph1Pin, true);
········ CPU.writePin(ph2Pin, true);
········ CPU.writePin(ph3Pin, false);
········ CPU.writePin(ph4Pin, false);
········ break;
······ case 1:
········ CPU.writePin(ph1Pin, false);
········ CPU.writePin(ph2Pin, true);
········ CPU.writePin(ph3Pin, true);
········ CPU.writePin(ph4Pin, false);
········ break;
······ case 2:
········ CPU.writePin(ph1Pin, false);
········ CPU.writePin(ph2Pin, false);
········ CPU.writePin(ph3Pin, true);
········ CPU.writePin(ph4Pin, true);
········ break;
······ case 3:
········ CPU.writePin(ph1Pin, true);
········ CPU.writePin(ph2Pin, false);
········ CPU.writePin(ph3Pin, false);
········ CPU.writePin(ph4Pin, true);
········ break;
···· }
· }
· /**
·· * Step forward clockwise
·· *
·· * @param steps Number of CW steps
·· * @param msDelay delay between steps in milliseconds
·· */
· public void stepFFwd(int steps, int msDelay) {
··· while (steps-- > 0) {
····· stpIdx = (stpIdx + 1) % 4;
····· setFullStep(stpIdx);
····· CPU.delay(msDelay * 10);
··· }
· }
· /**
·· * Step forward counter-clockwise
·· *
·· * @param steps Number of CCW steps
·· * @param msDelay delay between steps in milliseconds
·· */
· public void stepFRev(int steps, int msDelay) {
··· while (steps-- > 0) {
····· stpIdx = (stpIdx + 3) % 4;
····· setFullStep(stpIdx);
····· CPU.delay(msDelay * 10);
··· }
· }
}
The minimal delay between steps is when using msDelay=0,
the delay is then determined by the loop
while (steps-->0)
in which setFullStep() is called.
setFullStep() itself contains 4 writePin() statements.
To minimize that delay you need to rewrite it,
instead of 4 CPU.writePin() you use 1 CPU.writePort()
Another option to minimalize the delay, is by defining stpIdx global,
so you don't need to pass it as a parameter each time.
regards peter
In other words all I need are two pins, step and direction.·· Simple i guess. but
does that
switch (theStep) {
······ case 0:
········ CPU.writePin(ph1Pin, true);
········ CPU.writePin(ph2Pin, true);
········ CPU.writePin(ph3Pin, false);
········ CPU.writePin(ph4Pin, false);
········ break;
······ case 1:
········ CPU.writePin(ph1Pin, false);
········ CPU.writePin(ph2Pin, true);
········ CPU.writePin(ph3Pin, true);
········ CPU.writePin(ph4Pin, false);
········ break;
etc...
even matter anymore, or what exactly is is for. Do I need it?
Thanks,
gabe
http://www.parallax.com/dl/docs/prod/motors/Stepper_Motor_27964.pdf
You'll see the patterns are encoded in setFullStep.
If you have a different stepper motor, check the
datasheet on what patterns can be used.
regards peter