Johnny-five: Add support for Adafruit DRV8871

Created on 7 Apr 2018  路  6Comments  路  Source: rwaldron/johnny-five

I would love to see support for these simple but powerful motor drivers.

I can drive them right now, but its a bit hacky, since i need to initialize 2 motors for each direction, since this doesnt use a direction pin, but instead use 2 pwm inputs, one for each direction.

https://www.adafruit.com/product/3190

Motor Eg Programs Good First Issue

All 6 comments

Johnny-Five can support this motor driver. Try a configuration like this:

js // substitute your pin numbers of course motor = new five.Motor({ pins: { pwm: 3, dir: 12 }, invertPWM: true });
It doesn't matter which motor input pin is pwm and which one is dir.

Let me know if this works for you and we can add an alias in Motor.SHIELD_CONFIGS for this model number for future genreations.

Seems to almost work, but not matter if i use .start() or .reverse() it runs i the same direction.

That sounds like the PWM value isn't being inverted when the direction changes.

Make sure the invertPWM: true bit is there and try .forward() and .reverse() instead of .start(). That last one just resumes the most recent "on" state regardless of direction.

Oh wait, my last comment was in response to a comment that is no longer here...

The part about forward and reverse still hold true though

Ahh seems like it was .,start() that was the issue, works perfect with forward and reverse.
Thanks a lot, that shaved of some code! :)

I'm going to re-open as a reminder to add an example for the DRV-8871

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moeinrahimi picture moeinrahimi  路  4Comments

IainIsCreative picture IainIsCreative  路  10Comments

beriberikix picture beriberikix  路  11Comments

hxlnt picture hxlnt  路  6Comments

cannehag picture cannehag  路  12Comments