The motor controller is provided with a control word from the open8 micro controller. The control word is 8 bits wide, bits 3 down to 0 represents the number of steps that is to be moved. Bits 5,4 selects the motor that is to be rotated and bit 6 is used to select the direction of rotation (forward or reverse). Bit 7 is used for selecting between interrupting or not interrupting the microcontroller after task is completed.
Contorl word (8 bits) - control_word_reg
1.Bits 3 down to 0 – Number of steps to be rotated (step_counter)
- “1111” - 15 steps (example)
2.Bits 5 down to 4 – (select) The Motor that is to be rotated (Motor_select)
- Control_word(5) = 1, left motor is selected
- Control_word(4) = 1, right motor is selected
- Control_word(5,4) = “11”, both motors are selected
- Control_word(5,4) = “00”, No motor is selected
3.Bit 6 – Direction of rotation of the selected motor(s) (Motor_direction)
- Control_word(6) = 0, forward direction of rotation
- Control_word(6) = 1, reverse direction of rotation
4.Bit 7 – Interrupt upon task completion
- Control_word(7) = 1, interrupt the MC upon completion of task
- Control_word(7) = 0, do not interrupt the MC upon completion of task, execute the previous control word again.
Two modes of operations:
Depending on the bit 7, the motor controller can operate in
Autonomous mode – control_word(7) = '0'
The motor controller, loads the control word that is available in the control_word_register after completing a task and continues to execute it. It doesnt interrupt the micro controller after completion of the task. This frees the MC from servicing the motor controller when there is no need for it.
Slave mode – control_word(7) = '1'
The motor controller interrupts the MC after completion of the task. The microcontroller can load a new control word into the motor controller upon interrupt. This gives a greater controllability in terms of the number of steps to be rotated.
MOTOR CONTROLLER BLOCK DIAGRAM
WRITING INTO THE CONTROL WORD REGISTER (enable, control_word, wr_en)
The control word is decoded by the motor controller. The control word is written into the control register of the motor controller by selecting the motor controller using the enable signal, loading the control_word onto the control word line and writing into the register by pulling up the write enable (wr_en) line. The motor controller starts executing the control word loaded immediately after it is loaded.
INTERRUPTING THE CPU (task_completed, int_ack)
If the motor controller is posed to interrupt the CPU after it has completed its operation, The task_completed line goes high after completing its task. The motor controller expects an interrupt acknowledge signal. Upon the receipt of interrupt acknowledge signal, the task_completed line goes low and the motor controller waits for the control word to be loaded onto the control line. If it is not posed to interrupt the CPU, the task_completed remains low and doesnt interrupt.
INTERFACE WITH THE MOTOR(motor_output1, motor_output2, motor_feedback)
The motor controller can be interfaced with two stepper motors. The motor circuitry is expected to provide a signal upon rotation of the motor after each step. This signal is motor_feedback. The reception of this signal means that rotation of the motor by one step is complete. The 4 bit patterns to the two motors are provided by the motor_output1 and motor_output2 signal.