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



The library routine _4STEP.TDS drives four 4-phase stepper motors under interrupt from the TDS9092. 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 100 steps backwards at a speed of 250 units. The movement is done under interrupt so the microprocessor 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.


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 SGS-Thomson or Sprague part ULN2068B, or use n-channel MOSFETs as in the circuit, for example type ZVN2106A.

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.


The output compare interrupt 1 of the 16-bit free running timer 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.


By default, the interrupt occurs every 256 counts of the 16-bit free running timer 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 2400 steps per second.

Four motors using ports A and B are driven by this software. You can modify the software to 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 1 of the 16-bit timer is also used in the ASSIGN / RETURN; interrupt driven multitasking mechanism.

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