Pages

Wednesday 18 April 2018

ARM-LPC1768-Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.

Interface a Stepper motor and rotate it in clockwise and anti-clockwise direction.


Program

/**
  * @brief Run steeper motor Clockwise when switch = 1 and reverse direction when switch = 0
  * @Connection
  * SDA  ------------------>  P2.0
  * SCL  ------------------>  P2.1
  * TX   ------------------>  P2.2
  * RX   ------------------>  P2.3
* 5V(FRC) --------------->  5V on board (without this, stepper motor produces jerk)
  * switch ---------------->  P2.5
  */

#include <lpc17xx.h> 
#include "stepper.h"
#include "blink.h"

#define    Switch  5       /* switch is connected to P2.5 */
uint16_t i;

int main()
{
  uint32_t switchStatus;

  /* Configure GPIO pins for steeper motor windings */
  Stepper(0,1,2,3);

  while(1)
  {
    /* Turn On all the leds and wait for one second */
    switchStatus = GPIO_Read(Switch);  /* Read the switch status */
 
    if(switchStatus == 1)    /* If switch == 1, motor runs in clockwise direction */
    { 
      /* for sometime run tghe motor in forward direction */
      for(i = 10; i > 0; i--)
        Motor_Forward_Direction();
    }
    else
    {
      /* for sometime run tghe motor in forward direction */ 
      for(i = 10; i > 0; i--)
        Motor_Reverse_Direction();
    }
  }
}
Hardware Connection
ENA (L298 driver) to 5V
IN1 (L298 driver) to P2.1
IN2 (L298 driver) to P2.2
ENB (L298 driver) to 5V
IN4 (L298 driver) to P2.3
IN5 (L298 driver) to P2.4
VMS (L298 driver) to Vin (12Volts, development board)
GND (L298 driver) to
FRC of Stepper Motor to FRC of L298 driver
Output
Stepper Motor runs in forward direction for some time and runs in reverse direction in some time. This repeats continuously.

FOR DETAIL INFORMATION ABOUT ARM CORTEX DEVELOPMENT KIT : CLICK HERE

No comments:

Post a Comment