0

Makershed Motorshield_v1 w/ Metro M0 Express
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Makershed Motorshield_v1 w/ Metro M0 Express

by DarkenedLight on Fri Nov 08, 2019 12:37 am

Hi,

I am trying to use my adafruit motor sheild V1 with the Metro M0 Express, but I get an error when compiling the code.

Code: Select all | TOGGLE FULL SIZE
Arduino: 1.8.11 Hourly Build 2019/09/30 10:33 (Windows 10), Board: "Adafruit Metro M0 Express, Arduino, Off"

C:\arduino-nightly-windows\arduino-nightly\arduino-builder -dump-prefs -logger=machine -hardware C:\arduino-nightly-windows\arduino-nightly\hardware -hardware C:\Users\PowerOn\AppData\Local\Arduino15\packages -tools C:\arduino-nightly-windows\arduino-nightly\tools-builder -tools C:\arduino-nightly-windows\arduino-nightly\hardware\tools\avr -tools C:\Users\PowerOn\AppData\Local\Arduino15\packages -built-in-libraries C:\arduino-nightly-windows\arduino-nightly\libraries -libraries C:\Users\PowerOn\Documents\Arduino\libraries -fqbn=adafruit:samd:adafruit_metro_m0:usbstack=arduino,debug=off -ide-version=10811 -build-path C:\Users\PowerOn\AppData\Local\Temp\arduino_build_7726 -warnings=none -build-cache C:\Users\PowerOn\AppData\Local\Temp\arduino_cache_381780 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.bossac.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.8.0-48-gb176eee -prefs=runtime.tools.bossac-1.7.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0 -prefs=runtime.tools.bossac-1.8.0-48-gb176eee.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.8.0-48-gb176eee -prefs=runtime.tools.CMSIS-Atmel.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0 -prefs=runtime.tools.CMSIS-Atmel-1.2.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0 -prefs=runtime.tools.openocd.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino -prefs=runtime.tools.openocd-0.9.0-arduino.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino -prefs=runtime.tools.CMSIS.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -prefs=runtime.tools.CMSIS-4.5.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -verbose C:\Users\PowerOn\Documents\Arduino\sketch_nov07a\sketch_nov07a.ino
C:\arduino-nightly-windows\arduino-nightly\arduino-builder -compile -logger=machine -hardware C:\arduino-nightly-windows\arduino-nightly\hardware -hardware C:\Users\PowerOn\AppData\Local\Arduino15\packages -tools C:\arduino-nightly-windows\arduino-nightly\tools-builder -tools C:\arduino-nightly-windows\arduino-nightly\hardware\tools\avr -tools C:\Users\PowerOn\AppData\Local\Arduino15\packages -built-in-libraries C:\arduino-nightly-windows\arduino-nightly\libraries -libraries C:\Users\PowerOn\Documents\Arduino\libraries -fqbn=adafruit:samd:adafruit_metro_m0:usbstack=arduino,debug=off -ide-version=10811 -build-path C:\Users\PowerOn\AppData\Local\Temp\arduino_build_7726 -warnings=none -build-cache C:\Users\PowerOn\AppData\Local\Temp\arduino_cache_381780 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arm-none-eabi-gcc.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.arm-none-eabi-gcc-4.8.3-2014q1.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\arm-none-eabi-gcc\4.8.3-2014q1 -prefs=runtime.tools.bossac.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.8.0-48-gb176eee -prefs=runtime.tools.bossac-1.7.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.7.0 -prefs=runtime.tools.bossac-1.8.0-48-gb176eee.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\bossac\1.8.0-48-gb176eee -prefs=runtime.tools.CMSIS-Atmel.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0 -prefs=runtime.tools.CMSIS-Atmel-1.2.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.2.0 -prefs=runtime.tools.openocd.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino -prefs=runtime.tools.openocd-0.9.0-arduino.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\openocd\0.9.0-arduino -prefs=runtime.tools.CMSIS.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -prefs=runtime.tools.CMSIS-4.5.0.path=C:\Users\PowerOn\AppData\Local\Arduino15\packages\arduino\tools\CMSIS\4.5.0 -verbose C:\Users\PowerOn\Documents\Arduino\sketch_nov07a\sketch_nov07a.ino
Using board 'adafruit_metro_m0' from platform in folder: C:\Users\PowerOn\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.4
Using core 'arduino' from platform in folder: C:\Users\PowerOn\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.4
Detecting libraries used...
"C:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions "-D__SKETCH_NAME__=\"\"\"sketch_nov07a.ino\"\"\"" -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10811 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS -DUSB_VID=0x239A -DUSB_PID=0x8013 -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Metro M0 Express\"" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\variants\\metro_m0" "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\sketch\\sketch_nov07a.ino.cpp" -o nul
Alternatives for AFMotor.h: [Adafruit_Motor_Shield_library@1.0.1 Adafruit-Motor-Shield-library-master@1.0.0]
ResolveLibrary(AFMotor.h)
  -> candidates: [Adafruit_Motor_Shield_library@1.0.1 Adafruit-Motor-Shield-library-master@1.0.0]
