Python device # leading 00

I’m new to Steppers, tic’s and Python but I have read that in Python,Raspberry Pi 4, I can’t use leading OO’s for the device serial #. I tried the alternative device # and that didn’t work. I really need to define devices as I need to move each one a specific amount. I can address each one in the control center and terminal. I’m using 6 -
T 500.

My code in Python is:
ticcmd (‘d’, ‘00331613’, ‘- -position’ ‘20’)
I may have another issue in this but I can’t seem to even address the correct device leaving out the position. Suggestions, Thanks.

I was able to make this happen on one device. Found I forgot to use -d and I used quotes like “########” for device serial #. Now to move on to moving more than one motor. I’m using a GUI so I have to use define and then somehow list all the devices and how much to move them.
Any help appreciated.

Hello.

It sounds like you might be trying to write your own GUI, is that correct? Can you post your full code? Also, can you run ticcmd --list and post the results? Have you looked at the “Example code to run ticcmd in Python” section in the Tic Stepper Motor Controller User’s Guide?

- Amanda

Amanda, I am now able to address each device in my code, 3 so far, I think…I’m unable to fully test because I do not have motors yet and will not be delivered until the end of the month. There are green LED blinks on each Tic when I run and test my GUI. To answer your questions I was able to address then using the ticgui and list them in terminal. Yes I did run the example code and it worked for 1 Tic only. More than one throws an error message indicating that there is more than 1 device and I need to unplug all but 1 from usb. You may notice that I used 2 lines of the example code at the beginning of my GUI code. It would not run without it. I tried commenting that out line by line and it wouldn’t go. I am enclosing my GUI code. There are some commented out sections because I started this using some DC motors and the GPIO on the Pi 4. I’m doing all of my work writing code on the Pi.
Happy Pi Day!

# Importing Libraries

from tkinter import *
import tkinter.font
import subprocess
import yaml
# from ticcmd import ticcmd


# Libraries Imported


    

# tkinter GUI basic settings

Gui = Tk()
Gui.title("Slat Stepper Motor Control with Pi 4")
Gui.config(background= "#0060FF")
Gui.minsize(511,400)
Font1 = tkinter.font.Font(family = 'Helvetica', size = 9, weight = 'bold')

# tkinter GUI created

    

def ticcmd(*args):
    return subprocess.check_output(['ticcmd'] + list(args))

    
def MotorPos1():
    ticcmd('-d',"00331613",'--position', "100")
    ticcmd('-d',"00331629",'--position', "50")
    ticcmd('-d',"00331609",'--position', "110")
     

 
 
def MotorPos2(): 
    ticcmd('-d',"00331613",'--position', "100")
    ticcmd('-d',"00331629",'--position', "50")
    ticcmd('-d',"00331609",'--position', "10")
 
 
 
 
def MotorPos3():
    ticcmd('-d',"00331613",'--position', "75")
    ticcmd('-d',"00331629",'--position', "50")
    ticcmd('-d',"00331609",'--position', "100")
     

 
 
def Closed():
    ticcmd('-d',"00331613",'--position', "0")
    ticcmd('-d',"00331629",'--position', "0")
    ticcmd('-d',"00331609",'--position', "0")
     


#def MotorStop():
    #GPIO.output(16, GPIO.LOW) # Motor a and b will stop.
    #GPIO.output(18, GPIO.LOW)
    #GPIO.output(19, GPIO.LOW)
    #GPIO.output(24, GPIO.LOW)
    
#def ChangePWM(self):
    #ena.ChangeDutyCycle(Scale1.get())
    #enb.ChangeDutyCycle(Scale1.get())

#Scale1 = Scale(Gui, from_=0, to=100, orient = HORIZONTAL, resolution = 1, command = ChangePWM)
#Scale1.grid(row=4,column=2)

Text2 = Label(Gui,text='Set Positions Above', font = Font1, fg='#FFFFFF', bg = '#0060FF')
Text2.grid(row=2,column=2,columnspan=2)

#Text3 = Label(Gui,text='Set Move Speed', font = Font1, fg='#FFFFFF', bg = '#0060FF')
#Text3.grid(row=3,column=2,)


photo = PhotoImage (file='/home/pi/motor_slats/Slats_1resize2.png')
photo1 = PhotoImage (file='/home/pi/motor_slats/Slats_2resize2.png')
photo2 = PhotoImage (file='/home/pi/motor_slats/Slats_3resize.png')
photo3 = PhotoImage (file='/home/pi/motor_slats/Slats_closed.png')



##Button1 = Button(Gui, text='A-Clockwise', font = Font1, command = MotorClockwise, bg='bisque2', height = 0, width = 10)
#Button1.grid(row=4,column=0)

#Button2 = Button(Gui, text='All-Stop', font = Font1, command = MotorStop, bg='bisque2', height = 0, width = 10)
#Button2.grid(row=4,column=1)

#Button2 = Button(Gui, text='A-AntiClockwise', font = Font1, command = MotorAntiClockwise, bg='bisque2', height = 0, width = 10)
#Button2.grid(row=4,column=4)

Button2 = Button(Gui, command = MotorPos3, image= photo1, text = 'Position 3', compound= "center")
Button2.grid(row=0,column=3,)

Button2 = Button(Gui, command = MotorPos2, image= photo2, text = 'Position 2', compound= "center")
Button2.grid(row=0,column=2,)

Button0 = Button(Gui, command = MotorPos1, image= photo, text = 'Position 1', compound= "center")
Button0.grid(row=0,column=1,rowspan=2)

Button2 = Button(Gui, command = Closed, image= photo3, text = 'Closed', compound= "center")
Button2.grid(row=0,column=4,)



Text3 = Label(Gui,text='A Learning Project By Mike Knight', font = Font1, bg = '#0060FF', fg='#FFFFFF', padx = 25, pady = 25)
Text3.grid(row=6, column=2, columnspan=2)
#ticcmd('--exit-safe-start', '--position', str(new_target))
Gui.mainloop()

Thank you for the information. That’s great you’re able to resolve the problem with communicating with more than one Tic in your code. If you need more help or have additional questions, please let me know.

- Amanda