How to use 24v Stepper motors?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

How to use 24v Stepper motors?

Post by Kit101 »

Hi,
Apologies if I've missed something but I can't seem to find any product that will let me control 1 or 2 24v stepper motors up to 1amp using raspberry pi and an Adafruit product. I would like to use something from Adafruit as I like the python library and support but if its not possible is there a different product for this? I've seen the L298N but I have no experience with that... yet.

Thanks.

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

The only thing we have is the DRV8871. But you will need 2 of them to drive a stepper. See this guide for details: https://learn.adafruit.com/current-limi ... th-drv8871

www.pololu.com carries a wider range of stepper drivers and will definitely have something that will handle 24V @ 1A/phase.

User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

Re: How to use 24v Stepper motors?

Post by Kit101 »

adafruit_support_bill wrote: Mon Jan 30, 2023 4:43 pm See this guide for details: https://learn.adafruit.com/current-limi ... th-drv8871
Thank you for this. While the guide talks about using higher amp motors, I cant see anything about using a higher voltage than a single board is rated for. This is the diagram shown:
Stepper+2DRV8871.JPG
Stepper+2DRV8871.JPG (70.68 KiB) Viewed 210 times
Is there a certain way of wiring it to allow for 24v?
Thanks

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

I cant see anything about using a higher voltage than a single board is rated for.
The DRV8871 is rated for up to 45v.

User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

Re: How to use 24v Stepper motors?

Post by Kit101 »

Sorry! I missed that. Are there any resources where I can learn how to control 2 DRB8871s using any of the adafruit python libraries? I see the example using a Arduino but I'm using raspberry pi and I'm not sure how to translate from one to the other...yet

Many thanks

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

It would be the same as for the DRV8833 - except AIN1 & AIN2 would go to IN1 and IN2 on one of the boards and BIN1 7 BIN2 would go to IN1 and IN2 on the other board.

https://learn.adafruit.com/adafruit-tb6 ... cuitpython

User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

Re: How to use 24v Stepper motors?

Post by Kit101 »

Hello,
Thanks for the help, I have set it up and used the example code which works fine. However I can't seem to adjust the speed of the motor I would usually adjust the delay (time.sleep) in order to do this, however changing the delay to anything other than 0.01 (for the most part) makes the motor judder back and forth, and stall rather than rotate. This didn't happen on when using the motor hat unless the delay was too short.
Any ideas why that might be?

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

Post some photos showing all your connections. And also please post the code you are using.

User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

Re: How to use 24v Stepper motors?

Post by Kit101 »

Hello,

Thanks for the help, it turned out to be quite simple and just some bad connections, so I've made some proper circuit boards and its going well.

I am still finding that some time.sleep values result in the stepper motor stepping erratically. Its more of a shuddering motion as if the coil order is wrong.

For context about my project I am building a motorised pan tilt head for fairly heavy cameras. I want control two stepper motors to for the pan and tilt. As a proof of concept, using an ADS1115, I have mapped a potentiometer to the delay value.

I'm wondering if there is a limitation from the pi as to how fast it can control a stepper motor? Or if the motor issues is some sort of hardware clock or frequency limitation, maybe the combination of the ADS1115 and the Pi. Here is my code so far:

Code: Select all

import time
import board
import busio
import digitalio
import adafruit_ads1x15.ads1015 as ADS
from adafruit_ads1x15.ads1015 import Mode
from adafruit_ads1x15.analog_in import AnalogIn
from adafruit_motor import stepper

# Create the I2C bus
i2c = busio.I2C(board.SCL, board.SDA)

# Create the ADC object using the I2C bus
ads = ADS.ADS1015(i2c,data_rate= 3300, mode= Mode.CONTINUOUS)

# Create single-ended input on channel 0
chan = AnalogIn(ads, ADS.P0)

# To use with a Raspberry Pi:
coils = (
    digitalio.DigitalInOut(board.D19),  # A1
    digitalio.DigitalInOut(board.D26),  # A2
    digitalio.DigitalInOut(board.D20),  # B1
    digitalio.DigitalInOut(board.D21),  # B2
)

for coil in coils:
    coil.direction = digitalio.Direction.OUTPUT

motor = stepper.StepperMotor(coils[0], coils[1], coils[2], coils[3], microsteps=None)

def map_speed(value):
    DELAY_MIN = float(0.1)
    DELAY_MAX = float(0.00045)
    chan_min = float(32)
    chan_max = float(26370)
    # assuming that value ranges from 32 to 26370
    # and the desired delay ranges from 0.01 to 0.5
    return DELAY_MIN + (chan_value - chan_min) * (DELAY_MAX - DELAY_MIN) / (chan_max - chan_min)


STEPS = 3000

for step in range(STEPS):
    chan_value = chan.value # read the potentiometer value
    delay = map_speed(chan.voltage)
    motor.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
    time.sleep(delay)
    print(delay)

    motor.release()
Here is the setup
photo1676217331.jpeg
photo1676217331.jpeg (176.76 KiB) Viewed 120 times
The pot will eventually be replaced by a decent analogue joystick. But if you know of an easier way of doing this I would love to hear it!


Thanks

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

Stepper motor torque will decrease as the step rate increases. This is due to the inductance of the windings. At some point, the torque will become weak enough that the motor will start missing steps and behaving erratically.

The exact point where that occurs depends on a number of variables, including the motor characteristics, the supply voltage, the driver and the load. It also depends somewhat on your software.

Accelerating a motor - especially from a dead stop - requires substantially more torque than maintaining a constant speed. Good motion control software uses smooth "jerkless" acceleration profiles to gradually bring the motor up to speed.

In addition to avoiding problems such as missed steps at startup, this reduces the overall stress on the mechanical system and the attached load. With a load like a camera, this is something you should probably look into.

User avatar
Kit101
 
Posts: 31
Joined: Sat Mar 21, 2020 6:30 am

Re: How to use 24v Stepper motors?

Post by Kit101 »

Interesting.

Power supply is plenty powerful enough. I have definitely seen cheap NEMA steppers doing 400rpm but they're using an Arduino, not sure if that makes any difference?

I have written code that ramps up and down. But what doesn't make sense is that there are random ranges of time.sleep values that cause the shuddering, not just when it reaches its max rpm. Which is why I'm wondering if it's the combination of the ADC and the pi?

This page talks about chopper drives, I could try different motor control boards if that might help? Could you recommend any?

Lastly, could I use pwm instead to get smoother results?

Thanks agai .

User avatar
adafruit_support_bill
 
Posts: 88089
Joined: Sat Feb 07, 2009 10:11 am

Re: How to use 24v Stepper motors?

Post by adafruit_support_bill »

there are random ranges of time.sleep values that cause the shuddering, not just when it reaches its max rpm.
Because stepper motors do move in discrete steps, they are susceptible to oscillations at resonant frequencies and their harmonics. The specific frequencies will depend on the physical characteristics of the motor and whatever it is connected to. You can mitigate this by avoiding problematic frequencies and/or using alternative stepping modes such as micro-steps to minimize excitation of the resonant frequencies.

It is possible to implement microstepping with the DRV8871 using PWM. But it is a software intensive process. A more straightforward method is to use a driver with built-in microstepping and acceleration profiles such as the Pololu TIC controllers: https://www.pololu.com/category/212/tic ... ontrollers

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”