"C:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions "-D__SKETCH_NAME__=\"\"\"sketch_nov07a.ino\"\"\"" -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10811 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS -DUSB_VID=0x239A -DUSB_PID=0x8013 -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Metro M0 Express\"" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\variants\\metro_m0" "-IC:\\Users\\PowerOn\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_library" "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\sketch\\sketch_nov07a.ino.cpp" -o nul
"C:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions "-D__SKETCH_NAME__=\"\"\"sketch_nov07a.ino\"\"\"" -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10811 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS -DUSB_VID=0x239A -DUSB_PID=0x8013 -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Metro M0 Express\"" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\variants\\metro_m0" "-IC:\\Users\\PowerOn\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_library" "C:\\Users\\PowerOn\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_library\\AFMotor.cpp" -o nul
Error while detecting libraries included by C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library\AFMotor.cpp
Generating function prototypes...
"C:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions "-D__SKETCH_NAME__=\"\"\"sketch_nov07a.ino\"\"\"" -w -x c++ -E -CC -DF_CPU=48000000L -DARDUINO=10811 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS -DUSB_VID=0x239A -DUSB_PID=0x8013 -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Metro M0 Express\"" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\variants\\metro_m0" "-IC:\\Users\\PowerOn\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_library" "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\sketch\\sketch_nov07a.ino.cpp" -o "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\preproc\\ctags_target_for_gcc_minus_e.cpp"
"C:\\arduino-nightly-windows\\arduino-nightly\\tools-builder\\ctags\\5.8-arduino11/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\preproc\\ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"C:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\arm-none-eabi-gcc\\4.8.3-2014q1/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD "-D__SKETCH_NAME__=\"\"\"sketch_nov07a.ino\"\"\"" -DF_CPU=48000000L -DARDUINO=10811 -DARDUINO_SAMD_ZERO -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -DARDUINO_SAMD_ZERO -DARM_MATH_CM0PLUS -DADAFRUIT_METRO_M0_EXPRESS -DUSB_VID=0x239A -DUSB_PID=0x8013 -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Adafruit\"" "-DUSB_PRODUCT=\"Metro M0 Express\"" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino/Adafruit_TinyUSB_Core/tinyusb/src" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\cores\\arduino" "-IC:\\Users\\PowerOn\\AppData\\Local\\Arduino15\\packages\\adafruit\\hardware\\samd\\1.5.4\\variants\\metro_m0" "-IC:\\Users\\PowerOn\\Documents\\Arduino\\libraries\\Adafruit_Motor_Shield_library" "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\sketch\\sketch_nov07a.ino.cpp" -o "C:\\Users\\PowerOn\\AppData\\Local\\Temp\\arduino_build_7726\\sketch\\sketch_nov07a.ino.cpp.o"
In file included from C:\Users\PowerOn\Documents\Arduino\sketch_nov07a\sketch_nov07a.ino:1:0:

C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library/AFMotor.h:156:47: error: 'DC_MOTOR_PWM_RATE' was not declared in this scope

   AF_DCMotor(uint8_t motornum, uint8_t freq = DC_MOTOR_PWM_RATE);

                                               ^

