Temperature Controller
 Liquid Level Controller
 Load Positioning System
 Laser Cutting Machine
 Motion Control System

~: Stepper motor control section :~

The figure given below shows actual schematic diagram of this section 

 

 

 

As shown in figure major components are micro controller 89C51, LCD (16 X 2), and ULN2003A chip. 

Connections: - four push buttons s1 – s4 are connected with P1 pins P1.0 – P1.3. The data pins of LCD are connected with port P0 and three control signals EN, Rs & RW are connected with P3.1, P3.2 & P3.3 respectively. Rx pin (P3.0) is connected with Tx pin of auxiliary controller (89C2051) of RPM counting section. The lower nibble of port P2 drives stepper motor through ULN2003A chip. Four LEDs are connected with upper nibble of port P2 for different indications. Reset switch RST is connected as shown with master reset pin (9) of 89C51. A 12 MHz crystal is connected on pin no 18 & 19.

 

Operation:-

Four push buttons are used for following functions

  • S1: - to start stepper motor
  • S2: - to stop stepper motor
  • S3: - increase RPM
  • S4: - decrease RPM  

Four LEDs are used for following indication

  • L1(Green LED): - indicated motor is running by blinking
  • L2(Red LED): - indicates motor is stop
  • L3(Blue LED): - blinks when RPM is increased/decreased
  • L4(yellow LED): - blinks when data byte is received 

Initially the motor is stop (indicated by Red LED) and LCD displays set RPM. When S1 is pressed motor will start rotating at set RPM and it is indicated by blinking of Green LED. As the motor starts the interrupt is generated in RPM counting section and it will start counting pulses. After 10 sec it will count RPM and return the count. This count is displayed as current RPM on LCD. After every 10 sec this cycle repeats. Mean while if any one increases or decreases set RPM it will be displayed on LCD. For accurate counting every time when RPM is changed one has to reset auxiliary controller to start counting again.  

 

Software: -

Whole software can be subdivided in to following sections

  • Initialization
  • User inputs through keypad
  • LCD interfacing
  • Stepper motor control
  • Serial data reception 

The main function handles initialization and keypad interfacing. For rest we have different functions. LCD interfacing has four different functions, three functions to control stepper motor and interrupt subroutine to receive data through serial port.

 

Initialization: -

  • First both timer/counters are initialized. T0 as 16 bit counter to count external pulses and T1 as 16 bit timer to set baud rate for serial communication.
  • Then serial communication mode is initialized.
  • Ports are initialized as input or output like P1 as input and rests are as output. 
  • Initialization of LCD as 

Keypad interfacing: -

  • Initially program waits for any key press. It continuously poles port P1
  • When any key is pressed it will jump to that subroutine.
  • While rotating a motor continuously, it will again pole P1 for any key press if the key is pressed it will come out of the loop and jump to that subroutine.
  • After subroutine is complete it will again start rotating motor (if ‘stop’ key is not pressed) 

LCD interfacing: - it has five different functions

  • Writedat: this function sends data on D0-D7 that is to be displayed on screen
  • Writecmd: this function sends different commands on D0-D7 that will configure LCD
  • Writestr: this function writes whole string on LCD screen
  • Busy: this function checks busy flag of LCD. If LCD is busy no data or command is sent to it. It will be only sent when busy flag is clear
  • Display: this function first converts any HEX value into decimal and then convert this decimal value into ASCII format to display it on LCD screen 

Stepper motor control: - there are three functions

  • Rotate: this function continuously rotates the motor by sending sequential pulses (with desire delay in between) till any key is not pressed. Also it blinks LED L1 at a rate of PRF (Pulse repetition frequency)
  • Spdinc: this function increases RPM by decreasing the delay given in between pulses to the motor
  • Spddec: this function decreases RPM by increasing the delay given in between pulses to the motor 

The last function is actually interrupt subroutine that is called automatically when any data byte is received serially. Because the auxiliary controller (RPM counting section) sends three digits of RPM count (like 120, 062,050 etc.) this function is called thrice. Every time it stores the digit in to memory and finally when all digits are received it will display it as “current RPM” on LCD.

click here to view complete C code

All the projects are designed and developed by sight owner and they are thoroughly tested by him. ©Copyrights Ashutosh Bhatt 2010. All rights reserved.