Page 1 of 1

STC1000 for dummies for a dummy?

Posted: Mon Apr 22, 2019 10:45 pm
by hlaps1990
Hi,

I'm making a desktop injection molding machine and I thought I'd try Phidgets to control the two stepper motors, four heaters, two thermocouples and a limit switch.

I'm using:
1 x HUB0000 (Maybe an SBC some day)
2 x STC1000
1 x REL1100
1 x TM1101

Right now I'm stuck at step one: Making the steppers rotate. Everything seems to connect fine, and the motors work in the Phidgets control panel and examples, but I can't seem to get them to work using my Python script. The important exerpts are:

Code: Select all

    import sys
    import time
    from Phidget22.Devices.Stepper import *
    from Phidget22.PhidgetException import *
    from Phidget22.Phidget import *

    stp1 = Stepper()
    
    stp1.openWaitForAttachment(1000) #Seems to work fine
    stp1.setAcceleration(500000) #Value from console experimenting
    stp1.setVelocityLimit(35000) #Value from console experimenting
    stp1.setCurrentLimit(1.0) #Didn't see units in API, assuming 1 amp
    stp1.setControlMode(0x0) #Verbatim from API documentation, seems weird
    stp1.setEngaged(True) #Enable Stepper
    stp1.setTargetPosition(10000) #Random trial position from console
    time.sleep(5) # Assuming setTargetPosition isn't blocking
    stp1.setEngaged(False) #Disable after use
The script seems to connect, I can hear the fan on the power supply speed up when the driver is enabled, but the motor does not move. I am reasonably familiar with Python and use it for scripting motion control devices at work a lot, but I'm having a really hard time following all of the event handlers and layers of classes and libraries. I've poured over all of the examples on the Phidgets site but the Python examples seem more like guided tours of capability rather than simple "make a motor rotate 1 rev" or "read a temperature" examples. Any advice?

Re: STC1000 for dummies for a dummy?

Posted: Tue Apr 23, 2019 10:11 am
by mparadis
It took me a while to get to the bottom of this one but it turns out that calling setControlMode will always set your velocity limit to zero. This is intentional, so that your motor won't just start running when switching from step to run mode, and so that you don't end up with a negative velocity limit in step mode. I'll add something to the API that explains this behavior.

Anyways, step mode is the default so you can just remove that line and your program will work.

Re: STC1000 for dummies for a dummy?

Posted: Sun Apr 28, 2019 5:14 pm
by hlaps1990
Thanks mparadis, that fixed it! I've asked for Phidgets help a few times now and it feels like you always suggest something I swear I've tried before but I try it again because you told me to and it works :P!