As you can see, I have tried adding it before recreating it here, but no luck. After creating it again, I copy the files from the library on my computer into the corresponding directories, but when trying particle library add TMC5160 I get the following error:
I managed to successfully (I think) import the TMCStepper library and include it in my project. However, when compiling a sample code sketch from the library, I receive a couple of errors as per the image attached. This same sketch complies successfully in Arduino IDE though.
Below is the code and a screen grab of the errors.
#include <TMCStepper.h>
#define EN_PIN 6 // Enable
#define DIR_PIN 5 // Direction
#define STEP_PIN 4 // Step
#define CS_PIN A2// Chip select
#define SW_MOSI A5 // Software Master Out Slave In (MOSI)
#define SW_MISO A4 // Software Master In Slave Out (MISO)
#define SW_SCK A3 // Software Slave Clock (SCK)
//#define SW_RX 63 // TMC2208/TMC2224 SoftwareSerial receive pin
//#define SW_TX 40 // TMC2208/TMC2224 SoftwareSerial transmit pin
//#define SERIAL_PORT Serial1 // TMC2208/TMC2224 HardwareSerial port
//#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f // Match to your driver
// SilentStepStick series use 0.11
// UltiMachine Einsy and Archim2 boards use 0.2
// Panucatt BSD2660 uses 0.1
// Watterott TMC5160 uses 0.075
// Select your stepper driver type
//TMC2130Stepper driver(CS_PIN, R_SENSE); // Hardware SPI
//TMC2130Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK); // Software SPI
//TMC2660Stepper driver(CS_PIN, R_SENSE); // Hardware SPI
//TMC2660Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK);
//TMC5160Stepper driver(CS_PIN, R_SENSE);
TMC5160Stepper driver(CS_PIN, R_SENSE, SW_MOSI, SW_MISO, SW_SCK);
//TMC2208Stepper driver(&SERIAL_PORT, R_SENSE); // Hardware Serial
//TMC2208Stepper driver(SW_RX, SW_TX, R_SENSE); // Software serial
//TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
//TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);
void setup() {
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW); // Enable driver in hardware
// Enable one according to your setup
SPI.begin(); // SPI drivers
//SERIAL_PORT.begin(115200); // HW UART drivers
//driver.beginSerial(115200); // SW UART drivers
driver.begin(); // SPI: Init CS pins and possible SW SPI pins
// UART: Init SW UART (if selected) with default 115200 baudrate
driver.toff(5); // Enables driver in software
driver.rms_current(600); // Set motor RMS current
driver.microsteps(16); // Set microsteps to 1/16th
//driver.en_pwm_mode(true); // Toggle stealthChop on TMC2130/2160/5130/5160
//driver.en_spreadCycle(false); // Toggle spreadCycle on TMC2208/2209/2224
driver.pwm_autoscale(true); // Needed for stealthChop
}
bool shaft = false;
void loop() {
// Run 5000 steps and switch direction in software
for (uint16_t i = 5000; i>0; i--) {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(160);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(160);
}
shaft = !shaft;
driver.shaft(shaft);
}
Since the library is not public in the Particle library repository but contains loads of files itβs not that easy to debug your issue with Web IDE.
Maybe Workbench would be better.
I have not. I downloaded the library from Github and then uploaded as is. My first time having to import a library so had some difficulties along the way
I was not aware I had to include anything else as art is quite and extensive library. I am using the TMC2808 drivers at present without any libraries, but need ton upgrade to TMC5160 and seems due to SPI the library is needed.
I will try with Workbench even though I am not very familiar with it. I would still like to get the library working on Web IDE tough in order to be able to use OTA in future on this project as apposed to updating via USB all the time. I also tink there might be more people that could benefit from this library, or am I maybe the only one trying to drive stepper motors with Particle
I worked with Workbench a bit more and notice the cloud compile and flash. Apologies for the lack of knowledge, still learning and seems like a lot to take in in small amount of time, but doing my best
When compiling Workbench seems to present the same error even though the library is successfully imported in Workbench. adding it to Workbench seemed easy enough, so doubt I made a mistake there. These drivers seems to be a headache