diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..8851ffe --- /dev/null +++ b/.codespellrc @@ -0,0 +1,7 @@ +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +check-filenames = +check-hidden = +skip = ./.git,./extras/D11-Firmware/src,./src/src diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fa738ec --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# See: https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # See: https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily + labels: + - "topic: infrastructure" diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml new file mode 100644 index 0000000..e818685 --- /dev/null +++ b/.github/workflows/check-arduino.yml @@ -0,0 +1,28 @@ +name: Check Arduino + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Arduino Lint + uses: arduino/arduino-lint-action@v2 + with: + compliance: specification + library-manager: update + # Always use this setting for official repositories. Remove for 3rd party projects. + official: true + project-type: library diff --git a/.github/workflows/compile-bootloader.yml b/.github/workflows/compile-bootloader.yml new file mode 100644 index 0000000..fd005c4 --- /dev/null +++ b/.github/workflows/compile-bootloader.yml @@ -0,0 +1,66 @@ +name: Compile Bootloader + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-bootloader.yml" + - "extras/D11-Bootloader/**" + pull_request: + paths: + - ".github/workflows/compile-bootloader.yml" + - "extras/D11-Bootloader/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:mkrmotorshield:bootloader=0kb,pinmap=complete,lto=disabled + platforms: | + # Install MattairTech_Arduino:samd via Boards Manager for the toolchain + - name: MattairTech_Arduino:samd + source-url: https://www.mattairtech.com/software/arduino/package_MattairTech_index.json + # This needs to match with the version of MattairTech_Arduino:samd the Arduino fork is based on in order to get the right tool versions + version: 1.6.16 + # Install the platform with Motor Carrier support + - name: arduino:samd + source-url: https://github.com/arduino/ArduinoCore-samd.git + version: mkrmotorcarrier + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile bootloader + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + - name: Sodaq_wdt + sketch-paths: | + - extras/D11-Bootloader + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml new file mode 100644 index 0000000..94e89bc --- /dev/null +++ b/.github/workflows/compile-examples.yml @@ -0,0 +1,137 @@ +name: Compile Examples + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/compile-examples.yml" + - "examples/**" + - "src/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:nano_33_iot + platforms: | + - name: arduino:samd + type: nano + artifact-name-suffix: arduino-samd-nano_33_iot + - fqbn: arduino:samd:mkr1000 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkr1000 + - fqbn: arduino:samd:mkrzero + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrzero + - fqbn: arduino:samd:mkrwifi1010 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrwifi1010 + - fqbn: arduino:samd:mkrfox1200 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrfox1200 + - fqbn: arduino:samd:mkrwan1300 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrwan1300 + - fqbn: arduino:samd:mkrwan1310 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrwan1310 + - fqbn: arduino:samd:mkrgsm1400 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrgsm1400 + - fqbn: arduino:samd:mkrnb1500 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrnb1500 + - fqbn: arduino:samd:mkrvidor4000 + platforms: | + - name: arduino:samd + type: mkr + artifact-name-suffix: arduino-samd-mkrvidor4000 + - fqbn: arduino:mbed_portenta:envie_m7:target_core=cm4 + platforms: | + - name: arduino:mbed_portenta + type: mkr + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta + type: mkr + artifact-name-suffix: arduino-mbed_portenta-envie_m7 + + # make board type-specific customizations to the matrix jobs + include: + - board: + type: nano + libraries: | + - name: BNO055 + - name: Arduino_BQ24195 + sketch-paths: | + - examples/NanoMotorCarrier + - board: + type: mkr + libraries: | + - + sketch-paths: | + - examples/MKRMotorCarrier + + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile examples + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + # Install the library from the local path. + - source-path: ./ + ${{ matrix.libraries }} + sketch-paths: | + - examples/Flasher + + ${{ matrix.sketch-paths }} + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: sketches-report-${{ matrix.board.artifact-name-suffix }} diff --git a/.github/workflows/compile-firmware.yml b/.github/workflows/compile-firmware.yml new file mode 100644 index 0000000..4309550 --- /dev/null +++ b/.github/workflows/compile-firmware.yml @@ -0,0 +1,66 @@ +name: Compile Firmware + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/compile-firmware.yml" + - "extras/D11-Firmware/**" + pull_request: + paths: + - ".github/workflows/compile-firmware.yml" + - "extras/D11-Firmware/**" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms). + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + build: + name: ${{ matrix.board.fqbn }} + runs-on: ubuntu-latest + + env: + SKETCHES_REPORTS_PATH: sketches-reports + + strategy: + fail-fast: false + + matrix: + board: + - fqbn: arduino:samd:mkrmotorshield:bootloader=0kb,pinmap=complete,lto=disabled + platforms: | + # Install MattairTech_Arduino:samd via Boards Manager for the toolchain + - name: MattairTech_Arduino:samd + source-url: https://www.mattairtech.com/software/arduino/package_MattairTech_index.json + # This needs to match with the version of MattairTech_Arduino:samd the Arduino fork is based on in order to get the right tool versions + version: 1.6.16 + # Install the platform with Motor Carrier support + - name: arduino:samd + source-url: https://github.com/arduino/ArduinoCore-samd.git + version: mkrmotorcarrier + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Compile firmware + uses: arduino/compile-sketches@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fqbn: ${{ matrix.board.fqbn }} + platforms: ${{ matrix.board.platforms }} + libraries: | + - + sketch-paths: | + - extras/D11-Firmware/D11-Firmware.ino + enable-deltas-report: true + sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} + + - name: Save sketches report as workflow artifact + uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + path: ${{ env.SKETCHES_REPORTS_PATH }} + name: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/report-size-deltas.yml b/.github/workflows/report-size-deltas.yml new file mode 100644 index 0000000..39e2a0a --- /dev/null +++ b/.github/workflows/report-size-deltas.yml @@ -0,0 +1,24 @@ +name: Report Size Deltas + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/report-size-deltas.yml" + schedule: + # Run at the minimum interval allowed by GitHub Actions. + # Note: GitHub Actions periodically has outages which result in workflow failures. + # In this event, the workflows will start passing again once the service recovers. + - cron: "*/5 * * * *" + workflow_dispatch: + repository_dispatch: + +jobs: + report: + runs-on: ubuntu-latest + steps: + - name: Comment size deltas reports to PRs + uses: arduino/report-size-deltas@v1 + with: + # Regex matching the names of the workflow artifacts created by the "Compile Examples" workflow + sketches-reports-source: ^sketches-report-.+ diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml new file mode 100644 index 0000000..ef7d894 --- /dev/null +++ b/.github/workflows/spell-check.yml @@ -0,0 +1,22 @@ +name: Spell Check + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + spellcheck: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Spell check + uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml new file mode 100644 index 0000000..53a9f54 --- /dev/null +++ b/.github/workflows/sync-labels.yml @@ -0,0 +1,138 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md +name: Sync Labels + +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + pull_request: + paths: + - ".github/workflows/sync-labels.ya?ml" + - ".github/label-configuration-files/*.ya?ml" + schedule: + # Run daily at 8 AM UTC to sync with changes to shared label configurations. + - cron: "0 8 * * *" + workflow_dispatch: + repository_dispatch: + +env: + CONFIGURATIONS_FOLDER: .github/label-configuration-files + CONFIGURATIONS_ARTIFACT: label-configuration-files + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download JSON schema for labels configuration file + id: download-schema + uses: carlosperate/download-file-action@v2 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/arduino-tooling-gh-label-configuration-schema.json + location: ${{ runner.temp }}/label-configuration-schema + + - name: Install JSON schema validator + run: | + sudo npm install \ + --global \ + ajv-cli \ + ajv-formats + + - name: Validate local labels configuration + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --all-errors \ + -c ajv-formats \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "${{ env.CONFIGURATIONS_FOLDER }}/*.{yml,yaml}" + + download: + needs: check + runs-on: ubuntu-latest + + strategy: + matrix: + filename: + # Filenames of the shared configurations to apply to the repository in addition to the local configuration. + # https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/sync-labels + - universal.yml + + steps: + - name: Download + uses: carlosperate/download-file-action@v2 + with: + file-url: https://raw.githubusercontent.com/arduino/tooling-project-assets/main/workflow-templates/assets/sync-labels/${{ matrix.filename }} + + - name: Pass configuration files to next job via workflow artifact + uses: actions/upload-artifact@v4 + with: + path: | + *.yaml + *.yml + if-no-files-found: error + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + sync: + needs: download + runs-on: ubuntu-latest + + steps: + - name: Set environment variables + run: | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV" + + - name: Determine whether to dry run + id: dry-run + if: > + github.event_name == 'pull_request' || + ( + ( + github.event_name == 'push' || + github.event_name == 'workflow_dispatch' + ) && + github.ref != format('refs/heads/{0}', github.event.repository.default_branch) + ) + run: | + # Use of this flag in the github-label-sync command will cause it to only check the validity of the + # configuration. + echo "::set-output name=flag::--dry-run" + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Download configuration files artifact + uses: actions/download-artifact@v4 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + path: ${{ env.CONFIGURATIONS_FOLDER }} + + - name: Remove unneeded artifact + uses: geekyeggo/delete-artifact@v5 + with: + name: ${{ env.CONFIGURATIONS_ARTIFACT }} + + - name: Merge label configuration files + run: | + # Merge all configuration files + shopt -s extglob + cat "${{ env.CONFIGURATIONS_FOLDER }}"/*.@(yml|yaml) > "${{ env.MERGED_CONFIGURATION_PATH }}" + + - name: Install github-label-sync + run: sudo npm install --global github-label-sync + + - name: Sync labels + env: + GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # See: https://github.com/Financial-Times/github-label-sync + github-label-sync \ + --labels "${{ env.MERGED_CONFIGURATION_PATH }}" \ + ${{ steps.dry-run.outputs.flag }} \ + ${{ github.repository }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ae26f1 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# ArduinoMotorCarrier library + +[![Check Arduino status](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/check-arduino.yml) +[![Compile Examples status](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/compile-examples.yml) +[![Spell Check status](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/ArduinoMotorCarrier/actions/workflows/spell-check.yml) + +This library is designed to use the MKR Motor Carrier. The shield supports micro servo motors, DC motors and DC motors with encoder. This library, therefore, has functions and creates objects to support such hardware. Objects are automatically created when "ArduinoMotorCarrier.h" is included, hence no need to initiate objects manually. + +For more information about this library please visit us at + + +# License +Copyright (c) Arduino LLC. All right reserved. + +This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..6539e06 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,210 @@ +# ArduinoMotorCarrier library + +## Methods + +### `BATTERY` + +Returns information about the battery connected to the carrier. + +#### Syntax + +``` +battery.getRaw() +battery.getConverted() +battery.getFiltered() +``` + +#### Returns + +* _getRaw()_: returns the raw ADC read from the battery as an integer. +* _getConverted()_: returns the battery voltage converted to volts as a floating point. +* _getFiltered()_: returns the battery voltage converted to volts and filtered in the last 10 seconds. + + +#### Example + +``` + +#include + +//Variable to store the battery voltage +float batteryVoltage; +... +void loop() { + batteryVoltage = battery.getRaw()/236.0; //236 for Nano, 77 for MKR. + Serial.print("Battery voltage: "); + Serial.print(batteryVoltage,3); + Serial.print("V, Raw "); + Serial.println(battery.getRaw()); + delay(5000); //wait for a few seconds +} +``` + +### `SERVO` + +Represent the servomotors available on the MotorCarrier. There are 4 headers for servomotors. + +#### Syntax + +``` +servo1.setAngle(int) +servo2.setAngle(int) +servo3.setAngle(int) +servo4.setAngle(int) +``` + +#### Function + +* _setAngle(int)_: Set the rotation angle (from 0 to 180) + + +### `MOTOR` + +There is 4 objects pointing to each possible motor: M1, M2, M3 and M4. + +#### Syntax + +```` +M1.setDuty(int) +M2.setDuty(int) +M3.setDuty(int) +M4.setDuty(int) +```` + +#### Functions + +* _setDuty(int)_: Set the duty cycle of the dc motor (from -100 to +100) , 0 means stop. + + +### `ENCODER` + +Represents the 2 quadrature encoders embedded in the carrier board. The two objects are encoder1 and encoder2. + +#### Syntax + +```` +encoder1.getRawCount() +encoder2.resetCounter(); +```` + +#### Functions + +* _getRawCount()_: Returns the number of counts from start as an integer. +* _resetCounter(int)_: Resets counter to a certain value. + + +### `CONTROLLER` + +Represents the motor shield controller and exposes some high level functions. It also configures the battery charger (only on the NanoMotorCarrier) to start charging the battery. + +#### Syntax + +``` +controller.getFWVersion() +controller.reboot() +``` +### `PID` + +Allow setting Motor1 or Motor2 to a specific speed or position. There are two PID virtual objects in the controller: pid1 and pid2. pid1 acts on M1 and encoder1. pid2 acts on M2 and encoder2. It is advisable to control the motors using these functions. + +#### Syntax + +``` +pid1.setGains(float P, float I, float D) +``` + +#### Functions + +* _setGains(float P, float I, float D)_: Set PID gains. +* _resetGains()_: Reset PID gains to factory default settings. +* _setControlMode(cl_control)_: Set control mode to either `CL_VELOCITY` or `CL_POSITION`. +* _setSetpoint(cl_mode, int target)_: Set a specific velocity or position in one of the motors. Define cl_mode as `TARGET_POSITION` or `TARGET_VELOCITY` and the desired value in target. + +#### Example + +Example for PID position control. + +``` +#include +#define INTERRUPT_PIN 6 + +//Variable to change the motor speed and direction +static int duty = 0; + +int target; +float P; +float I; +float D; + +void setup() +{ + //Serial port initialization + Serial.begin(115200); + while (!Serial); + + //Establishing the communication with the motor shield + if (controller.begin()) + { + Serial.print("MKR Motor Shield connected, firmware version "); + Serial.println(controller.getFWVersion()); + } + else + { + Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + while (1); + } + + // Reboot the motor controller; brings every value back to default + Serial.println("reboot"); + controller.reboot(); + delay(500); + + int dutyInit = 0; + M1.setDuty(dutyInit); + M2.setDuty(dutyInit); + M3.setDuty(dutyInit); + M4.setDuty(dutyInit); + Serial.print("Duty: "); + Serial.println(dutyInit); + + P = 0.07f;//0.07 //0.2 + I = 0.0f; + D = 0.007f; + + /************* PID 1 ***********************/ + + pid1.setControlMode(CL_POSITION); + + //pid1.resetGains(); + pid1.setGains(P, I, D); //Proportional(change) Integral(change) Derivative + Serial.print("P Gain: "); + Serial.println((float)pid1.getPgain()); + Serial.print("I Gain: "); + Serial.println((float)pid1.getIgain()); + Serial.print("D Gain: "); + Serial.println((float)pid1.getDgain(), 7); + Serial.println(""); + + encoder1.resetCounter(0); + Serial.print("encoder1: "); + Serial.println(encoder1.getRawCount()); + target = 5000; + pid1.setSetpoint(TARGET_POSITION, target); +} + +void loop() { + + Serial.print("encoder1: "); + Serial.print(encoder1.getRawCount()); + Serial.print(" target: "); + Serial.println(target); + if (encoder1.getRawCount() == target) { + target += 1000; + Serial.print("Target reached: Setting new target.."); + pid1.setSetpoint(TARGET_POSITION, target); + //delay(5000); + } + + delay(50); +} +``` diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..8960d73 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,18 @@ +# ArduinoMotorCarrier library + + +This library allows you to use both the Arduino Nano Motor Carrier and the MKR Motor Carrier. The carrier supports inputs for servo motors, dc motors, and encoders, and can read the battery voltage level. This library, therefore, has functions and creates objects to support such hardware. In addition, the library supports PID control for position and velocity. Note that not all hardware features are supported in both carriers so take a look at the specifications for each board. You don't need to initiate any objects manually, they are automatically created when you include "ArduinoMotorCarrier.h" + +To use this library: + +``` +#include +``` + +## Circuit + +Connect the carrier to the main compatible board (MKR1010 or Nano 33 IoT), connect the LiPo battery, turn the switch on and connect the board to the computer using a micro USB cable. You can also connect the motors that you need for your project (servo or DC w/ or w/o encoders). + +## Examples + +* [Battery Read](https://docs.arduino.cc/tutorials/mkr-motor-carrier/mkr-motor-carrier-battery): Reading the battery level with the MKR Motor Carrier. diff --git a/examples/Flasher/Flasher.ino b/examples/Flasher/Flasher.ino index 3413ebc..d5f89f3 100644 --- a/examples/Flasher/Flasher.ino +++ b/examples/Flasher/Flasher.ino @@ -112,7 +112,7 @@ void setup() { Wire.beginTransmission(0x66); Wire.write((uint8_t)GET_VERSION); - Wire.write((uint32_t)0); + Wire.write(0); Wire.endTransmission(); Wire.requestFrom(0x66, 5); diff --git a/examples/Motor_test/CP3-SC1-GE3-PH.png b/examples/MKRMotorCarrier/Motor_test/CP3-SC1-GE3-PH.png similarity index 100% rename from examples/Motor_test/CP3-SC1-GE3-PH.png rename to examples/MKRMotorCarrier/Motor_test/CP3-SC1-GE3-PH.png diff --git a/examples/Motor_test/Motor_test.ino b/examples/MKRMotorCarrier/Motor_test/Motor_test.ino similarity index 86% rename from examples/Motor_test/Motor_test.ino rename to examples/MKRMotorCarrier/Motor_test/Motor_test.ino index fc00deb..4a15081 100644 --- a/examples/Motor_test/Motor_test.ino +++ b/examples/MKRMotorCarrier/Motor_test/Motor_test.ino @@ -13,15 +13,15 @@ void setup() Serial.begin(115200); while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("MKR Motor Connected connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -44,7 +44,7 @@ void loop() { //Take the battery status float batteryVoltage = (float)battery.getConverted(); - //Reset to the default values if the battery level is lower than 11V + //Reset to the default values if the battery level is lower than 11 V if (batteryVoltage < 11) { Serial.println(" "); @@ -83,8 +83,8 @@ void loop() { delay(50); } - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between MKR board & MKR Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/examples/Motor_test_encoder/CP3-SC1-GE3-PH.png b/examples/MKRMotorCarrier/Motor_test_encoder/CP3-SC1-GE3-PH.png similarity index 100% rename from examples/Motor_test_encoder/CP3-SC1-GE3-PH.png rename to examples/MKRMotorCarrier/Motor_test_encoder/CP3-SC1-GE3-PH.png diff --git a/examples/Motor_test_encoder/Motor_test_encoder.ino b/examples/MKRMotorCarrier/Motor_test_encoder/Motor_test_encoder.ino similarity index 87% rename from examples/Motor_test_encoder/Motor_test_encoder.ino rename to examples/MKRMotorCarrier/Motor_test_encoder/Motor_test_encoder.ino index f291265..4b267e4 100644 --- a/examples/Motor_test_encoder/Motor_test_encoder.ino +++ b/examples/MKRMotorCarrier/Motor_test_encoder/Motor_test_encoder.ino @@ -13,15 +13,15 @@ void setup() Serial.begin(115200); while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -49,7 +49,7 @@ void loop() { //Take the battery status float batteryVoltage = (float)battery.getConverted(); - //Reset to the default values if the battery level is lower than 11V + //Reset to the default values if the battery level is lower than 11 V if (batteryVoltage < 11) { Serial.println(" "); @@ -78,8 +78,8 @@ void loop() { Serial.println(encoder1.getCountPerSecond()); } - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between MKR board & MKR Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/examples/Servo_test/CP3-SC2-GE3-IL.png b/examples/MKRMotorCarrier/Servo_test/CP3-SC2-GE3-IL.png similarity index 100% rename from examples/Servo_test/CP3-SC2-GE3-IL.png rename to examples/MKRMotorCarrier/Servo_test/CP3-SC2-GE3-IL.png diff --git a/examples/Servo_test/Servo_test.ino b/examples/MKRMotorCarrier/Servo_test/Servo_test.ino similarity index 76% rename from examples/Servo_test/Servo_test.ino rename to examples/MKRMotorCarrier/Servo_test/Servo_test.ino index e5ecd01..8ada2df 100644 --- a/examples/Servo_test/Servo_test.ino +++ b/examples/MKRMotorCarrier/Servo_test/Servo_test.ino @@ -1,4 +1,3 @@ - #include #define INTERRUPT_PIN 6 @@ -11,15 +10,15 @@ void setup() Serial.begin(115200); while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("MKR Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -42,7 +41,7 @@ void loop() { //Take the battery status float batteryVoltage = (float)battery.getConverted(); - //Reset to the default values if the battery level is lower than 11V + //Reset to the default values if the battery level is lower than 11 V if (batteryVoltage < 11) { Serial.println(" "); @@ -57,7 +56,7 @@ void loop() { //Servo sweep from 0 position to 180 for (int i=0; i<180; i+=5) { - //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4 + //Choose which of the servo connectors you want to use: servo1(default), servo2, servo3 or servo4 servo1.setAngle(i); Serial.print("Servo position"); Serial.println(i); @@ -69,7 +68,7 @@ void loop() { //Servo sweep from 180 position to 0 for (int i=180; i>0; i-=5) { - //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4 + //Choose which of the servo connectors you want to use: servo1(default), servo2, servo3 or servo4 servo1.setAngle(i); Serial.print("Servo position"); Serial.println(i); @@ -77,8 +76,8 @@ void loop() { } } - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between MKR board & MKR Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/examples/Test/Test.ino b/examples/MKRMotorCarrier/Test/Test.ino similarity index 81% rename from examples/Test/Test.ino rename to examples/MKRMotorCarrier/Test/Test.ino index 3b06897..a7e0af8 100644 --- a/examples/Test/Test.ino +++ b/examples/MKRMotorCarrier/Test/Test.ino @@ -1,7 +1,7 @@ /* - MKR Motor Shield Test sketch - This sketch demonstrates some APIs exposed by the MKR Motor Shield library. - For the complete list, visit the reference page on https://www.arduino.cc/en/Reference/MKRMotorShield + MKR Motor Carrier Test sketch + This sketch demonstrates some APIs exposed by the ArduinoMotorCarrier library. + For the complete list, visit the reference page on https://www.arduino.cc/en/Reference/MKRMotorCarrier This example code is in the public domain. */ @@ -12,12 +12,12 @@ void setup() { Serial.begin(115200); while (!Serial); - // Start communicationg with the motor shield + // Start communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("MKR Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -46,7 +46,7 @@ void setup() { // This way, you can program the motor to reach a certain position or velocity without any further intervention. // The PID can be carefully tuned if a particular profile is needed. pid1.setControlMode(CL_POSITION); - pid1.setGains(25, 0, 3); + pid1.setGains(25.0f, 0.0f, 3.0f); pid1.setMaxAcceleration(4000); pid1.setSetpoint(TARGET_POSITION, 5000); } diff --git a/examples/NanoMotorCarrier/Battery_Charging/Battery_Charging.ino b/examples/NanoMotorCarrier/Battery_Charging/Battery_Charging.ino new file mode 100644 index 0000000..cf9e921 --- /dev/null +++ b/examples/NanoMotorCarrier/Battery_Charging/Battery_Charging.ino @@ -0,0 +1,35 @@ + +#include + +//Variable to store the battery voltage +float batteryVoltage; + +// the setup function runs once when you press reset or power the board +void setup() { + Serial.begin(115200); + //while (!Serial); + + if (controller.begin()) + { + Serial.print("Nano Motor Shield connected, firmware version "); + Serial.println(controller.getFWVersion()); + } + else + { + Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + while (1); + } +} + +// the loop function runs over and over again forever +void loop() { + + batteryVoltage = battery.getRaw()/236.0; + Serial.print("Battery voltage: "); + Serial.print(batteryVoltage,3); + //Serial.println("V"); + Serial.print("V, Raw "); + Serial.println(battery.getRaw()); + delay(5000); //wait for a few seconds + +} diff --git a/examples/Nano/DCMotorTest/DCMotorTest.ino b/examples/NanoMotorCarrier/DCMotorTest/DCMotorTest.ino similarity index 85% rename from examples/Nano/DCMotorTest/DCMotorTest.ino rename to examples/NanoMotorCarrier/DCMotorTest/DCMotorTest.ino index fffd38c..a68122a 100644 --- a/examples/Nano/DCMotorTest/DCMotorTest.ino +++ b/examples/NanoMotorCarrier/DCMotorTest/DCMotorTest.ino @@ -1,5 +1,4 @@ #include -#define INTERRUPT_PIN 6 //Variable to store the battery voltage static int batteryVoltage; @@ -13,15 +12,15 @@ void setup() Serial.begin(115200); //while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -30,7 +29,7 @@ void setup() controller.reboot(); delay(500); - int dutyInit = 0; // at 50 it works as espected, at 60 shift sides and is too small duty to move, at 70 is very big duty. + int dutyInit = 0; // at 50 it works as expected, at 60 shift sides and is too small duty to move, at 70 is very big duty. M1.setDuty(dutyInit); M2.setDuty(dutyInit); M3.setDuty(dutyInit); @@ -49,7 +48,7 @@ void loop() { //Take the battery status //float batteryVoltage = (float)battery.getConverted(); - //Reset to the default values if the battery level is lower than 11V + //Reset to the default values if the battery level is lower than 11 V // if (batteryVoltage < 11) // { // Serial.println(" "); @@ -89,8 +88,8 @@ void loop() { delay(10); } - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between Nano & Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/examples/Nano/EncoderTest/EncoderTest.ino b/examples/NanoMotorCarrier/EncoderTest/EncoderTest.ino similarity index 81% rename from examples/Nano/EncoderTest/EncoderTest.ino rename to examples/NanoMotorCarrier/EncoderTest/EncoderTest.ino index f8a2bb7..6b7697d 100644 --- a/examples/Nano/EncoderTest/EncoderTest.ino +++ b/examples/NanoMotorCarrier/EncoderTest/EncoderTest.ino @@ -1,5 +1,4 @@ #include -#define INTERRUPT_PIN 6 //Variable to store the battery voltage static int batteryVoltage; @@ -9,15 +8,15 @@ static int duty = 0; void setup() { - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -55,8 +54,8 @@ void loop() { Serial.println(encoder2.getCountPerSecond()); Serial.println(""); - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between Nano & Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/examples/Nano/IMU_Test/IMU_Test.ino b/examples/NanoMotorCarrier/IMU_Test/IMU_Test.ino similarity index 97% rename from examples/Nano/IMU_Test/IMU_Test.ino rename to examples/NanoMotorCarrier/IMU_Test/IMU_Test.ino index 91d407d..9801f09 100644 --- a/examples/Nano/IMU_Test/IMU_Test.ino +++ b/examples/NanoMotorCarrier/IMU_Test/IMU_Test.ino @@ -66,7 +66,7 @@ void setup() //This code is executed once void loop() //This code is looped forever { - if ((millis() - lastTime) >= 100) //To stream at 10Hz without using additional timers + if ((millis() - lastTime) >= 100) //To stream at 10 Hz without using additional timers { lastTime = millis(); diff --git a/examples/Nano/PID_Position_test/PID_Position_test.ino b/examples/NanoMotorCarrier/PID_Position_test/PID_Position_test.ino similarity index 90% rename from examples/Nano/PID_Position_test/PID_Position_test.ino rename to examples/NanoMotorCarrier/PID_Position_test/PID_Position_test.ino index 5d094a3..f8a9db0 100644 --- a/examples/Nano/PID_Position_test/PID_Position_test.ino +++ b/examples/NanoMotorCarrier/PID_Position_test/PID_Position_test.ino @@ -1,6 +1,4 @@ -#include -//#include -#define INTERRUPT_PIN 6 +#include //Variable to store the battery voltage static int batteryVoltage; @@ -16,15 +14,15 @@ void setup() Serial.begin(115200); while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -40,7 +38,7 @@ void setup() Serial.print("V, Raw "); Serial.println(battery.getRaw()); - int dutyInit = 0; // at 50 it works as espected, at 60 shift sides and is too small duty to move, at 70 is very big duty. + int dutyInit = 0; // at 50 it works as expected, at 60 shift sides and is too small duty to move, at 70 is very big duty. M1.setDuty(dutyInit); M2.setDuty(dutyInit); M3.setDuty(dutyInit); diff --git a/examples/Nano/ServoTest/ServoTest.ino b/examples/NanoMotorCarrier/ServoTest/ServoTest.ino similarity index 71% rename from examples/Nano/ServoTest/ServoTest.ino rename to examples/NanoMotorCarrier/ServoTest/ServoTest.ino index 9ec6b60..8f5477a 100644 --- a/examples/Nano/ServoTest/ServoTest.ino +++ b/examples/NanoMotorCarrier/ServoTest/ServoTest.ino @@ -2,7 +2,6 @@ #include //#include //#include -#define INTERRUPT_PIN 6 void setup() @@ -11,15 +10,15 @@ void setup() Serial.begin(115200); //while (!Serial); - //Establishing the communication with the motor shield + //Establishing the communication with the Motor Carrier if (controller.begin()) { - Serial.print("MKR Motor Shield connected, firmware version "); + Serial.print("Motor Carrier connected, firmware version "); Serial.println(controller.getFWVersion()); } else { - Serial.println("Couldn't connect! Is the red led blinking? You may need to update the firmware with FWUpdater sketch"); + Serial.println("Couldn't connect! Is the red LED blinking? You may need to update the firmware with FWUpdater sketch"); while (1); } @@ -43,7 +42,7 @@ void loop() { //Servo sweep from 0 position to 180 for (int i = 0; i < 180; i += 1) { - //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4 + //Choose which of the servo connectors you want to use: servo1(default), servo2, servo3 or servo4 servo1.setAngle(i); servo2.setAngle(i); servo3.setAngle(i); @@ -58,7 +57,7 @@ void loop() { //Servo sweep from 180 position to 0 for (int i = 180; i > 0; i -= 1) { - //Choose what of all the servo connectors do you want to use: servo1(default), servo2, servo3 or servo4 + //Choose which of the servo connectors you want to use: servo1(default), servo2, servo3 or servo4 servo1.setAngle(i); servo2.setAngle(i); servo3.setAngle(i); @@ -69,8 +68,8 @@ void loop() { } - //Keep active the communication MKR1000 & MKRMotorCarrier - //Ping the samd11 + //Keep active the communication between MKR board & MKR Motor Carrier + //Ping the SAMD11 controller.ping(); //wait delay(50); diff --git a/extras/D11-Bootloader/nvm.h b/extras/D11-Bootloader/nvm.h index 113be06..a86451f 100644 --- a/extras/D11-Bootloader/nvm.h +++ b/extras/D11-Bootloader/nvm.h @@ -1,7 +1,7 @@ #define APP_START 0x00001000 //This gives 1536 bytes of bootloader space. //#define FLASH_SIZE 0x00004000 //This gives 1536 bytes of bootloader space. -/* Target application size can be 15kB */ +/* Target application size can be 15 kB */ /* APP_SIZE is the application section size in kB */ /* Change as per APP_START */ #define APP_SIZE 5 //This is how much flash memory is left for the application. diff --git a/extras/D11-Bootloader/nvm.ino b/extras/D11-Bootloader/nvm.ino index 9c55dc3..ffd07b6 100644 --- a/extras/D11-Bootloader/nvm.ino +++ b/extras/D11-Bootloader/nvm.ino @@ -1,6 +1,6 @@ -/* Application starts from 1kB memory - Bootloader size is 1kB +/* Application starts from 1 kB memory - Bootloader size is 1 kB Change the address if higher boot size is needed -good site for quick conversions. +Good site for quick conversions: http://www.binaryhexconverter.com/hex-to-decimal-converter */ #include "nvm.h" diff --git a/extras/D11-Firmware/D11-Firmware.ino b/extras/D11-Firmware/D11-Firmware.ino index ab3035b..20aad0e 100644 --- a/extras/D11-Firmware/D11-Firmware.ino +++ b/extras/D11-Firmware/D11-Firmware.ino @@ -56,7 +56,7 @@ void setup() { encoders[0] = new EncoderWrapper(ENCODER_2_PIN_A, ENCODER_2_PIN_B, 1); encoders[1] = new EncoderWrapper(ENCODER_1_PIN_A, ENCODER_1_PIN_B, 0); - pid_control[0] = new PIDWrapper(encoders[0]->position, encoders[0]->velocity, dcmotors[0], 0, 10, 100); //10ms period velo, 100ms period pos + pid_control[0] = new PIDWrapper(encoders[0]->position, encoders[0]->velocity, dcmotors[0], 0, 10, 100); //10 ms period velo, 100 ms period pos pid_control[1] = new PIDWrapper(encoders[1]->position, encoders[1]->velocity, dcmotors[1], 1, 10, 100); Wire.begin(I2C_ADDRESS); diff --git a/extras/D11-Firmware/config.h b/extras/D11-Firmware/config.h index 3896279..b415d92 100644 --- a/extras/D11-Firmware/config.h +++ b/extras/D11-Firmware/config.h @@ -1,3 +1,3 @@ -// uncomment to compile for nano motor carrier +// uncomment to compile for Nano Motor Carrier -// #define NANO_MOTOR_CARRIER \ No newline at end of file +// #define NANO_MOTOR_CARRIER diff --git a/keywords.txt b/keywords.txt index 7f7d576..649f862 100644 --- a/keywords.txt +++ b/keywords.txt @@ -1,5 +1,5 @@ ################################################# -# Syntax Coloring Map For Arduino Motor Carrier +# Syntax Coloring Map For ArduinoMotorCarrier ################################################# ####################################### diff --git a/library.properties b/library.properties index e33d348..c47a034 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=ArduinoMotorCarrier -version=2.0.0 +version=2.0.3 author=Arduino maintainer=Arduino -sentence=Allows to use the Arduino Motor Carrier -paragraph=Allows to use the Arduino Motor Carrier +sentence=Allows use of the Arduino Motor Carrier +paragraph=(Nano and MKR version) category=Signal Input/Output -url=http://www.arduino.cc/en/Reference/ -architectures=samd +url=https://www.arduino.cc/reference/en/libraries/arduinomotorcarrier/ +architectures=samd,mbed_portenta includes=ArduinoMotorCarrier.h diff --git a/src/ArduinoMotorCarrier.cpp b/src/ArduinoMotorCarrier.cpp index 33d13d1..fee138c 100644 --- a/src/ArduinoMotorCarrier.cpp +++ b/src/ArduinoMotorCarrier.cpp @@ -1,5 +1,5 @@ /* - ArduinoMotorCarrier.cpp - Library for Arduino Motor Shields + ArduinoMotorCarrier.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -96,4 +96,3 @@ mc::PID pid1; mc::PID pid2; mc::Battery battery; - diff --git a/src/ArduinoMotorCarrier.h b/src/ArduinoMotorCarrier.h index 8d05a24..de29a82 100644 --- a/src/ArduinoMotorCarrier.h +++ b/src/ArduinoMotorCarrier.h @@ -1,5 +1,5 @@ /* - ArduinoMotorCarrier.h - Library for Arduino Motor Shields + ArduinoMotorCarrier.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/Battery.cpp b/src/Battery.cpp index 890b443..554bf8f 100644 --- a/src/Battery.cpp +++ b/src/Battery.cpp @@ -1,5 +1,5 @@ /* - Battery.cpp - Library for Arduino Motor Shields + Battery.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/Battery.h b/src/Battery.h index 781f085..737e412 100644 --- a/src/Battery.h +++ b/src/Battery.h @@ -1,5 +1,5 @@ /* - Battery.h - Library for Arduino Motor Shields + Battery.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/Common.h b/src/Common.h index 784e203..06c81a9 100644 --- a/src/Common.h +++ b/src/Common.h @@ -1,5 +1,5 @@ /* - Common.h - Library for Arduino Motor Shields + Common.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -14,6 +14,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_GENERIC_STM32H747_M4) +#define RESET _RESET +#endif + enum Commands { GET_VERSION = 0x01, RESET, diff --git a/src/DCMotor.cpp b/src/DCMotor.cpp index e837714..6e56805 100644 --- a/src/DCMotor.cpp +++ b/src/DCMotor.cpp @@ -1,5 +1,5 @@ /* - DCMotor.cpp - Library for Arduino Motor Shields + DCMotor.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/DCMotor.h b/src/DCMotor.h index b3b805b..2279491 100644 --- a/src/DCMotor.h +++ b/src/DCMotor.h @@ -1,5 +1,5 @@ /* - DCMotor.h - Library for Arduino Motor Shields + DCMotor.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/Encoder.cpp b/src/Encoder.cpp index 7b09f60..06dd6f2 100644 --- a/src/Encoder.cpp +++ b/src/Encoder.cpp @@ -1,5 +1,5 @@ /* - Encoder.cpp - Library for Arduino Motor Shields + Encoder.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/Encoder.h b/src/Encoder.h index db782f4..91f5455 100644 --- a/src/Encoder.h +++ b/src/Encoder.h @@ -1,5 +1,5 @@ /* - Encoder.h - Library for Arduino Motor Shields + Encoder.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/MKRMotorCarrier.h b/src/MKRMotorCarrier.h index cdf5285..d9943dd 100644 --- a/src/MKRMotorCarrier.h +++ b/src/MKRMotorCarrier.h @@ -1,5 +1,5 @@ /* - MKRMotorCarrier.h - Library for Arduino Motor Shields + MKRMotorCarrier.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -17,7 +17,7 @@ #ifndef __MKRMOTORSHIELD__ #define __MKRMOTORSHIELD__ -#warning "This Header is going to be deprecated please use ArduinoMotorCarrier.h" +#warning "This header is going to be deprecated please use ArduinoMotorCarrier.h" #include "ArduinoMotorCarrier.h" #endif diff --git a/src/MotorController.cpp b/src/MotorController.cpp index 2d30a96..73c06e1 100644 --- a/src/MotorController.cpp +++ b/src/MotorController.cpp @@ -1,5 +1,5 @@ /* - MotorCOntroller.cpp - Library for Arduino Motor Shields + MotorCOntroller.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -50,8 +50,8 @@ float mc::MotorController::getTemperature() { int mc::MotorController::begin() { Wire.begin(); - // PMIC initialization raw APIs: are sused to initialize the - // PMIC when used with nano 33 iot + // PMIC initialization raw APIs: are used to initialize the + // PMIC when used with Nano 33 IoT #ifdef ARDUINO_SAMD_NANO_33_IOT Serial.println("Board: Nano 33 IoT"); enable_battery_charging(); @@ -79,11 +79,11 @@ int mc::MotorController::getFreeRam() { void mc::MotorController::enable_battery_charging() { Wire.beginTransmission(PMIC_ADDRESS); Wire.write(PMIC_REG00); - Wire.write(0x06); // min sys voltage 3.88V + max input current 2.0 A + Wire.write(0x06); // min sys voltage 3.88 V + max input current 2.0 A Wire.endTransmission(); Wire.beginTransmission(PMIC_ADDRESS); Wire.write(PMIC_REG01); - Wire.write(0x1B); // Charge Battery + Minimum System Voltage 3.5V + Wire.write(0x1B); // Charge Battery + Minimum System Voltage 3.5 V Wire.endTransmission(); Wire.beginTransmission(PMIC_ADDRESS); Wire.write(PMIC_REG02); @@ -91,10 +91,10 @@ void mc::MotorController::enable_battery_charging() { Wire.endTransmission(); Wire.beginTransmission(PMIC_ADDRESS); Wire.write(PMIC_REG04); - Wire.write(0x9E); // Charge Voltage Limit 4.128V + Wire.write(0x9E); // Charge Voltage Limit 4.128 V Wire.endTransmission(); Wire.beginTransmission(PMIC_ADDRESS); Wire.write(PMIC_REG05); Wire.write(0x8A); // Enable Battery Charge termination + disable watchdog Wire.endTransmission(); -} \ No newline at end of file +} diff --git a/src/MotorController.h b/src/MotorController.h index f03a024..1c34a49 100644 --- a/src/MotorController.h +++ b/src/MotorController.h @@ -1,5 +1,5 @@ /* - MotorController.h - Library for Arduino Motor Shields + MotorController.h - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -38,4 +38,4 @@ class MotorController { }; } -#endif //__MKRMOTORCONTROLLER__ \ No newline at end of file +#endif //__MKRMOTORCONTROLLER__ diff --git a/src/NanoMotorCarrier.h b/src/NanoMotorCarrier.h index 63d1288..877e074 100644 --- a/src/NanoMotorCarrier.h +++ b/src/NanoMotorCarrier.h @@ -1,4 +1,4 @@ -/*- Library for Arduino Motor Shields +/*- Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,7 +16,7 @@ #ifndef __NANOMOTORSHIELD__ #define __NANOMOTORSHIELD__ -#warning "This Header is going to be deprecated please use ArduinoMotorCarrier.h" +#warning "This header is going to be deprecated please use ArduinoMotorCarrier.h" #include "ArduinoMotorCarrier.h" #endif diff --git a/src/PID.cpp b/src/PID.cpp index 776be40..64caf83 100644 --- a/src/PID.cpp +++ b/src/PID.cpp @@ -1,5 +1,5 @@ /* - PID.cpp - Library for Arduino Motor Shields + PID.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/ServoMotor.cpp b/src/ServoMotor.cpp index 1ee24eb..e570bb5 100644 --- a/src/ServoMotor.cpp +++ b/src/ServoMotor.cpp @@ -1,5 +1,5 @@ /* - ServoMotor.cpp - Library for Arduino Motor Shields + ServoMotor.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public diff --git a/src/ServoMotor.h b/src/ServoMotor.h index 229b772..49ac88c 100644 --- a/src/ServoMotor.h +++ b/src/ServoMotor.h @@ -1,5 +1,5 @@ /* - ServoMotor.cpp - Library for Arduino Motor Shields + ServoMotor.cpp - Library for Arduino Motor Carriers Copyright (c) 2018-2019 Arduino AG. All right reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public