using motorshield v1 with Stepper.h

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
StKn
 
Posts: 5
Joined: Fri Jun 28, 2024 10:45 am

using motorshield v1 with Stepper.h

Post by StKn »

Hello,

we have inherited an arduino with a motorshield v1 and a stepper. The stepper is connected to M3 & M4. We can operate the stepper with AFMotor.h https://github.com/adafruit/Adafruit-Mo ... ld-library without issues.

However since AFMotor is depreciated and we wanted to get some new steppers we plan to operate with Stepper.h https://www.arduino.cc/reference/en/libraries/stepper/ curiosity got me and i tried to run the motorshield v1 with stepper.h, but failed

i assume that the stepper has to be set up with the pins 4,7,8,12 used to operate the motorshield v1. The stepper constructor takes 4 pins as an argument, but the motorshield also seems to use pin 5 and 6. I randomly tried some combinations of these pins in the constructor (tried to read AFMotor.cpp and match with stepper.cpp but my knowledge did not suffice). This ended with the h-bridge smelling and a high temperature (it survived though), thus i aborted and now i am here

is it possible to operate the ada shield v1 with stepper.h? Can someone give a minimum working example?

best regards

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

Re: using motorshield v1 with Stepper.h

Post by adafruit_support_bill »

It is not possible to operate the V1 shield with stepper.h. You will need to use the AFMotor library.

Stepper.h assumes a direct mapping of Arduino pins to the legs of an H-Bridge. The V1 motor shield uses the Arduino pins to control a shift-register that interfaces to the H-Bridges. This frees up other pins so that they can be used to implement microstepping via PWM.

User avatar
StKn
 
Posts: 5
Joined: Fri Jun 28, 2024 10:45 am

Re: using motorshield v1 with Stepper.h

Post by StKn »

hey bill,

many thanks for the helpful answer! i think i undertsand the adafruit board a lot better now. Just to be sure i undertsood everything:
- the adafruit shield v1 features a latch, which enables the operation of two h-bridges. this replaces the direct mapping to a single h-bridge
- this latch was again replaced on the adafruit shield v2 by the I2C compatible TB6612 which again is operated by a adafruit motor class, but can also operate multiple steppers at once

is this correct?

Extending on the Adafruit shield v2: The original reason we thought about the stepper class was that we wanted to operate a stepper that requires more current (2-6A). However the ability of the adafruit board v2 to operate multiple steppers is impressive. Is there a adafruit fruit board that is stackable like the v2 shield and can power 4 steppers with up to 2A (from my glance at the shop, there are only boards with up to 1,2A)?

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

Re: using motorshield v1 with Stepper.h

Post by adafruit_support_bill »

- the adafruit shield v1 features a latch, which enables the operation of two h-bridges. this replaces the direct mapping to a single h-bridge
- this latch was again replaced on the adafruit shield v2 by the I2C compatible TB6612 which again is operated by a adafruit motor class, but can also operate multiple steppers at once

is this correct?
Almost.

* The latch was replaced by a PCA9685 PWM generator chip. This chip has an i2c interface. And it also eliminates the need to use all the PWM-capable GPIO pins from the Aruduino.
* The TB6612 are H-Bridge chips which replace the L293D H-Bridge chips from the V1. This doubles the current capability from 0.6A to 1.2A.
Is there a adafruit fruit board that is stackable like the v2 shield and can power 4 steppers with up to 2A (from my glance at the shop, there are only boards with up to 1,2A)?
We stock the Synthetos gShield which can handle up to 3 steppers with up to 2.5A/phase.
https://www.adafruit.com/product/1750

The TinyG does not stack. But can handle 4 steppers at 2.5A/phase.
https://www.adafruit.com/product/1749

User avatar
StKn
 
Posts: 5
Joined: Fri Jun 28, 2024 10:45 am

Re: using motorshield v1 with Stepper.h

Post by StKn »

had a look at tinyG and gShield and at the tinyG wiki, it seems to be operated with "coolterm". Also they seem to be tailored for CNC applications, but we need to controll our steppers indepently.

Is there a way/class to operate the tinyG steppers similar to the adafruit AFMotor class?

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

Re: using motorshield v1 with Stepper.h

Post by adafruit_support_bill »

Not sure about the tinyG, but the steppers on the gShield are controlled directly via Arduino pins and can be operated independently using the stepper library.

Another option would be to use stepper driver breakouts from Pololu. These are relatively inexpensive and work well with the stepper library: https://www.pololu.com/category/120/ste ... or-drivers

User avatar
StKn
 
Posts: 5
Joined: Fri Jun 28, 2024 10:45 am

Re: using motorshield v1 with Stepper.h

Post by StKn »

thanks again. Tried some more research on how to operate the gShield with stepper.h, but it seems to to be used mostly/exculsively with grbl.

Do you, by chance, know the pins to use with the stepper constructor for the gShield or any guide / documentation?

i found some older answers from you going this direction, but i could not yet figure out on how to do this specific gShield stepper.h set up
viewtopic.php?t=162805
viewtopic.php?t=90982

maybe more context: we want to operate two mechanical units to move a "probe" in x-y direction. These probes are a little heavy, thus stronger steppers. The ability to operate a shield with two steppers would make a nice logical organzition of the project. My current undertstanding/preference is that i would use 2x (Arduino uno R3 + gShield v5 + 2*NEMA 23)

The (pseudo) code on the arduino would look like similar to this

Code: Select all

#include <Stepper.h>

// create an instance of the stepper class, specifying
// the number of steps of the motor and the pins it's
// attached to
// https://www.arduino.cc/reference/en/libraries/stepper/stepper/
//      stepper(STEPS, p, p, p, p);

Stepper stepperX(200, ?, ?, ?, ?); <- what i am looking for
Stepper stepperY(200, ?, ?, ?, ?);

// the setup function runs once when you press reset or power the board
void setup() {
  Serial.begin(9600);
  ...
}

// the loop function runs over and over again forever
void loop() {
  if(Serial.Input(move:100)
    stepperX.step(100)
}
edit: the synthetos forums seem inactive, but i also tried to contact their support

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

Re: using motorshield v1 with Stepper.h

Post by adafruit_support_bill »

Do you, by chance, know the pins to use with the stepper constructor for the gShield or any guide / documentation?
Synthetos publishes the schematics here. It uses drivers with a 'step and direction' interface. So you need just 2 pins per motor. One to trigger a step and one to select the direction.
https://github.com/synthetos/grblShield ... ic_pg1.pdf

The step pins for motors X, Y and Z are D2, D3 and D4. The direction pins for motors X, Y and Z are D5, D6 and D7.
My current undertstanding/preference is that i would use 2x (Arduino uno R3 + gShield v5 + 2*NEMA 23)
Yes. Each gShield can handle up to 3 motors.

User avatar
StKn
 
Posts: 5
Joined: Fri Jun 28, 2024 10:45 am

Re: using motorshield v1 with Stepper.h

Post by StKn »

thanks for all the help!

am i correct to assume that the gShield will work with this
https://www.reichelt.de/hybridschrittmo ... os_4&nbc=1
https://cdn-reichelt.de/documents/daten ... S9820B.pdf
stepper in the " 测试二 " (second column) configuration?
It will draw 1.4A, while the gShield can yield 2.5

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

Re: using motorshield v1 with Stepper.h

Post by adafruit_support_bill »

The actual maximum current draw for a stepper motor is determined by Ohm's Law which is a function of the motor's phase resistance and the supply voltage. However, more advanced drivers like the one on the gShield have active current limiting. This lets you use a higher supply voltage for better performance, while limiting the peak current level to protect the motors, drivers and power supply from damaging current levels.
https://learn.adafruit.com/all-about-st ... he-stepper

This page shows how to set the current limits on the gShield.
https://discuss.inventables.com/t/setti ... imit/14998

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”