CodePudding user response:
The specific design yourselfCodePudding user response:
You also too few, moreCodePudding user response:
Is a cylindrical coordinate robot??????????CodePudding user response:
# include
# define uint unsigned int
# define uchar unsigned char
Uint I, j, k;
Uint N=128;//the spindle rotation degree Settings, 45 degree D=N */reduction ratio, using 1:16 reduction ratio of the stepper motor, rotating degree is D=128 * 45/16=360
Uchar code single_pos [4]={x0d x07 0, 0 x0b, 0, 0 x0e};//drive mode is single four turn table D - C - B - A
Uchar code single_rev [4]={0 x0e, 0 x0d, 0 x0b, 0 x07};//A single drive system, four inversion table A - B - C - D
Uchar code double_pos [4]={x09 x06 0, 0 x03, 0, 0 x0c};//double drive mode are four turn table AD - DC - CB - BA
Uchar code double_rev [4]={0 x0c, 0 x09, 0 x03, 0 x06};//double four drive method inversion table AB - BC - CD - DA
Uchar code eight_pos [8]={0 x06, 0 x07, 0 x03, 0 x0b, 0 x09, 0 x0d, 0 x0c, 0 x0e};//drive mode is eight beats table AD - D - DC - C - CB - B - BA - A
Uchar code eight_rev [8]={x0d x0e 0, 0 x0c, 0, 0 x09, 0 x0b, 0 x03, 0 x07, 0 x06};//the driving mode of eight beats inversion table - AB - B - BC - C - CD - D - DA
Void delay (uint z);
Void m_single_pos ();
Void m_single_rev ();
Void m_double_pos ();
Void m_double_rev ();
Void m_eight_pos ();
Void m_eight_rev ();
Void main ()
{
While (1)
{
M_single_pos ();//the single drive mode is to turn 360 degrees in four
Delay (200);
M_single_rev ();//the single drive mode turn 360 degrees in four
Delay (200);
M_double_pos ();//double drive mode is to turn 360 degrees in four
Delay (200);
M_double_rev ();//double drive mode turn 360 degrees in four
Delay (200);
M_eight_pos ();//eight beats driving mode is turned 360 degrees
Delay (200);
M_eight_rev ();//the driving mode of eight beats inverted 360 degrees
Delay (200);
}
}
/* * * * * * * * * * * * * * * * * * * * millisecond delay z * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Void delay (uint z)
{
Uint x, y;
For (x=z; X> 0; X -)
For (y=110; Y> 0; Y -);
}
/* * * * * * * * * * * * * * * * * * * single four drive forward (45/16) N * * * * * * * * * * * * * * * * * * * * * * * */
Void m_single_pos ()
{
For (k=0; K{
j=0;
for(i=0; i<4. I++)//in a single four work modes, a pulse rotor rotation Angle of 5.625 * 2=11.25, four shoot at 45 degrees
{
The P2=single_pos [j];
delay(5);//appropriate delay, ensure the rotor rotation time, delay time too short film
will be droppedj++;
}
}
}
/* * * * * * * * * * * * * * * * * * * single four drive inversion (N * 45/16 degrees) * * * * * * * * * * * * * * * * * * * * * * */
Void m_single_rev ()
{
For (k=0; K{
j=0;
for(i=0; i<4. I++)//in a single four work modes, a pulse rotor rotation Angle of 5.625 * 2=11.25, four shoot at 45 degrees
{
The P2=single_rev [j];
delay(5);
j++;
}
}
}
/* * * * * * * * * * * * * * * * * * * double four drive forward (45/16) N * * * * * * * * * * * * * * * * * * * * * * * */
Void m_double_pos ()
{
For (k=0; K{
j=0;
for(i=0; i<4. I++)//in double four work modes, a pulse rotor rotation Angle of 5.625 * 2=11.25, four shoot at 45 degrees
{
The P2=double_pos [j];
Delay (8);
j++;
}
}
}
/* * * * * * * * * * * * * * * * * * * double four drive inversion (45/16) N * * * * * * * * * * * * * * * * * * * * * * * */
Void m_double_rev ()
{
For (k=0; K{
j=0;
for(i=0; i<4. I++)//in double four work modes, a pulse rotor rotation Angle of 5.625 * 2=11.25, four shoot at 45 degrees
{
The P2=double_rev [j];
Delay (8);
j++;
}
}
}
/* * * * * * * * * * * * * * * * * * * eight beats driving forward (45/16) N * * * * * * * * * * * * * * * * * * * * * * * */
Void m_eight_pos ()
{
For (k=0; K{
j=0;
for(i=0; i<8; I++)//in eight beats working mode, a pulse rotor rotation Angle of 5.625 degrees, eight beats a total of 45 degrees
{
The P2=eight_pos [j];
delay(2);
j++;
}
}
}
/* * * * * * * * * * * * * * * * * * * eight beats driving reverse (45/16) N * * * * * * * * * * * * * * * * * * * * * * * */
Void m_eight_rev ()
{
For (k=0; K{
j=0;
for(i=0; i<8; I++)//in eight beats working mode, a pulse rotor rotation Angle of 5.625 degrees, eight beats a total of 45 degrees
{
The P2=eight_rev [j];
delay(2);
j++;
}
}
}