Skip to content
This repository has been archived by the owner on Jul 15, 2018. It is now read-only.

Velocity Control of Rotate Stepper Implemented #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lamwx
Copy link
Contributor

@lamwx lamwx commented Feb 2, 2018

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.

@lamwx lamwx requested a review from newmanjoel February 2, 2018 04:10
Copy link
Member

@newmanjoel newmanjoel left a 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);
Copy link
Member

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);
Copy link
Member

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);

Copy link
Member

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);
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants