Git Product home page Git Product logo

Comments (3)

Chr157i4n avatar Chr157i4n commented on June 12, 2024

Hey,

i guess you used Marlin with StallGuard on a 3D-printer (so a different setup).
I implemented the StallGuard-Feature while using pliers to "stall" the motor, which in my case worked perfectly.

I would suggest to test and determine the current first. Try to decrease the current until the motor starts to stall with your setup and the use like 10%-50% more current to reliable actuate the motor.
When you have determined your current you can try to find you StallGuard value.

In the set_vactual function you can use the show_stallguard_result parameter to print the stallguard result values while the motor is moving:

def set_vactual(self, vactual, duration=0, acceleration=0, show_stallguard_result=False, show_tstep=False):
self._stop = False
current_vactual = 0
sleeptime = 0.05
if(vactual<0):
acceleration = -acceleration
if(duration != 0):
self.log("vactual: "+str(vactual)+" for "+str(duration)+" sec", Loglevel.INFO.value)
else:
self.log("vactual: "+str(vactual), Loglevel.INFO.value)
self.log(str(bin(vactual)), Loglevel.INFO.value)
self.log("writing vactual", Loglevel.INFO.value)
if(acceleration == 0):
self.tmc_uart.write_reg_check(reg.VACTUAL, vactual)
if(duration != 0):
self._starttime = time.time()
current_time = time.time()
while((not self._stop) and (current_time < self._starttime+duration)):
if(acceleration != 0):
time_to_stop = self._starttime+duration-abs(current_vactual/acceleration)
#self.log("cur: "+str(current_time)+ "\t| stop: "+str(time_to_stop)+ "\t| vac: "+str(current_vactual)+ "\t| acc: "+str(acceleration), Loglevel.INFO.value)
if(acceleration != 0 and current_time > time_to_stop):
current_vactual -= acceleration*sleeptime
self.tmc_uart.write_reg_check(reg.VACTUAL, int(round(current_vactual)))
time.sleep(sleeptime)
elif(acceleration != 0 and abs(current_vactual)<abs(vactual)):
current_vactual += acceleration*sleeptime
#self.log("current_vactual: "+str(int(round(current_vactual))), Loglevel.INFO.value)
self.tmc_uart.write_reg_check(reg.VACTUAL, int(round(current_vactual)))
time.sleep(sleeptime)
if(show_stallguard_result):
self.log("StallGuard result: "+str(self.get_stallguard_result()), Loglevel.INFO.value)
time.sleep(0.1)
if(show_tstep):
self.log("TStep result: "+str(self.get_tstep()), Loglevel.INFO.value)
time.sleep(0.1)
current_time = time.time()
self.tmc_uart.write_reg_check(reg.VACTUAL, 0)
return not self._stop

In the datasheet of the TMC2209
https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_datasheet_rev1.08.pdf
on site 59 there are the following instructions:

INITIAL PROCEDURE FOR TUNING STALLGUARD SGTHRS

  1. Operate the motor at the normal operation velocity for your application and monitor SG_RESULT.
  2. Apply slowly increasing mechanical load to the motor. Check the lowest value of SG_RESULT
    before the motor stalls. Use this value as starting value for SGTHRS (apply half of the value).
  3. Now monitor the StallGuard output signal via DIAG output (configure properly, also set
    TCOOLTHRS to match the lower velocity limit for operation) and stop the motor when a pulse is
    seen on the respective output. Make sure, that the motor is safely stopped whenever it is stalled.
    Increase SGTHRS if the motor becomes stopped before a stall occurs.
  4. The optimum setting is reached when a stall is safely detected and leads to a pulse at DIAG in
    the moment where the stall occurs. SGTHRS in most cases can be tuned for a certain motion
    velocity or a velocity range. Make sure, that the setting works reliable in a certain range (e.g. 75%
    to 150% of desired velocity) and also under extreme motor conditions (lowest and highest
    applicable temperature).

from tmc2209_raspberry_pi.

rmalchow avatar rmalchow commented on June 12, 2024

hi christian,

awesome! this is really helpful. thank you very much. for my application - i was using a 3d printer board, but i only need one channel, and there's a raspi in the mix anyways - so it seems a waste to use a separate marlin board. i will try your suggestions, and hope i can lower my parts count :)

thanks!

.rm

from tmc2209_raspberry_pi.

Chr157i4n avatar Chr157i4n commented on June 12, 2024

Hey,

i will close this issue now.
If you have still problems with tuning StallGuard, feel free to reopen this issue.

from tmc2209_raspberry_pi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.