I'm using two tb6600 to control two step motors. It's for letter writing cnc machine. Moving single axis works fine.
I want to push 2 steppers in the same time along a diagonal.
I tried to calculate ratio x:y, so if x is making more steps than y for 1 y do n x steps. This worked, but machine was shaking no mater how i adjusted delays between step high and low. When i use PWM there is no shaking, but i can't figure out how to make it follow diagonal.
Second try was to use PWM with analogWrite.
if(delayX > delayY){
analogWrite(stepPinX, 128);
analogWrite(stepPinY, 128);
delay(delayY);
analogWrite(stepPinY, 0);
delay(delayX - delayY);
analogWrite(stepPinX, 0);
}else if(delayX <= delayY){
analogWrite(stepPinX, 128);
analogWrite(stepPinY, 128);
delay(delayX);
analogWrite(stepPinX, 0);
delay(delayY - delayX);
analogWrite(stepPinY, 0);
}
This doesn't works obviously. It reaches end point, but it doesn't follow diagonal. If i set duty cycle to 2 or 128 it doesn't matter. Isn't duty cycle supposed to change speed of stepper motor?
What am i missing here and how can this be done?