sketch_nov07a:7:19: error: call to 'AF_DCMotor::AF_DCMotor(uint8_t, uint8_t)' uses the default argument for parameter 2, which is not yet defined

 AF_DCMotor motor(1);

                   ^

Multiple libraries were found for "AFMotor.h"
 Used: C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library
 Not used: C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit-Motor-Shield-library-master
Using library Adafruit_Motor_Shield_library at version 1.0.1 in folder: C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library
exit status 1
call to 'AF_DCMotor::AF_DCMotor(uint8_t, uint8_t)' uses the default argument for parameter 2, which is not yet defined


I believe that there must be an issue in the library that is causing the issue, but I cannot seem to find it.

Below is my code and the library that I'm using. Any help would be appreciated.

CODE:
Code: Select all | TOGGLE FULL SIZE
#include <AFMotor.h>

int valueMin = 0;   
int valueMax = 100;
int fanSpeed;
int value;
AF_DCMotor motor(1);

void setup() {
  Serial.begin(9600);
  motor.run(FORWARD);
 
}

void loop() { 
 
      fanSpeed = map(value, valueMin, valueMax, 0, 255); // the actual speed of fan
      motor.setSpeed(fanSpeed);
      Serial.println(fanSpeed);
      Serial.println(value);
      delay(1000);
}


LIBRARY:
Code: Select all | TOGGLE FULL SIZE
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

/*
 * Usage Notes:
 * For PIC32, all features work properly with the following two exceptions:
 *
 * 1) Because the PIC32 only has 5 PWM outputs, and the AFMotor shield needs 6
 *    to completely operate (four for motor outputs and two for RC servos), the
 *    M1 motor output will not have PWM ability when used with a PIC32 board.
 *    However, there is a very simple workaround. If you need to drive a stepper
 *    or DC motor with PWM on motor output M1, you can use the PWM output on pin
 *    9 or pin 10 (normally use for RC servo outputs on Arduino, not needed for
 *    RC servo outputs on PIC32) to drive the PWM input for M1 by simply putting
 *    a jumber from pin 9 to pin 11 or pin 10 to pin 11. Then uncomment one of the
 *    two #defines below to activate the PWM on either pin 9 or pin 10. You will
 *    then have a fully functional microstepping for 2 stepper motors, or four
 *    DC motor outputs with PWM.
 *
 * 2) There is a conflict between RC Servo outputs on pins 9 and pins 10 and
 *    the operation of DC motors and stepper motors as of 9/2012. This issue
 *    will get fixed in future MPIDE releases, but at the present time it means
 *    that the Motor Party example will NOT work properly. Any time you attach
 *    an RC servo to pins 9 or pins 10, ALL PWM outputs on the whole board will
 *    stop working. Thus no steppers or DC motors.
 *
 */
// <BPS> 09/15/2012 Modified for use with chipKIT boards


#ifndef _AFMotor_h_
#define _AFMotor_h_

#include <inttypes.h>
#if defined(__AVR__)
    #include <avr/io.h>

    //#define MOTORDEBUG 1

    #define MICROSTEPS 16                       // 8 or 16

    #define MOTOR12_64KHZ _BV(CS20)             // no prescale
    #define MOTOR12_8KHZ _BV(CS21)              // divide by 8
    #define MOTOR12_2KHZ _BV(CS21) | _BV(CS20)  // divide by 32
    #define MOTOR12_1KHZ _BV(CS22)              // divide by 64

    #define MOTOR34_64KHZ _BV(CS00)             // no prescale
    #define MOTOR34_8KHZ _BV(CS01)              // divide by 8
    #define MOTOR34_1KHZ _BV(CS01) | _BV(CS00)  // divide by 64
   
    #define DC_MOTOR_PWM_RATE   MOTOR34_8KHZ    // PWM rate for DC motors
    #define STEPPER1_PWM_RATE   MOTOR12_64KHZ   // PWM rate for stepper 1
    #define STEPPER2_PWM_RATE   MOTOR34_64KHZ   // PWM rate for stepper 2
   
