Skip to main content

Meadow.Foundation.Motors.Stepper.Em542s

Em542s
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Motors.Stepper.Em542s

Code Example

private IStepperMotor stepper;

public override Task Initialize()
{
stepper = new Em542s(
Device.Pins.D15.CreateDigitalOutputPort(),
Device.Pins.D14.CreateDigitalOutputPort(),
inverseLogic: true);

return base.Initialize();
}

public override Task Run()
{
var direction = RotationDirection.Clockwise;

// max rate for this drive
var rate = new Meadow.Units.Frequency(200, Meadow.Units.Frequency.UnitType.Kilohertz);

while (true)
{
Resolver.Log.Info($"{direction}");

stepper.Rotate(360f, direction, rate);
Thread.Sleep(1000);

direction = direction switch
{
RotationDirection.CounterClockwise => RotationDirection.Clockwise,
_ => RotationDirection.CounterClockwise
};
}
}

Sample project(s) available on GitHub