Remarks
A4988 | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
public class MeadowApp : App<F7Micro, MeadowApp>
{
public MeadowApp()
{
StepperSample();
}
public void StepperSample_Divisors()
{
var a = new A4988(Device, Device.Pins.D01, Device.Pins.D00, Device.Pins.D04, Device.Pins.D03, Device.Pins.D02);
var s = (StepDivisor[])Enum.GetValues(typeof(StepDivisor));
//var s = new StepDivisor[] { StepDivisor.Divisor_2 };
while (true)
{
foreach (var sd in s)
{
a.StepDivisor = sd;
a.Rotate(360);
Thread.Sleep(2000);
}
}
}
public void StepperSample()
{
var a = new A4988(Device, Device.Pins.D01, Device.Pins.D00, Device.Pins.D04, Device.Pins.D03, Device.Pins.D02);
var s = (StepDivisor[])Enum.GetValues(typeof(StepDivisor));
while (true)
{
foreach (var sd in s)
{
for (var d = 2; d < 5; d++)
{
Console.WriteLine($"180 degrees..Speed divisor = {d}..1/{(int)sd} Steps..{a.Direction}...");
a.RotationSpeedDivisor = d;
a.StepDivisor = sd;
a.Rotate(180);
Thread.Sleep(500);
}
}
a.Direction = (a.Direction == RotationDirection.Clockwise) ? RotationDirection.Counterclockwise : RotationDirection.Clockwise;
}
}
}
Characteristic | Locus |
---|---|
Inheritance | System.Object > A4988 |
Inherited Members | System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone() |
Namespace | Meadow.Foundation.Motors.Stepper |
Assembly | A4988.dll |
Syntax
public class A4988
Constructors
A4988(IIODevice, IPin, IPin)
Creates an instance of the A4988 Stepper Motor Driver
Declaration
public A4988(IIODevice device, IPin step, IPin direction)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | The IIoDevice instance that can create Digital Output Ports |
IPin | step | The Meadow pin connected to the STEP pin of the A4988 |
IPin | direction | The Meadow pin connected to the DIR pin of the A4988 |
Remarks
You must provide either all of the micro-step (MS) lines or none of them
A4988(IIODevice, IPin, IPin, IPin)
Creates an instance of the A4988 Stepper Motor Driver
Declaration
public A4988(IIODevice device, IPin step, IPin direction, IPin enable)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | The IIoDevice instance that can create Digital Output Ports |
IPin | step | The Meadow pin connected to the STEP pin of the A4988 |
IPin | direction | The Meadow pin connected to the DIR pin of the A4988 |
IPin | enable | The (optional) Meadow pin connected to the ENABLE pin of the A4988 |
A4988(IIODevice, IPin, IPin, IPin, IPin, IPin)
Creates an instance of the A4988 Stepper Motor Driver
Declaration
public A4988(IIODevice device, IPin step, IPin direction, IPin ms1, IPin ms2, IPin ms3)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | The IIoDevice instance that can create Digital Output Ports |
IPin | step | The Meadow pin connected to the STEP pin of the A4988 |
IPin | direction | The Meadow pin connected to the DIR pin of the A4988 |
IPin | ms1 | The (optional) Meadow pin connected to the MS1 pin of the A4988 |
IPin | ms2 | The (optional) Meadow pin connected to the MS2 pin of the A4988 |
IPin | ms3 | The (optional) Meadow pin connected to the MS3 pin of the A4988 |
Remarks
You must provide either all of the micro-step (MS) lines or none of them
A4988(IIODevice, IPin, IPin, IPin, IPin, IPin, IPin)
Creates an instance of the A4988 Stepper Motor Driver
Declaration
public A4988(IIODevice device, IPin step, IPin direction, IPin enable, IPin ms1, IPin ms2, IPin ms3)
Parameters
Type | Name | Description |
---|---|---|
IIODevice | device | The IIoDevice instance that can create Digital Output Ports |
IPin | step | The Meadow pin connected to the STEP pin of the A4988 |
IPin | direction | The Meadow pin connected to the DIR pin of the A4988 |
IPin | enable | The (optional) Meadow pin connected to the ENABLE pin of the A4988 |
IPin | ms1 | The (optional) Meadow pin connected to the MS1 pin of the A4988 |
IPin | ms2 | The (optional) Meadow pin connected to the MS2 pin of the A4988 |
IPin | ms3 | The (optional) Meadow pin connected to the MS3 pin of the A4988 |
Remarks
You must provide either all of the micro-step (MS) lines or none of them
Properties
Direction
Sets or gets the direction of rotation used for Step or Rotate methods.
Declaration
public RotationDirection Direction { get; set; }
Property Value
Type | Description |
---|---|
RotationDirection |
RotationSpeedDivisor
Divisor used to adjust rotaional speed of the stepper motor
Declaration
public int RotationSpeedDivisor { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
StepAngle
Gets or sets the angle, in degrees, of one step for the connected stepper motor.
Declaration
public float StepAngle { get; set; }
Property Value
Type | Description |
---|---|
System.Single |
StepDivisor
Divisor for micro-stepping a motor. This requires the three micro-step control lines to be connected to the motor.
Declaration
public StepDivisor StepDivisor { get; set; }
Property Value
Type | Description |
---|---|
StepDivisor |
StepsPerRevolution
Gets the number of steps/micro-steps in the current configuration required for one 360-degree revolution.
Declaration
public int StepsPerRevolution { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Rotate(Single)
Rotates the stepper motor a specified number of degrees
Declaration
public void Rotate(float degrees)
Parameters
Type | Name | Description |
---|---|---|
System.Single | degrees |
Rotate(Single, RotationDirection)
Rotates the stepper motor a specified number of degrees
Declaration
public void Rotate(float degrees, RotationDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.Single | degrees | |
RotationDirection | direction | Direction of rotation |
Step(Int32)
Rotates the stepper motor a specified number of steps (or microsteps)
Declaration
public void Step(int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | Number of steps to rotate |
Step(Int32, RotationDirection)
Rotates the stepper motor a specified number of steps (or microsteps)
Declaration
public void Step(int count, RotationDirection direction)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | count | Number of steps to rotate |
RotationDirection | direction | Direction of rotation |