I'm using Adafruit Class Library for Windows IoT Core with the MotorHat.
I can get the stepper motors 1 & 2 to work individually. How do I get BOTH to work at the same time?
Looking for examples in C#.
Thanks!!
C# MotorHat Both Stepper Motors Run Same Time?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- cschron
- Posts: 11
- Joined: Fri Dec 11, 2015 9:44 am
- Franklin97355
- Posts: 23940
- Joined: Mon Apr 21, 2008 2:33 pm
Re: C# MotorHat Both Stepper Motors Run Same Time?
Please post you code so we can see what you've tried.
- cschron
- Posts: 11
- Joined: Fri Dec 11, 2015 9:44 am
Re: C# MotorHat Both Stepper Motors Run Same Time?
Below is the code. When the button is pressed Stepper 1 works then Stepper 2 works. But what I want is both Steppers to go at same time. THANKS!!
Code: Select all
using Windows.UI.Xaml;
using AdafruitClassLibrary;
namespace Blinky
{
public sealed partial class MainPage
{
static MotorHat motorHat;
static MotorHat.Stepper stepper1;
static MotorHat.Stepper stepper2;
public MainPage()
{
InitializeComponent();
motorHat = new MotorHat();
motorHat.InitAsync(1600).ConfigureAwait(true);
stepper1 = motorHat.GetStepper(100, 1);
stepper2 = motorHat.GetStepper(100, 2);
}
private void buttonON_Click(object sender, RoutedEventArgs e)
{
while (true)
{
motor1();
motor2();
}
}
public void motor1() {
stepper1.SetSpeed(500); //10 rpm
stepper1.step(2000, MotorHat.Stepper.Command.FORWARD, MotorHat.Stepper.Style.DOUBLE);
}
public void motor2()
{
stepper2.SetSpeed(500); //10 rpm
stepper2.step(2000, MotorHat.Stepper.Command.FORWARD, MotorHat.Stepper.Style.DOUBLE);
}
}
}
- adafruit2
- Posts: 22194
- Joined: Fri Mar 11, 2005 7:36 pm
Re: C# MotorHat Both Stepper Motors Run Same Time?
you should perform one step at a time, interleaved
- cschron
- Posts: 11
- Joined: Fri Dec 11, 2015 9:44 am
Re: C# MotorHat Both Stepper Motors Run Same Time?
Thank you that worked!
Please be positive and constructive with your questions and comments.