Ticcmd jumps to next line


I am using the ticcmd to run stepper motors for my project. For example when I run the ticcmd to tell my stepper motor to go to a certain position, the ticcmd doesn’t wait until the motor position has reached. Instead when I run the ticcmd it automatically goes to the next command in my script. I do not want this to happen.

Is there any way to fix this using the ticcmd.


I think pololu team can give you a better solution if you share your code and circuit connection.

We are trying to run a stepper motor to move an actuator to a position, and after it reaches that position we want the use the velocity to move until it hits a switch. But the ticcmd seems to not work sequentially and the second phase starts before the actuator reaches the required position.

#First using position argument:
   microsteps=$(echo $2*1600/72 | bc)
   ticcmd -d 00293724 --resume --position $microsteps 

   while 1>0
      pos=$(bash getpositions.sh 00293724 steps)

      if [[ $pos -eq "$microsteps" ]];then
         ticcmd -d 00293724 --deenergize

#Then in the next step using speed:
   microvelocity=$(echo $2*1600/72*10000 | bc)
   ticcmd -d 00293724 --resume -y $microvelocity
   ticcmd -d 00293724 --deenergize 

The second part starts before the first part is done.

There are a couple of ways you could go about doing something like that. A rudimentary way would be to have your program wait a long enough amount of time to let the motion to complete using the sleep command. Alternatively, for a more elegant, but complicated solution, you could repeatedly read the “Current position” variable and wait until it is equal to the target position you set. You can do this with ticcmd by running ticcmd --status --full, parsing the output, and extracting the “Current position” variable information you are interested in. You can find information about doing that in this post from David.


Is there a way to change how the ticcmd functions in order for it to not go to the next line? For example tweak it in the source code? Is this possible in bash?


I generally wouldn’t recommend trying to edit the source code of ticcmd unless you really know what you’re doing. You should be able to write bash script that waits until the commanded position has been reached, similar to the one you posted before. It sounds like that one is not working how you expect; could you post the contents of your getpositions.sh script?