Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emilio Corigliano
Skyward Boardcore
Commits
4ac27494
Commit
4ac27494
authored
2 years ago
by
Alberto Nidasio
Browse files
Options
Downloads
Patches
Plain Diff
[Stepper] Updated microstepping implementation
parent
3fa9b5b7
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/actuators/Stepper.h
+8
-10
8 additions, 10 deletions
src/shared/actuators/Stepper.h
src/shared/actuators/StepperPWM.h
+2
-2
2 additions, 2 deletions
src/shared/actuators/StepperPWM.h
with
10 additions
and
12 deletions
src/shared/actuators/Stepper.h
+
8
−
10
View file @
4ac27494
...
...
@@ -125,6 +125,7 @@ protected:
miosix
::
GpioPin
directionPin
;
float
speed
;
// [rev/s]
float
stepAngle
;
// [deg/step]
float
microStepAngle
;
// [deg/step]
bool
revertDirection
;
MicroStep
microStep
;
miosix
::
GpioPin
enablePin
;
...
...
@@ -163,6 +164,7 @@ inline void Stepper::setSpeed(float speed) { this->speed = speed; }
inline
void
Stepper
::
setMicroStepping
(
MicroStep
microStep
)
{
this
->
microStep
=
microStep
;
microStepAngle
=
stepAngle
/
static_cast
<
float
>
(
microStep
);
switch
(
microStep
)
{
...
...
@@ -201,8 +203,7 @@ inline void Stepper::move(int16_t steps)
if
(
speed
==
0
)
return
;
unsigned
int
halfStepDelay
=
1e6
/
(
speed
*
360
/
stepAngle
*
static_cast
<
int
>
(
microStep
));
unsigned
int
halfStepDelay
=
1e6
/
(
speed
*
360
/
microStepAngle
);
if
(
revertDirection
==
(
steps
>=
0
))
directionPin
.
low
();
...
...
@@ -222,10 +223,7 @@ inline void Stepper::move(int16_t steps)
currentPosition
+=
steps
;
}
inline
void
Stepper
::
moveDeg
(
float
degrees
)
{
move
(
degrees
/
stepAngle
*
static_cast
<
int
>
(
microStep
));
}
inline
void
Stepper
::
moveDeg
(
float
degrees
)
{
move
(
degrees
/
microStepAngle
);
}
inline
void
Stepper
::
setPosition
(
int16_t
steps
)
{
...
...
@@ -234,7 +232,7 @@ inline void Stepper::setPosition(int16_t steps)
inline
void
Stepper
::
setPositionDeg
(
float
position
)
{
setPosition
(
position
/
stepAngle
*
static_cast
<
int
>
(
microStep
)
);
setPosition
(
position
/
microStep
Angle
);
}
inline
int16_t
Stepper
::
getCurrentPosition
()
{
return
currentPosition
;
}
...
...
@@ -242,7 +240,7 @@ inline int16_t Stepper::getCurrentPosition() { return currentPosition; }
inline
float
Stepper
::
getCurrentDegPosition
()
{
return
static_cast
<
float
>
(
getCurrentPosition
())
*
stepAngle
/
static_cast
<
in
t
>
(
microStep
);
static_cast
<
floa
t
>
(
microStep
);
}
}
// namespace Boardcore
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/shared/actuators/StepperPWM.h
+
2
−
2
View file @
4ac27494
...
...
@@ -117,13 +117,13 @@ inline StepperPWM::StepperPWM(CountedPWM &pwm, miosix::GpioPin stepPin,
inline
void
StepperPWM
::
setSpeed
(
float
speed
)
{
this
->
speed
=
speed
;
pwm
.
setFrequency
(
speed
*
360
/
stepAngle
*
static_cast
<
int
>
(
microStep
)
);
pwm
.
setFrequency
(
speed
*
360
/
microStep
Angle
);
}
inline
void
StepperPWM
::
setMicroStepping
(
MicroStep
microStep
)
{
Stepper
::
setMicroStepping
(
microStep
);
pwm
.
setFrequency
(
speed
*
360
/
stepAngle
*
static_cast
<
int
>
(
microStep
)
);
pwm
.
setFrequency
(
speed
*
360
/
microStep
Angle
);
}
inline
void
StepperPWM
::
move
(
int16_t
steps
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment