Introduction To ARM7

This generation introduced the Thumb 16-bit instruction set providing improved code density compared to previous designs. The most widely used ARM7 designs implement the ARMv4T architecture, but some implement ARMv3 or ARMv5TEJ. All these designs use a Von Neumann architecture, thus the few versions comprising a cache do not separate data and instruction caches.

ARM ARCHITECTURE

In this section we will start programming LPC2138 with the brief introduction we had in the previous section. As described earlier in order to start programming LPC 2138 programming, we will start with the architecture of LPC 2138 first and then proceed with the GPIO pins.

ABOUT GPIO

General-purpose input/output (GPIO) is a generic pin on an integrated circuit whose behavior, including whether it is an input or output pin, can be controlled by the user at run time.

ARM

ARM is a family of instruction set architectures for computer processors based on a reduced instruction set computing (RISC) architecture developed by British company ARM Holdings..

mobile computing

A CPU chip is designed for portable computers, it is typically housed in a smaller chip package, but more importantly, in order to run cooler, it uses lower voltages than its desktop counterpart and has more "sleep mode" capability. A mobile processor can be throttled down to different power levels or sections of the chip can be turned off entirely when not in use. Further, the clock frequency may be stepped down under low processor loads. This stepping down conserves power and prolongs battery life..

ARM 7

ARM is the industry's leading supplier of microprocessor technology, offering the widest range of microprocessor cores to address the performance, power and cost requirements for almost all application markets.
Showing posts with label Stepper moto. Show all posts
Showing posts with label Stepper moto. Show all posts

Thursday, 4 December 2014

DC Stepper motor Interfacing

Stepper Motor

A stepper motor is a brushless, synchronous electric motor that can divide a full rotation into a large number of steps. When commutated electronically, the motor's position can be controlled precisely, without any feedback mechanism.


Figure 1 : Stepper motor function

Figure 2 : stator winding configuration

HALF STEP 8-STEP SEQUENCE


Code for stepper motor
/* connections
PORT1   P1.24 connected to SW1
PORT1   P1.25connected to SW2
PORT1   P1.26 connected to SW3
Connect PORT1  P1.16  P1.17  P1.18 to the Stepper motor*/

#include<LPC214x.h>     // Define LPC2148 Header File
#include <stdio.h>

#define SW1    24    //SW1 (P1.24)
#define SW2    25    //SW2 (P1.25)
#define SW3    26    //SW3 (P1.26)
#define COIL_A 16    //change the Stepper Motor Port!

void motor_cw(void);
void motor_ccw(void);
void delay(int);
  
unsigned char STEP[] = {0x09, 0x08, 0x0C, 0x04, 0x06, 0x02, 0x03, 0x01};// from the above table
void main(void)
{
       unsigned char i = 0;         
   PINSEL2 &= 0xFFFFFFF3;   // P1.16 - P1.31 as GPIO
   IODIR1 = 0x000F0000;        // P1.16 - P1.19 as Output
 
   while(1)                           // Loop forever
   {
           if (!(IOPIN1 & (1<<SW1)))    //  check Switch SW1 ON/OFF
      {
         motor_cw();            // Stepper Motor clockwise
           }

      else if (!(IOPIN1 & (1<<SW2)))   //check for  Switch SW2 ON/OFF
      {
         motor_ccw();     // Stepper Motor anticlockwise
           }

      else if (!(IOPIN1 & (1<<SW3)))  // check for Switch SW3 ON/OFF
 {
             while (i < 12)
             {
            motor_cw (); // clockwise for req. angle
               i++;
            } 
     }
          else
         i = 0;
  }
}

void delay(int n)   // for delay
{
   int i,j;
   for(i=0;i<n;i++)
   {
      for(j=0;j<0x3FF0;j++)
           {;}
   }
}

 void motor_ccw(void)   // anti- clockwise rotation
{
   unsigned int i=0;

   while (STEP[i] != '\0')
   {
      IOSET1 = STEP[i] << COIL_A;
      delay(1);
      IOCLR1 = STEP[i] << COIL_A;
      delay(1);
      i++;
   }
}
  
void motor_cw(void)   // clock wise rotation
{
   int i = 7;
   while (i >= 0)
   {
      IOSET1 = STEP[i] << COIL_A;
      delay(1);
      IOCLR1 = STEP[i] << COIL_A;
      delay(1);
      i--;
   }
}

Connections:
 Output :
/* Don’t forget to keep VBAT 3v */