| Home | Control Home | µC Stepper Control 2 | µC Stepper Control 2 Plus |
by Martin Clausen (mc AT rotgradpsi DOT de)
This circuit employs a MCU to control up to four unipolar stepper motors via RS232.
If bipolar steppers can also be employed, please use Stepper Control 2 Plus instead!
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.
Make sure that the controller resets within a few 10ms, so do not use a reset capacitor larger than 1µF. This is important, since the outputs of the 8051 are high during reset. Consequently all motor coils are driven. This can only be avoided by additional external logic (two 74HC541 with /enable connected to reset of the MCU), but this is normally not needed.
The hold jumper is used to switch off the hold current through the motor coils, while all four motors stand still. A closed jumper corresponds to no hold current. The jumper is read every 200µ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, 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.
| Motor No or Command | Mode And Direction | Steps | Steptime | Addtional Response | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 |
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: 200µs | none | Move motor 0 with given steptime, mode and direction the number of steps. | ||||||||||||||||||
| 1 | same as Motor No 0 | ||||||||||||||||||||||
| 2 | same as Motor No 0 | ||||||||||||||||||||||
| 3 | same as Motor No 0 | ||||||||||||||||||||||
| 4 | dummy | Lower byte is writen to GPIO | dummy | none | Write to GPIO. To pins which are used as inputs, only ones should be written. | ||||||||||||||||||
| 5 | dummy | dummy | dummy | Device Address, two digit hex-number, line end character | Read GPIO | ||||||||||||||||||
| 6 | motor no | dummy | dummy | Device Address, four digit hex-number, line end character | The "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. | ||||||||||||||||||
| 7 | motor no | Maximum 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: 10 ms | Acceleration Must be 1 at least. default: 2 | none | It is important to set these parameters to obtain optimum performance (fast vibration-free movement without loss of steps). | ||||||||||||||||||
| 8 | dummy | dummy | dummy | Device Address, one digit hex-number, line end character | Check 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. | ||||||||||||||||||
| MSB - LSB | Baudrate / kbps |
|---|---|
| 111 | 115.2 |
| 110 | 57.6 |
| 101 | 38.4 |
| 100 | 19.2 |
| 011 | 9.6 |
| 010 | 4.8 |
| 001 | 2.4 |
| 000 | 1.2 |
Meaning of 1 and 0 in this table:
| Sign | Switch |
|---|---|
| 1 | closed |
| 0 | open |
The baudrate jumper are read up on reset.
Capacitors:
Resistors:
Mechanic:
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