Skip to content

Commit

Permalink
Remove initialize public method
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpolidoro committed Apr 24, 2023
1 parent 70733c8 commit a90da74
Show file tree
Hide file tree
Showing 12 changed files with 303 additions and 252 deletions.
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* Library Information
- Name :: TMC429
- Version :: 1.3.4
- Version :: 2.0.0
- License :: BSD
- URL :: https://github.com/janelia-arduino/TMC429
- Author :: Peter Polidoro
Expand Down
3 changes: 0 additions & 3 deletions examples/Communicating/Communicating.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ void setup()
Serial.begin(BAUD);

tmc429.setup(CHIP_SELECT_PIN,CLOCK_FREQUENCY_MHZ);

tmc429.initialize();

}

void loop()
Expand Down
1 change: 0 additions & 1 deletion examples/Communicating_ESP32/Communicating_ESP32.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void setup()
ledcWrite(0, 1);

tmc429.setup(CHIP_SELECT_PIN, CLOCK_FREQUENCY_MHZ);
tmc429.initialize();
}

void loop()
Expand Down
2 changes: 0 additions & 2 deletions examples/Limits/Limits.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ void setup()
Serial.begin(BAUD);

tmc429.setup(CHIP_SELECT_PIN,CLOCK_FREQUENCY_MHZ);

tmc429.initialize();
}

void loop()
Expand Down
96 changes: 96 additions & 0 deletions examples/RampMode/RampMode.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include <Arduino.h>
#include <TMC2209.h>
#include <TMC429.h>

const long SERIAL_BAUD_RATE = 115200;
const int BETWEEN_MOVE_DELAY = 2000;
const int CHECK_AT_POSITION_DELAY = 500;

// Stepper driver settings
HardwareSerial & serial_stream = Serial1;
// current values may need to be reduced to prevent overheating depending on
// specific motor and power supply voltage
const int RUN_CURRENT_PERCENT = 40;
const int MICROSTEPS_PER_STEP = 256;

// Instantiate stepper driver
TMC2209 stepper_driver;

// Stepper controller settings
const int CHIP_SELECT_PIN = 10;
const int CLOCK_FREQUENCY_MHZ = 32;
const int MOTOR_INDEX = 0;
const int STEPS_PER_REV = 200;
const int MICROSTEPS_PER_REV = STEPS_PER_REV*MICROSTEPS_PER_STEP;
const long REVS_PER_MOVE = 10;
const long TARGET_POSITION = REVS_PER_MOVE * MICROSTEPS_PER_REV;
const int ACCELERATION_MAX = 2 * MICROSTEPS_PER_REV;
const long ZERO_POSITION = 0;
const long VELOCITY_MAX = 2 * MICROSTEPS_PER_REV;
const long VELOCITY_MIN = 500;

// Instantiate stepper controller
TMC429 stepper_controller;

long target_position, actual_position;

void setup()
{
Serial.begin(SERIAL_BAUD_RATE);

stepper_driver.setup(serial_stream);
stepper_driver.setRunCurrent(RUN_CURRENT_PERCENT);
stepper_driver.enableAutomaticCurrentScaling();
stepper_driver.enableAutomaticGradientAdaptation();
stepper_driver.enableCoolStep();

stepper_controller.setup(CHIP_SELECT_PIN, CLOCK_FREQUENCY_MHZ);
stepper_controller.disableLeftSwitchStop(MOTOR_INDEX);
stepper_controller.disableRightSwitches();
stepper_controller.disableRightSwitchStop(MOTOR_INDEX);
stepper_controller.setLimitsInHz(MOTOR_INDEX, VELOCITY_MIN, VELOCITY_MAX, ACCELERATION_MAX);
stepper_controller.setRampMode(MOTOR_INDEX);

stepper_controller.setActualPosition(MOTOR_INDEX, ZERO_POSITION);
stepper_controller.setTargetPosition(MOTOR_INDEX, ZERO_POSITION);

stepper_driver.enable();
}

void loop()
{
actual_position = stepper_controller.getActualPosition(MOTOR_INDEX);
Serial.print("actual position: ");
Serial.println(actual_position);
Serial.println();
delay(BETWEEN_MOVE_DELAY);

Serial.print("set target position: ");
Serial.println(TARGET_POSITION);
stepper_controller.setTargetPosition(MOTOR_INDEX, TARGET_POSITION);
while (!stepper_controller.atTargetPosition(MOTOR_INDEX))
{
Serial.print("target position: ");
Serial.println(stepper_controller.getTargetPosition(MOTOR_INDEX));
Serial.print("actual position: ");
Serial.println(stepper_controller.getActualPosition(MOTOR_INDEX));
delay(CHECK_AT_POSITION_DELAY);
}
Serial.println("at target position!");
Serial.println();
delay(BETWEEN_MOVE_DELAY);

Serial.print("set target position: ");
Serial.println(ZERO_POSITION);
stepper_controller.setTargetPosition(MOTOR_INDEX, ZERO_POSITION);
while (!stepper_controller.atTargetPosition(MOTOR_INDEX))
{
Serial.print("target position: ");
Serial.println(stepper_controller.getTargetPosition(MOTOR_INDEX));
Serial.print("actual position: ");
Serial.println(stepper_controller.getActualPosition(MOTOR_INDEX));
delay(CHECK_AT_POSITION_DELAY);
}
Serial.println();
delay(BETWEEN_MOVE_DELAY);
}
110 changes: 0 additions & 110 deletions examples/TMC2209/TMC2209.ino

