Skip to content

Conversation

@LVB1961
Copy link

@LVB1961 LVB1961 commented Nov 15, 2020

Hello ,
I tried something with a servo and a PCA9685 board by using the sketch underneath :
Everytime i want to compile i get the error:
'PCA9685_ServoEvaluator' does not name a type...
I downloaded the newest drive but the error remains .
I do not know how to go any further because i only started with Arduino this year ...
Can anyone put me on the right track in this one ?
Thans ,
Best regards ,
Luc

/*
Servo Motor Control using Arduino and PCA9685 Driver
by Dejan, https://howtomechatronics.com

 Library: https://github.com/NachtRaveVL/PCA9685-Arduino

*/

#include <Wire.h>
#include "PCA9685.h"

PCA9685 driver;

//PCA9685 outputs = 12-bit = 4096 steps
// 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms
// 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps
PCA9685_ServoEvaluator pwmServo(102, 470); // (-90deg, +90deg)

// Second Servo
// PCA9685_ServoEvaluator pwmServo2(102, 310, 505); // (0deg, 90deg, 180deg)

void setup() {
Wire.begin(); // Wire must be started first
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
driver.resetDevices(); // Software resets all PCA9685 devices on Wire line
driver.init(B000000); // Address pins A5-A0 set to B000000
driver.setPWMFrequency(50); // Set frequency to 50Hz
}
void loop() {
driver.setChannelPWM(0, pwmServo.pwmForAngle(-90));
delay(1000);
driver.setChannelPWM(0, pwmServo.pwmForAngle(0));
delay(1000);
driver.setChannelPWM(0, pwmServo.pwmForAngle(90));
delay(1000);
}

NachtRaveVL and others added 28 commits March 19, 2017 18:47
Arduino TWI library expects 7 bit addresses. The TWI library wrapped by the Wire library performs the address shift and adds the r/w bit to the address. See here https://github.com/esp8266/Arduino/blob/master/cores/esp8266/core_esp8266_si2c.c#L184
" if(!twi_write_byte(((address << 1) | 0) & 0xFF)) {"
and
"if(!twi_write_byte(((address << 1) | 1) & 0xFF)) {".

Confirmed with three chained PCA9685 boards connected a NodeMCU.
change to utf8
I suggest cast retVal to unsigned (or PCA9685_PWM_FULL to signed) to overcome comparison between signed and unsigned integer values.

Compiler error:
```
Compiling .pio/build/leonardo/lib021/PCA9685 16-Channel PWM Driver Module Library_ID2100/PCA9685.cpp.o
In file included from .pio/libdeps/leonardo/PCA9685 16-Channel PWM Driver Module Library_ID2100/PCA9685.h:56:0,
                 from .pio/libdeps/leonardo/PCA9685 16-Channel PWM Driver Module Library_ID2100/PCA9685.cpp:25:
.pio/libdeps/leonardo/PCA9685 16-Channel PWM Driver Module Library_ID2100/PCA9685.cpp: In member function 'uint16_t PCA9685_ServoEvaluator::pwmForAngle(float)':
~/.platformio/packages/framework-arduino-avr/cores/arduino/Arduino.h:95:58: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
                                                          ^
.pio/libdeps/leonardo/PCA9685 16-Channel PWM Driver Module Library_ID2100/PCA9685.cpp:833:22: note: in expansion of macro 'constrain'
     return (uint16_t)constrain((int)roundf(retVal), 0, PCA9685_PWM_FULL);
```
…(low/high) phase values since I noticed a fork containing such. Added library.json for platformIO.
* - Upping version to 1.2.15
- Modified constructor/initializer pathways
- Added convenience constructor/initializer
- Expanded initialization mode settings
- Removed extraneous 1 on defines
- Standardized i2c buffer length determination
- Expanded & standardized comments/documentation
- Moved Wire begin into library (standardization across libraries)
- Reworked examples
- Added dyanmic phase balancer
- Various other standardizations

* Wording

* Adding VS code settings, better debug output

* Adding another datasheet

* Standardizing i2c naming

* Correct i2c datatype, adding getI2CSpeed

* Wrong identifier

* Refined getI2CSpeed to deal with software i2c, correcting returntype on i2c_init

* Documentation updates.

* Documentation updates

* Documentation updates.

* Documentation updates.

* More documentation updates.

* More doc updates.

* fixing offset

* Continuous servo support

* More doc updates

* Adding some spacing

* Better Espressif support

* Documentation updates.

* Documentation updates.

* Correcting tabs. Removing extraneous begin stuff. Almost code complete.

* Lots of documentation updates, clarifications, and some better logging code.

* Improved documentation. Corrected a few more things. Ready for release.

* Last one

Co-authored-by: NachtRaveVL <nachtravevl@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants