0

Problems with Adafruit Motorshield v2.3 and Arduino Due
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Wed Jul 06, 2022 10:29 am

I try to control a stepper motor with an Adafruit Motor Shield v2.3 using an Arduino Due.
The Shield is configured to 3.3V logic corresponding to the instellation guide.
I tested the shield with an Arduino uno R3 and it works fine before switching it to 3v and it still works fine with the 3v logic jumper connected. I tested my solder point and there is only a connection to the 3V pin and no connection to 5V (even though it looks like a mess).
The Program I'm using is the same for the uno and due and I'm out of Ideas how I can get the thing to work.

On the due I get the "error!" message over the serial monitor.

It is crusical for me to be using an due. An uno or uno wifi hasn't enough sram for my project.... sadly

This is the code I use:
Code: Select all | TOGGLE FULL SIZE
#include <AccelStepper.h>
#include <Adafruit_MotorShield.h>


Adafruit_MotorShield AFMS(0x60); // Default address, no jumpers

// Connect two steppers with 200 steps per revolution (1.8 degree)
// to the top shield
Adafruit_StepperMotor *myStepper = AFMS.getStepper(200, 1);


// you can change these to DOUBLE or INTERLEAVE or MICROSTEP!
// wrappers for the first motor!
void forwardstep1() {
  myStepper->onestep(BACKWARD, SINGLE);
}
void backwardstep1() {
  myStepper->onestep(FORWARD, SINGLE);
}

// Now we'll wrap the 3 steppers in an AccelStepper object
AccelStepper stepper(forwardstep1, backwardstep1);

void setup()
{
  Serial.begin(9600);
  Serial.println("Setup!");
  if (!AFMS.begin())
  {
    Serial.println("error!");
  }

  stepper.setMaxSpeed(500.0);
  stepper.setAcceleration(50.0);
  stepper.moveTo(200);
}

void loop()

    // Change direction at the limits
    if (stepper.distanceToGo() == 0)
   stepper.moveTo(-stepper.currentPosition());

    stepper.run();
}


Thanks in advance!
Attachments
adafruitshield.jpg
solder point on the motor shield
adafruitshield.jpg (33.96 KiB) Viewed 133 times

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Wed Jul 06, 2022 10:31 am

Please post photos showing all of your soldering to the shield.

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

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Wed Jul 06, 2022 10:41 am

Sadly that’s all I get. It’s only the message “error!” indicating that the begin() function did return false. Is there a way I can get more information why it failed?

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Wed Jul 06, 2022 1:57 pm

Please post photos showing all of your soldering to the shield.

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

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Fri Jul 08, 2022 12:34 pm

These are my soldering points of the stacking headers. I check all of them with a multimeter and they look fine.
Attachments
59550440-CC3F-42BC-8291-4F23D3A87149.jpeg
59550440-CC3F-42BC-8291-4F23D3A87149.jpeg (306.53 KiB) Viewed 80 times
98E60B67-D350-45F6-B0F7-CCDF8F64B803.jpeg
98E60B67-D350-45F6-B0F7-CCDF8F64B803.jpeg (401.38 KiB) Viewed 80 times

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Fri Jul 08, 2022 12:38 pm

Those all look fine. Other than the logic voltage level, the only other difference between connecting to an UNO and a Due is the pins used for i2c.

One more thing to try: Run the i2c scanner and report the results: https://learn.adafruit.com/scanning-i2c ... es/arduino

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

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Fri Jul 08, 2022 12:53 pm

I used the code provided and changed the wire to "wire1" and got this result in the serial monitor:

Code: Select all | TOGGLE FULL SIZE
18:38:18.495 -> Scanning...
18:38:18.495 -> I2C device found at address 0x60  !
18:38:18.543 -> I2C device found at address 0x70  !
18:38:18.590 -> done


Do I have to define wich wire to use to work with the shield? and how can I do that?

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Fri Jul 08, 2022 12:57 pm

Yea, Arduino didn't follow their own standard with the Due. There is an optional parameter on the begin() function to pass in a pointer to a wire interface to use:

Code: Select all | TOGGLE FULL SIZE
bool Adafruit_MotorShield::begin(uint16_t freq, TwoWire *theWire) {
  // init PWM w/_freq
  _pwm = Adafruit_MS_PWMServoDriver(_addr);
  if (!_pwm.begin(theWire))
    return false;
  _freq = freq;
  _pwm.setPWMFreq(_freq); // This is the maximum PWM frequency
  for (uint8_t i = 0; i < 16; i++)
    _pwm.setPWM(i, 0, 0);
  return true;
}

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

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Fri Jul 08, 2022 1:09 pm

Thanks, but I'm a bit lost here. How do I call the function and pass the correct wire?

Also did I just not find it on the learning Site (https://learn.adafruit.com/adafruit-mot ... o/overview) or is this part missing?

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Fri Jul 08, 2022 1:18 pm

The function prototype from the header file is: https://github.com/adafruit/Adafruit_Mo ... orShield.h
Code: Select all | TOGGLE FULL SIZE
bool begin(uint16_t freq = 1600, TwoWire *theWire = &Wire);


So your call to
Code: Select all | TOGGLE FULL SIZE
AFMS.begin();

translates to:
Code: Select all | TOGGLE FULL SIZE
AFMS.begin(1600, &Wire);


And you should be able override the wire parameter with:
Code: Select all | TOGGLE FULL SIZE
AFMS.begin(1600, &Wire1);

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

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by m41er on Fri Jul 08, 2022 1:47 pm

Thank you very much! It works :D

m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Re: Problems with Adafruit Motorshield v2.3 and Arduino Due

by adafruit_support_bill on Fri Jul 08, 2022 1:59 pm

Good to hear! Thanks for the update.

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

Please be positive and constructive with your questions and comments.