Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
//change angles in about 12 secondsfor(i=300;i<900;i++){servo(i);delay_ms(20);}//change angles 5 times faster using 5 as the multiplieri=300;while(i<900){servo(i);i=i+5;delay_ms(20);}
Isn't this an example of PID control where the various constants can be used to move smoothly from A to B?
Try creating a recursive function
Is there a way to find out the position of the servo, so that it will "lock on" unto that position
Also, I made a moveservo method that uses the current position, the position you want it to go, and the speed you want it to travel to move the servo. The problem is, I cant control two servos at the same time, since it will wait for the first moveservo method to complete, and then start the next moveservo method. Is there an easy way to run two methods at the same time without writing a new moveservo method that moves two servos?
[blah blah blah]//your code herei=300//calculated required speedconstant=3;//increase this number to slow servo speedi=(i+i_old*constant)/(constant+1);//smoothing functionservo1(i);i=i_old;j=300//calculated required speedconstant=3;//increase this number to slow servo speedj=(j+j_old*constant)/(constant+1);//smoothing functionservo2(j);j=j_old;delay_ms(28);
for(i=700;i<900;i++){servo_1(i);servo_2(700);servo_3(700);delay_ms(28);}
However, can I still use timers to control servos, even if I'm using timers to interpret data from a receiver (from my other radio control thread)?
QuoteTry creating a recursive functionNot allowed on microcontrollers . . .