differences between circuitpython and python library for PCA

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jf_NH
 
Posts: 4
Joined: Tue Mar 23, 2021 4:15 am

differences between circuitpython and python library for PCA

Post by jf_NH »

Hello
PCA9685 has the option for each channel to set on and off time.
This is implemented in Adafruit Python library:
https://github.com/adafruit/Adafruit_Python_PCA9685
that I use on raspberry
I need to port my application to a windows pc using a mcp2221 breakout

but I cannot find this "time on-time off" feature in the circuit python library:

https://github.com/adafruit/Adafruit_Ci ... on_PCA9685

My understanding is that one can only set a duty factor and all channels are turned on at the same time

Do I miss something?

If not I am not able to add it on my own as I am relatively novice to python and some coding structures used in these libraries are foreign to me. There are also major differences between the python and circuit python library so porting one feature from one library to the other is also beyond my abilities.

Could somebody be kind enough to explain to me how to add this feature to the circuit python library?
Thank You

User avatar
jf_NH
 
Posts: 4
Joined: Tue Mar 23, 2021 4:15 am

Re: differences between circuitpython and python library for

Post by jf_NH »

OK I found a dirty solution for my problem of controlling independently tOn and t Off ( to smooth the ripple on my power supply) and not just the duty factor. I post it here in case it can helps someone else but my fix is really dirty and should be propoerly rewritten before proposing a commit to the library

what I did:
Playing with an oscilloscope and the library
https://github.com/adafruit/Adafruit_Ci ... pca9685.py

I observed that there is a parameter value which is used in the dutyfactor setter . but the passed value is a tuple (0, value)
in fact I quickly understood and observed on the oscilloscope by comparing output of 2 channels that the first value is tOn ( 0 by default on the github library) and the second is tOff . I guess it will have been pretty obvious if I had been able to understand the class StructArray but this is beyond my current paygrade.
.
So I just changed the original library by making value a list of 2 elements The first element is tOn second is tOff duty factor is tOff-tOn
... et voila..
I can smooth my power supply output easily now..
I also rewrote the library to deal with 12 bits only which makes things easier and sufficient for my application...
As stated above its dirty but it works.

It will be nice is somebody could upgrade the library with this feature (as I have shown thereis very little to do) to allow for different tOn. PCA9685 can control serious powers and spreading the tOn when possible is a very nice feature to have ( and its already present on the raspi version of the library )
just my 2cts

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”