Pages

Thursday, December 20, 2012

MDrive – Part 1 of 4

These posts focus on controlling intelligent precision electric motors from Windows applications written in C#.  Specifically, we will be controlling a Schneider Electric M-Drive stepper motor with an integrated encoder and controller.

mdrive17_mdi

Posts in This Series

Disclaimer

Now before you think this is a sales pitch, I want to be clear that this is my personal blog and I am not employed or being compensated by Schneider Electric in any way.  They did not supply me with any special assistance, provide me with any free or discounted hardware, or even give me a box of fine chocolates.

Stepper Basics

A stepper motor is a relatively simple thing.  While there are a myriad of internet resources describing how stepper motors work, I’ll just stick to the Schneider website.  These two blog posts by Bob Parente do a very nice job of explaining how a stepper motor works, and how micro-stepping works.  In all honesty, you don’t really need to read his posts to understand my posts, but since there is no virtue in ignorance, take a moment to read them anyway.

Gathering Hardware Together

Various motors are available from Schneider.  This invaluable hardware document contains a lot of technical motor details for the various models, including mechanical and electrical specifications.  These motors come in single, double, triple and sometimes quad stack configurations.  Increasing stacks increases the motor’s axial length and torque.

mdrives

After choosing and obtaining a motor, you will also need a 12-48 VDC power supply.  The current requirements are clearly spelled out in the hardware document.  Also, check the hardware document for the proper power connector and wire gauge that you will need.

You will need a means to communicate with the motor from your PC via an RS422 port.  Again, check the hardware document for the type of RS422 connector needed for the motor side.  As for the PC, the easiest solution is a USB to RS422 converter.

Schneider sells converters such as the MDI1CRZ14A4.  Make sure to order the correct cable for your motor because connectors for the various models are not all the same.  You might find that the Schneider cables are a bit overpriced.  You should also know that as of this writing, their USB driver is unsigned so it will not work in Windows 8.  I signed my copy of their driver to get around this problem, but I don’t think that is something I recommend.

mdcc403-001-4624

I have had great success with products from US Converters, specifically the single port XS890 and the four port UTS-M14.  Once connected, the new RS422 port should be accessible from Windows as “COM3” (or higher).  I did not have to manually install any drivers to use these products.

xs890     utsm14_small

Schneider goes to great lengths to explain how the cables should be grounded and shielded.  Follow their instructions to prevent communication glitches.  They also stress repeatedly that hot connections are a no-no and could damage the electronics.  Over the years, I’ve seen two of these motors (out of hundreds) take a hit and become unusable, so take their warnings seriously.

Gathering Software Together

Once your motor is connected and powered up, you will need some sort of software to communicate with it.  Any terminal emulator will do.  Schneider offers their own free IMS Terminal program that works fine but does occasionally lock up.  I don’t use it anymore.  I mean, just look at it.

To make things easier for everyone, I have written a program called MDrive which is available in source code form on Codeplex. More on that in part 3.  Until then, here is a pretty screen shot.

MDriveApp

Once everything is connected, powering up the motor will cause it to display a copyright message and a “>” prompt on your terminal emulator.  To make the motor spin one revolution, type “MR 51200”.  This invaluable MCode document is the official guide to the various commands you can send to the motor.  The next post will cover MCode programming.

Motor Features

Here is a quick overview of what these motors really are:

The MDrive is a stepper motor that is configured for 200 full steps per revolution.  That means the smallest amount the shaft can rotate using normal stepping is 1.8 degrees.  However, with micro-stepping enabled, the motor can position itself in any one of 256 locations between each full step.  This allows positioning of the motor to any of 51200 positions per revolution.  That equates to 0.007 degrees per micro-step.  The motor can spin at speeds as slow as 1 micro-step per second (~0.001 rpm) and as fast as (about) 1000 rpm with a low load.

The MDrive contains an embedded computer that controls the movement of the stepper motor and can communicate with an external PC via RS422.  The embedded computer can accept a myriad of commands to control all aspects of motion.

The MDrive contains an embedded magnetic encoder with a resolution of 2048 positions per revolution.  The encoder allows the embedded computer to track the actual position of the shaft.  This means that if the shaft stops spinning, the embedded computer can recognize the stall event and take appropriate action.  The encoder also allows the motor to return to an exact position time and time again – even if the stepper motor previously stalled or the shaft missed a few steps and fell behind.  Another neat benefit is that the embedded computer can detect movement of the shaft even if the stepper motor is not running.  The encoder also has an index mark, enabling the shaft to find a known “home” angular position.

The MDrive has several digital I/O lines and an analog input line.   The embedded computer can be programmed to react to changes in the input lines and drive the output lines in just about any way desired.

The MDrive supports scripting, which allows it to run intricate sequences.  A script can be configured to start up when the motor is powered up - allowing the motor to run autonomously and react to external events.  Alternatively, the motor can remain connected to a PC via an RS422 communications port to be part of a more complex external-computer-controlled system.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.