#elif defined(__PIC32MX__)
    //#define MOTORDEBUG 1
   
    // Uncomment the one of following lines if you have put a jumper from
    // either pin 9 to pin 11 or pin 10 to pin 11 on your Motor Shield.
    // Either will enable PWM for M1
    //#define PIC32_USE_PIN9_FOR_M1_PWM
    //#define PIC32_USE_PIN10_FOR_M1_PWM

    #define MICROSTEPS 16       // 8 or 16

    // For PIC32 Timers, define prescale settings by PWM frequency
    #define MOTOR12_312KHZ  0   // 1:1, actual frequency 312KHz
    #define MOTOR12_156KHZ  1   // 1:2, actual frequency 156KHz
    #define MOTOR12_64KHZ   2   // 1:4, actual frequency 78KHz
    #define MOTOR12_39KHZ   3   // 1:8, acutal frequency 39KHz
    #define MOTOR12_19KHZ   4   // 1:16, actual frequency 19KHz
    #define MOTOR12_8KHZ    5   // 1:32, actual frequency 9.7KHz
    #define MOTOR12_4_8KHZ  6   // 1:64, actual frequency 4.8KHz
    #define MOTOR12_2KHZ    7   // 1:256, actual frequency 1.2KHz
    #define MOTOR12_1KHZ    7   // 1:256, actual frequency 1.2KHz

    #define MOTOR34_312KHZ  0   // 1:1, actual frequency 312KHz
    #define MOTOR34_156KHZ  1   // 1:2, actual frequency 156KHz
    #define MOTOR34_64KHZ   2   // 1:4, actual frequency 78KHz
    #define MOTOR34_39KHZ   3   // 1:8, acutal frequency 39KHz
    #define MOTOR34_19KHZ   4   // 1:16, actual frequency 19KHz
    #define MOTOR34_8KHZ    5   // 1:32, actual frequency 9.7KHz
    #define MOTOR34_4_8KHZ  6   // 1:64, actual frequency 4.8KHz
    #define MOTOR34_2KHZ    7   // 1:256, actual frequency 1.2KHz
    #define MOTOR34_1KHZ    7   // 1:256, actual frequency 1.2KHz
   
    // PWM rate for DC motors.
    #define DC_MOTOR_PWM_RATE   MOTOR34_39KHZ
    // Note: for PIC32, both of these must be set to the same value
    // since there's only one timebase for all 4 PWM outputs
    #define STEPPER1_PWM_RATE   MOTOR12_39KHZ
    #define STEPPER2_PWM_RATE   MOTOR34_39KHZ
   
#endif

// Bit positions in the 74HCT595 shift register output
#define MOTOR1_A 2
#define MOTOR1_B 3
#define MOTOR2_A 1
#define MOTOR2_B 4
#define MOTOR4_A 0
#define MOTOR4_B 6
#define MOTOR3_A 5
#define MOTOR3_B 7

// Constants that the user passes in to the motor calls
#define FORWARD 1
#define BACKWARD 2
#define BRAKE 3
#define RELEASE 4

// Constants that the user passes in to the stepper calls
#define SINGLE 1
#define DOUBLE 2
#define INTERLEAVE 3
#define MICROSTEP 4

/*
#define LATCH 4
#define LATCH_DDR DDRB
#define LATCH_PORT PORTB

#define CLK_PORT PORTD
#define CLK_DDR DDRD
#define CLK 4

#define ENABLE_PORT PORTD
#define ENABLE_DDR DDRD
#define ENABLE 7

#define SER 0
#define SER_DDR DDRB
#define SER_PORT PORTB
*/

// Arduino pin names for interface to 74HCT595 latch
#define MOTORLATCH 12
#define MOTORCLK 4
#define MOTORENABLE 7
#define MOTORDATA 8

class AFMotorController
{
  public:
    AFMotorController(void);
    void enable(void);
    friend class AF_DCMotor;
    void latch_tx(void);
    uint8_t TimerInitalized;
};

class AF_DCMotor
{
 public:
  AF_DCMotor(uint8_t motornum, uint8_t freq = DC_MOTOR_PWM_RATE);
  void run(uint8_t);
  void setSpeed(uint8_t);

