code for controlling Encoder Dc Servo

I having a encoder Dc Servo Motor and i need to control the motor using RXD and TXD ports on Arduino Uno R3.

I am using 100K Potentiometer as analog input.[/img]

so what should be the program code for my project ??
or what are the codes that must be used to control the motor??

RMCS220x_DCServo+Driver_5.pdf (503 KB)

Must you use uart serial to control the servo? It would be much simpler to send servo PWM signals using the Servo library. You need only one signal wire. There are examples in the IDE to help understand the library. If you just want to control the motor you can do that with the pot, no Arduino needed.

I need to use arduino as 2 more servo has to be controlled
so is there any way that i can use arduino RDX and TXD port to control the motor

You can use the hardware Tx and Rx pins if you like but they will need to be unplugged in order to upload your program and you will not be able to use Serial.print() to help debugging.

You should consider using SoftwareSerial as then you can define your own Tx and Rx pins within reason.

That said, I still don't understand why you need to use Serial to control the servo. Can you please give a link to the servo that you are using ?

You can control up to 6 servos With a Uno and Servo library. The data sheet explains how to do it with UART serial. You need a serial port for each servo unless you do some multiplexing.

groundfungus:
You can control up to 6 12 servos with a Uno and Servo library. The data sheet explains how to do it with UART serial. You need a serial port for each servo unless you do some multiplexing.

Thanks AWOL, I confuse PWM with servo for some reason.

Servos use PWM, but it's a very low duty cycle, and a much lower frequency than the hardware PWM.

I am using High Torque Encoder Dc Servo RMCS 2201 for my project (http://robokits.co.in/shop/index.php?main_page=product_info&cPath=2_71&products_id=364)
so how can i control this motor with arduino uno R3 and use potentiometer as analog input ??

RMCS220x_DCServo+Driver_5.pdf (503 KB)

Read the pot through an analog input ( will be 0 to 1023), Per the data sheet the servo expects 600 to 2400 microsecond PWM pulses with 1500 microseconds servo centered. Use map(0,1023,600,2400) to map the pot output to the servo input. Use Servo.write() to send value to servo.
Look at the examples in the servo library that comes with the IDE to see how to set up for servos. Do not try to power the servo with the arduino power supply.

int potVal = analogRead(potPin);
potVal = map((0,1023,600,2400);
Servo.write(potVal);

map() reference file:///C:/Program%20Files/Arduino/Arduino%20ERW%201.0.4/reference/Map.html

I can't help feeling you will be wasting a lot of the capability of that motor if you control it just with a PWM signal. How will you get any position feed back? Why not use the I2C interface which will leave your Arduino serial connections free?

I presume you bought the motor because you need the encoder facility and not because it got mixed up with a hobby R/C servo which is a completely different thing - unfortunately using the same name.

...R

Robin is right. Servo lib will not allow reading information from the servo. As the OP only mentioned controlling the servo, I was trying to keep it simple. He seems to want to control 3 such servos. Serial (UART) communication is required to change the I2C address, so we seem to have come full circle.

Use a Mega2560 which has 4 USARTs. Probably cheaper than the motors.

...R

Trupalpatel:
I need to use arduino as 2 more servo has to be controlled
so is there any way that i can use arduino RDX and TXD port to control the motor

If you want to use tx/rx control for more than one servo, you will need more than one tx/rx serial port (mega), or multiplex the single serial output to the different servos from the single uno serial port.