This file was deleted.

2 changes: 0 additions & 2 deletions examples/TMC429_TMC26X_EVAL/TMC429_TMC26X_EVAL.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ void setup()
bool communicating = step_dir_controller.communicating();
Serial << "communicating: " << communicating << "\n";

step_dir_controller.initialize();

const int microsteps_per_rev = STEPS_PER_REV*MICROSTEPS_PER_STEP;
velocity_max = microsteps_per_rev*REVS_PER_SEC_MAX;
velocity_inc = microsteps_per_rev/INC_PER_REV;
Expand Down
2 changes: 0 additions & 2 deletions examples/TestConnection/TestConnection.ino
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ void setup()

bool communicating = tmc429.communicating();
Serial << "communicating: " << communicating << "\n";

tmc429.initialize();
}

void loop()
Expand Down
68 changes: 68 additions & 0 deletions examples/VelocityMode/VelocityMode.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include <Arduino.h>
#include <TMC2209.h>
#include <TMC429.h>

const long SERIAL_BAUD_RATE = 115200;
const int LOOP_DELAY = 1000;

// Stepper driver settings
HardwareSerial & serial_stream = Serial1;
// current values may need to be reduced to prevent overheating depending on
// specific motor and power supply voltage
const int RUN_CURRENT_PERCENT = 40;
const int MICROSTEPS_PER_STEP = 256;

// Instantiate stepper driver
TMC2209 stepper_driver;

// Stepper controller settings
const int CHIP_SELECT_PIN = 10;
const int CLOCK_FREQUENCY_MHZ = 32;
const int MOTOR_INDEX = 0;
const int STEPS_PER_REV = 200;
const int REVS_PER_SEC_MAX = 2;
const int MICROSTEPS_PER_REV = STEPS_PER_REV*MICROSTEPS_PER_STEP;
const int ACCELERATION_MAX = MICROSTEPS_PER_REV / 2;
const long VELOCITY_MAX = REVS_PER_SEC_MAX * MICROSTEPS_PER_REV;
const long VELOCITY_MIN = 50;

// Instantiate stepper controller
TMC429 stepper_controller;

long target_velocity, actual_velocity;

void setup()
{
Serial.begin(SERIAL_BAUD_RATE);

stepper_driver.setup(serial_stream);
stepper_driver.setRunCurrent(RUN_CURRENT_PERCENT);
stepper_driver.enableAutomaticCurrentScaling();
stepper_driver.enableAutomaticGradientAdaptation();
stepper_driver.enableCoolStep();

stepper_controller.setup(CHIP_SELECT_PIN, CLOCK_FREQUENCY_MHZ);
stepper_controller.disableLeftSwitchStop(MOTOR_INDEX);
stepper_controller.disableRightSwitches();
stepper_controller.setVelocityMode(MOTOR_INDEX);
stepper_controller.setLimitsInHz(MOTOR_INDEX, VELOCITY_MIN, VELOCITY_MAX, ACCELERATION_MAX);

stepper_driver.enable();
}

void loop()
{
delay(LOOP_DELAY);

stepper_controller.setTargetVelocityInHz(MOTOR_INDEX, VELOCITY_MAX);
Serial.print("set target_velocity: ");
Serial.println(target_velocity);
Serial.print("at target_velocity: ");
Serial.println(stepper_controller.atTargetVelocity(MOTOR_INDEX));

target_velocity = stepper_controller.getTargetVelocityInHz(MOTOR_INDEX);

actual_velocity = stepper_controller.getActualVelocityInHz(MOTOR_INDEX);
Serial.print("actual_velocity: ");
Serial.println(actual_velocity);
}
3 changes: 1 addition & 2 deletions library.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name=TMC429
version=1.3.4
version=2.0.0
author=Peter Polidoro <[email protected]>
maintainer=Peter Polidoro <[email protected]>
sentence=Trinamic TMC429 triple-axis dedicated step and direction motion controller.
paragraph=Like this project? Please star it on GitHub!
category=Device Control
url=https://github.com/janelia-arduino/TMC429.git
architectures=*
depends=Streaming
Loading

0 comments on commit a90da74

Please sign in to comment.