Shiva WROTE:Sorry for didn't mention it previously.
I have 2 versions, Modified and Unmodified. Both are having the same problems. I can't use unmodified servo and keeps on giving them pulse, cos the rotation will keeps on going and I'm afraid will spoil the motor.
Therefore, what I could do for unmodified is I gave 1ms, it turned, and then I increased the duty cycle, it still happens the same and I directly stop the testing.
Shiva, please be clear on what you want to ask as this will lead forumer to different recommendation and solution. Cytron only sell C36 for modified servo (except for special request) and the modified servo from Cytron only have 2 wires. In your case, since you mentioned that the servo you have is C40 and have 3 wires, so we will assume you are using standard servo.
But you also mention that it keep rotating in right direction, a standard servo cannot rotate in a direction 360 degree or continuously, the boundary is only 180 degree. That is the reason Aurora and I ask you whether is modified or unmodified servo. I have checked the sample source code provided in product page. The sample source code actually generate pulses with the pulse width of 0.7ms for 50 times and jump to generate pulses width of 2.0ms for another 50 times. It will then keep looping between these 2 routines to generate pulses of 0.7ms and 2.0ms. If everything works nicely and connection is correct, the servo should will rotate clockwise, stop a while , rotate anti clockwise, stop a while and repeat until you stop the PIC or power off.
If you are using the sample source code, how do you give 1 ms and change in the middle of program running? Because the sample code is generating 0.7ms and 2.0ms pulses only. If you have edited the sample source code, have you compile it and load the new hex code to your PIC board with a programmer? Another concern is about giving pulses, not pulse. From your statement, you said you give 1ms, is the pulse being generated continuously? You need to generate continuous pulse, thus it come the "pulses".
I would really recommend you to check the pulses from PIC to servo signal pin with an oscilloscope.
You can check the unmodified servo by turning the servo horn clock wise or anti clock wise when it is unpowered. A standard servo have boundary for 180 degree only. It should have a stopper to limit the rotation. Of course don't use force to rotate until you break the stopper.