101100 / pca9685 Goto Github PK
View Code? Open in Web Editor NEWPCA9685 I2C 16-channel PWM/servo driver Node.js module
License: MIT License
PCA9685 I2C 16-channel PWM/servo driver Node.js module
License: MIT License
I'm getting a lot of flickering when multiple channels have the same off-step.
The PCA9685 uses a load balancing strategy when multiple channels have the same off step. The strategy involves turning all channels to of for a single cycle. This library can be modified to disable the load balancing by changing the PCA9685 object declaration from:
PCA9685 pwmController;
to
PCA9685 pwmController(wire, PCA9685_PhaseBalancer_None);
Disabling the load balancing does seem to clean up the flicker.
I'm rather new to this or I would've tried to figure out how to implement it myself, but is it possible to disable the load balancer in this library?
Good morning,
Is this module compatible with the PCA9633?
Thanks and best regards!
Hi, I think the second line in the example should be
var Pca9685Driver = require("pca9685").Pca9685Driver;
the original version var Pca9685Driver = require("pca9685");
does not work here in my setup (node.js v4.3.2 and RPI 2).
Hello, can I use it to control the ESC? , because they are PWM
Hello,
I want to drive continuous rotating servo (for wheel) in "NodeJs" with "pca9685" on RaspBerry Pi. I succeed to drive "angle servo" with command pwm.setPulseLength( port, pulseLen, 0);
I see other commands like :
pwm.setDutyCycle( port, ratio, 0);
or
pwm.setPulseRange( port, min, max);
But I don't know how to drive the continuous rotating servo,
my setup:
servo on channel 0, controls a turret on a model tank
servo on channel 8, controls the elevation of the cannon
When I run the below code with staggered timeout offsets (offset1=2000, offset2=4000), it all works perfectly. But if I run with the /same/ offsets (4000 for both, for example), the servos appear to lose track of what they were doing.
I'm not familiar with TypeScript, so am not certain I'll find anything in your code, but what it /appears/ to be is a variable from one servo's controller has been set with global scope and is being referenced by the other servo's controller by accident.
pca9685 = new Pca9685Driver({
i2c: i2cBus.openSync(1),
address: 0x40,
frequency: 50,
debug: true
}, function() {
console.log("Initialization done");
});
function laserTurretBase(deg) {
var servoNumber=0;
if (deg<0 || deg>180) {
return;
}
pca9685.setPulseLength(servoNumber, 1500+Math.ceil((deg-90)/180*1499));
clearTimeout(timers.laserTurretBase);
timers.laserTurretBase=setTimeout(function() {
pca9685.setPulseRange(servoNumber, 0, -1);
}, 3000);
}
function laserTurretElevation(deg) {
var servoNumber=8;
if (deg<0 || deg>180) {
return;
}
pca9685.setPulseLength(servoNumber, 1500+Math.ceil((deg-90)/180*1499));
clearTimeout(timers.laserTurretElevation);
timers.laserTurretElevation=setTimeout(function() {
pca9685.setPulseRange(servoNumber, 0, -1);
}, 3000);
}
laserTurretBase(90);
laserTurretElevation(90);
var offset1=4000, offset2=4000;
setTimeout(function() {
laserTurretElevation(45);
setTimeout(function() {
laserTurretElevation(135);
setTimeout(function() {
laserTurretElevation(90);
}, 4000);
}, 4000);
}, offset1);
setTimeout(function() {
laserTurretBase(45);
setTimeout(function() {
laserTurretBase(135);
setTimeout(function() {
laserTurretBase(90);
}, 4000);
}, 4000);
}, offset2);
hi,
when i run the example servo.js i get this error:
pca9685 Reseting PCA9685 +0ms
Error initializing PCA9685
when i copy paste the example under usage from the https://github.com/101100/pca9685 i get a positive output
Initialization done
Pulse range set.
Channel 6 is off.
i started looking in these examples because i get this Error initializing PCA9685 in node-red-contrib-pca9685 aswel
any ideas?
Using Adafruit's driver (python), reversing the throttle as easy as:
kit.continuous_servo[3].throttle = 1
and to reverse it
kit.continuous_servo[3].throttle = -1
I am not finding any details about that in the readme or anywhere in the examples. any details?
Thanks
Enhancement request: In my project, I want the servos to move at less than the maximum possible speed. For example, if today going from 0 to 180 degrees takes (and I'm making this up) 1.5 seconds, this would be a rate of 8.3msecs/degree. I would like to be able to change that rate to other values ... for example if I made it 20msecs/degree then a 180 degree rotation would take 3.6 seconds.
Sadly, I haven't studied enough on the pca9685 or this module's internals to say if such a thing is easy, hard or even technically achievable.
I am running on the May 10th 2016 build of Raspbian on a Pi3. The JavaScript I am running is:
var i2cBus = require("i2c-bus");
var Pca9685Driver = require("pca9685").Pca9685Driver;
var options = {
i2c: i2cBus.openSync(1),
address: 0x40,
frequency: 50,
debug: true
};
pwm = new Pca9685Driver(options, function() {
console.log("Initialization done");
});
pwm.setPulseLength(0, 1500);
I am running node.js version 4.4.4.
When I run the script, the error reported is:
$ sudo node test.js
pca9685 Reseting PCA9685 +0ms
pca9685 Setting PWM frequency to 50 Hz +16ms
pca9685 Pre-scale value: 121 +8ms
pca9685 Setting PWM channel, channel: 0, pulseLength: 1500, onStep: 0 +2ms
pca9685 Setting PWM channel, channel: 0, onStep: 0, offStep: 306 +2ms
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
pca9685 Error reading mode (to set frequency) +97ms { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'readByte' }
Initialization done
pca9685 Setting prescale to: 121 +2ms
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
Error writing to PCA8685 via I2C { [Error: EIO, Input/output error] errno: 5, code: 'EIO', syscall: 'writeByte' }
/home/pi/projects/bubbles/node_modules/i2c-bus/i2c-bus.js:244
i2c.writeByteAsync(device, cmd, byte, cb);
^
Error: EINVAL, incorrect arguments passed to writeByte(int fd, int cmd, int byte, function cb)
at Error (native)
at Bus.<anonymous> (/home/pi/projects/bubbles/node_modules/i2c-bus/i2c-bus.js:244:9)
at Immediate.immediate._onImmediate (timers.js:440:18)
at processImmediate [as _immediateCallback] (timers.js:383:17)
Hello,
This in already done in fork "https://github.com/fustaro/pca9685" but you should update your i2c-bus version to last one.
Otherwise it cause this error:
_node_modules/pca9685/dist/src/pca9685.d.ts:1:10 - error TS2724: '"../../../@types/i2c-bus"' has no exported member named 'I2cBus'. Did you mean 'I2CBus'?
The tsconfig.json file contains the "target" property twice.
I installed 2.2.0 from npm and when I try and use it as a dependency in a project, I get the error:
Error: Cannot find module 'pca9685'
As I tried to diagnose, I find that the pca9685 module's package.json has main
listed as dist/index.js
but there is no such directory/file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.