I just got a new Futaba S3003 in, and I installed it on my plotter. When I set the servo to it's "zero" position with universal Gcode sender by sending the "M5" message to my Arduino, it rotates about 60 degrees (counter clockwise). When I try to rotate it to the 20 degrees mark, it turns 20 more degrees in the direction it has already turned (counter clockwise). How do I make the zero position the point at which the servo hasn't rotated at all from its minimum position?
The "read me" file on the github page has the following information:
you can change the pulse duration in the file spindle_control.c:
define RC_SERVO_SHORT 15 // Timer ticks for 0.6ms pulse duration (9 for 0.6ms)
define RC_SERVO_LONG 32 // Timer ticks for 2.5 ms pulse duration (39 for 2.5ms)
define RC_SERVO_INVERT 1 // Uncomment to invert servo direction
If you want to have the servo working from 0 --> 180 degrees change RC_SERVO_SHORT and put 9, RC_SERVO_LONG and put 39 If you want invert the servo direction uncomment the line above.
Are C_SERVO_SHORT and C_SERVO_LONG what I need to change in order to change the pulse width though? I altered the values to what I posted above and reuploaded everything, but I don't think anything changed.
Try this test sketch with the Servo library to see how your servo responds to different settings, type a position (0 to 180) or if you type a number greater than 200 it will be interpreted as microseconds, in the top of serial monitor and hit [ENTER], start at 90 (or 1500) and work your way toward zero 5 degrees (or 50 micros) at a time, then toward 180 (2400?).
#include <Servo.h>
Servo servo;
int pos = 0;
void setup() {
// initialize serial:
Serial.begin(9600); //set serial monitor baud rate to match
servo.attach(9);
}
void loop() {
// if there's any serial available, read it:
while (Serial.available() > 0) {
// look for the next valid integer in the incoming serial stream:
int pos = Serial.parseInt();
pos = constrain(pos, 0, 2400);
servo.write(pos);
Serial.print(" degrees = ");
Serial.print(servo.read());
Serial.print("\t");
Serial.print("microseconds = ");
Serial.println(servo.readMicroseconds());
}
}
Keep in mind, the Arduino servo library has a default refresh time of 20000 microseconds, if your library has a different refresh rate you may have to adjust accordingly, for example the servo library has a minimum pulse width (0 degrees) of 544 uS, 1500 uS (90 deg) and max of 2400 uS (180 deg). If your lib has a refresh rate of, say, 5000 then 5000 / 20000 = 0.25, you may have to multiply all the above pulse widths by that number.
The G codes M2, M3 & M5 are for spindle motor control and usually followed by a speed command like, "M2, S300", totally separate from Z axis commands like "G1, Z2.5,F0.2". I thought you were using the servo to move the Z axis?