Open jkozniewski opened 1 month ago
Check #66 and let me know if it helped
Hi, I think I might know what the problem is, see datasheet pg no 38 and pg no 39 `https://www.analog.com/media/en/technical-documentation/data-sheets/TMC2209_datasheet_rev1.09.pdf
Especially pg no 39
For the automatic tuning to work properly, a tuning procedure is required first, morever are you setting the IRUN
and IHOLD
values properly in your code?
I think with your full code it will be easier to help you
Hi - thanks for your feedback. In the end I've ditched UART mode, as for some reasons it started to work pretty decently in standalone mode (I guess I might did some stupid mistake with not setting ENABLE pin in the right state, curiously the motor runs regardless of wether ENABLE is high or low, which should not happen, and also in standalone mode it seems I can't really achieve true freewheeling behaviour - when disabled the the holding torque is just a bit less then when enabled....)
Another thing - I have switched to 24v since just now I've learned that I should not be worried about motor voltage rating and 12v can, and even should be driven by higher voltage - like 24v which substantially helped with the torque / speed...
Nonetheless in terms of UART and this library - i have encountered this "tuning procedure" but found none info of how should such procedure be performed - any insights regarding this matter @peterpolidoro ? As for IRUN
/ IHOLD
values - didn't find any examples of how to set them via library is it related to this example - https://github.com/janelia-arduino/TMC2209/blob/main/examples/UnidirectionalCommunication/Standstill/Standstill.ino ?
Seems that in standalone mode when disabled via ENABLE pin it defaults to something other than FREEWHEELING
- my guess would be NORMAL
or BRAKING
?
Hi, yes you almost always want to use a much higher voltage power supply than your motor voltage rating when the driver provides current control. The motor generates back-emf when it spins so you need higher power supply voltage to be able to supply enough current to the motor. The bigtreetech boards say they can go up to 28V, so using 28V will be able to provide the most current (torque) at higher speeds. Using a 12V power supply for a 12V motor will mean that you have almost no current available when you spin at speed so the torque will be super low and the motor might stop spinning altogether.
The tuning procedure is described in detail in the datasheet. I have found that sometimes it is easy to do properly and sometimes it is difficult, depending on the exact setup. So for this library, I default to disabling the automatic current scaling and automatic gradient adaptation because I have found they perform poorly in some setups. Anyone is free, however, to enable them and perform the tuning procedure and see if they can get it to work well.
You also have a good point about the library defaulting to low torque. Again, however, I do this on purpose to make it less likely that someone will blindly hook up a small motor and accidentally fry it. Again, anyone is free to increase the settings to use higher current as long as the power supply is up to the task.
You should be able to do anything in UART mode that you can do in standalone mode. I prefer UART mode since it gives total control over the driver, but you do have to know about the settings which can take a lot of datasheet reading. The freewheeling mode can be set with one of the library methods. The motor should freewheel when you set the hold current to zero: stepper_driver.setHoldCurrent(0); and you set the standstill mode to freewheeling: stepper_driver.setStandstillMode(stepper_driver.FREEWHEELING);
Thanks for clarification - all makes sense. Though it would be great to have some code example of actually performing the automated tuning procedure (even if it's not performed by default by the library for good reason you have mentioned) - I've read the docs and it's seems to be indeed described in detail but I'm not sure I understand everything to be able to translate it into code directly and small details might probably derail whole procedure making it hard to test / debug.
That explains why my 2A stepper only draws around 0.5A, sometimes even less (not moving in that case) and recently it started drawing a lot more power
I observed some weird behaviors that when I have the ESP32 connected via USB to the PC and use an external power supply the stepper is a lot slower than when I power the esp32 through a 12V -> 5V converter. All GND are connected through a ground plane on the pcb. I guess that this is related to me not doing the calibration procedure, resulting in random current draw.
From the datasheet I found this graphic, is this the calibration procedure for the current scaling? (This is for stealth chop? but the mentioned flags seem to suggest that it calibrates the current adaption?)
So to calibrate the stepper, you do the following:
enableAutomaticCurrentScaling()
and enableAutomaticGradientAdaptation()
(not sure if you have to enable stealth chop explicitly as well?)stepper_driver.enable()
(this should charge the coils of the stepper motor, so it shouldn't move freely anymore?)delay(300)
is enough?)PWM_GRAD_AUTO
, I guess this is the enableAutomaticGradientAdaptation()
, so one can skip the medium speed movement calibration?Is this it or did I miss something?
I have not tried the tuning procedure because for my application it is not required, however I have a few comments
TPWM_THRS
to 0 to always work in stealthchop mode.PDN_UART
pin is grounded, which means you are operating the driver in stand alone modePWM_GRAD
the function enableAutomaticGradientAdaptation()
should be calledWill try it out myself when I get the time, for now I am trying to get the sensorless homing working.
I spent the last few days tweaking my code and reading the datasheet. Some things are still broken (the stepper is quite loud, even though I enabled StealthChop), but it is in a useable state.
Be careful about the current, I tried the code with a stepper motor that is rated for up to 2A (I am not even able to reach that current, likely because of the sense resistor on the pcb only working up to 1.77A). Therefore, it uses the entire range for the current from 0 to 100 (only the check_stall function would have to be adjusted and the constant for the run current).
Because you mentioned that you have low torque, I added my stall guard code that automatically increases/decreases the current when it does not have enough torque.
Not sure what your setup is, but I am pretty sure that you do not want to use the internal sense resistor. The pcbs with the chip on it, like this one
already have an external sense resistor on the pcb.
I get very low torque as well when I select the internal sense resistor. I haven't figured out how to configure it correctly, but the external sense resistor (selected by default) works fine.
Hello - I'm testing the TMC2209 BIGTREETECH v 1.3 drivers without UART config and no matter which microstepping option I set via MS1/MS2 pins or what potentiometer value I set (tested max clockwise / counterclockwise positions) the motor has almost no torque I can stop the shaft by just gently grabbing / pressing it and any higher speed just makes the motor to vibrate instead of turning because of so low power.
I have tested the same stepper with A4988 driver and even with max microstepping it has much greater torque.
Then I have used this library and providing settings via UART and managed to get more torque setting PWM offset / gradient manually to max values:
although that makes stepper hot and much louder than with automatic settings:
that on the other hand give almost no torque - just like in standalone mode....
So is this default almost useless torque of TMC2209 BIGTREETECH v 1.3 something to be expected from those drivers or am I doing something terribly wrong ?
For the reference I'm using 200 steps / rev, 0.5A current 12v stepper, powered by 12v power supply rated for 3.0A and as for microcontrollers I have used Arduino UNO and Teensy 4.1 (and Pico PI in standalone only mode as there seem to be no library for TMC2209 on this platform unfortunately).
Anyone experienced same situation ? I'd be grateful for any hints of how ro optimally setup the drivers either via this lib or any hardware-related means ? BTW - I have also posted an issue at Bigtreetech github - https://github.com/bigtreetech/BIGTREETECH-TMC2209-V1.2/issues/19