Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

stepper motor control using pic 16f872

Status
Not open for further replies.

wada

Newbie level 1
Joined
Oct 7, 2005
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,288
stepper motor control algorithm profile pic

I want to design and implement a stepper motor controller built around a pic 16f872. Would like to use motors found in LX300 dot matrix printers. Could someone help me with the ideas as to how I will be able to implement this.
 

You would have to find a stepper motor controller to control the motor.
The controller would be controlled by the PIC.
The best way to do it is using PIC's timers and interrupts to generate pulses to the motor controller. Depends what frequency you need to move the motor
 

Use L293D or TLE4726 for interface and this algorithm (full pass) for control (CCS Compiler):

char port_a;
#byte port_a = 0x05 //Initial address of Porta_A

char port_c;
#byte port_c = 0x07 //Initial address of Porta_C

// It's depends of pins that are you using
#define BOB1B port_a,4
#define BOB1A port_a,5

#define BOB2B port_c,4
#define BOB2A port_c,5


// Variables
static unsigned int8 flag_step; //Motor position flag;
static unsigned int32 steps; //pass counter



void Close_Motor(void)
{
switch(flag_step) // Next pass
{
case 1:
bit_set(BOB1B); // Pass 1
bit_clear(BOB1A);
bit_clear(BOB2B);
bit_set(BOB2A);
flag_step = 2;
steps--; // Dec pass number variable
break;
case 2:
bit_clear(BOB1B); // Pass 2
bit_set(BOB1A);
bit_clear(BOB2B);
bit_set(BOB2A);
flag_step = 3;
steps--; // Dec pass number variable
break;
case 3:
bit_clear(BOB1B); // Pass 3
bit_set(BOB1A);
bit_set(BOB2B);
bit_clear(BOB2A);
flag_step = 4;
steps--; // Dec pass number variable break;
case 4:
bit_set(BOB1B); // Pass 4
bit_clear(BOB1A);
bit_set(BOB2B);
bit_clear(BOB2A);
flag_step = 1;
steps--; // Dec pass number variable
break;
}
return;
}


void Open_Motor(void)
{
switch(flag_step) // Next pass
{
case 1: // Pass 1
bit_clear(BOB1B);
bit_set(BOB1A);
bit_set(BOB2B);
bit_clear(BOB2A);
flag_step = 4;
steps++; // Inc pass number variable
break;
case 2: // Pass 2
bit_set(BOB1B);
bit_clear(BOB1A);
bit_set(BOB2B);
bit_clear(BOB2A);
flag_step = 1;
steps++; // Inc pass number variable
break;
case 3: // Pass 3
bit_set(BOB1B);
bit_clear(BOB1A);
bit_clear(BOB2B);
bit_set(BOB2A);
flag_step = 2;
steps++; // Inc pass number variable
break;
case 4: // Pass 4
bit_clear(BOB1B);
bit_set(BOB1A);
bit_clear(BOB2B);
bit_set(BOB2A);
flag_step = 3;
steps++; // Inc pass number variable
break;
}
return;
}

void main(void)
{
steps = 1; //Initial value of pass
}

Then you need put a delay routine between pass (obeyed the maximum operational frequency of motor) and speed that you need.

leomecma
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top