-
Notifications
You must be signed in to change notification settings - Fork 2
Velocity Control of Rotate Stepper Implemented #9
base: master
Are you sure you want to change the base?
Conversation
Updating Fork
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but I would like to see more defines and a little more restructuring to keep like things together.
upper.SetOutputLimits(-255, 255); | ||
|
||
//testLED | ||
pinMode(13, OUTPUT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this pin? ca we use a define?
int rotateCurrentSteps {0}; | ||
bool rotateZeroSet {0}; | ||
int rotateLimitState {0}; | ||
int stepsToRotate; | ||
int rotateDir; | ||
Stepper rotateStepper(stepsPerRevolution, 9, 10, 11, 12); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pins should be defined using #defines
|
||
if (rotateCurrentSteps == 0) digitalWrite(13, HIGH); | ||
else digitalWrite(13, LOW); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please explain why this is here
@@ -149,6 +161,7 @@ void serialEvent() { | |||
case 4: | |||
// this might cause an issue trying to left shift a char | |||
RotateMode = POSITION; | |||
rotateStepper.setSpeed(60); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is the range of speeds that we can go between? 0-255?
} | ||
|
||
current = rotateCurrentSteps / 800 * 360; | ||
return current; | ||
return RotateCurrent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the limit switch is low (not actuated), and its in velocity mode, what is RotateCurrent equal to?
//included counting steps here due to problem of missed steps. This seems to have fixed it. Further testing required. | ||
rotateStepper.step(rotateDir * 10); | ||
rotateCurrentSteps = rotateCurrentSteps + rotateDir * 10; | ||
RotateCurrent = rotateCurrentSteps / stepsPerRevolution * 360; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this answers my previous question but why is this in the output and not the feedback?
I added some functionality for the joystick control of the rotation stepper motor. It's a bit messy, avoiding missing steps got a bit tricky as did keeping the zero, but seems to be functioning. Let me know what you think. I changed the way I got data from direct_motor_control slightly to keep the arduino code more readable for me, but It would be easy to switch back.