Setspeed() get's used in conjunction with runSpeed(). At the moment I do
motor.targetPosition(12345);
while (motor.distanceToGo() != 0)
{
motor.run();
}
Doing it without acceleration should be something like:
long newPosition= 12345;
motor.targetPosition(newPosition);
if ((motor.currentPosition - newPosition) < 0) // motor needs to go backwards
{
// make negative speed if motor is to go backwards
motor.setSpeed(0-newPosition);
}
while (motor.distanceToGo() != 0)
{
// run speed doesn't implement acceleration
motor.runSpeed();
}
but in practice I couldn't get that to work. Not sure why, and very possibly was just being a dimwit.
The reason that C17 will always be slower than C01 is because it's made up of lots of tiny moves with a pause for recalculation in between each move. It chops the line up into segments. There is a setting "maxSegmentLength" (or something) that controls how big each segment is. If you're in the controller and press "i" you'll see a little overlay that shows some useful debugging stuff, and one of the values at the bottom is this maxSegmentLength. It might be called something slightly different at the moment. But it can be changed with "<" and ">". A value of 1 will make the machine pause to recalculate after every single step, so it is the most accurate, but the slowest. As you increase the values then you will begin to get a less and less straight line on the page. Each segment will start and end on the axis of the line, but it will deviate from the line during each segment.
This value is also visible in the C17 command, it's the last number in the command. Because your steps are so tiny, you might find that you can increase this to quite a high value before you start getting zigzag lines, and actually, if there's no acceleration curves, you might find less zigzag anyway.
|