PCA9685 (i2c 16 ch.pwm)+ Ardublock

102 views
Skip to first unread message

Adarom

unread,
Sep 24, 2018, 6:47:11 PM9/24/18
to Ardublock
Has anyone tried to or had success with controlling the adafruit PCA9685 16 channel servo board using Ardublock? I've started experimenting, but if anyone already knew how to do it, I would really appreciate some help/advice.

Thank you,
Adam

Canarias Vive

unread,
May 5, 2020, 3:36:17 PM5/5/20
to Ardublock
No, yo tambien lo estoy buscando. Es tan comun, pero sorprendentemente no esta incluido en las librerias. Lo conseguiste?

David Harris

unread,
May 5, 2020, 4:18:23 PM5/5/20
to ardu...@googlegroups.com
Sorry, no Spanish here :-(
I have played with this chip.  It needs a bunch of initialization before you can send it the servo commands: 
1. Put it onto sleep mode: send 0x40, 0, 0x30, where 0x40 is its address, 0 is the register and 0x30 the data
2. Set pre-scaler to get a 50Hz cycle time: send 0x40, 0xfe, 0x83
3. Wake up again: send 0x40, 0, 0xa0
4. To set servo send: 0x40, addr, start.low, start.high, end.low, end.high
    where:
      addr is the set of control registers for a servo, addr = 6+4*servo#;
      start.low, start.high is the start-time of the pulse, so 0x0123 would be 0x23,0x01
      end,low, end.high is end time for pulse.  
   So, if you keep start-time at 0, then end-tie can range from about 160-450 to get 800-2200ms pulse length, 
  and the command for servo0 would be 0x40, 6, 0, 0, end.low, end.high
  and for servo1: 0x40, 10, 0, 0, end.low, end.high

See Adafruit's library for more details.  

Good luck!

David
PS -- this is from memory, so might have error.  These sites are useful: 

--
You received this message because you are subscribed to the Google Groups "Ardublock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ardublock+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ardublock/6693e3c5-7ce1-44a9-b8ba-1e1c1752187a%40googlegroups.com.

Canarias Vive

unread,
May 6, 2020, 11:56:42 AM5/6/20
to Ardublock
Hi David, really sorry don't know what the fuck happened that I read and understood in English but replied in Spanish. Bipolar things of bi fluent speakers I guess.

I appreciate the answer you gave. But I really don't understand waht you mean. The main purpose is to have a block that you can drag and connect all digitals and analogs inputs or outputs and this shouls work as a any other coded block. The thing is that Ardublock ash been abandoned or something and they didn't keep developing it further.

I think everyone knows how to work with PCA9685 libraries as long as they know the functions. The thing is, how beatitufull and easier would be to upgrade code or make complex projects if we could program inblocks using the servo PWM 16 channel driver.

So the question is, what ever is that you replied, is related on how to make a block of code for use it as a block in ARDUBLOCK and therefore allow ARDUBLOCK to compile/transform it from BLOCKS to .ino code where it legits use the PCA 9685 and the libraries?

Thanks

El martes, 5 de mayo de 2020, 21:18:23 (UTC+1), dpha...@telus.net escribió:
Sorry, no Spanish here :-(
I have played with this chip.  It needs a bunch of initialization before you can send it the servo commands: 
1. Put it onto sleep mode: send 0x40, 0, 0x30, where 0x40 is its address, 0 is the register and 0x30 the data
2. Set pre-scaler to get a 50Hz cycle time: send 0x40, 0xfe, 0x83
3. Wake up again: send 0x40, 0, 0xa0
4. To set servo send: 0x40, addr, start.low, start.high, end.low, end.high
    where:
      addr is the set of control registers for a servo, addr = 6+4*servo#;
      start.low, start.high is the start-time of the pulse, so 0x0123 would be 0x23,0x01
      end,low, end.high is end time for pulse.  
   So, if you keep start-time at 0, then end-tie can range from about 160-450 to get 800-2200ms pulse length, 
  and the command for servo0 would be 0x40, 6, 0, 0, end.low, end.high
  and for servo1: 0x40, 10, 0, 0, end.low, end.high

See Adafruit's library for more details.  

Good luck!

David
PS -- this is from memory, so might have error.  These sites are useful: 

On Tue, May 5, 2020 at 12:36 PM Canarias Vive <raul.ig...@gmail.com> wrote:
No, yo tambien lo estoy buscando. Es tan comun, pero sorprendentemente no esta incluido en las librerias. Lo conseguiste?

El lunes, 24 de septiembre de 2018, 23:47:11 (UTC+1), Adarom escribió:
Has anyone tried to or had success with controlling the adafruit PCA9685 16 channel servo board using Ardublock?  I've started experimenting, but if anyone already knew how to do it, I would really appreciate some help/advice.

Thank you,
Adam

--
You received this message because you are subscribed to the Google Groups "Ardublock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ardu...@googlegroups.com.

David Harris

unread,
May 6, 2020, 1:01:18 PM5/6/20
to ardu...@googlegroups.com
Hi --

Sorry, I don't use  Ardublocks, but looking at it, it appears there are I2C blocks.   

So,
    I2C write: device address: 64,  register address: 0, value: 3
    I2C write: device address: 64,  register address: 254, value: 131
    I2C write: device address: 64,  register address: 0, value: 160
should set up the PCA9685.
I am not sure how you send multiple values in one write:
   I2C write: device address: 64,  register address: 6+4*servo#, value: (0,0,350/256, 350&255)
or something should set the servo position.  

Should be able to define a block that does all this.  

Does that help?  Please ignore, if not helpful.  

David


To unsubscribe from this group and stop receiving emails from it, send an email to ardublock+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ardublock/4d46679a-20b0-4b1e-9cf1-ca11bee4fbb5%40googlegroups.com.

Canarias Vive

unread,
May 6, 2020, 1:16:15 PM5/6/20
to ardu...@googlegroups.com
The thing is probably the amount of users using ardublock is so low that most of them only use it as it is. I haven’t read anything of people adding their own block to Arduino block. So maybe what you are saying making sense but I don’t have that much knowledge. And I believe that making a lock to work is much more complex because you have to include libraries and after it you have to define the functions. Which aren’t just the device address if it is related somehow which I don’t even know. So let’s wait another comes with some knowledge about ardublock. 
Thanks anyway.

Thanks so much.

On 6 May 2020, at 18:01, David Harris <drdph...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages