I connected a HS-311 to a signal generator and gave it a square wave (0-5v) at different frequencies but I did not get a good range of speeds.
I think the HS-311 has about 50 different speeds it can go at. I ran a test on it many years ago to test the number of speeds it can do, but my memory is bad and I dont remember how exactly the test was done . . .
And another problem was that two different motors did not give the same speed for the same frequencies. How to go about this??
Usually they will all go the same speed, but I've had a few servos in the past that didnt. You will need to calibrate the speed for each servo by adding or subtracting some small amount of time to the servo square wave pulse. If your robot as a whole has a good control system, the speed differences will correct itself.
I shall be grateful if you could explain to me how you managed to control the movement of the robot like spin, movement at different angles etc...
It was actually somewhat complicated. If you have a PC controlling your robot, you can use trig functions. Each motor moves at a speed that is a function of the direction of desired travel.
servo speed = speed_constant*cos(angle_of_wheel - angle_of_travel)
I however used a microcontroller so trig is out of the question - microcontrollers take a significant amount of time to do a trig calculation. Instead I had to write a trig lookup table
with a resolution of about 10 degrees. Basically you precalculate cos(angle) and then the microcontroller just looks up that value from an array.
It gets even more complicated if you want to control overall vehicle speed, or do spinning while traveling in a certain direction.
Oh, one reason I chose four wheels over three is that four is mathematically simpler - three wheels requires 3 calculations while four wheels requires 2 (calculate two, then reverse direction for the other two with a minus sign).
I think a lot of this will become obvious when you start building the robot . . .