Monday, October 22, 2012

RS232 Stepper motor control (attiny2313)

The goal

Drive stepper motor from serial port RS232.

Usability

High.

Parts

  • signal wires
  • attiny2313
  • ULN2003a
  • prototype board or any other

Code

Electric diagram

Electric diagram

Description

This board is used to drive stepper motor from RS232 port. After reset position in the running program is set to 0. If a valid data is received on USART port, motor starts to move, exactly X or -X steps.

Drive sequence


Assuming that you already connected this board by RS232 to PC, you can control motor by those commands:

What board can receive


R - reset communication. It should by send every time, when we send position value.

NNH - Number Number Horizontal -> e.g. 05H or 48H, the 'NN' are position with one leading zero at left. the 'H' means Horizontal, It was added for future, maybe someday this board can drive Vertical and Horizontal motor position.

What board can send: 


E - error, wrong communication, e.g. no 'R' received, or wrong number, or missing 'H" char,
O - ok, send after motor position have changed (after end of driving sequence)

Example


Proper communication


board < R
board > O
board < 28H
board (wait some time)  > O

Wrong communication


board < R
board > O
board < asf
board (immediately)  > E

Final



No comments:

Post a Comment