0

Help with "stepper" motor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help with "stepper" motor

by tammclaughlin on Sun May 02, 2021 2:24 pm

Hi,
I am trying to create a miniature revolving stage where the stage will revolve 180 degrees and using a stepper motor (28BYJ48) and itsy bitsy M0.
Presently I can't get it to move as I am only testing with 3V. Waiting on some battery packs to give 5V but though I would see some movement with 3V.
In any case, I wonder if a servo motor would also work?
When the itsy bitsy is powered on I would want the motor to reset to that the stage is facing the correct way. Is this possible?
Would it be easier to use a servo motor that can be controlled in such an accurate way?

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by adafruit_support_bill on Sun May 02, 2021 2:30 pm

Waiting on some battery packs to give 5V but though I would see some movement with 3V.

You should see some movement at 3v. The torque will just be about about 60% of max.

When the itsy bitsy is powered on I would want the motor to reset to that the stage is facing the correct way. Is this possible?
Would it be easier to use a servo motor that can be controlled in such an accurate way?

That is simpler to do with a servo motor, since it has position feedback. To do it with a stepper, you would need to add a limit switch to detect when it reached the 'home' position at startup.

adafruit_support_bill
 
Posts: 81559
Joined: Sat Feb 07, 2009 10:11 am

Re: Help with "stepper" motor

by tammclaughlin on Sun May 02, 2021 2:53 pm

Thanks.

I have just started on this project so likely not wired something up correctly but wanted to check if it would be easier with a servo before I started to debug.
Would the "TowerPro Servo Motor - MG92B 360°" suit my needs?
I am using circuitpython

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by adafruit_support_bill on Sun May 02, 2021 3:05 pm

The MG92B 360 is not really a 'servo', since it has no position feedback: https://learn.adafruit.com/adafruit-mot ... ion-servos

You can control it with CircuitPython, but you would not have any control over the position - only the speed and direction of rotation.

The MG90D is a true 'servo' and would be a good choice for small projects: https://www.adafruit.com/product/1143
The MG995R has more torque for larger projects. https://www.adafruit.com/product/1142

Either can be controlled via CircuitPython.

adafruit_support_bill
 
Posts: 81559
Joined: Sat Feb 07, 2009 10:11 am

Re: Help with "stepper" motor

by tammclaughlin on Sun May 02, 2021 3:53 pm

Thanks.
The MG995R was not available so I ordered the MG99R which is an upgrade to the 5R.
Getting excited now :-)

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by tammclaughlin on Thu May 06, 2021 9:14 am

Hi,

I now have the MG996R connected to my itsy bitsy M0 and seeing a strange issue where the motor just keeps spinning. So I uploaded just the following code (lib imports not all shown)
I updated the circuit python firmware on the itsybitsy to the latest V6.


from adafruit_motor import servo
# Analog input on A1
analog1in = AnalogIn(board.A1)
#servo_pwm = pulseio.PWMOut(board.D12, frequency=50)
servo_pwm = pulseio.PWMOut(board.D12, duty_cycle=2 ** 15, frequency=50)
servo = servo.Servo(servo_pwm)

while True:

for angle in range(0, 180, 5):
print ("running servo angle" + str(angle))
servo.angle = angle
time.sleep(1)
print ("done servo steps")


And what I see is the the servo runs continuous in multiple rotations clockwise for the angles 0 to 45 and then rotates the opposite way in as expected in small angles with the delay and then from 95 onwards it continues in the same direction in a continuous motion before stopping at 180.
Any ideas what's going on?

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by adafruit_support_bill on Thu May 06, 2021 9:27 am

I'm not familiar with that model. But from what you describe, it sounds like a continuous rotation 'servo'.

According to the ServoDatabase, there are both 180 degree and 360 degree versions of it.
https://servodatabase.com/servo/towerpro/mg996r

The Tower website does not offer any useful details on that.
https://www.towerpro.com.tw/product/mg996r/

adafruit_support_bill
 
Posts: 81559
Joined: Sat Feb 07, 2009 10:11 am

Re: Help with "stepper" motor

by tammclaughlin on Thu May 06, 2021 9:42 am

The one I bought does say 360 degrees on it.
This is the one: https://thepihut.com/products/towerpro- ... 3179440190

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by tammclaughlin on Thu May 06, 2021 9:44 am

I have now bought the MG90D as this was one of the ones recommended above.

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by tammclaughlin on Thu May 06, 2021 9:45 am

I wonder if the strange behaviour was also to do with power fluctuations as every so often the micro controller would go into safe mode as it could not
supply enough power to the motor.

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by adafruit_support_bill on Thu May 06, 2021 10:28 am

Power could definitely be a problem if you are trying to power it through the microcontroller. Servos are pretty power hungry. They also generate a lot of electrical noise which can interfere with the processor as well.

adafruit_support_bill
 
Posts: 81559
Joined: Sat Feb 07, 2009 10:11 am

Re: Help with "stepper" motor

by tammclaughlin on Fri May 07, 2021 9:55 am

Hi,
I am now using an MG90D and it it working as expected.
Thanks for the help.

Tam

tammclaughlin
 
Posts: 10
Joined: Tue Jun 25, 2019 7:02 am

Re: Help with "stepper" motor

by adafruit_support_bill on Fri May 07, 2021 10:07 am

Good to hear! Thanks for the follow-up.

adafruit_support_bill
 
Posts: 81559
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.