Legolas69:
Yeah i allready read all posts on forum about 6wire servo, but my car is new .. maybe i can control this by sending some values to its chip?
The 6 wires from servo going to an chip which has those info on it : 2609A / JCB / U4001D
i didnt find any info about that chip, but you find if i use an oscilloscope and check all wires.. i will can send with arduino some values to the right pin so i can have the steering ;
This is a possibility - certainly worth a try, but don't be surprised if you end up burning something out or whatnot with your hacking.
Honest, the best approach would be to simple replace that toy servo with a standard hobby servo; that, or return the vehicle and purchase one with a real hobby servo (3-wire).
If you wanted to use that servo, as already has been shown the other thread posted shows how the wires are more or less connected inside - you would probably want to verify the wiring for yours (in case wire colors are different or connected differently).
So - you have six wires - three of them are for the motor (two for the motor terminals, the third going to the capacitor common connection - you might be able to ignore that wire), the other three to the internal potentiometer.
The motor terminals would need to be connected to a suitable h-bridge driver circuit; I won't elaborate further on this, other than to say that the h-bridge needs to be rated for the motor in the servo.
The other wires to the potentiometer would need to be connected so that the "outer" terminals of the potentiometer connect to 5 volts and ground, while the wiper terminal gets connected to an analog input pin on the Arduino.
Then - the following pseudocode should help you write some real Arduino code to control the servo's motor:
moveToPosition(toPosition):
error = 5
done = FALSE
while (!done):
atPosition = readPosition()
if (atPosition > toPosition - error && atPosition < toPosition + error):
done = TRUE
else:
if (atPosition > toPosition - error):
motorCCW()
if (atPosition < toPosition + error):
motorCW()
motorStop()
To explain this code - first off, if you implemented this code as-is (but translated to work with the Arduino) - it would be "blocking" - that is, it would stay within the loop until it finished, then exit; you would really want to implement something better - non-blocking, and likely based on a timer interrupt to keep the "servo" updated; this code is just to give you an idea of how a software servo can be implemented, nothing more.
-
So - you would pass in to the code the position you want to move the servo to (0-1023).
-
An error value is set - this is to establish a "window" for the position comparison; real analog servos do this as well, but it is done electrically using a comparator circuit. This window is needed to be set to eliminate oscillation, "hunting" by the servo, and to cope with inaccuracies of the potentiometer. It may be increased or decreased as needed (larger values make the servo less positionally accurate).
-
A flag is then set to FALSE that controls when the loop can be exited, then the loop begins.
-
In the loop, we read the position of the potentiometer (0-1023).
-
We then compare it to the position we want to be at - within the "error window"; if the position falls within that window around the position we want to be at, then we set the flag to exit the loop, stop the motor, and exit the function.
-
Otherwise, depending on whether the position we are current at is greater than (or less than) the position we want to move to, we activate the motor to turn counter-clockwise or clockwise.
Those are basically the steps. You could expand it to pass in a "speed" parameter (then pass those to the motor actuation functions to PWM the motor at a particular speed if you wanted). You could also implement the system using a PID control algorithm (if you wanted more accuracy).
As can be seen, though, this is a much more complicated system to implement for a cheap RC car chassis robot; really only worth it if you have no other choice. But note, this kind of code could be used to create a large-scale steering servo system - especially if the Arduino (or more likely, a standalone ATTiny or something) was dedicated to the task, in which case the while() loop would just sit inside the "loop" structure, while listening for data being read from the serial port, or from some other communication method.
Anyhow - again, I think you would be better served by a different chassis, or by replacing the servo - unless as one of your goals you wanted to educate yourself on how a servo really works...
Good luck, and I hope this helps.