Quantcast
Channel: Motor drivers forum - Recent Threads
Viewing all articles
Browse latest Browse all 21975

RE: DRV8823 Control

$
0
0

Hi Rick,

Stepper motor used in the project is having 1.8 degrees angle for Fullstep.

Following is the code that is used to rotate the stepper motor.

U8 full_mseq_A_B[16] = {
    0xCF,0x03,
    0x1F,0X00,
    0X4F,0X03,
    0X4C,0X07,
    0X4D,0X03,
    0X1D,0X03,
    0XCD,0X03,
    0XC0,0X07
    };

void rotate_Motor(U8 dir, const F32 angle_to_rotate)
{
static U8 index_temp =0;
F32 i = 0.0;

    for(i = 0.0;i <= angle_to_rotate;i=i+0.9)
    {
        if( dir )
        {
          if( index_temp < 7 )
          index_temp++;
        else          index_temp = 0;
        }
        else
        {
          if( index_temp > 0 )
            index_temp--;
          else
          index_temp = 7;
        }
        //Send the data on SPI communication to Stepper motor driver
        Spi_Session_Layer_write(&full_mseq_A_B[index_temp*2],2);
        delay_ms(1);
    }

}

For 360 degree rotation, there is no issue.

void main(void)

{

rotate_motor((U8)1, 360);

while(1)  {   }

}

Following code is not working as expected, (expected is to shift 90 Degrees, but there is, minute deviation in the angle(starting from 0 degrees to 90 degrees)

This deviation is more if rotate_motor((U8)1, 45) function is called for 5 or 6 or 7 or 8 times before while(1)).

void main(void)

{

rotate_motor((U8)1, 45);

rotate_motor((U8)1, 45);

while(1){}

}

Please do needful in understanding why there is a deviation in angle , if the function rotate_motor((U8)1, 45) is called for 8 times.(expected is to rotate 45 degrees * 8  = 360 degrees),

But motor is rotating >352 degrees and < 360.degrees.(what is the exact error angle is not known).

Thanks

Rakesh


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>