stepper interfacing with 89c51 sequence problem...

Status
Not open for further replies.

aliraza786

Full Member level 4
Joined
Nov 10, 2009
Messages
210
Helped
14
Reputation
28
Reaction score
14
Trophy points
1,298
Location
Lahore, Pakistan, Pakistan
Activity points
2,914
hello guys. i have littel problem i couldn't get solution yet.. i interfaced stepper with uc .When i give angle to move to that angel. it works fine. e.g move to angel 48 degree.it moves to 48 degree but after that if i give angel less then 48 to move on then it give error of some degrees some time it stop 2 degree before the exact angel given some time reach the exact angel... and sometimes give one degree angel error.problem only come when i come from higher angel to lower angel.i think i have problem with counter clockwise steeping sequence because clockwise steping sequence is ok and stepper works fine for clockwise rotation but problem comes when we have to come back from higher angel to lowe


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if(pv<step) //pv is previous value of angel
  {
   l1=1;l2=1;l3=1;l4=1;
   step=step-pv;
  for(q=0; q<step;q++)
  { 
    if(x==0)
    { l1=1; l2=0; l3=0; l4=1;}
    delay(100);
    if(x==1)
   {  l1=1; l2=1; l3=0; l4=0;}
    delay(100);
    if(x==2)
   {  l1=0; l2=1; l3=1; l4=0;   }
    delay(100);
    if(x==3)
    {  l1=0; l2=0; l3=1; l4=1;}
    delay(100);
    x++;
    if(x==4)
    {x=0;}
  }
   l1=1;l2=1;l3=1;l4=1;
   }
  if(pv>step)
  {
   l1=1; l2=1; l3=1; l4=1;
   step=pv-step;
   for(q1=0; q1<step;q1++)
  { 
   l1=0; l2=0; l3=0; l4=0;
   if(x1==0)
    {l1=0; l2=0; l3=1; l4=1;}
    delay(100);
   if(x1==1)
   {l1=0; l2=1; l3=1; l4=0; }
    delay(100);
   if(x1==2)
   {l1=1; l2=1; l3=0; l4=0;}
    delay(100);
   if(x1==3)
    {l1=1; l2=0; l3=0; l4=1;}
    delay(100);
    x1++;
    if(x1==4)
    {x1=0;}
   }
  }
  return ;   
}



this is my code kindly help me.
 

Hi,

assuming x1 is declared as static, try to remove line 3,9,12,15,23,27,31,34,37,40
increase delay in line 18,43 and try to move first one step at time forward (at least 4 step)
and later one step at time reverse (at least 4 step) and observe if the motor follow the sequence.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…