PWM Control of Stepper Motor - Timer Stop Input - Python - U6 | LabJack
 

PWM Control of Stepper Motor - Timer Stop Input - Python - U6

2 posts / 0 new
Last post
labjake
labjake's picture
PWM Control of Stepper Motor - Timer Stop Input - Python - U6

Hello,

Totally new at programming LabJacks with Python here. I'm trying to send numSteps number of steps to a stepper motor driver. When I run the following code, however, it runs indefinitely.

I have FIO0 jumpered to FIO1, where FIO0 sends the pulsed signal to the driver, and FIO1 is the counter.

Also, is there any way to send a specific number of PWM pulses without jumpering and counting the pulses in the second FIO?

Thank you,

Jake

import u6

d = u6.U6()
d.getFeedback(u6.BitDirWrite(0, 1), u6.BitDirWrite(1, 0))   # Set FIO0 to digital output

numSteps = 700
s = ""

d.configTimerClock(TimerClockBase = 2)
d.configIO(NumberTimersEnabled = 2, TimerCounterPinOffset=0)
d.getFeedback(u6.Timer0Config(TimerMode = 0, Value = 32768), u6.Timer1Config(TimerMode = 9, Value = int(numSteps)))
s = input("Press enter to exit.")

d.configIO(NumberTimersEnabled = 0)    
d.close()

 

LabJack Support
LabJack Support's picture
What issues are you seeing?

What issues are you seeing? Is the program just not getting to the "Press enter to exit" output and are you seeing any errors?

Your code looks okay and when I run it, it stops the PWM output after the desired number of pulses. Additionally, nothing from LabJackPython in your script should block it from finishing unless there is some communication error (and a timeout error should likely occur in that case).

If you are not doing so already, I would recommend removing all external connections besides USB and the FIO0-FIO1 jumper for testing. Please also ensure your FIO0 and FIO1 screw terminals are tightly screwed down on the jumper wire.