Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

release() problems
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

release() problems

by kriz on Tue Jul 21, 2020 11:23 am

I use the https://www.adafruit.com/product/2348 with the correct steppers for a project and everything works fine. After doing the stepping I release() the steppers for obvious reasons (heat and power-consumption). it all works fine when I start my Python-script directly from the commandline:

python3 DMO_buiten.py

But when I run this script in rc.local (for autobooting) or directly from the commandline with "sudo"

sudo python3 DMO_buiten.py

Everything works except the release() function. I get this errror:

Traceback (most recent call last):
File "DMO_buiten.py", line 87, in <module>
kit.stepper1.release()
AttributeError: 'StepperMotor' object has no attribute 'release'

What I'm I doing wrong?
Thanks for the help in advance.

Kriz

kriz
 
Posts: 4
Joined: Tue Jul 21, 2020 4:40 am

Re: release() problems

by adafruit_support_carter on Tue Jul 21, 2020 12:39 pm

You probably have multiple and different libraries installed. When running via sudo, it is using something different.

Did you use sudo when you installed the library?
https://learn.adafruit.com/adafruit-dc- ... -3011591-3

adafruit_support_carter
 
Posts: 16268
Joined: Tue Nov 29, 2016 2:45 pm

Re: release() problems

by kriz on Wed Jul 22, 2020 1:45 pm

I have checked, uninstalled and re-installed all Adafruit stuff; the problem remains. This is the script:

Code: Select all | TOGGLE FULL SIZE
from adafruit_motorkit import MotorKit
from adafruit_motor import stepper
kit = MotorKit()

teller = 1
while (teller < 50) :
  kit.stepper1.onestep(direction=stepper.BACKWARD, style=stepper.DOUBLE)
  teller +=1

kit.stepper1.release()


Running "python3 TEST_release.py" works fine.
Running "sudo python3 TEST_release.py" returns this error.

Code: Select all | TOGGLE FULL SIZE
kit.stepper1.release()
AttributeError: 'StepperMotor' object has no attribute 'release'


Do you have any hint or clue what this can be?

Thanks for your reply in advance,
regards
Kriz

kriz
 
Posts: 4
Joined: Tue Jul 21, 2020 4:40 am

Re: release() problems

by adafruit_support_carter on Wed Jul 22, 2020 1:52 pm

Launch Python interactively with sudo:
Code: Select all | TOGGLE FULL SIZE
sudo python3

at the Python REPL prompt (>>>), run these commands:
Code: Select all | TOGGLE FULL SIZE
from adafruit_motor import stepper
dir(stepper)
dir(stepper.StepperMotor)

and post the output here, like this:
Code: Select all | TOGGLE FULL SIZE
>>> from adafruit_motor import stepper
>>> dir(stepper)
['__class__', '__file__', '__name__', '__version__', 'const', 'math', '__repo__', 'FORWARD', 'BACKWARD', 'SINGLE', 'DOUBLE', 'INTERLEAVE', 'MICROSTEP', 'StepperMotor']
>>> dir(stepper.StepperMotor)
['__class__', '__init__', '__module__', '__name__', '__qualname__', 'release', '_update_coils', 'onestep']
>>>

adafruit_support_carter
 
Posts: 16268
Joined: Tue Nov 29, 2016 2:45 pm

Re: release() problems

by kriz on Wed Jul 22, 2020 5:19 pm

In the meantime I was getting impatient and I did a re-install of Raspian and all the libraries necessary and guess what? It all works fine now.

I think you were right with that sudo was looking at another version of the stepper software. I think this happened when I was developing the stepper application.

I learned a lot and thanks again for your great support and help.

regards,

Kriz

kriz
 
Posts: 4
Joined: Tue Jul 21, 2020 4:40 am

Re: release() problems

by adafruit_support_carter on Wed Jul 22, 2020 5:28 pm

Yeah! Glad it's working now. Trying to clean up library installs and conflicting libraries, etc. can be a real pain. Sometimes the easiest way is to just start over like that. Good luck with your project. Have fun!

adafruit_support_carter
 
Posts: 16268
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.