Problems with Adafruit Motorshield v2.3 and Arduino Due

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

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
m41er
 
Posts: 6
Joined: Tue Jul 05, 2022 3:48 am

Problems with Adafruit Motorshield v2.3 and Arduino Due

Post by m41er »

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

#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
solder point on the motor shield
solder point on the motor shield
adafruitshield.jpg (33.96 KiB) Viewed 499 times

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

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

Post by adafruit_support_bill »

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

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

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

Post by m41er »

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?

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

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

Post by adafruit_support_bill »

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

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

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

Post by m41er »

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 446 times
98E60B67-D350-45F6-B0F7-CCDF8F64B803.jpeg
98E60B67-D350-45F6-B0F7-CCDF8F64B803.jpeg (401.38 KiB) Viewed 446 times

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

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

Post by adafruit_support_bill »

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

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

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

Post by m41er »

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

Code: Select all

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?

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

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

Post by adafruit_support_bill »

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

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;
}

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

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

Post by m41er »

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?

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

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

Post by adafruit_support_bill »

The function prototype from the header file is: https://github.com/adafruit/Adafruit_Mo ... orShield.h

Code: Select all

bool begin(uint16_t freq = 1600, TwoWire *theWire = &Wire);
So your call to

Code: Select all

AFMS.begin(); 
translates to:

Code: Select all

AFMS.begin(1600, &Wire); 
And you should be able override the wire parameter with:

Code: Select all

AFMS.begin(1600, &Wire1); 

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

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

Post by m41er »

Thank you very much! It works :D

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

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

Post by adafruit_support_bill »

Good to hear! Thanks for the update.

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

Return to “Arduino Shields from Adafruit”