-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bigtree and M4 Express; communication not working #59
Comments
How does it fail exactly? Your code seems to compile. Do you mean that when you run it you are unable to communicate with the TMC2209? Do you have an oscilloscope? Can you look at the serial lines and see if it is sending the messages properly? |
Thx for replying promptly. d:......\Arduino\Sketches\libraries\TMC2209\src\TMC2209\TMC2209.cpp: In member function 'void TMC2209::setup(HardwareSerial&, long int, TMC2209::SerialAddress, int16_t, int16_t)': exit status 1 Compilation error: exit status 1 |
What happen when you run your code with the unmodified TMC2209 library files? You should be already setting the alternate pins in your code, you should not need to do that inside the TMC2209 library code as well. |
With stepper_driver.setup(serial_stream); unmodified library ; serial2, |
I will have to read about sercom to know more about how to fix it. |
Thank you again for your quick answer.
In the meantime, I am enjoying your library on serial 1. A very nice and good product.
Quite complicated chip with all its possibilities! Digging in the datasheet now!
On the sercom: I did test the serial2 while configured with the sercom coding. That worked on A2,A3. Tested with oscilloscope.
I am sorry but I mislead you in my last mail saying it did not compile.
I restarted the IDE and used the program below on the Adafruit M4 Express. Now it compiles, but there is no output on the (sercom pins) A2 and A3. (Oscilloscope)
The IDE says : “stepper not communicating”.
Joost
The sketch:
#include <Arduino.h>
#include <TMC2209.h>
#include "wiring_private.h"
// Serial2 on SERCOM4
#define PIN_SERIAL2_RX A3 // RX
#define PIN_SERIAL2_TX A2 // Tx
#define PAD_SERIAL2_RX (SERCOM_RX_PAD_1)
#define PAD_SERIAL2_TX (UART_TX_PAD_0)
const long SERIAL_BAUD_RATE = 19200;
Uart Serial2(&sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
//Uart Serial3(&sercom0, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
// Instantiate TMC2209
TMC2209 stepper_driver;
HardwareSerial & serial_stream = Serial2; // this should connect the Rx and Tx pins to the library
void SERCOM4_0_Handler()
{
Serial2.IrqHandler();
}
void SERCOM4_1_Handler()
{
Serial2.IrqHandler();
}
void SERCOM4_2_Handler()
{
Serial2.IrqHandler();
}
void SERCOM4_3_Handler()
{
Serial2.IrqHandler();
}
void setup()
{
//Serial.begin(115200);
Serial.begin(115200);
while (!Serial) {}
Serial.println("Begin set-up");
Serial2.begin(115200);
// Assign pins 12 & 13 SERCOM functionality
pinPeripheral(PIN_SERIAL2_RX, PIO_SERCOM_ALT);
pinPeripheral(PIN_SERIAL2_TX, PIO_SERCOM_ALT);
//stepper_driver.setup(serial_stream, SERIAL_BAUD_RATE, TMC2209::SERIAL_ADDRESS_0, PIN_SERIAL2_RX, PIN_SERIAL2_TX);
stepper_driver.setup(serial_stream);
Serial.println("Set-up completed");
}
void loop()
{
Serial.println("start loop");
if (stepper_driver.isSetupAndCommunicating())
{
Serial.println("Stepper driver is setup and communicating!");
Serial.println("Try turning driver power off to see what happens.");
}
else if (stepper_driver.isCommunicatingButNotSetup())
{
Serial.println("Stepper driver is communicating but not setup!");
Serial.println("Running setup again...");
stepper_driver.setup(serial_stream);
}
else
{
Serial.println("Stepper driver is not communicating!");
Serial.println("Try turning driver power on to see what happens.");
}
Serial.println();
stepper_driver.getVersion();
stepper_driver.getSettings();
delay(2000);
}
From: Peter Polidoro ***@***.***>
Sent: Friday, 15 March 2024 00:14
To: janelia-arduino/TMC2209 ***@***.***>
Cc: Oegtsgeest ***@***.***>; State change ***@***.***>
Subject: Re: [janelia-arduino/TMC2209] Bigtree and M4 Express; communication not working (Issue #59)
I will have to read about sercom to know more about how to fix it.
—
Reply to this email directly, view it on GitHub <#59 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACZKROZI6J4GSMXSQPU4OYTYYIVMJAVCNFSM6AAAAABES6ZBJOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJYGYZDQMRXGQ> .
You are receiving this because you modified the open/close state. <https://github.com/notifications/beacon/ACZKROY2LQTDHOIJWHLHUNLYYIVMJA5CNFSM6AAAAABES6ZBJOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTXECS3E.gif> Message ID: ***@***.*** ***@***.***> >
…--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
|
Hi,
My setup with an Adafruit M4-expressboard with a bigtree TMC2209 works when I use serial1.
However I need the serial1 fo a GPS shield, so I created Serial2 by using sercom code.
This created serialport on A3 (Rx) and A2 (Tx) is tested seperately and works.
But I can not get it to work with the TMC2209. The biderectional testcommunication program fails.
Probably it has to do that I need an alternate Rx and Tx? But I do not understand then why the HardwareSerial & serial_stream = Serial2 statement does not work.
Would it be enough if I change all the ESP32 words for for SAMD51 in the TMC2209.h and TMC2209.cpp?
This before I start messing with the library. :-)
Please find below the code of the program.
Help is appreciated.
Joost
#include <Arduino.h>
#include <TMC2209.h>
#include "wiring_private.h"
// Serial2 on SERCOM4
#define PIN_SERIAL2_RX A3 // RX
#define PIN_SERIAL2_TX A2 // Tx
#define PAD_SERIAL2_RX (SERCOM_RX_PAD_1)
#define PAD_SERIAL2_TX (UART_TX_PAD_0)
const long SERIAL_BAUD_RATE = 115200;
Uart Serial2(&sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
// Instantiate TMC2209
TMC2209 stepper_driver;
HardwareSerial & serial_stream = Serial2; // this connects the Rx and Tx pins to the libary
void SERCOM4_0_Handler() // required to get sercom4 working
{
Serial2.IrqHandler();
}
void SERCOM4_1_Handler()
{
Serial2.IrqHandler();
}
void SERCOM4_2_Handler()
{
Serial2.IrqHandler();
}
void SERCOM4_3_Handler()
{
Serial2.IrqHandler();
}
void setup()
{
Serial.begin(115200);
while (!Serial) {}
Serial.println("Begin set-up");
Serial2.begin(115200);
// Assign pins 12 & 13 SERCOM functionality
pinPeripheral(PIN_SERIAL2_RX, PIO_SERCOM_ALT);
pinPeripheral(PIN_SERIAL2_TX, PIO_SERCOM_ALT);
stepper_driver.setup(serial_stream);
Serial.println("Set-up completed");
}
void loop()
{
Serial.println("start loop");
if (stepper_driver.isSetupAndCommunicating())
{
Serial.println("Stepper driver is setup and communicating!");
Serial.println("Try turning driver power off to see what happens.");
}
else if (stepper_driver.isCommunicatingButNotSetup())
{
Serial.println("Stepper driver is communicating but not setup!");
Serial.println("Running setup again...");
stepper_driver.setup(serial_stream);
}
else
{
Serial.println("Stepper driver is not communicating!");
Serial.println("Try turning driver power on to see what happens.");
}
Serial.println();
stepper_driver.getVersion();
stepper_driver.getSettings();
delay(2000);
}
The text was updated successfully, but these errors were encountered: