PCA9685 with C1+

Post Reply
L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

PCA9685 with C1+

Post by L67GS »

Has anybody successfully used PCA9685 PWM controller with C0 / C1+ in C++? I see wiringpi support for PWM, open to suggestions here.

User avatar
mctom
Posts: 2273
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 282 times
Been thanked: 371 times
Contact:

Re: PCA9685 with C1+

Post by mctom »

You mean that Adafruit module, or you're designing your own PCB?

This chip is controlled via I2C bus and generates PWM waveforms internally, so I think this has nothing to do with WiringPi's PWM support.

Honestly, since you're going to code in C++, I'd skip WiringPi altogether and drive it without a middleman (and dependency burden in the future)
First, make sure i2c drivers are working correctly:
https://wiki.odroid.com/odroid-c1/appli ... e/gpio/i2c

To interface this chip all you need to do is to write to I2C bus, no reading is required.
From HK's demo code, you can get "inspiration" how the I2C devices are handled. This is an example of a very clean library, using linux i2c library instead of wiring pi.
https://github.com/hardkernel/WEATHER-B ... r/si1132.c

Alternatively you just grab someone else's C++ library and get it over with:
https://github.com/TeraHz/PCA9685

One pro tip: unless you wish to duel with udev stuff, you'll need sudo to access /dev/i2c-x - and your code too.

By the way, the Adafruit board is marketed as servomotor driver, but the chip in fact is just a LED driver. The current capabilities of this chip are quite limited, 10/25mA push/pull. I wonder how badly it runs over its specs in most projects..
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

User avatar
joerg
Posts: 1729
Joined: Tue Apr 01, 2014 2:14 am
languages_spoken: german, english, español
ODROIDs: C1, C1+, C2, N1, N2, C4
Location: Germany
Has thanked: 155 times
Been thanked: 332 times
Contact:

Re: PCA9685 with C1+

Post by joerg »

I use this device on C2 with a library from here: https://github.com/Reinbert/pca9685
It's an addon for wiringPi.

L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

Re: PCA9685 with C1+

Post by L67GS »

Thanks guys, I'm going to try the wiringpi solution first, then go oldschool if necessary. It's an adafruit clone from Amazon.
A significant robotics project I'd do on the M1, but I just got a few servos coming to play with so I'd like to use my trusty C1+ at work, it's easier to hide in the toolbox on my bench.

User avatar
mctom
Posts: 2273
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 282 times
Been thanked: 371 times
Contact:

Re: PCA9685 with C1+

Post by mctom »

M1, huh? Are you going to use NPU in this project?
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

Re: PCA9685 with C1+

Post by L67GS »

mctom wrote:
Mon Aug 15, 2022 4:50 pm
M1, huh? Are you going to use NPU in this project?
Not now, but eventually I hope to. I've been experimenting with airbags, air muscles, and now servos to build up to that. Air bags are the big prize I feel, soft robotics has many advantages over hard. I'm kicking around the idea of making a CO2 generator to run muscles and bags, but I don't think it would yield enough CFM for anything useful.

User avatar
mctom
Posts: 2273
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 282 times
Been thanked: 371 times
Contact:

Re: PCA9685 with C1+

Post by mctom »

That's really interesting. If IMUs are powerful enough to perfectly guide a drone I can't see why not drive "soft robotics" actuators in a similar manner.
My pal back in college has built a robotic arm complete with human fingers and all, that was his MEng thesis. I helped him etch a fudgeton of PCBs for all that. He wanted to use air muscles, but the budget forced him to use stepper motors and servos instead.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

Re: PCA9685 with C1+

Post by L67GS »

Air muscles are cheap, I've made them from surgical gloves and expanding wire covering. By using a bladder that takes little effort to expand the muscles are far more efficient and faster than those who have to overcome the silicone tubing bladder resistance to inflate. 10 PSI is enough to do great things with an efficient air muscle.
I've molded platinum silicone in the past, so next I'll be experimenting with saturating the woven wire covering with liquid platinum silicone and not even using a bladder.

Air bags are proving to be more challenging, I'm looking at the possibility of making them from platinum silicone, and blowing them the way one would blow a glass orb to make some that are a few centimeters across to play with.

The idea of servo's is to control valves I've designed that use an odd shaped cam to pinch or release the pressure and vent tubes on either side. Damn, I really need a 3D printer, lol.

L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

Re: PCA9685 with C1+

Post by L67GS »

The Reinbert solution is really popular, but it really twisted my sack on the C1+. I ended up with this and it's very simple:
https://www.chiefdelphi.com/t/pca9685-servo-code/161166

There's a really simple sample for servo in there too, I've already hacked and molested it in ways that would make a professional developer cry.

User avatar
mctom
Posts: 2273
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 282 times
Been thanked: 371 times
Contact:

Re: PCA9685 with C1+

Post by mctom »

Yeah, that's the library I linked to in my first reply.
Except someone has tampered with it and added stuff here and there.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

L67GS
Posts: 909
Joined: Wed Apr 22, 2020 3:02 pm
languages_spoken: English, Jibberish, Pig Latin
ODROIDs: XU4, M1 8GB, C1+, (3) C0's, H3+, N2L 4GB, and a whole big pile of accessories, VU7A Plus,, MIPI-CSI Camera Kit, etc....
Location: Great Lakes Region, U.S.A
Has thanked: 268 times
Been thanked: 115 times
Contact:

Re: PCA9685 with C1+

Post by L67GS »

I'll be darned, yes it is. The fork I found had servo example code, so he already had the pulse math done, lol.

User avatar
mctom
Posts: 2273
Joined: Wed Nov 11, 2020 4:44 am
languages_spoken: english, polish
ODROIDs: OGA, XU4, C2, M1, H3+, SP3, Vu8M
Location: Gdansk, Poland
Has thanked: 282 times
Been thanked: 371 times
Contact:

Re: PCA9685 with C1+

Post by mctom »

I don't trust people who upload archives on GitHub like it was a file sharing service, lol. But I can't imagine this code being malicious in any way.

Let that serve as a testament to quality of that library.
Punk ain't no religious cult, punk means thinking for yourself!

Maintainer of PiStackMon

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 3 guests