sync it
parent
946ff71217
commit
22890b0902
|
@ -0,0 +1,6 @@
|
|||
[submodule "hal/hal-pca9685/Adafruit-PWM-Servo-Driver-Library"]
|
||||
path = hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library
|
||||
url = https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
|
||||
[submodule "hal/hal-ads1115/doc/ADS1X15"]
|
||||
path = hal/hal-ads1115/doc/ADS1X15
|
||||
url = https://github.com/RobTillaart/ADS1X15.git
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 320f17e077b32aef3b43a144d0b1bcc3c8d8ea00
|
46
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/ISSUE_TEMPLATE.md
vendored
Normal file
46
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/ISSUE_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
Thank you for opening an issue on an Adafruit Arduino library repository. To
|
||||
improve the speed of resolution please review the following guidelines and
|
||||
common troubleshooting steps below before creating the issue:
|
||||
|
||||
- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
|
||||
the forums at http://forums.adafruit.com to ask questions and troubleshoot why
|
||||
something isn't working as expected. In many cases the problem is a common issue
|
||||
that you will more quickly receive help from the forum community. GitHub issues
|
||||
are meant for known defects in the code. If you don't know if there is a defect
|
||||
in the code then start with troubleshooting on the forum first.
|
||||
|
||||
- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
|
||||
check all of the steps and commands to run have been followed. Consult the
|
||||
forum if you're unsure or have questions about steps in a guide/tutorial.
|
||||
|
||||
- **For Arduino projects check these very common issues to ensure they don't apply**:
|
||||
|
||||
- For uploading sketches or communicating with the board make sure you're using
|
||||
a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
|
||||
very hard to tell the difference between a data and charge cable! Try using the
|
||||
cable with other devices or swapping to another cable to confirm it is not
|
||||
the problem.
|
||||
|
||||
- **Be sure you are supplying adequate power to the board.** Check the specs of
|
||||
your board and plug in an external power supply. In many cases just
|
||||
plugging a board into your computer is not enough to power it and other
|
||||
peripherals.
|
||||
|
||||
- **Double check all soldering joints and connections.** Flakey connections
|
||||
cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
|
||||
|
||||
- **Ensure you are using an official Arduino or Adafruit board.** We can't
|
||||
guarantee a clone board will have the same functionality and work as expected
|
||||
with this code and don't support them.
|
||||
|
||||
If you're sure this issue is a defect in the code and checked the steps above
|
||||
please fill in the following fields to provide enough troubleshooting information.
|
||||
You may delete the guideline and text above to just leave the following details:
|
||||
|
||||
- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
|
||||
|
||||
- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
|
||||
VERSION HERE**
|
||||
|
||||
- List the steps to reproduce the problem below (if possible attach a sketch or
|
||||
copy the sketch code in too): **LIST REPRO STEPS BELOW**
|
26
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
26
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
Thank you for creating a pull request to contribute to Adafruit's GitHub code!
|
||||
Before you open the request please review the following guidelines and tips to
|
||||
help it be more easily integrated:
|
||||
|
||||
- **Describe the scope of your change--i.e. what the change does and what parts
|
||||
of the code were modified.** This will help us understand any risks of integrating
|
||||
the code.
|
||||
|
||||
- **Describe any known limitations with your change.** For example if the change
|
||||
doesn't apply to a supported platform of the library please mention it.
|
||||
|
||||
- **Please run any tests or examples that can exercise your modified code.** We
|
||||
strive to not break users of the code and running tests/examples helps with this
|
||||
process.
|
||||
|
||||
Thank you again for contributing! We will try to test and integrate the change
|
||||
as soon as we can, but be aware we have many GitHub repositories to manage and
|
||||
can't immediately respond to every request. There is no need to bump or check in
|
||||
on a pull request (it will clutter the discussion of the request).
|
||||
|
||||
Also don't be worried if the request is closed or not integrated--sometimes the
|
||||
priorities of Adafruit's GitHub code (education, ease of use) might not match the
|
||||
priorities of the pull request. Don't fret, the open source community thrives on
|
||||
forks and GitHub makes it easy to keep your changes in a forked repo.
|
||||
|
||||
After reviewing the guidelines above you can delete this text from the pull request.
|
32
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/workflows/githubci.yml
vendored
Normal file
32
hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/workflows/githubci.yml
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit PCA9685 PWM Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
|
@ -0,0 +1,8 @@
|
|||
# osx
|
||||
.DS_Store
|
||||
|
||||
# doxygen
|
||||
Doxyfile*
|
||||
doxygen_sqlite3.db
|
||||
html
|
||||
*.tmp
|
|
@ -0,0 +1,374 @@
|
|||
/*!
|
||||
* @file Adafruit_PWMServoDriver.cpp
|
||||
*
|
||||
* @mainpage Adafruit 16-channel PWM & Servo driver
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* This is a library for the 16-channel PWM & Servo driver.
|
||||
*
|
||||
* Designed specifically to work with the Adafruit PWM & Servo driver.
|
||||
*
|
||||
* Pick one up today in the adafruit shop!
|
||||
* ------> https://www.adafruit.com/product/815
|
||||
*
|
||||
* These displays use I2C to communicate, 2 pins are required to interface.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit andopen-source hardware by purchasing products
|
||||
* from Adafruit!
|
||||
*
|
||||
* @section author Author
|
||||
*
|
||||
* Limor Fried/Ladyada (Adafruit Industries).
|
||||
*
|
||||
* @section license License
|
||||
*
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#include "Adafruit_PWMServoDriver.h"
|
||||
|
||||
//#define ENABLE_DEBUG_OUTPUT
|
||||
|
||||
/*!
|
||||
* @brief Instantiates a new PCA9685 PWM driver chip with the I2C address on a
|
||||
* TwoWire interface
|
||||
*/
|
||||
Adafruit_PWMServoDriver::Adafruit_PWMServoDriver()
|
||||
: _i2caddr(PCA9685_I2C_ADDRESS), _i2c(&Wire) {}
|
||||
|
||||
/*!
|
||||
* @brief Instantiates a new PCA9685 PWM driver chip with the I2C address on a
|
||||
* TwoWire interface
|
||||
* @param addr The 7-bit I2C address to locate this chip, default is 0x40
|
||||
*/
|
||||
Adafruit_PWMServoDriver::Adafruit_PWMServoDriver(const uint8_t addr)
|
||||
: _i2caddr(addr), _i2c(&Wire) {}
|
||||
|
||||
/*!
|
||||
* @brief Instantiates a new PCA9685 PWM driver chip with the I2C address on a
|
||||
* TwoWire interface
|
||||
* @param addr The 7-bit I2C address to locate this chip, default is 0x40
|
||||
* @param i2c A reference to a 'TwoWire' object that we'll use to communicate
|
||||
* with
|
||||
*/
|
||||
Adafruit_PWMServoDriver::Adafruit_PWMServoDriver(const uint8_t addr,
|
||||
TwoWire &i2c)
|
||||
: _i2caddr(addr), _i2c(&i2c) {}
|
||||
|
||||
/*!
|
||||
* @brief Setups the I2C interface and hardware
|
||||
* @param prescale
|
||||
* Sets External Clock (Optional)
|
||||
* @return true if successful, otherwise false
|
||||
*/
|
||||
bool Adafruit_PWMServoDriver::begin(uint8_t prescale) {
|
||||
if (i2c_dev)
|
||||
delete i2c_dev;
|
||||
i2c_dev = new Adafruit_I2CDevice(_i2caddr, _i2c);
|
||||
if (!i2c_dev->begin())
|
||||
return false;
|
||||
reset();
|
||||
|
||||
// set the default internal frequency
|
||||
setOscillatorFrequency(FREQUENCY_OSCILLATOR);
|
||||
|
||||
if (prescale) {
|
||||
setExtClk(prescale);
|
||||
} else {
|
||||
// set a default frequency
|
||||
setPWMFreq(1000);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sends a reset command to the PCA9685 chip over I2C
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::reset() {
|
||||
write8(PCA9685_MODE1, MODE1_RESTART);
|
||||
delay(10);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Puts board into sleep mode
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::sleep() {
|
||||
uint8_t awake = read8(PCA9685_MODE1);
|
||||
uint8_t sleep = awake | MODE1_SLEEP; // set sleep bit high
|
||||
write8(PCA9685_MODE1, sleep);
|
||||
delay(5); // wait until cycle ends for sleep to be active
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Wakes board from sleep
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::wakeup() {
|
||||
uint8_t sleep = read8(PCA9685_MODE1);
|
||||
uint8_t wakeup = sleep & ~MODE1_SLEEP; // set sleep bit low
|
||||
write8(PCA9685_MODE1, wakeup);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets EXTCLK pin to use the external clock
|
||||
* @param prescale
|
||||
* Configures the prescale value to be used by the external clock
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::setExtClk(uint8_t prescale) {
|
||||
uint8_t oldmode = read8(PCA9685_MODE1);
|
||||
uint8_t newmode = (oldmode & ~MODE1_RESTART) | MODE1_SLEEP; // sleep
|
||||
write8(PCA9685_MODE1, newmode); // go to sleep, turn off internal oscillator
|
||||
|
||||
// This sets both the SLEEP and EXTCLK bits of the MODE1 register to switch to
|
||||
// use the external clock.
|
||||
write8(PCA9685_MODE1, (newmode |= MODE1_EXTCLK));
|
||||
|
||||
write8(PCA9685_PRESCALE, prescale); // set the prescaler
|
||||
|
||||
delay(5);
|
||||
// clear the SLEEP bit to start
|
||||
write8(PCA9685_MODE1, (newmode & ~MODE1_SLEEP) | MODE1_RESTART | MODE1_AI);
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Mode now 0x");
|
||||
Serial.println(read8(PCA9685_MODE1), HEX);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the PWM frequency for the entire chip, up to ~1.6 KHz
|
||||
* @param freq Floating point frequency that we will attempt to match
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Attempting to set freq ");
|
||||
Serial.println(freq);
|
||||
#endif
|
||||
// Range output modulation frequency is dependant on oscillator
|
||||
if (freq < 1)
|
||||
freq = 1;
|
||||
if (freq > 3500)
|
||||
freq = 3500; // Datasheet limit is 3052=50MHz/(4*4096)
|
||||
|
||||
float prescaleval = ((_oscillator_freq / (freq * 4096.0)) + 0.5) - 1;
|
||||
if (prescaleval < PCA9685_PRESCALE_MIN)
|
||||
prescaleval = PCA9685_PRESCALE_MIN;
|
||||
if (prescaleval > PCA9685_PRESCALE_MAX)
|
||||
prescaleval = PCA9685_PRESCALE_MAX;
|
||||
uint8_t prescale = (uint8_t)prescaleval;
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Final pre-scale: ");
|
||||
Serial.println(prescale);
|
||||
#endif
|
||||
|
||||
uint8_t oldmode = read8(PCA9685_MODE1);
|
||||
uint8_t newmode = (oldmode & ~MODE1_RESTART) | MODE1_SLEEP; // sleep
|
||||
write8(PCA9685_MODE1, newmode); // go to sleep
|
||||
write8(PCA9685_PRESCALE, prescale); // set the prescaler
|
||||
write8(PCA9685_MODE1, oldmode);
|
||||
delay(5);
|
||||
// This sets the MODE1 register to turn on auto increment.
|
||||
write8(PCA9685_MODE1, oldmode | MODE1_RESTART | MODE1_AI);
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Mode now 0x");
|
||||
Serial.println(read8(PCA9685_MODE1), HEX);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the output mode of the PCA9685 to either
|
||||
* open drain or push pull / totempole.
|
||||
* Warning: LEDs with integrated zener diodes should
|
||||
* only be driven in open drain mode.
|
||||
* @param totempole Totempole if true, open drain if false.
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::setOutputMode(bool totempole) {
|
||||
uint8_t oldmode = read8(PCA9685_MODE2);
|
||||
uint8_t newmode;
|
||||
if (totempole) {
|
||||
newmode = oldmode | MODE2_OUTDRV;
|
||||
} else {
|
||||
newmode = oldmode & ~MODE2_OUTDRV;
|
||||
}
|
||||
write8(PCA9685_MODE2, newmode);
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Setting output mode: ");
|
||||
Serial.print(totempole ? "totempole" : "open drain");
|
||||
Serial.print(" by setting MODE2 to ");
|
||||
Serial.println(newmode);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Reads set Prescale from PCA9685
|
||||
* @return prescale value
|
||||
*/
|
||||
uint8_t Adafruit_PWMServoDriver::readPrescale(void) {
|
||||
return read8(PCA9685_PRESCALE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the PWM output of one of the PCA9685 pins
|
||||
* @param num One of the PWM output pins, from 0 to 15
|
||||
* @param off If true, returns PWM OFF value, otherwise PWM ON
|
||||
* @return requested PWM output value
|
||||
*/
|
||||
uint16_t Adafruit_PWMServoDriver::getPWM(uint8_t num, bool off) {
|
||||
uint8_t buffer[2] = {uint8_t(PCA9685_LED0_ON_L + 4 * num), 0};
|
||||
if (off)
|
||||
buffer[0] += 2;
|
||||
i2c_dev->write_then_read(buffer, 1, buffer, 2);
|
||||
return uint16_t(buffer[0]) | (uint16_t(buffer[1]) << 8);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the PWM output of one of the PCA9685 pins
|
||||
* @param num One of the PWM output pins, from 0 to 15
|
||||
* @param on At what point in the 4096-part cycle to turn the PWM output ON
|
||||
* @param off At what point in the 4096-part cycle to turn the PWM output OFF
|
||||
* @return 0 if successful, otherwise 1
|
||||
*/
|
||||
uint8_t Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on,
|
||||
uint16_t off) {
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Setting PWM ");
|
||||
Serial.print(num);
|
||||
Serial.print(": ");
|
||||
Serial.print(on);
|
||||
Serial.print("->");
|
||||
Serial.println(off);
|
||||
#endif
|
||||
|
||||
uint8_t buffer[5];
|
||||
buffer[0] = PCA9685_LED0_ON_L + 4 * num;
|
||||
buffer[1] = on;
|
||||
buffer[2] = on >> 8;
|
||||
buffer[3] = off;
|
||||
buffer[4] = off >> 8;
|
||||
|
||||
if (i2c_dev->write(buffer, 5)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Helper to set pin PWM output. Sets pin without having to deal with
|
||||
* on/off tick placement and properly handles a zero value as completely off and
|
||||
* 4095 as completely on. Optional invert parameter supports inverting the
|
||||
* pulse for sinking to ground.
|
||||
* @param num One of the PWM output pins, from 0 to 15
|
||||
* @param val The number of ticks out of 4096 to be active, should be a value
|
||||
* from 0 to 4095 inclusive.
|
||||
* @param invert If true, inverts the output, defaults to 'false'
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::setPin(uint8_t num, uint16_t val, bool invert) {
|
||||
// Clamp value between 0 and 4095 inclusive.
|
||||
val = min(val, (uint16_t)4095);
|
||||
if (invert) {
|
||||
if (val == 0) {
|
||||
// Special value for signal fully on.
|
||||
setPWM(num, 4096, 0);
|
||||
} else if (val == 4095) {
|
||||
// Special value for signal fully off.
|
||||
setPWM(num, 0, 4096);
|
||||
} else {
|
||||
setPWM(num, 0, 4095 - val);
|
||||
}
|
||||
} else {
|
||||
if (val == 4095) {
|
||||
// Special value for signal fully on.
|
||||
setPWM(num, 4096, 0);
|
||||
} else if (val == 0) {
|
||||
// Special value for signal fully off.
|
||||
setPWM(num, 0, 4096);
|
||||
} else {
|
||||
setPWM(num, 0, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the PWM output of one of the PCA9685 pins based on the input
|
||||
* microseconds, output is not precise
|
||||
* @param num One of the PWM output pins, from 0 to 15
|
||||
* @param Microseconds The number of Microseconds to turn the PWM output ON
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::writeMicroseconds(uint8_t num,
|
||||
uint16_t Microseconds) {
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print("Setting PWM Via Microseconds on output");
|
||||
Serial.print(num);
|
||||
Serial.print(": ");
|
||||
Serial.print(Microseconds);
|
||||
Serial.println("->");
|
||||
#endif
|
||||
|
||||
double pulse = Microseconds;
|
||||
double pulselength;
|
||||
pulselength = 1000000; // 1,000,000 us per second
|
||||
|
||||
// Read prescale
|
||||
uint16_t prescale = readPrescale();
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(prescale);
|
||||
Serial.println(" PCA9685 chip prescale");
|
||||
#endif
|
||||
|
||||
// Calculate the pulse for PWM based on Equation 1 from the datasheet section
|
||||
// 7.3.5
|
||||
prescale += 1;
|
||||
pulselength *= prescale;
|
||||
pulselength /= _oscillator_freq;
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(pulselength);
|
||||
Serial.println(" us per bit");
|
||||
#endif
|
||||
|
||||
pulse /= pulselength;
|
||||
|
||||
#ifdef ENABLE_DEBUG_OUTPUT
|
||||
Serial.print(pulse);
|
||||
Serial.println(" pulse for PWM");
|
||||
#endif
|
||||
|
||||
setPWM(num, 0, pulse);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Getter for the internally tracked oscillator used for freq
|
||||
* calculations
|
||||
* @returns The frequency the PCA9685 thinks it is running at (it cannot
|
||||
* introspect)
|
||||
*/
|
||||
uint32_t Adafruit_PWMServoDriver::getOscillatorFrequency(void) {
|
||||
return _oscillator_freq;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Setter for the internally tracked oscillator used for freq
|
||||
* calculations
|
||||
* @param freq The frequency the PCA9685 should use for frequency calculations
|
||||
*/
|
||||
void Adafruit_PWMServoDriver::setOscillatorFrequency(uint32_t freq) {
|
||||
_oscillator_freq = freq;
|
||||
}
|
||||
|
||||
/******************* Low level I2C interface */
|
||||
uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) {
|
||||
uint8_t buffer[1] = {addr};
|
||||
i2c_dev->write_then_read(buffer, 1, buffer, 1);
|
||||
return buffer[0];
|
||||
}
|
||||
|
||||
void Adafruit_PWMServoDriver::write8(uint8_t addr, uint8_t d) {
|
||||
uint8_t buffer[2] = {addr, d};
|
||||
i2c_dev->write(buffer, 2);
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/*!
|
||||
* @file Adafruit_PWMServoDriver.h
|
||||
*
|
||||
* This is a library for our Adafruit 16-channel PWM & Servo driver.
|
||||
*
|
||||
* Designed specifically to work with the Adafruit 16-channel PWM & Servo
|
||||
* driver.
|
||||
*
|
||||
* Pick one up today in the adafruit shop!
|
||||
* ------> https://www.adafruit.com/product/815
|
||||
*
|
||||
* These driver use I2C to communicate, 2 pins are required to interface.
|
||||
* For Arduino UNOs, thats SCL -> Analog 5, SDA -> Analog 4.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit andopen-source hardware by purchasing products
|
||||
* from Adafruit!
|
||||
*
|
||||
* Limor Fried/Ladyada (Adafruit Industries).
|
||||
*
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
#ifndef _ADAFRUIT_PWMServoDriver_H
|
||||
#define _ADAFRUIT_PWMServoDriver_H
|
||||
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// REGISTER ADDRESSES
|
||||
#define PCA9685_MODE1 0x00 /**< Mode Register 1 */
|
||||
#define PCA9685_MODE2 0x01 /**< Mode Register 2 */
|
||||
#define PCA9685_SUBADR1 0x02 /**< I2C-bus subaddress 1 */
|
||||
#define PCA9685_SUBADR2 0x03 /**< I2C-bus subaddress 2 */
|
||||
#define PCA9685_SUBADR3 0x04 /**< I2C-bus subaddress 3 */
|
||||
#define PCA9685_ALLCALLADR 0x05 /**< LED All Call I2C-bus address */
|
||||
#define PCA9685_LED0_ON_L 0x06 /**< LED0 on tick, low byte*/
|
||||
#define PCA9685_LED0_ON_H 0x07 /**< LED0 on tick, high byte*/
|
||||
#define PCA9685_LED0_OFF_L 0x08 /**< LED0 off tick, low byte */
|
||||
#define PCA9685_LED0_OFF_H 0x09 /**< LED0 off tick, high byte */
|
||||
// etc all 16: LED15_OFF_H 0x45
|
||||
#define PCA9685_ALLLED_ON_L 0xFA /**< load all the LEDn_ON registers, low */
|
||||
#define PCA9685_ALLLED_ON_H 0xFB /**< load all the LEDn_ON registers, high */
|
||||
#define PCA9685_ALLLED_OFF_L 0xFC /**< load all the LEDn_OFF registers, low */
|
||||
#define PCA9685_ALLLED_OFF_H 0xFD /**< load all the LEDn_OFF registers,high */
|
||||
#define PCA9685_PRESCALE 0xFE /**< Prescaler for PWM output frequency */
|
||||
#define PCA9685_TESTMODE 0xFF /**< defines the test mode to be entered */
|
||||
|
||||
// MODE1 bits
|
||||
#define MODE1_ALLCAL 0x01 /**< respond to LED All Call I2C-bus address */
|
||||
#define MODE1_SUB3 0x02 /**< respond to I2C-bus subaddress 3 */
|
||||
#define MODE1_SUB2 0x04 /**< respond to I2C-bus subaddress 2 */
|
||||
#define MODE1_SUB1 0x08 /**< respond to I2C-bus subaddress 1 */
|
||||
#define MODE1_SLEEP 0x10 /**< Low power mode. Oscillator off */
|
||||
#define MODE1_AI 0x20 /**< Auto-Increment enabled */
|
||||
#define MODE1_EXTCLK 0x40 /**< Use EXTCLK pin clock */
|
||||
#define MODE1_RESTART 0x80 /**< Restart enabled */
|
||||
// MODE2 bits
|
||||
#define MODE2_OUTNE_0 0x01 /**< Active LOW output enable input */
|
||||
#define MODE2_OUTNE_1 \
|
||||
0x02 /**< Active LOW output enable input - high impedience */
|
||||
#define MODE2_OUTDRV 0x04 /**< totem pole structure vs open-drain */
|
||||
#define MODE2_OCH 0x08 /**< Outputs change on ACK vs STOP */
|
||||
#define MODE2_INVRT 0x10 /**< Output logic state inverted */
|
||||
|
||||
#define PCA9685_I2C_ADDRESS 0x40 /**< Default PCA9685 I2C Slave Address */
|
||||
#define FREQUENCY_OSCILLATOR 25000000 /**< Int. osc. frequency in datasheet */
|
||||
|
||||
#define PCA9685_PRESCALE_MIN 3 /**< minimum prescale value */
|
||||
#define PCA9685_PRESCALE_MAX 255 /**< maximum prescale value */
|
||||
|
||||
/*!
|
||||
* @brief Class that stores state and functions for interacting with PCA9685
|
||||
* PWM chip
|
||||
*/
|
||||
class Adafruit_PWMServoDriver {
|
||||
public:
|
||||
Adafruit_PWMServoDriver();
|
||||
Adafruit_PWMServoDriver(const uint8_t addr);
|
||||
Adafruit_PWMServoDriver(const uint8_t addr, TwoWire &i2c);
|
||||
bool begin(uint8_t prescale = 0);
|
||||
void reset();
|
||||
void sleep();
|
||||
void wakeup();
|
||||
void setExtClk(uint8_t prescale);
|
||||
void setPWMFreq(float freq);
|
||||
void setOutputMode(bool totempole);
|
||||
uint16_t getPWM(uint8_t num, bool off = false);
|
||||
uint8_t setPWM(uint8_t num, uint16_t on, uint16_t off);
|
||||
void setPin(uint8_t num, uint16_t val, bool invert = false);
|
||||
uint8_t readPrescale(void);
|
||||
void writeMicroseconds(uint8_t num, uint16_t Microseconds);
|
||||
|
||||
void setOscillatorFrequency(uint32_t freq);
|
||||
uint32_t getOscillatorFrequency(void);
|
||||
|
||||
private:
|
||||
uint8_t _i2caddr;
|
||||
TwoWire *_i2c;
|
||||
Adafruit_I2CDevice *i2c_dev = NULL; ///< Pointer to I2C bus interface
|
||||
|
||||
uint32_t _oscillator_freq;
|
||||
uint8_t read8(uint8_t addr);
|
||||
void write8(uint8_t addr, uint8_t d);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,19 @@
|
|||
# Adafruit PCA9685 PWM Servo Driver Library 
|
||||
|
||||
|
||||
This is a library for our Adafruit 16-channel PWM & Servo driver, shield or FeatherWing
|
||||
|
||||
<a href="https://www.adafruit.com/products/815"><img src="https://cdn-shop.adafruit.com/970x728/815-04.jpg" height="300"/></a>
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
* https://www.adafruit.com/products/815
|
||||
* https://www.adafruit.com/product/1411
|
||||
* https://www.adafruit.com/product/2928
|
||||
|
||||
These drivers use I2C to communicate, 2 pins are required to interface.
|
||||
|
||||
Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information.
|
||||
|
||||
All text above must be included in any redistribution
|
|
@ -0,0 +1,49 @@
|
|||
/***************************************************
|
||||
This is an example for our Adafruit 16-channel PWM & Servo driver
|
||||
GPIO test - this will set a pin high/low
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/815
|
||||
|
||||
These drivers use I2C to communicate, 2 pins are required to
|
||||
interface.
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
// called this way, it uses the default address 0x40
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
|
||||
// you can also call it with a different address you want
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
|
||||
// you can also call it with a different address and I2C interface
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("GPIO test!");
|
||||
|
||||
pwm.begin();
|
||||
pwm.setPWMFreq(1000); // Set to whatever you like, we don't use it in this demo!
|
||||
|
||||
// if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
|
||||
// some i2c devices dont like this so much so if you're sharing the bus, watch
|
||||
// out for this!
|
||||
Wire.setClock(400000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Drive each pin in a 'wave'
|
||||
for (uint8_t pin=0; pin<16; pin++) {
|
||||
pwm.setPWM(pin, 4096, 0); // turns pin fully on
|
||||
delay(100);
|
||||
pwm.setPWM(pin, 0, 4096); // turns pin fully off
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
/***************************************************
|
||||
This is an example for our Adafruit 16-channel PWM & Servo driver
|
||||
to calibrate the frequency of the oscillator clock of the PCA9685.
|
||||
|
||||
CAUTION: DO NOT CONNECT ANY VOLTAGE HIGHER THAN THE BOARD LIMITS.
|
||||
For 3.3V boards, like the ESP8266, remove any 5V input. The setup will
|
||||
feed the voltage back into the board to measure the frequency.
|
||||
KABOEM, SMOKE if you use too much VOLTAGE.
|
||||
|
||||
Connect the PCA9685 with I2C (Ground, VCC, SCL, SCA) and apply
|
||||
voltage on V+. See above not higher than board limits.
|
||||
Connect the signal (yellow pin, PWM) of the PCA9685 to your board:
|
||||
Default is pin 3, last of first block.
|
||||
Default is pin 14 (of your ESP8266).
|
||||
|
||||
Formula for prescale to get the targetted frequency (=update_rate) is:
|
||||
prescale = round ( osc_clock / 4096 * update_rate) - 1
|
||||
rewritten: osc_clock = (prescale + 1) * 4096 * update_rate
|
||||
We will measure the real update_rate to assert the real osc_clock.
|
||||
|
||||
***************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
// called this way, it uses the default address 0x40
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
|
||||
// you can also call it with a different address you want
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40);
|
||||
// you can also call it with a different address and I2C interface
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
|
||||
|
||||
#if (defined(ESP8266) || defined(ESP32))
|
||||
|
||||
// Applied frequency in the test: can be changed to get the optimal
|
||||
// oscillator calibration for your targetted frequency.
|
||||
#define FREQUENCY 50
|
||||
|
||||
// CAUTION: ONLY CONNECT server and ESP WITHOUT 5V ON V+ or green breakout supply pins. Use 3.3V on V+
|
||||
#define PIN_SERVO_FEEDBACK 3 // Connect Yellow PWM pin, 3 = last on first block
|
||||
#define PIN_BOARD_FEEDBACK 14 // 14 => D5 on NodeMCU
|
||||
|
||||
uint8_t prescale = 0;
|
||||
// loop
|
||||
#define INTERVAL 1000 // 1 sec
|
||||
int32_t lastEvaluation = 0;
|
||||
uint16_t frozenCounter = 0;
|
||||
uint16_t countDeviations = 0;
|
||||
|
||||
uint32_t totalCounter = 0;
|
||||
uint32_t totalTime = 0; // in millis
|
||||
uint32_t realOsciFreq = 0;
|
||||
uint32_t multiplier = 4096;
|
||||
|
||||
// interrupt
|
||||
volatile uint16_t interruptCounter = 0;
|
||||
|
||||
ICACHE_RAM_ATTR void handleInterrupt() {
|
||||
interruptCounter = interruptCounter + 1;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("PCA9685 Oscillator test");
|
||||
|
||||
// set PCA9685
|
||||
pwm.begin();
|
||||
pwm.setPWMFreq(FREQUENCY); // Set some frequency
|
||||
pwm.setPWM(PIN_SERVO_FEEDBACK,0,2048); // half of time high, half of time low
|
||||
prescale = pwm.readPrescale(); // read prescale
|
||||
Serial.printf("Target frequency: %u\n", FREQUENCY);
|
||||
Serial.printf("Applied prescale: %u\n", prescale);
|
||||
|
||||
// prepare interrupt on ESP pin
|
||||
pinMode(PIN_BOARD_FEEDBACK, INPUT);
|
||||
attachInterrupt(digitalPinToInterrupt(PIN_BOARD_FEEDBACK), handleInterrupt, RISING);
|
||||
|
||||
// take a breath and reset to zero
|
||||
delay(10);
|
||||
interruptCounter = 0;
|
||||
lastEvaluation = millis();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (millis() - lastEvaluation > INTERVAL)
|
||||
{
|
||||
// first freeze counters and adjust for new round
|
||||
frozenCounter = interruptCounter; // first freeze counter
|
||||
interruptCounter = interruptCounter - frozenCounter;
|
||||
lastEvaluation += INTERVAL;
|
||||
|
||||
totalCounter += frozenCounter;
|
||||
totalTime += 1;
|
||||
|
||||
// only print deviations from targetted frequency
|
||||
//if (frozenCounter != FREQUENCY)
|
||||
{
|
||||
multiplier = 4096;
|
||||
realOsciFreq = (prescale + 1) * totalCounter; // first part calcutlation
|
||||
// now follows an ugly hack to have maximum precision in 32 bits
|
||||
while (((realOsciFreq & 0x80000000) == 0) && (multiplier != 1))
|
||||
{
|
||||
realOsciFreq <<= 1;
|
||||
multiplier >>= 1;
|
||||
}
|
||||
realOsciFreq /= totalTime;
|
||||
if (multiplier) realOsciFreq *= multiplier;
|
||||
|
||||
countDeviations++;
|
||||
Serial.printf("%4u", countDeviations);
|
||||
Serial.printf(" Timestamp: %4" PRIu32 " ", totalTime);
|
||||
Serial.printf(" Freq: %4u ", frozenCounter);
|
||||
Serial.printf(" Counter: %6" PRIu32 " ", totalCounter);
|
||||
Serial.printf(" calc.osci.freq: %9" PRIu32 "\n",realOsciFreq);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#else
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("PCA9685 Oscillator test");
|
||||
Serial.println("yet not available for your board."); // please help adapt the code!
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
|
||||
#endif // ESP8266/ESP32
|
|
@ -0,0 +1,69 @@
|
|||
/***************************************************
|
||||
This is an example for our Adafruit 16-channel PWM & Servo driver
|
||||
PWM test - this will drive 16 PWMs in a 'wave'
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/815
|
||||
|
||||
These drivers use I2C to communicate, 2 pins are required to
|
||||
interface.
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
// called this way, it uses the default address 0x40
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
|
||||
// you can also call it with a different address you want
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
|
||||
// you can also call it with a different address and I2C interface
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("16 channel PWM test!");
|
||||
|
||||
pwm.begin();
|
||||
/*
|
||||
* In theory the internal oscillator (clock) is 25MHz but it really isn't
|
||||
* that precise. You can 'calibrate' this by tweaking this number until
|
||||
* you get the PWM update frequency you're expecting!
|
||||
* The int.osc. for the PCA9685 chip is a range between about 23-27MHz and
|
||||
* is used for calculating things like writeMicroseconds()
|
||||
* Analog servos run at ~50 Hz updates, It is importaint to use an
|
||||
* oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip.
|
||||
* 1) Attach the oscilloscope to one of the PWM signal pins and ground on
|
||||
* the I2C PCA9685 chip you are setting the value for.
|
||||
* 2) Adjust setOscillatorFrequency() until the PWM update frequency is the
|
||||
* expected value (50Hz for most ESCs)
|
||||
* Setting the value here is specific to each individual I2C PCA9685 chip and
|
||||
* affects the calculations for the PWM update frequency.
|
||||
* Failure to correctly set the int.osc value will cause unexpected PWM results
|
||||
*/
|
||||
pwm.setOscillatorFrequency(27000000);
|
||||
pwm.setPWMFreq(1600); // This is the maximum PWM frequency
|
||||
|
||||
// if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
|
||||
// some i2c devices dont like this so much so if you're sharing the bus, watch
|
||||
// out for this!
|
||||
Wire.setClock(400000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Drive each PWM in a 'wave'
|
||||
for (uint16_t i=0; i<4096; i += 8) {
|
||||
for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
|
||||
pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );
|
||||
}
|
||||
#ifdef ESP8266
|
||||
yield(); // take a breather, required for ESP8266
|
||||
#endif
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
/***************************************************
|
||||
This is an example for our Adafruit 16-channel PWM & Servo driver
|
||||
Servo test - this will drive 8 servos, one after the other on the
|
||||
first 8 pins of the PCA9685
|
||||
|
||||
Pick one up today in the adafruit shop!
|
||||
------> http://www.adafruit.com/products/815
|
||||
|
||||
These drivers use I2C to communicate, 2 pins are required to
|
||||
interface.
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit and open-source hardware by purchasing
|
||||
products from Adafruit!
|
||||
|
||||
Written by Limor Fried/Ladyada for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
****************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_PWMServoDriver.h>
|
||||
|
||||
// called this way, it uses the default address 0x40
|
||||
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
|
||||
// you can also call it with a different address you want
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
|
||||
// you can also call it with a different address and I2C interface
|
||||
//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);
|
||||
|
||||
// Depending on your servo make, the pulse width min and max may vary, you
|
||||
// want these to be as small/large as possible without hitting the hard stop
|
||||
// for max range. You'll have to tweak them as necessary to match the servos you
|
||||
// have!
|
||||
#define SERVOMIN 150 // This is the 'minimum' pulse length count (out of 4096)
|
||||
#define SERVOMAX 600 // This is the 'maximum' pulse length count (out of 4096)
|
||||
#define USMIN 600 // This is the rounded 'minimum' microsecond length based on the minimum pulse of 150
|
||||
#define USMAX 2400 // This is the rounded 'maximum' microsecond length based on the maximum pulse of 600
|
||||
#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates
|
||||
|
||||
// our servo # counter
|
||||
uint8_t servonum = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("8 channel Servo test!");
|
||||
|
||||
pwm.begin();
|
||||
/*
|
||||
* In theory the internal oscillator (clock) is 25MHz but it really isn't
|
||||
* that precise. You can 'calibrate' this by tweaking this number until
|
||||
* you get the PWM update frequency you're expecting!
|
||||
* The int.osc. for the PCA9685 chip is a range between about 23-27MHz and
|
||||
* is used for calculating things like writeMicroseconds()
|
||||
* Analog servos run at ~50 Hz updates, It is importaint to use an
|
||||
* oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip.
|
||||
* 1) Attach the oscilloscope to one of the PWM signal pins and ground on
|
||||
* the I2C PCA9685 chip you are setting the value for.
|
||||
* 2) Adjust setOscillatorFrequency() until the PWM update frequency is the
|
||||
* expected value (50Hz for most ESCs)
|
||||
* Setting the value here is specific to each individual I2C PCA9685 chip and
|
||||
* affects the calculations for the PWM update frequency.
|
||||
* Failure to correctly set the int.osc value will cause unexpected PWM results
|
||||
*/
|
||||
pwm.setOscillatorFrequency(27000000);
|
||||
pwm.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
|
||||
|
||||
delay(10);
|
||||
}
|
||||
|
||||
// You can use this function if you'd like to set the pulse length in seconds
|
||||
// e.g. setServoPulse(0, 0.001) is a ~1 millisecond pulse width. It's not precise!
|
||||
void setServoPulse(uint8_t n, double pulse) {
|
||||
double pulselength;
|
||||
|
||||
pulselength = 1000000; // 1,000,000 us per second
|
||||
pulselength /= SERVO_FREQ; // Analog servos run at ~60 Hz updates
|
||||
Serial.print(pulselength); Serial.println(" us per period");
|
||||
pulselength /= 4096; // 12 bits of resolution
|
||||
Serial.print(pulselength); Serial.println(" us per bit");
|
||||
pulse *= 1000000; // convert input seconds to us
|
||||
pulse /= pulselength;
|
||||
Serial.println(pulse);
|
||||
pwm.setPWM(n, 0, pulse);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Drive each servo one at a time using setPWM()
|
||||
Serial.println(servonum);
|
||||
for (uint16_t pulselen = SERVOMIN; pulselen < SERVOMAX; pulselen++) {
|
||||
pwm.setPWM(servonum, 0, pulselen);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
for (uint16_t pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--) {
|
||||
pwm.setPWM(servonum, 0, pulselen);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
|
||||
// Drive each servo one at a time using writeMicroseconds(), it's not precise due to calculation rounding!
|
||||
// The writeMicroseconds() function is used to mimic the Arduino Servo library writeMicroseconds() behavior.
|
||||
for (uint16_t microsec = USMIN; microsec < USMAX; microsec++) {
|
||||
pwm.writeMicroseconds(servonum, microsec);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
for (uint16_t microsec = USMAX; microsec > USMIN; microsec--) {
|
||||
pwm.writeMicroseconds(servonum, microsec);
|
||||
}
|
||||
|
||||
delay(500);
|
||||
|
||||
servonum++;
|
||||
if (servonum > 7) servonum = 0; // Testing the first 8 servo channels
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#######################################
|
||||
# Classes, datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
Adafruit_PWMServoDriver KEYWORD1
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
begin KEYWORD2
|
||||
reset KEYWORD2
|
||||
sleep KEYWORD2
|
||||
wakeup KEYWORD2
|
||||
setExtClk KEYWORD2
|
||||
setPWMFreq KEYWORD2
|
||||
setOutputMode KEYWORD2
|
||||
getPWM KEYWORD2
|
||||
setPWM KEYWORD2
|
||||
setPin KEYWORD2
|
||||
readPrescale KEYWORD2
|
||||
writeMicroseconds KEYWORD2
|
||||
setOscillatorFrequency KEYWORD2
|
||||
getOscillatorFrequency KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
FREQUENCY_OSCILLATOR LITERAL1
|
|
@ -0,0 +1,10 @@
|
|||
name=Adafruit PWM Servo Driver Library
|
||||
version=3.0.2
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Adafruit PWM Servo Driver Library
|
||||
paragraph=Adafruit PWM Servo Driver Library
|
||||
category=Device Control
|
||||
url=https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library
|
||||
architectures=*
|
||||
depends=Adafruit BusIO
|
|
@ -0,0 +1,26 @@
|
|||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012, Adafruit Industries
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holders nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<Library LVVersion="17008000">
|
||||
<Property Name="NI.Lib.Icon" Type="Bin">&Q#!!!!!!!)!"1!&!!!-!%!!!@````]!!!!"!!%!!!(^!!!*Q(C=\>8"<2MR%!813:"$A*T51;!7JA7VI";G"6V^6!P4AFJ1#^/#7F!,TN/'-(++=IC2(-TVS+O`80+:3[QDNP9VYEO]0GP@@NM_LD_\`K4&2`NI`\;^0.WE\\ZH0]8D2;2'N3K6]:DK>?1D(`H)2T\SFL?]Z3VP?=N,8P+3F\TE*5^ZSF/?]J3H@$PE)1^ZS*('Z'/C-?A99(2'C@%R0--T0-0D;QT0]!T0]!S0,D%]QT-]QT-]<IPB':\B':\B->1GG?W1]QS0Y;.ZGK>ZGK>Z4"H.UQ"NMD:Q'Q1DWM6WUDT.UTR/IXG;JXG;JXF=DO:JHO:JHO:RS\9KP7E?BZT(-&%]R6-]R6-]BI\C+:\C+:\C-6U54`%52*GQ$)Y1Z;<3I8QJHO,R+YKH?)KH?)L(J?U*V<9S$]XDE0-E4`)E4`)EDS%C?:)H?:)H?1Q<S:-]S:-]S7/K3*\E3:Y%3:/;0N*A[=<5+18*YW@<,<E^J>YEO2U2;`0'WJ3R.FOM422L=]2[[,%?:KS(&'PR9SVKL-7+N1CR`LB9[&C97*0%OPH2-?Y_<_KK,OKM4OKI$GKP>I^<`X,(_`U?N^MNLN>L8#[8/*`0=4K>YHA]RO&QC0V_(\P>\OUV].XR^E,Y_6Z[=@YH^5\`3`_$>W.]DF`(N59`!/<!-PQ!!!!!</Property>
|
||||
<Property Name="NI.Lib.SourceVersion" Type="Int">385908736</Property>
|
||||
<Property Name="NI.Lib.Version" Type="Str">1.0.0.0</Property>
|
||||
<Property Name="NI.LV.All.SourceOnly" Type="Bool">false</Property>
|
||||
<Item Name="pca9685-begin.vi" Type="VI" URL="../pca9685-begin.vi"/>
|
||||
<Item Name="pca9685-setOutputMode.vi" Type="VI" URL="../pca9685-setOutputMode.vi"/>
|
||||
<Item Name="pca9685-setPWM.vi" Type="VI" URL="../pca9685-setPWM.vi"/>
|
||||
<Item Name="pca9685-setPWMFreq.vi" Type="VI" URL="../pca9685-setPWMFreq.vi"/>
|
||||
</Library>
|
Binary file not shown.
|
@ -2,5 +2,5 @@
|
|||
Mobile-Robot-K4-001 = "172.22.11.2"
|
||||
|
||||
[My Computer]
|
||||
My Computer = "192.168.1.5"
|
||||
My Computer = "192.168.1.7"
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[ProjectWindow_Data]
|
||||
ProjectExplorer.ClassicPosition[String] = "33,1,859,446"
|
||||
ProjectExplorer.ClassicPosition[String] = "37,4,1013,422"
|
||||
|
||||
|
|
|
@ -213,6 +213,45 @@ AddOutputFilter chunkFilter
|
|||
<Item Name="_chatReg.vi" Type="VI" URL="../../hal/hal-ads1115/_chatReg.vi"/>
|
||||
<Item Name="ads1115.lvlib" Type="Library" URL="../../hal/hal-ads1115/ads1115.lvlib"/>
|
||||
</Item>
|
||||
<Item Name="hal-pca9685" Type="Folder">
|
||||
<Item Name="doc" Type="Folder">
|
||||
<Item Name="Adafruit-PWM-Servo-Driver-Library" Type="Folder">
|
||||
<Item Name=".github" Type="Folder">
|
||||
<Item Name="workflows" Type="Folder">
|
||||
<Item Name="githubci.yml" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/workflows/githubci.yml"/>
|
||||
</Item>
|
||||
<Item Name="ISSUE_TEMPLATE.md" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/ISSUE_TEMPLATE.md"/>
|
||||
<Item Name="PULL_REQUEST_TEMPLATE.md" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.github/PULL_REQUEST_TEMPLATE.md"/>
|
||||
</Item>
|
||||
<Item Name="examples" Type="Folder">
|
||||
<Item Name="gpiotest" Type="Folder">
|
||||
<Item Name="gpiotest.ino" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/examples/gpiotest/gpiotest.ino"/>
|
||||
</Item>
|
||||
<Item Name="oscillator" Type="Folder">
|
||||
<Item Name="oscillator.ino" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/examples/oscillator/oscillator.ino"/>
|
||||
</Item>
|
||||
<Item Name="pwmtest" Type="Folder">
|
||||
<Item Name="pwmtest.ino" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/examples/pwmtest/pwmtest.ino"/>
|
||||
</Item>
|
||||
<Item Name="servo" Type="Folder">
|
||||
<Item Name="servo.ino" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/examples/servo/servo.ino"/>
|
||||
</Item>
|
||||
</Item>
|
||||
<Item Name=".gitignore" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/.gitignore"/>
|
||||
<Item Name="Adafruit_PWMServoDriver.cpp" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/Adafruit_PWMServoDriver.cpp"/>
|
||||
<Item Name="Adafruit_PWMServoDriver.h" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/Adafruit_PWMServoDriver.h"/>
|
||||
<Item Name="keywords.txt" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/keywords.txt"/>
|
||||
<Item Name="library.properties" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/library.properties"/>
|
||||
<Item Name="license.txt" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/license.txt"/>
|
||||
<Item Name="README.md" Type="Document" URL="../../hal/hal-pca9685/doc/Adafruit-PWM-Servo-Driver-Library/README.md"/>
|
||||
</Item>
|
||||
<Item Name="PCA9685.pdf" Type="Document" URL="../../hal/hal-pca9685/doc/PCA9685.pdf"/>
|
||||
</Item>
|
||||
<Item Name="example" Type="Folder">
|
||||
<Item Name="setpwm.vi" Type="VI" URL="../../hal/hal-pca9685/example/setpwm.vi"/>
|
||||
</Item>
|
||||
<Item Name="pca9685.lvlib" Type="Library" URL="../../hal/hal-pca9685/pca9685.lvlib"/>
|
||||
</Item>
|
||||
</Item>
|
||||
<Item Name="midle" Type="Folder">
|
||||
<Item Name="Sensor Line" Type="Folder">
|
||||
|
@ -259,6 +298,7 @@ AddOutputFilter chunkFilter
|
|||
<Item Name="myRIO v1.0 Channel Reservation Info.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/Resource Manager/typedefs/myRIO v1.0 Channel Reservation Info.ctl"/>
|
||||
<Item Name="myRIO v1.0 Channel Reservation List.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/Resource Manager/typedefs/myRIO v1.0 Channel Reservation List.ctl"/>
|
||||
<Item Name="myRIO v1.0 Clear All IRQ.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/IRQ/vis/myRIO v1.0 Clear All IRQ.vi"/>
|
||||
<Item Name="myRIO v1.0 Close I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Close I2C.vi"/>
|
||||
<Item Name="myRIO v1.0 Close UART.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/UART/vis/myRIO v1.0 Close UART.vi"/>
|
||||
<Item Name="myRIO v1.0 Close.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/myRIO v1.0 Close.vi"/>
|
||||
<Item Name="myRIO v1.0 Configure I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Configure I2C.vi"/>
|
||||
|
@ -274,8 +314,11 @@ AddOutputFilter chunkFilter
|
|||
<Item Name="myRIO v1.0 Reserve Channel.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/Resource Manager/vis/myRIO v1.0 Reserve Channel.vi"/>
|
||||
<Item Name="myRIO v1.0 Reserve I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Reserve I2C.vi"/>
|
||||
<Item Name="myRIO v1.0 Reset FPGA.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/myRIO v1.0 Reset FPGA.vi"/>
|
||||
<Item Name="myRIO v1.0 Shutdown I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Shutdown I2C.vi"/>
|
||||
<Item Name="myRIO v1.0 Timer IRQ Info FGV.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/IRQ/vis/myRIO v1.0 Timer IRQ Info FGV.vi"/>
|
||||
<Item Name="myRIO v1.0 Unreserve Channel List.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/Resource Manager/vis/myRIO v1.0 Unreserve Channel List.vi"/>
|
||||
<Item Name="myRIO v1.0 Unreserve Channel.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/Resource Manager/vis/myRIO v1.0 Unreserve Channel.vi"/>
|
||||
<Item Name="myRIO v1.0 Unreserve I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Unreserve I2C.vi"/>
|
||||
<Item Name="myRIO v1.0 Wait for RDY.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/System/vis/myRIO v1.0 Wait for RDY.vi"/>
|
||||
<Item Name="myRIO v1.0 Write I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/I2C/vis/myRIO v1.0 Write I2C.vi"/>
|
||||
<Item Name="myRIO v1.1 FPGA.lvbitx" Type="Document" URL="/<vilib>/myRIO/FPGA/bitfiles/myRIO v1.1 FPGA.lvbitx"/>
|
||||
|
@ -290,11 +333,24 @@ AddOutputFilter chunkFilter
|
|||
<Item Name="roboRIO AI IRQ FPGA Reference.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/IRQ/typedefs/roboRIO AI IRQ FPGA Reference.ctl"/>
|
||||
<Item Name="roboRIO DI IRQ FPGA Reference.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/IRQ/typedefs/roboRIO DI IRQ FPGA Reference.ctl"/>
|
||||
<Item Name="roboRIO I2C Channels FPGA Reference.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/typedefs/roboRIO I2C Channels FPGA Reference.ctl"/>
|
||||
<Item Name="roboRIO IO Config FPGA Reference.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/typedefs/roboRIO IO Config FPGA Reference.ctl"/>
|
||||
<Item Name="roboRIO v1.0 Build Mutex Name.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/vis/roboRIO v1.0 Build Mutex Name.vi"/>
|
||||
<Item Name="roboRIO v1.0 Build MUX Configuration I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Build MUX Configuration I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 CAN Interface Manager.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/CAN/vis/roboRIO v1.0 CAN Interface Manager.vi"/>
|
||||
<Item Name="roboRIO v1.0 Channel Reservation Info.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/typedefs/roboRIO v1.0 Channel Reservation Info.ctl"/>
|
||||
<Item Name="roboRIO v1.0 Channel Reservation List.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/typedefs/roboRIO v1.0 Channel Reservation List.ctl"/>
|
||||
<Item Name="roboRIO v1.0 Clear All IRQ.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/IRQ/vis/roboRIO v1.0 Clear All IRQ.vi"/>
|
||||
<Item Name="roboRIO v1.0 Close I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Close I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 Configure I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Configure I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 Configure IO.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/vis/roboRIO v1.0 Configure IO.vi"/>
|
||||
<Item Name="roboRIO v1.0 Connector List.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/typedefs/roboRIO v1.0 Connector List.ctl"/>
|
||||
<Item Name="roboRIO v1.0 Create Configuration List.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/vis/roboRIO v1.0 Create Configuration List.vi"/>
|
||||
<Item Name="roboRIO v1.0 ISR Agent.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/IRQ/vis/roboRIO v1.0 ISR Agent.vi"/>
|
||||
<Item Name="roboRIO v1.0 Read I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Read I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 Shutdown I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Shutdown I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 Unreserve Channel List.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/vis/roboRIO v1.0 Unreserve Channel List.vi"/>
|
||||
<Item Name="roboRIO v1.0 Unreserve Channel.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/Resource Manager/vis/roboRIO v1.0 Unreserve Channel.vi"/>
|
||||
<Item Name="roboRIO v1.0 Unreserve I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Unreserve I2C.vi"/>
|
||||
<Item Name="roboRIO v1.0 Write I2C.vi" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/roboRIO v1.0/I2C/vis/roboRIO v1.0 Write I2C.vi"/>
|
||||
<Item Name="System FPGA Reference.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/System/typedefs/System FPGA Reference.ctl"/>
|
||||
<Item Name="Timer IRQ Array.ctl" Type="VI" URL="/<vilib>/myRIO/Common/Instrument Driver Framework/myRIO v1.0/IRQ/typedefs/Timer IRQ Array.ctl"/>
|
||||
|
|
Loading…
Reference in New Issue