Go to Triangle Digital Support Home Page TDS2020F TECHNICAL MANUAL
Hardware expansion
Stepper motors
Live website search
Enter key words
 

STEPPER MOTORS

Stepper motor interface

Stepper motor interface
Click the diagram for more detail, or to save a copy:
1. in Internet Explorer right click on the picture and select "Save Target as..."
2. in Netscape double-click the picture to open the file, then under "File" select the "Save As" option.


OVERVIEW

The library routine #4STEP.TDS supplied with the UPDATE SERVICE, page 38, drives four 4-phase stepper motors under interrupt from the TDS2020F. Your application code determines direction, speed and number of steps for each of the four motors. All can move simultaneously with different settings.

For example 2 -100 250 DRIVE sends motor number 2 backwards by 100 steps at a speed of 250 units. The movement is done under interrupt so the processor is not held up while the action occurs. It can be doing other things like writing to a display, monitoring limit switches or creating an acceleration profile. See file #1STEP.TDS for an example of the latter.

HARDWARE

Each of the four stepper motors is connected to either the odd bits or even bits of Port A or Port B as follows:

 

 

Motor 0:

bitsá 0á 2 4á 6

Port A

 

Motor 1:

bitsá 1á 3 5á 7

Port A

 

Motor 2:

bitsá 0á 2 4á 6

Port B

 

Motor 3:

bitsá 1á 3á 5á 7

Port B

 

A suitable quad driver IC is the ST Microelectronics or Allegro MicroSystems part ULN2068B, or use n-channel enhancement mode 5V-drive MOSFETs as in the circuit.

PRINCIPLE OF OPERATION

The Output Compare Interrupt B of free running timer 3 is used to generate regular interrupts, which decrement a variable for each motor. When zero is reached a bit-pattern is rotated and output to the motor. The pattern is organised to generate a 4-phase stepper drive with either full or half steps as selected. Note that no 'stepper-driver card' is needed, it is all done in software.

CUSTOMISATION

By default the interrupt occurs every 256 counts of free running timer 3 i.e. every 208Ás. The output compare register is moved forward by 256 counts on each interrupt ready for the next one. You can adjust the interrupt rate to give up to 7402 steps per second but the recommended value gives a maximum speed of 1500 steps/sec for each motor and places an 11% load on the microprocessor.

This software drives four motors using ports A and B. You can use only the two connected to Port A if Port B is in use for a matrix keyboard. Motors can be run on other ports simply by changing the addresses defined. By such changes any number of motors can be supported.

Note that the Output Compare register B of timer 3 is also used in the ASSIGN/RETURN; interrupt driven multitasking mechanism. If you also need to have background tasks written in high-level Forth choose one of these alternatives:

 

q       Change this program to use timer 1 or 2.

q       Use the full multitasker provided with the Update Service. This uses output compare A of timer 3 for its pre-emptive capability and is compatible with the stepper motor software.

Go to Triangle Digital Support Home Page Go to top   Next page