diff --git a/.github/workflows/check-arduino.yml b/.github/workflows/check-arduino.yml index adb330f..97b2bf2 100644 --- a/.github/workflows/check-arduino.yml +++ b/.github/workflows/check-arduino.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Arduino Lint - uses: arduino/arduino-lint-action@v1 + uses: arduino/arduino-lint-action@v2 with: compliance: specification library-manager: update diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 39fd50f..af33e87 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Compile example sketches uses: arduino/compile-sketches@v1 @@ -54,7 +54,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} - name: Save memory usage change report as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v6 with: if-no-files-found: error path: ${{ env.SKETCHES_REPORTS_PATH }} diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index ef7d894..8fc4b8c 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Spell check uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/sync-labels.yml b/.github/workflows/sync-labels.yml index 9cde1ac..6808710 100644 --- a/.github/workflows/sync-labels.yml +++ b/.github/workflows/sync-labels.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Download JSON schema for labels configuration file id: download-schema @@ -70,7 +70,7 @@ jobs: 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@v3 + uses: actions/upload-artifact@v6 with: path: | *.yaml @@ -105,16 +105,16 @@ jobs: echo "::set-output name=flag::--dry-run" - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Download configuration files artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v7 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} path: ${{ env.CONFIGURATIONS_FOLDER }} - name: Remove unneeded artifact - uses: geekyeggo/delete-artifact@v2 + uses: geekyeggo/delete-artifact@v5 with: name: ${{ env.CONFIGURATIONS_ARTIFACT }} diff --git a/README.md b/README.md index 567d7e9..2336228 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,14 @@ > [!IMPORTANT] > -> This library is an upgraded and improved version designed to replace the deprecated [Arduino_MachineControl](https://github.com/arduino-libraries/Arduino_MachineControl). -> +> This library is an upgraded and improved version designed to replace the deprecated [Arduino_MachineControl](https://github.com/arduino-libraries/Arduino_MachineControl). If you need assistance with migration, refer to the [migration guide](https://docs.arduino.cc/tutorials/portenta-machine-control/pmc-arduino-library). +> > Please note that all the [examples](./examples/) provided in this repository are not compatible with the deprecated library. The Portenta Machine Control library enables efficient management of the features of the Portenta Machine Control board. The Arduino Portenta Machine Control is a versatile industrial unit for driving machinery. It offers soft-PLC control, diverse I/O options, and flexible network connectivity. -📦 For more information about this product: -https://www.arduino.cc/pro/hardware/product/portenta-machine-control +📦 For more information about this product, please visit the [product page](https://www.arduino.cc/pro/hardware/product/portenta-machine-control) and refer to the [user manual](https://docs.arduino.cc/tutorials/portenta-machine-control/user-manual/). 📖 For more information about this library please read the documentation [here](./docs/). diff --git a/docs/README.md b/docs/README.md index 56c50af..c0752f1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,17 +1,17 @@ # Portenta Machine Control Library -[![Check Arduino status](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/check-arduino.yml) -[![Compile Examples status](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/compile-examples.yml) -[![Spell Check status](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_MachineControl/actions/workflows/spell-check.yml) +[![Check Arduino status](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/check-arduino.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/check-arduino.yml) +[![Compile Examples status](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/compile-examples.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/compile-examples.yml) +[![Spell Check status](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/spell-check.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/actions/workflows/spell-check.yml) -[![License](https://img.shields.io/badge/License-LGPLv2.1-blue.svg)](https://github.com/arduino-libraries/Arduino_MachineControl/blob/master/LICENSE.txt) +[![License](https://img.shields.io/badge/License-MPLv2.0-blue.svg)](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/blob/main/LICENSE) The Portenta Machine Control Library is a C++ library designed to efficiently manage the functionalities of the Portenta Machine Control board. It provides extensive support for inputs such as digital, analog, and encoder signals, while offering outputs including digital and analog signals. This library also menages communication through protocols like CAN-BUS and serial ports, and allows connectivity via Ethernet, USB, Wi-Fi, and Bluetooth Low Energy. The library empowers users to easily initialize, control, and access the diverse functionalities of the Portenta Machine Control, enhancing its capability and adaptability for industrial applications. 📚 For more information about this library please visit us at: -https://www.arduino.cc/reference/en/libraries/arduino_machinecontrol +https://www.arduino.cc/reference/en/libraries/arduino_portentamachinecontrol/ ## Features @@ -42,8 +42,8 @@ To use this library, you must have a properly powered Portenta Machine Control b Here is a minimal example to control a digital output: ```cpp -// Include the Arduino MachineControl library -#include +// Include the Arduino PortentaMachineControl library +#include void setup() { // Initialize the digital outputs module of the MachineControl library @@ -65,6 +65,7 @@ void loop() { - **[Analog_input_0_10V](../examples/Analog_input/Analog_input_0_10V):** This example demonstrates how to read analog input signals in the 0-10V range. - **[Analog_input_4_20mA](../examples/Analog_input/Analog_input_4_20mA):** This example demonstrates how to read analog input signals in the 4-20mA range. - **[Analog_input_NTC](../examples/Analog_input/Analog_input_NTC):** This example shows reading analog input signals from NTC temperature probes. +- **[Fast_Analog_input_0_10V](../examples/Analog_input/Fast_Analog_input_0_10V):** This example demonstrates how to read analog input signals in the 0-10V range using the [Arduino_AdvancedAnalog](https://github.com/arduino-libraries/Arduino_AdvancedAnalog) library. - **[Analog_Out](../examples/Analog_Out):** This example shows how to control analog output signals. - **[ReadCan](../examples/CAN/ReadCan):** This example demonstrates how to read data using the CAN-BUS communication protocol. - **[WriteCan](../examples/CAN/WriteCan):** This example demonstrates how to send data using the CAN-BUS communication protocol. @@ -88,4 +89,4 @@ The API documentation can be found [here](./api.md). ## License -This library is released under the [LGPLv2.1 license](https://github.com/arduino-libraries/Arduino_MachineControl/blob/master/LICENSE.txt). +This library is released under the [MPL-2.0 license](https://github.com/arduino-libraries/Arduino_PortentaMachineControl/blob/main/LICENSE). diff --git a/examples/Analog_Out/Analog_Out.ino b/examples/Analog_Out/Analog_Out.ino index d154fed..0a168b5 100644 --- a/examples/Analog_Out/Analog_Out.ino +++ b/examples/Analog_Out/Analog_Out.ino @@ -9,9 +9,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Analog_input/Analog_input_0_10V/Analog_input_0_10V.ino b/examples/Analog_input/Analog_input_0_10V/Analog_input_0_10V.ino index c1c9bff..698a6e4 100644 --- a/examples/Analog_input/Analog_input_0_10V/Analog_input_0_10V.ino +++ b/examples/Analog_input/Analog_input_0_10V/Analog_input_0_10V.ino @@ -11,9 +11,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Analog_input/Analog_input_4_20mA/Analog_input_4_20mA.ino b/examples/Analog_input/Analog_input_4_20mA/Analog_input_4_20mA.ino index ac6b795..7d67c6a 100644 --- a/examples/Analog_input/Analog_input_4_20mA/Analog_input_4_20mA.ino +++ b/examples/Analog_input/Analog_input_4_20mA/Analog_input_4_20mA.ino @@ -11,9 +11,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino b/examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino index 7a3ab25..010e401 100644 --- a/examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino +++ b/examples/Analog_input/Analog_input_NTC/Analog_input_NTC.ino @@ -13,9 +13,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Analog_input/Fast_Analog_input_0_10V/Fast_Analog_input_0_10V.ino b/examples/Analog_input/Fast_Analog_input_0_10V/Fast_Analog_input_0_10V.ino index 7d2e01c..a4d986e 100644 --- a/examples/Analog_input/Fast_Analog_input_0_10V/Fast_Analog_input_0_10V.ino +++ b/examples/Analog_input/Fast_Analog_input_0_10V/Fast_Analog_input_0_10V.ino @@ -11,7 +11,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/CAN/ReadCan/ReadCan.ino b/examples/CAN/ReadCan/ReadCan.ino index acecb49..75c6474 100644 --- a/examples/CAN/ReadCan/ReadCan.ino +++ b/examples/CAN/ReadCan/ReadCan.ino @@ -8,9 +8,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/CAN/WriteCan/WriteCan.ino b/examples/CAN/WriteCan/WriteCan.ino index 727cc10..4ea4c3d 100644 --- a/examples/CAN/WriteCan/WriteCan.ino +++ b/examples/CAN/WriteCan/WriteCan.ino @@ -8,9 +8,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Digital_output/Digital_output.ino b/examples/Digital_output/Digital_output.ino index 87c73e0..908bde2 100644 --- a/examples/Digital_output/Digital_output.ino +++ b/examples/Digital_output/Digital_output.ino @@ -15,9 +15,9 @@ * * NOTE: connect pin "24V IN" of the DIGITAL_OUTPUTS connector to 24V * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Digital_programmable/Digital_input/Digital_input.ino b/examples/Digital_programmable/Digital_input/Digital_input.ino index c2ed18b..0cbe06b 100644 --- a/examples/Digital_programmable/Digital_input/Digital_input.ino +++ b/examples/Digital_programmable/Digital_input/Digital_input.ino @@ -7,9 +7,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Digital_programmable/GPIO_programmable/GPIO_programmable.ino b/examples/Digital_programmable/GPIO_programmable/GPIO_programmable.ino index 2b9f982..94ac303 100644 --- a/examples/Digital_programmable/GPIO_programmable/GPIO_programmable.ino +++ b/examples/Digital_programmable/GPIO_programmable/GPIO_programmable.ino @@ -9,9 +9,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Encoders/Encoders.ino b/examples/Encoders/Encoders.ino index c241322..c7a640e 100644 --- a/examples/Encoders/Encoders.ino +++ b/examples/Encoders/Encoders.ino @@ -8,9 +8,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Ethernet/Ethernet.ino b/examples/Ethernet/Ethernet.ino index 3857491..e8adf61 100644 --- a/examples/Ethernet/Ethernet.ino +++ b/examples/Ethernet/Ethernet.ino @@ -9,7 +9,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/RS232/RS232.ino b/examples/RS232/RS232.ino index c66df65..1373afa 100644 --- a/examples/RS232/RS232.ino +++ b/examples/RS232/RS232.ino @@ -13,9 +13,9 @@ * - Connect PMC RXP to RS232 Device TXD * - Connect PMC GND to RS232 Device GND * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/RS485_fullduplex/RS485_fullduplex.ino b/examples/RS485_fullduplex/RS485_fullduplex.ino index d7e79a3..ff4dbe6 100644 --- a/examples/RS485_fullduplex/RS485_fullduplex.ino +++ b/examples/RS485_fullduplex/RS485_fullduplex.ino @@ -12,9 +12,9 @@ * - Connect TXP to A(+) and TXN to B(-) * - Connect RXP to Y(+) and RXN to Z(-) * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include "Arduino_PortentaMachineControl.h" @@ -38,7 +38,7 @@ void setup() { // - Half Duplex // - No A/B and Y/Z 120 Ohm termination enabled // Enable the RS485/RS232 system - MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication + MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial_config and preamble and postamble times for RS485 communication // Enable Full Duplex mode // This will also enable A/B and Y/Z 120 Ohm termination resistors @@ -70,4 +70,4 @@ void loop() { sendNow = millis() + sendInterval; } -} \ No newline at end of file +} diff --git a/examples/RS485_halfduplex/RS485_halfduplex.ino b/examples/RS485_halfduplex/RS485_halfduplex.ino index 049096c..9da354a 100644 --- a/examples/RS485_halfduplex/RS485_halfduplex.ino +++ b/examples/RS485_halfduplex/RS485_halfduplex.ino @@ -11,9 +11,9 @@ * - A Slave device with RS485 interface * - Connect TXP to A(+) and TXN to B(-) * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include "Arduino_PortentaMachineControl.h" @@ -37,7 +37,7 @@ void setup() { // - Half Duplex // - No A/B and Y/Z 120 Ohm termination enabled // Enable the RS485/RS232 system - MachineControl_RS485Comm.begin(115200, 0, 500); // Specify baudrate, and preamble and postamble times for RS485 communication + MachineControl_RS485Comm.begin(115200, SERIAL_8N1, 0, 500); // Specify baudrate, serial config and preamble and postamble times for RS485 communication // Start in receive mode MachineControl_RS485Comm.receive(); @@ -65,4 +65,4 @@ void loop() { sendNow = millis() + sendInterval; } -} \ No newline at end of file +} diff --git a/examples/RTC/RTC.ino b/examples/RTC/RTC.ino index cf87cfa..ba94ef4 100644 --- a/examples/RTC/RTC.ino +++ b/examples/RTC/RTC.ino @@ -8,9 +8,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include @@ -62,7 +62,7 @@ void loop() { Serial.print(":"); Serial.println(MachineControl_RTCController.getSeconds()); - time_t utc_time = time(NULL); + time_t utc_time = MachineControl_RTCController.getEpoch(); Serial.print("Date as UTC time: "); Serial.println(utc_time); Serial.println(); diff --git a/examples/RTC_Alarm/RTC_Alarm.ino b/examples/RTC_Alarm/RTC_Alarm.ino index 594fbb3..a2aa7d5 100644 --- a/examples/RTC_Alarm/RTC_Alarm.ino +++ b/examples/RTC_Alarm/RTC_Alarm.ino @@ -8,9 +8,9 @@ * - Portenta H7 * - Portenta Machine Control * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Temp_probes_RTD/Temp_probes_RTD.ino b/examples/Temp_probes_RTD/Temp_probes_RTD.ino index 2fe8826..b732bec 100644 --- a/examples/Temp_probes_RTD/Temp_probes_RTD.ino +++ b/examples/Temp_probes_RTD/Temp_probes_RTD.ino @@ -12,9 +12,9 @@ * - Portenta Machine Control * - 3-wire RTD or 2-wire RTD * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/Temp_probes_Thermocouples/Temp_probes_Thermocouples.ino b/examples/Temp_probes_Thermocouples/Temp_probes_Thermocouples.ino index 98d9ce2..db62fd7 100644 --- a/examples/Temp_probes_Thermocouples/Temp_probes_Thermocouples.ino +++ b/examples/Temp_probes_Thermocouples/Temp_probes_Thermocouples.ino @@ -11,9 +11,9 @@ * - Two K Type thermocouple temperature sensors connected to TEMP PROBES CH0 and CH1 * - A J Type thermocouple temperature sensor connected to TEMP PROBES CH3 * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/examples/USB_host/USB_host.ino b/examples/USB_host/USB_host.ino index ac47db7..2f07c04 100644 --- a/examples/USB_host/USB_host.ino +++ b/examples/USB_host/USB_host.ino @@ -8,9 +8,9 @@ * - Portenta Machine Control * - USB device (e.g., keyboard, mouse, etc.) * - * Initial author: Riccardo Rizzo @Rocketct - * Authors who have contributed to updates: - * - Leonardo Cavagnis @leonardocavagnis + * This example code is in the public domain. + * Copyright (c) 2024 Arduino + * SPDX-License-Identifier: MPL-2.0 */ #include diff --git a/library.properties b/library.properties index 928a25b..850305f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_PortentaMachineControl -version=1.0.0 +version=1.0.4 author=Arduino maintainer=Arduino sentence=Arduino Library for Portenta Machine Control (PMC) diff --git a/src/DigitalOutputsClass.cpp b/src/DigitalOutputsClass.cpp index 97eb7a4..cf492f4 100644 --- a/src/DigitalOutputsClass.cpp +++ b/src/DigitalOutputsClass.cpp @@ -77,7 +77,7 @@ void DigitalOutputsClass::write(uint8_t channel, PinStatus val) { void DigitalOutputsClass::writeAll(uint8_t val_mask) { for (uint8_t ch = 0; ch < 8; ch++) { - if (val_mask && (1 << ch)) { + if (val_mask & (1 << ch)) { write(ch, HIGH); } else { write(ch, LOW); @@ -94,4 +94,4 @@ void DigitalOutputsClass::_setAutoRetryMode() { } DigitalOutputsClass MachineControl_DigitalOutputs; -/**** END OF FILE ****/ \ No newline at end of file +/**** END OF FILE ****/ diff --git a/src/EncoderClass.cpp b/src/EncoderClass.cpp index 3fe546f..7308f07 100644 --- a/src/EncoderClass.cpp +++ b/src/EncoderClass.cpp @@ -63,5 +63,14 @@ int EncoderClass::getRevolutions(int channel) { } } +void EncoderClass::setEncoding(int channel, QEI::Encoding encoding) { + switch (channel) { + case 0: + return _enc0.setEncoding(encoding); + case 1: + return _enc1.setEncoding(encoding); + } +} + EncoderClass MachineControl_Encoders; /**** END OF FILE ****/ \ No newline at end of file diff --git a/src/EncoderClass.h b/src/EncoderClass.h index ecb18d1..3f76085 100644 --- a/src/EncoderClass.h +++ b/src/EncoderClass.h @@ -94,6 +94,16 @@ class EncoderClass { */ int getRevolutions(int channel); + /** + * @brief Set the encoding type for the specified encoder channel. + * + * This method changes the encoding type from the default X2_ENCODING. + * + * @param channel The encoder channel (0 or 1) to be changed. + * @param encoding The encoding type. + */ + void setEncoding(int channel, QEI::Encoding encoding); + private: QEI _enc0; // QEI object for encoder 0 QEI _enc1; // QEI object for encoder 1 diff --git a/src/RS485CommClass.cpp b/src/RS485CommClass.cpp index 4cd4b75..c7afa6d 100644 --- a/src/RS485CommClass.cpp +++ b/src/RS485CommClass.cpp @@ -17,7 +17,7 @@ RS485CommClass::RS485CommClass(arduino::UART& uart_itf, PinName rs_tx_pin, PinNa RS485CommClass::~RS485CommClass() { } -void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay) { +void RS485CommClass::begin(unsigned long baudrate, uint16_t config, int predelay, int postdelay) { /* Pinout configuration */ pinMode(PinNameToIndex(MC_RS485_TX_PIN), OUTPUT); pinMode(PinNameToIndex(MC_RS485_RX_PIN), OUTPUT); @@ -45,7 +45,7 @@ void RS485CommClass::begin(unsigned long baudrate, int predelay, int postdelay) _enable(); /* Call begin() base class to initialize RS485 communication */ - RS485Class::begin(baudrate, predelay, postdelay); + RS485Class::begin(baudrate, config, predelay, postdelay); return; } @@ -92,4 +92,4 @@ void RS485CommClass::_disable() { arduino::UART _UART4_ {MC_RS485_TX_PIN, MC_RS485_RX_PIN, NC, NC}; RS485CommClass MachineControl_RS485Comm(_UART4_); -/**** END OF FILE ****/ \ No newline at end of file +/**** END OF FILE ****/ diff --git a/src/RS485CommClass.h b/src/RS485CommClass.h index b518533..a87d91e 100644 --- a/src/RS485CommClass.h +++ b/src/RS485CommClass.h @@ -54,10 +54,11 @@ class RS485CommClass : public RS485Class { * This method initializes the RS485 communication protocol with the specified baud rate and pre/post delays. * * @param baudrate The desired baud rate for the RS485 communication. + * @param config The desired Serial config (bits, parity and stopbits), see HardwareSerial.h * @param predelay The delay before sending data in the RS485 communication (default: RS485_DEFAULT_PRE_DELAY). * @param postdelay The delay after sending data in the RS485 communication (default: RS485_DEFAULT_POST_DELAY). */ - void begin(unsigned long baudrate = 115200, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY); + void begin(unsigned long baudrate = 115200, uint16_t config = SERIAL_8N1, int predelay = RS485_DEFAULT_PRE_DELAY, int postdelay = RS485_DEFAULT_POST_DELAY); /** * @brief Close the RS485 communication protocol. diff --git a/src/RTDTempProbeClass.cpp b/src/RTDTempProbeClass.cpp index a64a910..382c21a 100644 --- a/src/RTDTempProbeClass.cpp +++ b/src/RTDTempProbeClass.cpp @@ -20,7 +20,7 @@ RTDTempProbeClass::RTDTempProbeClass(PinName rtd_cs_pin, PinName ch_sel1_pin, PinName ch_sel2_pin, PinName rtd_th_pin) -: MAX31865Class(rtd_cs_pin), _rtd_cs{rtd_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel0_pin}, _ch_sel2{ch_sel2_pin}, _rtd_th{rtd_th_pin} +: MAX31865Class(rtd_cs_pin), _rtd_cs{rtd_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel1_pin}, _ch_sel2{ch_sel2_pin}, _rtd_th{rtd_th_pin} { } RTDTempProbeClass::~RTDTempProbeClass() diff --git a/src/TCTempProbeClass.cpp b/src/TCTempProbeClass.cpp index 9bf5138..7d40699 100644 --- a/src/TCTempProbeClass.cpp +++ b/src/TCTempProbeClass.cpp @@ -18,8 +18,9 @@ uint8_t* boardInfo(); TCTempProbeClass::TCTempProbeClass(PinName tc_cs_pin, PinName ch_sel0_pin, PinName ch_sel1_pin, - PinName ch_sel2_pin) -: MAX31855Class(tc_cs_pin), _tc_cs{tc_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel0_pin}, _ch_sel2{ch_sel2_pin} + PinName ch_sel2_pin, + PinName tc_th_pin) +: MAX31855Class(tc_cs_pin), _tc_cs{tc_cs_pin}, _ch_sel0{ch_sel0_pin}, _ch_sel1{ch_sel1_pin}, _ch_sel2{ch_sel2_pin}, _tc_th{tc_th_pin} { } TCTempProbeClass::~TCTempProbeClass() @@ -31,6 +32,7 @@ bool TCTempProbeClass::begin() { pinMode(_ch_sel0, OUTPUT); pinMode(_ch_sel1, OUTPUT); pinMode(_ch_sel2, OUTPUT); + pinMode(_tc_th, OUTPUT); pinMode(_tc_cs, OUTPUT); @@ -92,11 +94,13 @@ void TCTempProbeClass::end() { void TCTempProbeClass::_enable() { digitalWrite(_tc_cs, LOW); + digitalWrite(_tc_th, LOW); } void TCTempProbeClass::_disable() { digitalWrite(_tc_cs, HIGH); + digitalWrite(_tc_th, HIGH); } TCTempProbeClass MachineControl_TCTempProbe; -/**** END OF FILE ****/ \ No newline at end of file +/**** END OF FILE ****/ diff --git a/src/TCTempProbeClass.h b/src/TCTempProbeClass.h index 7001042..f0e74a0 100644 --- a/src/TCTempProbeClass.h +++ b/src/TCTempProbeClass.h @@ -41,7 +41,8 @@ class TCTempProbeClass: public MAX31855Class { TCTempProbeClass(PinName tc_cs_pin = MC_TC_CS_PIN, PinName ch_sel0_pin = MC_TC_SEL0_PIN, PinName ch_sel1_pin = MC_TC_SEL1_PIN, - PinName ch_sel2_pin = MC_TC_SEL2_PIN); + PinName ch_sel2_pin = MC_TC_SEL2_PIN, + PinName tc_th_pin = MC_TC_TH_PIN); /** * @brief Destruct the TCTempProbeClass object. @@ -74,6 +75,7 @@ class TCTempProbeClass: public MAX31855Class { PinName _ch_sel0; // Pin for the first channel selection bit PinName _ch_sel1; // Pin for the second channel selection bit PinName _ch_sel2; // Pin for the third channel selection bit + PinName _tc_th; // Pin for the TC/RTD connection /** * @brief Enable the chip select (CS) of the MAX31855 digital converter. diff --git a/src/pins_mc.h b/src/pins_mc.h index d89a75c..089466c 100644 --- a/src/pins_mc.h +++ b/src/pins_mc.h @@ -84,6 +84,7 @@ #define MC_TC_SEL0_PIN MC_RTD_SEL0_PIN #define MC_TC_SEL1_PIN MC_RTD_SEL1_PIN #define MC_TC_SEL2_PIN MC_RTD_SEL2_PIN +#define MC_TC_TH_PIN MC_RTD_TH_PIN /* USB */ #define MC_USB_PWR_PIN PB_14 diff --git a/src/utility/MAX31865/MAX31865.cpp b/src/utility/MAX31865/MAX31865.cpp index 985812e..cdcd1e4 100644 --- a/src/utility/MAX31865/MAX31865.cpp +++ b/src/utility/MAX31865/MAX31865.cpp @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2021 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "MAX31865.h" diff --git a/src/utility/MAX31865/MAX31865.h b/src/utility/MAX31865/MAX31865.h index f95969b..eb689af 100644 --- a/src/utility/MAX31865/MAX31865.h +++ b/src/utility/MAX31865/MAX31865.h @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2021 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #ifndef MAX31865_H #define MAX31865_H diff --git a/src/utility/QEI/QEI.cpp b/src/utility/QEI/QEI.cpp index db767db..7ef3f57 100644 --- a/src/utility/QEI/QEI.cpp +++ b/src/utility/QEI/QEI.cpp @@ -148,19 +148,7 @@ QEI::QEI(PinName channelA, currState_ = (chanA << 1) | (chanB); prevState_ = currState_; - //X2 encoding uses interrupts on only channel A. - //X4 encoding uses interrupts on channel A, - //and on channel B. - channelA_.rise(mbed::callback(this, &QEI::encode)); - if(encoding != X1_ENCODING){ - channelA_.fall(mbed::callback(this, &QEI::encode)); - } - - //If we're using X4 encoding, then attach interrupts to channel B too. - if (encoding == X4_ENCODING) { - channelB_.rise(mbed::callback(this, &QEI::encode)); - channelB_.fall(mbed::callback(this, &QEI::encode)); - } + setEncoding(encoding); //Index is optional. if (index != NC) { index_.rise(mbed::callback(this, &QEI::index)); @@ -193,6 +181,24 @@ int QEI::getRevolutions(void) { } +void QEI::setEncoding(Encoding encoding) { + //X2 encoding uses interrupts on only channel A. + //X4 encoding uses interrupts on channel A, + //and on channel B. + channelA_.rise(mbed::callback(this, &QEI::encode)); + if(encoding != X1_ENCODING){ + channelA_.fall(mbed::callback(this, &QEI::encode)); + } else { + channelA_.fall(0); + } + + //If we're using X4 encoding, then attach interrupts to channel B too. + if (encoding == X4_ENCODING) { + channelB_.rise(mbed::callback(this, &QEI::encode)); + channelB_.fall(mbed::callback(this, &QEI::encode)); + } +} + // +-------------+ // | X1 Encoding | // +-------------+ diff --git a/src/utility/QEI/QEI.h b/src/utility/QEI/QEI.h index 8e6fba0..caa449d 100644 --- a/src/utility/QEI/QEI.h +++ b/src/utility/QEI/QEI.h @@ -208,6 +208,13 @@ class QEI { */ int getRevolutions(void); + /** + * Set the ecoding type of the encoder. + * + * Changes the type of encoding used by the encoder from the default X2_ENCODING. + */ + void setEncoding(Encoding encoding); + private: /** diff --git a/src/utility/RTC/PCF8563T.cpp b/src/utility/RTC/PCF8563T.cpp index 57d5a21..307eb96 100644 --- a/src/utility/RTC/PCF8563T.cpp +++ b/src/utility/RTC/PCF8563T.cpp @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2020 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "PCF8563T.h" #define PCF8563T_ADDRESS 0x51 diff --git a/src/utility/RTC/PCF8563T.h b/src/utility/RTC/PCF8563T.h index 12786cb..5ac6be5 100644 --- a/src/utility/RTC/PCF8563T.h +++ b/src/utility/RTC/PCF8563T.h @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2020 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #ifndef _PCF8563T_H_INCLUDED #define _PCF8563T_H_INCLUDED diff --git a/src/utility/THERMOCOUPLE/MAX31855.cpp b/src/utility/THERMOCOUPLE/MAX31855.cpp index 80f580e..03f5b23 100644 --- a/src/utility/THERMOCOUPLE/MAX31855.cpp +++ b/src/utility/THERMOCOUPLE/MAX31855.cpp @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2020 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "MAX31855.h" const double MAX31855Class::Jm210_760[] ; @@ -227,7 +208,7 @@ float MAX31855Class::readReferenceTemperature(int type) // The cold junction reference temperature is stored in the first 11 word's bits // sent by the Thermocouple-to-Digital Converter - rawword = rawword & 0x7FF; + rawword = rawword & 0xFFF; // check sign bit and convert to negative value. if (rawword & 0x800) { ref = (0xF800 | (rawword & 0x7FF))*0.0625; @@ -235,7 +216,7 @@ float MAX31855Class::readReferenceTemperature(int type) // multiply for the LSB value ref = rawword * 0.0625f; } - Serial.println(ref); + return ref; } diff --git a/src/utility/THERMOCOUPLE/MAX31855.h b/src/utility/THERMOCOUPLE/MAX31855.h index 4334c3c..f2924b7 100644 --- a/src/utility/THERMOCOUPLE/MAX31855.h +++ b/src/utility/THERMOCOUPLE/MAX31855.h @@ -1,22 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (c) 2020 Arduino SA. - - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #ifndef _MAX31855_H_ #define _MAX31855_H_ diff --git a/src/utility/ioexpander/ArduinoIOExpander.cpp b/src/utility/ioexpander/ArduinoIOExpander.cpp index 461e72e..b2c1738 100644 --- a/src/utility/ioexpander/ArduinoIOExpander.cpp +++ b/src/utility/ioexpander/ArduinoIOExpander.cpp @@ -1,19 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (C) 2020 Arduino AG (http://www.arduino.cc/) - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #include "ArduinoIOExpander.h" bool ArduinoIOExpanderClass::begin() diff --git a/src/utility/ioexpander/ArduinoIOExpander.h b/src/utility/ioexpander/ArduinoIOExpander.h index e7cd402..66e4de1 100644 --- a/src/utility/ioexpander/ArduinoIOExpander.h +++ b/src/utility/ioexpander/ArduinoIOExpander.h @@ -1,19 +1,3 @@ -/* - This file is part of the MachineControl library. - Copyright (C) 2020 Arduino AG (http://www.arduino.cc/) - 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 Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - #pragma once #include