ClearPath Servo Library & Info for Arduino

ClearPath Servos are AMAZING!

Using them with an Arduino UNO to get over 1,100 IPM rapids on a linear stage!

 

 

These ClearPath Servo’s are amazing.

Using an Arduino and ClearPath’s free diagnostic software, we get the motor lifting 34 lbs VERTICALLY at over 800 inches per minute!!

 

 

Library Updates

A new step & direction library has been released for use with Arduino and ClearPath motors. This update makes the library more user friendly and easier to read, as well as pushing important bug fixes.

Click here to download the latest libraries: https://github.com/Teknic-ClearPath/ClearPath-Arduino-Step-And-Direction

Updated Library Compatible LoopedSpeed Program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<pre class="aLF-aPX-K0-aPE">/*StepAndDirection
  Runs a Teknic Clearpath motor in step and direction mode, back and forth
  This example code is in the public domain.
 ** all step/dir pins have to be inserted into pins 8-13 (not including ~enable - enable can go anywhere)!
 */


#include <ClearPathMotorSD.h>
#include <ClearPathStepGen.h>

ClearPathMotorSD X; // initialize a Motor

ClearPathStepGen machine(&X);  //initialize the controller and pass the reference to the motor we are controlling

boolean IsSDHPmodel=false;
boolean IsSDSKmodel=true;

double TotalDistance=75000;     // distance in Steps - check step/rev in ClearPath MSP config file (1,600 steps/rev)  

void setup(){      
    Serial.begin(9600);
    X.attach(8,9,6,4);      //Direction/A is pin 8, Step/B is pin 9, Enable is pin 6, HLFB is pin 4  //JWS: HFLB = high level feedback info coming from motor to arduino
    X.setMaxVel(95000);  // Set max Velocity.  Parameter can be between 2 and 100,000
    X.setMaxAccel(1500000);  // Set max Acceleration.  Parameter can be between 4000 and 2,000,000
    X.enable();  // Enable motor, reset the motor position to 0 //JWS: enable happens automatically per Clearpath (whenever enabled) - no actual arduino code required
 
    Serial.print("Homing...");      // wait until the command is finished and then 1 more second
    while(!X.readHLFB()) {
        Serial.print('.');
      }
   
    Serial.println();
    Serial.println("Homing Complete");
    delay(200);
 
    machine.Start();     // Set up the ISR to constantly check motor position.

  }

void loop(){
    X.move(TotalDistance);
    Serial.print("Full Move...");
    while(!X.commandDone()||!X.readHLFB())
      {
        Serial.print('.');
      }
      Serial.println();
    Serial.println("Move Done");

    // Move the motor back to home
    X.move(-TotalDistance);
    Serial.print("Return Move...");
    while(!X.commandDone()||!X.readHLFB())
      {
        Serial.print('.');
      }
      Serial.println();
    Serial.println("Move Done");
}</pre>