Hi,
I'm trying to implement a TMC5160 as a stepper motor controller for the tilt on a PTZ security camera. The tilt is configured so there is only one limit switch, located at the bottom of travel. We are talking to the controller over a RS485 line, so the code I am using is directly writing to the registries using Python.
The code I am using has two distinct modes of travel - "Absolute", in which the controller has an exact pan or tilt distance to travel, and "Relative", in which the axis will move at a variable speed and distance as directed by a joystick. Setting up the limits in absolute mode is no problem - it can be set mathematically using the number of steps that the drive has, and the controller can filter that input before sending the command to the TMC.
The biggest challenge I am struggling with is the fact I have no upper reference switch for the upper part of the travel. The motor will stall when the axis hits the hard stop, and then I loose my zero on the tilt axis. I messed around with stallguard, and found a speed where it can activate successfully, but that is where I reach a roadblock - There does not seem to be any way to set this limit in the TMC5160 registers, and stallguard appears to be rather unreliable with a variable speed system to actually implement.
Is there a way to set up an automatic position stop using one of the position registers like XACTUAL or XLATCH? I'm going to investigate on the software side to see if I can implement a stop on that side