Using a Servo

Hello all.  I am an extreme Noobie  and have a question for you gurus.  I have built my own printer from scrap printers.  I have the X,Y, and Z axis all set up and calibrated.  Now my question is how could I set up a servo in Repetier-Firmware to activate a servo to control a cheap EBay 3d pen?

This is where I got the idea from; http://www.instructables.com/id/Super-Cheap-3D-Printer-From-CD-Rom-Drives/?ALLSTEPS


Thank you all for any help

Comments

  • You simply configure a servo in firmware. You can have up to 4. Then control it with M340 where needed. The pin you configure is the signal pin of your servo. Make sure to have extra power supply for it. Taking 5V from board is normally a very bad idea as servos draw too much current.







    - M340 P<servoId> S<pulseInUS> R<autoOffIn ms>: servoID = 0..3, Servos are controlled by a pulse with normally between 500 and 2500 with 1500ms in center position. 0 turns servo off. R allows automatic disabling after a while.

  • Thank you for the response.  I'll dig through the code and find where I need to enable it.
  • edited September 2016
    I have tried that and I get "Unknown Command:N12 M340 S500 P0""
  • You have to enable serve feature in configuration.h to get the command. Only defining the pin is not enough!
  • This is what I have in configuration.h .  I am using a Mega 2560 with RAMPS 1.4 board.


    /* ======== Servos =======
    Control the servos with
    M340 P<servoId> S<pulseInUS>   / ServoID = 0..3  pulseInUs = 500..2500
    Servos are controlled by a pulse width normally between 500 and 2500 with 1500ms in center position. 0 turns servo off.
    WARNING: Servos can draw a considerable amount of current. Make sure your system can handle this or you may risk your hardware!
    */
    #define FEATURE_SERVO 1
    #define SERVO0_PIN 12
    #define SERVO1_PIN -1
    #define SERVO2_PIN -1
    #define SERVO3_PIN -1
    #define SERVO0_NEUTRAL_POS  1500
    #define SERVO1_NEUTRAL_POS  0
    #define SERVO2_NEUTRAL_POS  0
    #define SERVO3_NEUTRAL_POS  0
    #define UI_SERVO_CONTROL 1
    #define FAN_KICKSTART_TIME  200

            #define FEATURE_WATCHDOG 1



    Am I missing anything else??

  • In Commands.cpp you have

    #if FEATURE_SERVO
    case 340: // M340
    if(com->hasP() && com->P<4 && com->P>=0) {
    int s = 0;
    if(com->hasS())
    s = com->S;
    uint16_t r = 0;
    if(com->hasR()) // auto off time in ms
    r = com->R;
    HAL::servoMicroseconds(com->P,s,r);
    }
    break;
    #endif // FEATURE_SERVO

    so with #define FEATURE_SERVO 1 you should have that command. Not sure what you can do to not have it when you set it.
  • Leave it to me to break something that can't be broken, LOL

    Thanks for all your help.  I'll try and figure out what I broke.

  • I got it figured out.


  • How did you solve this. Enabling Feature_Servo does not add that to the command and adding this trows error that do not compile
Sign In or Register to comment.