Skyward boardcore
Loading...
Searching...
No Matches
StepperPWM.h
Go to the documentation of this file.
1/* Copyright (c) 2022 Skyward Experimental Rocketry
2 * Authors: Alberto Nidasio, Emilio Corigliano
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22
23#pragma once
24
25#include <interfaces-impl/gpio_impl.h>
26#include <interfaces/delays.h>
27#include <utils/TestUtils/MockGpioPin.h>
28
29#include "Stepper.h"
31
32namespace Boardcore
33{
34
35class StepperPWM : public Stepper
36{
37public:
52 CountedPWM& pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin,
53 float speed = 1, float stepAngle = 1.8, bool revertDirection = false,
54 uint16_t microStep = 1,
56 miosix::GpioPin enablePin = MockGpioPin());
57
63 void setSpeed(float speed) override;
64
73 void setMicroStepping(uint16_t microStep) override;
74
78 void move(int16_t steps) override;
79
92 float getCurrentDegPosition() override;
93
94private:
95 // This class is not copyable!
96 StepperPWM& operator=(const StepperPWM&) = delete;
97 StepperPWM(const StepperPWM& p) = delete;
98
99 void setDirection();
100
101 CountedPWM& pwm;
102};
103
104} // namespace Boardcore
This class generates a PWM signal for a chosen number of pulses.
Definition CountedPWM.h:60
miosix::GpioPin directionPin
Definition Stepper.h:151
miosix::GpioPin stepPin
Definition Stepper.h:150
uint16_t microStep
Definition Stepper.h:156
miosix::GpioPin enablePin
Definition Stepper.h:158
@ COMMON_CATHODE
All - signals connected to Gnd.
StepperPWM(CountedPWM &pwm, miosix::GpioPin stepPin, miosix::GpioPin directionPin, float speed=1, float stepAngle=1.8, bool revertDirection=false, uint16_t microStep=1, PinConfiguration pinConfiguration=PinConfiguration::COMMON_CATHODE, miosix::GpioPin enablePin=MockGpioPin())
Construct a new StepperPWM object.
float getCurrentDegPosition() override
Returns the current angle of the stepper.
void move(int16_t steps) override
Move the stepper motor by the specified amount of steps.
void setMicroStepping(uint16_t microStep) override
Set the motor driver micro stepping configuration.
void setSpeed(float speed) override
Changes the stepper motor speed.
This file includes all the types the logdecoder script will decode.