Low cost solutions to Data Acquisition & Control.
Data Sheets and Application Notes Product Warranty Return Policy How to Order Company Profile
 

 

Click for the BBB Business Review of this Computer Software Publishers & Developers in Fort Walton Beach FL  

Weeder Technologies
90-A Beal Pkwy NW
Fort Walton Beach FL 32548
850-863-5723
info@weedtech.com

Established: 1989
DUNS: 969723154
CAGE CODE: 4T5L9
 

How to control a stepper motor

With ModCom, controlling a Stepper Motor Driver Module such as the WTSMD-M or the WTMCD-M could not be easier. From a simple Push Button that sends the motor to a specific position, to a complex Script that runs a whole series of movement routines that can be repeated with precision and used on single or multiple axis platforms. In either case you will need a Push Button to activate the stepper motor so choose one from the <Place Object> menu at the top of the screen and move it to the desired position using the mouse. Follow the steps below to set up the Push Button for operation.

Using a Push Button to move the motor:

Step 1: To set the properties of the Push Button, right-click on the object. This will bring up the Properties dialog box which contains a number of user defined attributes which can be used to customize the Push Button's appearance and operation.

Step 2: From the command set shown in Table 2 of the product data sheet, choose the command string which is required to move the stepper motor to a desired position and type it in the box at the upper right hand corner of the Press-Button Function section.

Step 3: Close out the dialog box and start the main run-time loop by clicking on the green "Run" button at the top of the screen. Once in run mode, you can use the left mouse button to click on the Push Button and ModCom will transmit the command which you entered in the dialog box and send the stepper motor on its way to the target position.

You can place multiple Push Buttons on the screen and use them to send the motor to various positions with a click of a mouse, but be sure to wait until the motor reaches its target position before clicking on a subsequent button. The Stepper Motor Driver Module will not hear any new commands while it is in the process of moving the motor.

Using a Push Button to start a Script:

Step 1: To set the properties of the Push Button, right-click on the object. This will bring up the Properties dialog box which contains a number of user defined attributes which can be used to customize the Push Button's appearance and operation.

Step 2: From the drop-down menu at the upper right hand corner of the Press-Button Function section, select "Run a Script" and then type in a name for the Script in the box at the right.

Step 3: Close out the Push Button dialog box and open the Script dialog box by selecting "Scripts" from the <Run-Loop> menu. Click on the "New" button and in the box labeled "ID Label", type in the same Script name that you used in the Push Button dialog box.

Step 4: Use the "Add Step" button to create the individual step functions of the Script. See Scripts for more details about how to configure a Script and the various functions that a Script is capable of performing. When transmitting a command to move the stepper motor, it is best to include the "Wait for this data" function afterwards so that the Script will stop and wait until the stepper motor reaches the target position before continuing with the next step function. Below is an example of a typical Script which can be used to move the stepper motor to various points.

<Transmit Command>AM1000Move stepper motor to position 1000
<Wait for this Data>AM1000Wait for motor to reach target position
<Pause Milliseconds>1000Pause for 1 second before continuing
<Transmit Command>AM2500Move stepper motor to position 2500
<Wait for this Data>AM2500Wait for motor to reach target position
<Pause Milliseconds>500Pause for 0.5 seconds before continuing
<Transmit Command>AM1500Move stepper motor to position 1500
<Wait for this Data>AM1500Wait for motor to reach target position
<Pause Milliseconds>2500Pause for 2.5 seconds before continuing
<Transmit Command>AM0Move stepper motor to position 0
<Wait for this Data>AM0Wait for motor to reach target position

Step 5: Close out the Script dialog boxes and start the main run-time loop by clicking on the green "Run" button at the top of the screen. Once in run mode, you can use the left mouse button to click on the Push Button and ModCom will start executing the Script, sending the stepper motor through the series of move operations defined in the Script dialog box. You could also use a variable to represent the target position in each Script command string. Allowing you to send the motor to a position indicated by an Input Window for example, which can be changed on the fly during run-time. Or you could use the Read from File function in your Script to read the various motor position values from a text file.

Controlling multiple axis:

With ModCom, it is possible to move more then one stepper motor simultaneously. To do this, write a separate Script for each move operation and for each motor, and then write a main Script that calls the individual move Scripts. Since each Script operates independent of each other, you can have multiple Scripts running at the same time. Below is an example of how to move two motors to a target position concurrently. The first two Scripts move the individual motors, the third Script is the master which should be started by a pushbutton to execute the move operation.

MotorA Script ID Label
<Transmit Command>AM1000Move motor A to position 1000
<Wait for this Data>AM1000Wait for motor A to reach target position
   
MotorB Script ID Label
<Transmit Command>BM5000Move motor B to position 5000
<Wait for this Data>BM5000Wait for motor B to reach target position
   
Main Script ID Label
<Start a Script>MotorAStart Motor A's move Script
<Start a Script>MotorBStart Motor B's move Script
<Wait Script End>MotorAWait for Motor A to stop moving
<Wait Script End>MotorBWait for Motor B to stop moving
...additional steps  
<Start a Script>MainMake this Script a continuous loop

It doesn't matter which stepper motor reaches its target position first, the Main Script will wait until both MotorA and MotorB Scripts have ended before moving on to any additional steps. You should define a separate subscript similar to MotorA and MotorB for each move operation and then call it from the Main Script. As shown above, at the end of the Main Script, you can include an extra step to restart itself, and the series of move operations will repeat until some other object in ModCom halts the Main Script.