Thread: more about the code

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    3

    more about the code

    dear all,
    here is the basic function to run a stepper motor.
    Code:
    void move_x1ccw(int distance,int speed)
    {
    	int j;
    	distance=200*distance;/* for 1.8 deg stepper motor */
    	for(j=0;j<distance;j++)
    	{
    		 outportb(dport,0x02);
    		 delay(speed);
    		 outportb(dport,0x03);
    		 delay(speed);
    	}
    }
    void move_x1cw (int distance,int speed)
    {
    	int i;
    	distance=200*distance; /*for 1.8 deg stepper motor */
    	for(i=0;i<distance;i++)
    	{
    		outportb(dport,0x00);
    		delay(speed);
    		outportb(dport,0x01);
    		delay(speed);
    		 /* printf("%2d\n",rotation);*/
    	}
    }
    void work1(int dir,int distance,int speed)
    {
    	switch(dir)
    	{
    		case 'f':
    		{
    			printf("\n\n\t\tmotor-x1 moving in forward direction...");
    			move_x1cw(distance,speed);
    			break;
    		}
    		case 'r':
    		{
    			printf("\n\n\t\tmotor-x1 moving in reverse direction...");
    			move_x1ccw(distance,speed);
    			break;
    		}
    		case '27':
    		{
    			exit(0);
    		}
    		default:
    		{
    			usage();
    			break;
    		}
    	}
    }
    these functions are capable to run one stepper motor.
    motor1_cw for its clockwise rotation and the other for the anti-clockwise rotation.

    the robot is a pure assembly and it is a scara type robot aimed to work for handling purposes for the materials in the tool room.

    dear salem this robot does not have any manual,it is being prepared by a group of students.

    dear magos thanks for the ckt dia. for the printer port , i think this would be helpful for further research.


    &#91;code]&#91;/code]tagged by Salem

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    For future reference, you should use code tags to surround posted code. It helps it keep formatting, and it looks much better (ie: it's easier to read).

    [code]
    ... code goes here ...,
    [/code]


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM