I'm programming a SCARA robot, and I do not understand the command used to move the arm clockwise and counterclockwise. It's defined, deg=40, ppport 0x378
scanf("%d", %26amp;theta );
mov=theta*deg;
if(mov%26gt;0)
{
(outp) (pport, 0x0E); //move CCW
_sleep(mov);
(outp) (pport, 0x00);
}
if(mov%26lt;0)
{
mov=mov*-1;
(outp) (pport, 0x0D); //moveCW
_sleep(mov);
(outp) (pport, 0x00);
}
I can move the arm using this program, but I do not understand which command is used to move it. I figure it's the _sleep command, but I do not understand what it exactly does.
Can anybody help me with this?
I have a task to program in C language, I saw an example program, and I don't understand this command...?
(outp) (pport, 0x0E); //move CCW
this starts the arm moving CC.
then the program waits some (mov) milliseconds
then the arm is stopped with
(outp) (pport, 0x00);
if you asked for 10 degrees then the sleep would be 40 times 10 degrees. It seems that someone has worked out 40milliseconds of moving results in one degree.
Reply:Looks to me that the command "(outp) (pport, 0x0E)" and the "(outp) (pport, 0x0D)" is sending/output signal to different devices to turn in different direction.
While the arm is turning, the _sleep command is just to stop the continue execution of the code. The variable "theta" is the time in seconds to move one degree. So if you stop the code for 3 second, the arm will turn for 3 second.
The code "(outp) (pport, 0x00);" will stop the arm from turning by setting the output signal to zero.
marguerite
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment