0

Steppers sometimes not running smoothly
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Steppers sometimes not running smoothly

by AnnBel on Wed Jul 24, 2019 4:32 pm

Hi

I have 2 stepper motors connected to a RPi and sometimes they do not run smoothly:
- running together : working fine
- 1 running separately : also fine
- other running separately: not running smoothly

My test : after 5 sec I switch the runs:
both running > ok
time.sleep(5)
1 running > disturbed
time.sleep(5)
both running > ok
time.sleep(5)
other running > ok

Is it a technical issue? Or can I change my programming code ?

Thx

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by AnnBel on Wed Jul 24, 2019 4:33 pm

(I'm starting and stopping the steppers using multiprocessing (Process.start & .terminate) and kit.stepper.release command

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by adafruit_support_carter on Wed Jul 24, 2019 4:46 pm

It's probably related to the multi-threading. Can you recreate the issue with a non-threaded example?

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

Re: Steppers sometimes not running smoothly

by AnnBel on Wed Jul 24, 2019 5:00 pm

Ok thank you, I'll try that.
Is it a solution to work with signal library > kill signal when stopping the process ?

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by adafruit_support_carter on Wed Jul 24, 2019 6:16 pm

That's more of a multi-threading question and would depend on your program. For now, just see if you can recreate the issue with the most simple program possible.

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

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 1:51 am

Hi ,

In the most simple scenario (without threading) I cannot run the steppers correctly.
Steppers are blocking the program.

I'm using the following logic:

for i in range(fictive number to run steppers for undefined time):
for i in range(200):
kit.stepper.onestep()

after 5 sec I try to switch (time.sleep(5)) but these code is ignored because steppers are blocking the main thread.

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 12:14 pm

Hi

I'm sorry but would you please provide an alternative / resolution?

Thank you a lot

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by adafruit_support_carter on Thu Jul 25, 2019 12:41 pm

If you ignore threading/blocking for now, does this simple program drive the stepper(s) as expected?
https://github.com/adafruit/Adafruit_Ci ... pletest.py

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

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 2:25 pm

indeed if I run them separately (with basic code) they both do not run correctly

When running together, they run perfectly

What can be the root cause & solution ?

Thank you

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by adafruit_support_carter on Thu Jul 25, 2019 3:34 pm

indeed if I run them separately (with basic code) they both do not run correctly

OK, let's investigate this. Can you post a photo of your setup showing how everything is connected.

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

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 3:46 pm

Thanks,
Hereby attached a photo of the my setup

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 3:47 pm

Photo

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 3:52 pm

Photo hereby attached
Attachments
20190725_213737_2.jpg
20190725_213737_2.jpg (158.25 KiB) Viewed 175 times

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Re: Steppers sometimes not running smoothly

by adafruit_support_carter on Thu Jul 25, 2019 4:04 pm

Thanks. The example is only written for one motor, then one attached to M1/M2, which is fine for testing. Can you provide more info on what "do not run correctly" means when running the example? Is it turning, but not smoothly? Or is it not turning at all?

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

Re: Steppers sometimes not running smoothly

by AnnBel on Thu Jul 25, 2019 4:11 pm

yes indeed, turning but not making rotations.

Here below what happens:

Both
for i in range(600):
kit.stepper1.onestep()
kit.stepper2.onestep()

>> spinning and making 3 rotations

1 of the 2 (seperately):
for i in range(600):
kit.stepper1.onestep()

>> spinning but not completing 3 rotations (1,5 rotation)

the other of the 2:

for i in range(600):
kit.stepper2.onestep()

>> spinning but not completing 3 rotations (0,5)

Thank you,

Kind regards, Ann

AnnBel
 
Posts: 48
Joined: Sat Apr 20, 2019 5:59 pm

Please be positive and constructive with your questions and comments.