Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

Characteristic Locus
Inheritance object > Em542s
Implements IStepperMotor
Inherited Members object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Motors.Stepper
Assembly Em542s.dll

Syntax

public class Em542s : IStepperMotor

Constructors

Em542s(IDigitalOutputPort, IDigitalOutputPort, IDigitalOutputPort?, int, bool)

Initializes a new instance of the Em542s class with the specified parameters.

Declaration
public Em542s(IDigitalOutputPort pulse, IDigitalOutputPort direction, IDigitalOutputPort? enable = null, int stepsPerRevolution = 200, bool inverseLogic = false)

Parameters

Type Name Description
IDigitalOutputPort pulse

The digital output port for controlling the pulse signal.

IDigitalOutputPort direction

The digital output port for controlling the direction of rotation.

IDigitalOutputPort enable

The optional digital output port for enabling or disabling the motor (if available).

int stepsPerRevolution

The number of steps per revolution for the stepper motor (default is 200).

bool inverseLogic

A value indicating whether the logic for the stepper motor driver is inverted (default is false).

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

Properties

Direction

This class is for the Em542s Stepper Motor Driver

Declaration
public RotationDirection Direction { get; set; }

Property Value

Type Description
RotationDirection

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

InverseLogic

Gets a value indicating whether or not the logic for the stepper motor driver is inverted.

Declaration
public bool InverseLogic { get; }

Property Value

Type Description
bool

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

LinearAccelerationConstant

Gets or sets a constant that affects the rate of linear acceleration for the motor. A lower value yields faster acceleration. Motors with more mass or larger steps require slower acceleration

Declaration
public int LinearAccelerationConstant { get; set; }

Property Value

Type Description
int

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

MinimumStartupDwellMicroseconds

Gets or sets the minimum step dwell time when motor changes from stationary to moving. Motors with more mass or larger steps require more dwell.

Declaration
public int MinimumStartupDwellMicroseconds { get; set; }

Property Value

Type Description
int

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

StepsPerRevolution

Gets the number of steps per revolution of the stepper motor.

Declaration
public int StepsPerRevolution { get; }

Property Value

Type Description
int

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

Methods

Step(int, RotationDirection, Frequency)

Moves the stepper motor a specified number of steps in a given direction at a specified rate.

Declaration
public void Step(int steps, RotationDirection direction, Frequency rate)

Parameters

Type Name Description
int steps

The number of steps to move.

RotationDirection direction

The direction of rotation.

Frequency rate

The rotation rate in steps per second.

Remarks

Em542s
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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