Society of Robots - Robot Forum

Software => Software => Topic started by: offy on April 12, 2009, 09:23:46 PM

Title: SoftwareServo Libary sucks. who agrees?
Post by: offy on April 12, 2009, 09:23:46 PM
So I have been working on my robot, most of it needing SoftwareServo, but so many problems, each time the servo moves it gets a small and smaller distance. It gets mixed up, I would be controling 1 softwareservo and a differnt one will move. Is anyone else having these problems? Is there a new softwareservo libary?
Title: Re: SoftwareServo Libary sucks. who agrees?
Post by: Razor Concepts on April 12, 2009, 09:26:14 PM
There is a weird thing with softwareservo when updating one servo it has to update the other servo as well (when doing the refresh method). I don't like that either it kind of messes with the other servos, wish they would have a refresh option for just one servo.

But what do you mean a smaller and smaller distance? Post up the code. As long as the values are between 0 and 180 it should be okay.
Title: Re: SoftwareServo Libary sucks. who agrees?
Post by: offy on April 12, 2009, 09:35:34 PM
This is what I have so far.
Code: [Select]
#include <Servo.h>
#include <SoftwareServo.h>
Servo right;
Servo left;
SoftwareServo head;
SoftwareServo right_main;
SoftwareServo right_side;
SoftwareServo left_main;
SoftwareServo left_side;
int right_arm_side = 0;
int right_arm_side1 = 180;
int headValue = 0;
int headValue1 = 180;
char val;

void setup() {
  right.attach(9);
  left.attach(10);
  head.attach(11);
  right_main.attach(5);
  right_side.attach(3);
  left_main.attach(6);
  left_side.attach(8);
  Serial.begin(9600);
}

void loop() {

  if( Serial.available() )
  {
    val = Serial.read();
  if( val == 'A' )
  {
    left.write(135);
    right.write(135);
  }
  if( val == 'D' )
  {
    left.write(45);
    right.write(45);
  }
  if( val == 'W' )
  {
    left.write(45);
    right.write(135);
  }
  if( val == 'S' )
  {
    left.write(95);
    right.write(95);
    delay(250);
    left.write(135);
    right.write(45);
  }
  if( val == ' ' )
  {
    left.write(96);
    right.write(99);
  }
  if( val == 'E' )
  {
   headValue = headValue + 100;
   head.write(headValue);
   SoftwareServo::refresh();
  }
   if( val == 'Q' )
  {
   headValue1 = headValue1 - 100;
   head.write(headValue1);
   SoftwareServo::refresh();
  }
  if( val == 'H' )
  {
    right_arm_side1 = right_arm_side1 - 5;
    right_side.write(right_arm_side1);
    SoftwareServo::refresh();
  }
  if( val == 'F' )
  {
    right_arm_side = right_arm_side + 5;
    right_side.write(right_arm_side);
    SoftwareServo::refresh();
  }
  delay(1);
  }
}

by smaller and smaller I mean

the servo will first turn this far
|            |
|      |
|   |
| |

so like that.if that makes sense.
Title: Re: SoftwareServo Libary sucks. who agrees?
Post by: Razor Concepts on April 12, 2009, 09:41:57 PM
Does it happen for your right_arm_side servos?

For the headValue servo, when you press the button it either adds 100 or subtracts 100. So if the value is 180, subtract 100 is 80. Subtract 100 and the servo will go to 0, so it will seem like it moved a shorter distance.
Title: Re: SoftwareServo Libary sucks. who agrees?
Post by: offy on April 12, 2009, 09:45:12 PM
I can't even get it to go all the way to 0, it will do like 100, than 50, 20, 1, 1, 1, 1, 0