µC Stepper Control 2

by Martin Clausen (mc AT rotgradpsi DOT de)

This circuit employs a MCU to control up to two bipolar stepper motors via RS232.

Not recommended for new designs, for reference only, please use Stepper Control 2 Plus instead!

Features

Usage of Device

The device utilizes a 8051 and two driver chips to allow the user to control up to two bipolar stepper motors via RS232. All commands from the PC are passed through. If the device receives a command with it own address, it will also move the motors as required. All commands end with a line end character. This is normally CR.

Address and line end character can be changed easily, just send me a mail with your demands.

The LED will be on after power-up. After each correct command it will toggle between on and off. If a buffer overflow occurs, the LED will stay permanently off and the MCU is stopped.

The hold jumper is used to switch off the hold current through the motor coils, while both motors stand still. A closed jumper corresponds to no hold current. The jumper is read every 100µs. If you want to control this pin via RS232 you could use a GPIO pin. There is no direct control of this feature via software, because in some application the motors might be driven with a higher current than allowed for infinite time because of too high power dissipation. Since in this case wrong settings might damage the motors this option is normally not accessible via RS232.

The GPIO lines are located at P1 of the MCU. They are open collector outputs with a weak pull-up resistor and contain also a circuit for read back. Refer to the microcontroller datasheet for details. The state of the GPIO after reset is high. Note that you need to write an one to a GPIO before it is possible to use it as an input, if it has been used as an output since the last reset.

If you send a new command while the old one is still executed on the same motor, the controller will change to the parameters of the new command, without the full execution of the previous command. If this occurs, a calculated position on the PC will not match the real position.

Messages from the controller are sent with its own address first and then followed by the data in hex-code (nibble by nibble from msb to lsb).

Note, that due to the limitations in computational power and number of timers, the motion profiler increases and dereceases the steptime linearly. In case of a long acceleration/deceleration time (maximum steptime > 3*steptime) this leads to large derivation from an almost linear to hyperbolic velocity profile and smoth motion without the loss of steps is not reached. See µC Stepper Control 2 Plus for a version for a single bipolar motor with a more advanced motion profiler.

Comand Structure

Motor No or
Command
Mode And DirectionStepsSteptimeAddtional ResponseDescription
0
ValueMode / Direction
0full step, clockwise
1full step, counterclockwise
2half step, clockwise
3half step, counterclockwise
4quarter step, clockwise
5quarter step, counterclockwise
6quarter step, clockwise
7quarter step, counterclockwise

8 and 9 will warp around to 0 and 1 respectively.
Value: 0000 to 9999
Units: full/half/quarter steps depending on mode
Value: 00 to 99
Units: 100µs
noneMove motor 0 with given steptime, mode and direction the number of steps.
1same as Motor No 0
2invalid
3invalid
4dummyLower byte is writen to GPIOdummynoneWrite to GPIO.
To pins which are used as inputs, only ones should be written.
5dummydummydummyDevice Address, two digit hex-number, line end characterRead GPIO
6motor nodummydummyDevice Address, four digit hex-number, line end characterThe "steps to do register" is snapshot at the low transition of IE0 and send.
Demanding data from a non-existing motor no will lead to invalid data being send, but no error message.
7motor noMaximum steptime
Should be limited to 255, otherwise the maximum steptime modulo 256 is taken. In case the maximum steptime is shorter than the steptime, the motion will consist of steps with the steptime in between only.
default: 5 ms
Acceleration
Must be 1 at least.
default: 2
noneIt is important to set these parameters to obtain optimum performance (fast vibration-free movement without loss of steps).
8dummydummydummyDevice Address, one digit hex-number, line end characterCheck if any motor is still running.
The response will be a hex-number with the bits of the corresponding motors set if they are running.

Baudrate Selection

MSB - LSBBaudrate / kbps
111115.2
11057.6
10138.4
10019.2
0119.6
0104.8
0012.4
0001.2

Meaning of 1 and 0 in this table:

SignSwitch
1closed
0open

The baudrate jumper are read up on reset.

Parts

Driver IC Recommendations

Typeno. of chips
for two motors
max. currentmax. voltageinhibit polaritycomment
TCA372720,75A50VPX.6temperature prealarm via inhibit and GPIO possible,
no gitch filter for current sensing possible: Do not use, if the motor is connected via a long cabel!
UDN291620.75A45Vnone 
UDN291721.5A45VPX.7obsolete
PBL371741A46Vnone 
TEA371740.8A45Vnone 
TEA371841.2A50Vnonetemperature prealarm and alarm via GPIO possible
LMD1824543A55VPX.7use brake as enable

see Stepper Driver Connection Schemes for more information

Download of Program and Circuit

The part description in schematics is read as follows:
part type + value in exponential form + package description + subpart number in package
for example: C1040805,1 means Capacitor, 100nF, package SMD 0805, first subpart in package

Disclaimer: No warranty at all!
Copyright by Martin Clausen, Germany.
Contact the author: mc AT rotgradpsi DOT de
Impressum