go away spammer

Author Topic: Strange code problem  (Read 2930 times)

0 Members and 1 Guest are viewing this topic.

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Strange code problem
« on: February 14, 2008, 08:06:09 PM »
Alright, while working on a demo for my project I found something strange, all of the servos are hooked up the same way, number 4 and 5 always rotate the same direction and they are modified, numbers 1 through 3 all rotate clockwise then reset, but number 0 goes the opposite direction, the other 3 servos are hitec, while the first one is from parallax, is this what the problem is?

Code: [Select]
int i;
for(i=0;i<150;i++)
{
PORT_ON(PORTD,7);
delay_cycles(25);
PORT_OFF(PORTD,7);
delay_cycles(200);
}


while(1)
{

for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(20);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);

PORT_ON(PORTD, 1);
delay_cycles(20);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);

PORT_ON(PORTD, 2);
delay_cycles(20);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);

PORT_ON(PORTD, 3);
delay_cycles(20);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);

PORT_ON(PORTD, 4);
delay_cycles(20);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);

PORT_ON(PORTD, 5);
delay_cycles(20);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);

for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(25);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);

PORT_ON(PORTD, 1);
delay_cycles(25);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);

PORT_ON(PORTD, 2);
delay_cycles(25);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);

PORT_ON(PORTD, 3);
delay_cycles(25);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);

PORT_ON(PORTD, 4);
delay_cycles(25);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);

PORT_ON(PORTD, 5);
delay_cycles(25);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);

for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(30);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);

PORT_ON(PORTD, 1);
delay_cycles(30);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);

PORT_ON(PORTD, 2);
delay_cycles(30);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);

PORT_ON(PORTD, 3);
delay_cycles(30);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);

PORT_ON(PORTD, 4);
delay_cycles(30);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);

PORT_ON(PORTD, 5);
delay_cycles(30);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);

for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(35);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);

PORT_ON(PORTD, 1);
delay_cycles(35);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);

PORT_ON(PORTD, 2);
delay_cycles(35);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);

PORT_ON(PORTD, 3);
delay_cycles(35);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);

PORT_ON(PORTD, 4);
delay_cycles(35);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);

PORT_ON(PORTD, 5);
delay_cycles(35);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);

for(i=0;i<25;i++)
{
PORT_ON(PORTD, 0);
delay_cycles(40);
PORT_OFF(PORTD, 0);//keep off
delay_cycles(200);

PORT_ON(PORTD, 1);
delay_cycles(40);
PORT_OFF(PORTD, 1);//keep off
delay_cycles(200);

PORT_ON(PORTD, 2);
delay_cycles(40);
PORT_OFF(PORTD, 2);//keep off
delay_cycles(200);

PORT_ON(PORTD, 3);
delay_cycles(40);
PORT_OFF(PORTD, 3);//keep off
delay_cycles(200);

PORT_ON(PORTD, 4);
delay_cycles(40);
PORT_OFF(PORTD, 4);//keep off
delay_cycles(200);

PORT_ON(PORTD, 5);
delay_cycles(40);
PORT_OFF(PORTD, 5);//keep off
delay_cycles(200);
}
delay_cycles(2000);




/* Servo Test Code
i=250;
while(i>0)
{
servo_left(40);
i--;
}

i=250;
while(i>0)
{
servo_left(24);
i--;
}
*/

//rprintf("Initialization Complete\r\n");

//output message to serial (use hyperterminal)
//print("Hello, World! Read My Analog: %u\r\n", sensor_0);

//delay_cycles(500);//a small delay to prevent crazy oscillations
}
/*********ADD YOUR CODE ABOVE THIS LINE **********/

return 0;
}
« Last Edit: February 15, 2008, 06:49:11 AM by gamefreak »
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Strange code problem
« Reply #1 on: February 15, 2008, 12:16:42 PM »
does the parallax servo work fine if you change the code to go the other way?

Offline gamefreakTopic starter

  • Supreme Robot
  • *****
  • Posts: 543
  • Helpful? 2
  • Robo-Enthusiast
Re: Strange code problem
« Reply #2 on: February 15, 2008, 07:19:10 PM »
all of the servos go to the end, then rotate back to the starting delay, although the modified servos only rotate in a single direction, the potentiometer is probably off and I dont have an oscilloscope, are there any cheap ones?
All hail Rodney, the holy 555 timer
And Steve said: "Let there be lead!"

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Strange code problem
« Reply #3 on: February 16, 2008, 04:40:41 PM »
You use a multimeter to measure potentiometers, not oscilloscope ;)

Anyway, assume that the parallax servos require a different square wave to operate. Just try changing the frequency and see what happens.

As for a cheaper servo, the HS-311 is always $8.99

 


Get Your Ad Here

data_list