Arduino Step and Direction controller code

Hi,

I just wanted to post a piece of code that took some work and i hope is useful.

It is a command-driven step-and-direction controller. I used it to send commands from c# to drive a Schneider MDrive or two.

The hardest part was the READ to get it reliable. It should be now, it takes care of a timing issue.

The Parser figures out what command was sent. Writing what each command does is then pretty easy if you follow some of the existing commands. It has the basics like MOVE ABSOLUTE and RELATIVE.

Happy Motoring!

asd.ino (12.1 KB)

Thank you for sharing.

You may wish to look at serial input basics - simple, reliable, non-blocking and no timing issues

Can you post a link to the Schneider MDrive datasheet. I'm sure others will be interested.

I'm not sure how you are controlling the speed of the motor. If it is just using delay() or delayMicroseconds() I would suggest you use use millis() or micros() as illustrated in the second example in this simple stepper code

...R
Stepper Motor Basics