How do I implement a home Limit Switch with a Tic Stepper?

I’m using a Tic 825 stepper controller (in I2C mode), Pololu stepper motor, and a lead screw for an Arduino project. When my project is first turned on, I want the stepper motor to move until it touches a limit switch so that I can establish a home position. I have all the hardware setup, the motors working and responding to basic commands, and I’m able to detect the limit switch (on a digital pin). I assume that I should create an Arduino loop that moves the stepper forward until the limit switch is tripped, and then stop the stepper. What is the best Tic commands to use to do that (i.e. keep the stepper moving until something happens)? Do you have any example Arduino code for this sort of application?

Hello.

It sounds like the “Halt and set position” command is what you are looking for. You can find more details on that command under the “Command reference” section in the Tic stepper motor controller user’s guide. We do not have an example that specifically does what you are describing, but you can find a few code examples in the Arduino library for the Tic showing how to use the Halt and set position command (e.g. I2CPositionControl).

By the way, in case you do not already know, you might consider using the Tic’s kill switch input feature. Any of the Tic’s control pins can be set to a “Kill switch” function, which is used as a digital input that can tell the Tic to stop moving the motor. When triggered, the Tic will decelerate to zero speed and hold position by default, but you can change this behavior with the “Soft error response” setting. More details about it are under the “Error handling” and “Pin configuration” sections of the user’s guide.

- Amanda

Amanda, Thank you. In my Arduino loop (that keeps looping until the limit switch is hit), what Tic command should I use to move the stepper motor forward?

Inside the loop, should I keep sending the tic.setTargetVelocity(2000000); command over and over again until the limit switch is tripped?

Or should I send the tic.setTargetVelocity(2000000); command prior to going into the loop? And just put a resetCommandTimeout(); in the loop so that it keeps going until stopped by the limit switch?

Based on your description, it seems that the “Set target velocity” command would work for your application. Both options sound fine, but the second option is better since it is not sending the same “Set target velocity” command repeatedly.

- Amanda

In the TIC Blog there is a setup with limit switches using the advances settings and Tic control pins scl, sda, tx, and rx

Hello, Joltnjoe333.

Thanks for pointing that out here. For everyone else, this is the blog post where we discuss the recently released firmware update that adds the limit switch feature:

-Nathan

A post was split to a new topic: Using a kill switch with the Tic