 private:
  uint8_t motornum, pwmfreq;
};

class AF_Stepper {
 public:
  AF_Stepper(uint16_t, uint8_t);
  void step(uint16_t steps, uint8_t dir,  uint8_t style = SINGLE);
  void setSpeed(uint16_t);
  uint8_t onestep(uint8_t dir, uint8_t style);
  void release(void);
  uint16_t revsteps; // # steps per revolution
  uint8_t steppernum;
  uint32_t usperstep, steppingcounter;
 private:
  uint8_t currentstep;

};

uint8_t getlatchstate(void);

#endif


I am aware that this is an old shield and that it just most likely won't work with the M0. If there is no work around, would my best option be to get the V2 since it talks over i2c?

Thank you

DarkenedLight
 
Posts: 3
Joined: Fri Oct 04, 2019 6:18 pm

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by adafruit_support_mike on Fri Nov 08, 2019 4:45 am

It looks like you have two copies of the Motor Shield library:

Code: Select all | TOGGLE FULL SIZE
 C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library
 Not used: C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit-Motor-Shield-library-master
It would probably be safest to throw both of them away and download a fresh copy of the latest version.

adafruit_support_mike
 
Posts: 60271
Joined: Thu Feb 11, 2010 2:51 pm

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by adafruit_support_bill on Fri Nov 08, 2019 6:53 am

I am aware that this is an old shield and that it just most likely won't work with the M0. If there is no work around, would my best option be to get the V2 since it talks over i2c?

It might work. We have not tried it since the V1 shield was discontinued several years ago. The M0 supports PWM on most of the same pins as the 'classic' Arduinos this board was designed for.

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

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by DarkenedLight on Fri Nov 08, 2019 5:46 pm

Thank you for the replies.

So i got rid of both libraries and then re added the normal one from the IDE libraries manager.

I still cant compile the code.

My error now is
Code: Select all | TOGGLE FULL SIZE
C:\Users\PowerOn\Documents\Arduino\libraries\Adafruit_Motor_Shield_library/AFMotor.h:156:47: error: 'DC_MOTOR_PWM_RATE' was not declared in this scope

   AF_DCMotor(uint8_t motornum, uint8_t freq = DC_MOTOR_PWM_RATE);

                                               ^

sketch_nov07a:7:21: error: 'MOTOR12_64KHZ' was not declared in this scope

 AF_DCMotor motor(4, MOTOR12_64KHZ);

I know these are declared in the library AFMotor.h. Is there something in the library that the M0 chip can not read?

I complied the same code onto my Leonardo and it worked just fine, so there must be some with the M0 and the library that aren't getting along.

Thanks

DarkenedLight
 
Posts: 3
Joined: Fri Oct 04, 2019 6:18 pm

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by adafruit_support_bill on Fri Nov 08, 2019 7:54 pm

The AFMotor library predates the existence of the Due, so some of the processor specific functionality such as setting PWM frequencies may not be compatible. Unfortunately this library is no longer supported.

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

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by DarkenedLight on Fri Nov 08, 2019 8:02 pm

So is there any hope of using this shield with the M0?

I don't know much about coding or making a library, but could I make my own library or is the tech on the shield out dated/incompatible with the M0 express?

Thanks again for the help so far

DarkenedLight
 
Posts: 3
Joined: Fri Oct 04, 2019 6:18 pm

Re: Makershed Motorshield_v1 w/ Metro M0 Express

by adafruit_support_bill on Sat Nov 09, 2019 7:26 am

Technically, it should be possible to do since all the necessary pins have PWM capability. However, the M0 processor architecture is completely different from that of the Atmega328 on the UNO. So the part of the library that configures the PWM would need to be re-written for the M0.

This page discusses some of the differences between the M0 and earlier processors:
https://learn.adafruit.com/adafruit-met ... ches-to-m0

PWM in particular is discussed here:
https://learn.adafruit.com/adafruit-met ... tro-m0-7-6

The V2 shield avoids all these issues since it only needs the 2 i2c pins for communication. i2c is supported on the same 2 pins on every R3 and later Arduino and compatible processor.

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

Please be positive and constructive with your questions and comments.