Using the Raspberry Pi Pico, PCA9685 and MicroPython for Robotics

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 76

  • @mynamesbond
    @mynamesbond 2 місяці тому +1

    thanks for taking time to write the MicroPython code for PCA9685. I didn't want to go down the circuit python route so this is just what I needed ✌

  • @onesandzeros
    @onesandzeros Місяць тому

    Thanks Kevin, very interesting. Your recent Pico 2 live streams got me interested in this.
    "Solder" comes from the French souder iirc and the L was added because it's rude in British English, as you said. American English doesn't have that word, so there's no concern. In Canada they pronounce the L.

  • @CyberOne
    @CyberOne 3 роки тому +2

    I used 4 of those in my InMoov build.
    It does work, I used a Raspberry Pi 3 at the time.
    I'm remaking Fred and have 2 in so far :-)

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Awesome! I’m glad you’ve tried that and it works for InMoov, that validates the idea I have for it too

  • @shockbob
    @shockbob 8 місяців тому

    Thanks for the amazing video. I grabbed your code and it worked the first time!!

  • @toni-si2np
    @toni-si2np Місяць тому

    I know this probably an old question but could you explain why, when I try to install the zip file onto a pico connected to a RPi4 I consistently get a long error message. I have no problem with other zip files. It appears to run someway through the process and then crashes.

  • @LinuzoFPV
    @LinuzoFPV 3 роки тому +1

    Right on Kevin! nice work

  • @Videogame9559
    @Videogame9559 10 місяців тому

    hi what uf2 file are running your programme in as i no unstruc or no pca9685 not found what do i need to install first please kevin as servo isn't running

  • @MatthewRay1
    @MatthewRay1 5 місяців тому

    I've got my PCA9685 board set up as per tutorial, but running the i2c.scan() function just returns "[ ]". Does anyone have any suggestions? I've triple checked the wiring

  • @antitialaman7301
    @antitialaman7301 2 роки тому +1

    Can anyone tell me why I couldn't install adafruit-circuitpython-servokit on my raspberry pi zero?
    I have installed Python 3.9.2 and I2C is enabled. The issue tells 'could not fin a version that satisfies the requirement'.
    I'm stuck, can someone help me? TY.

  • @pflanzgarten
    @pflanzgarten 2 роки тому

    Thank a lot for the work.
    Working now on a ESP32 and "Archive" folder in PicoCat repo files version
    Enought to start. I'm new on micropython.
    SDA & SCL are 21 & 22 in this microcontroller.
    I will try on a RPI Pico too.

    • @gabriel-wf8ym
      @gabriel-wf8ym 4 місяці тому

      se puede poner el programa a un esp32?

  • @arunkranadeep9712
    @arunkranadeep9712 7 місяців тому

    Hi kevin,I got a error can you help me .this - importerror: no module named 'adafruit_servokit'

  • @kuraneko_15
    @kuraneko_15 3 роки тому +1

    とても参考になります。
    ありがとうございます。

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому +1

      ありがとうございました (Thank you)

  • @Pony_Slaystation
    @Pony_Slaystation 2 роки тому +2

    Hello! I have a question - I build my own project with robo-hand and i used your code, because it perfectly work with servos on RPI Pico. But I have a trouble and watch again this video. I saw that angle of servo working with pca9685 on 180 not right 180, its some of 165-170. Why it happens? In my project I need true 180 angle and 0 angle. Thank you for answer.

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      It’s to do with a couple of things - the servo may have a wider range -10 to 190 for example so sending a pulse width that works for one doesn’t work for this one. More expensive servos are more accurate but all of them always need calibration.

    • @Pony_Slaystation
      @Pony_Slaystation 2 роки тому +1

      @@kevinmcaleer28 And how can i fix this problem? I thought that because PWM troubles in PCA controller - isn`t it right?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      @@Pony_Slaystation think of it this way - you tell the pca9685 board to make servo one go to 90, but if the servo isn’t that accurate it will go to something approximating that. You csn manually tweak it by measuring the angle and changing the pulse width for that specific servo. I’d use a map function to correct this

    • @Pony_Slaystation
      @Pony_Slaystation 2 роки тому

      @@kevinmcaleer28 Oh, okay! Thank you very much!)

  • @Videogame9559
    @Videogame9559 11 місяців тому

    Hi Kevin your got into great detail. How do I load the code on my pi pico do I use thonny and I don't know how use cat ? I'm. Using pca9685 servo board . What uf2 do I use ?please as like build a skull moving with a pan and tilt and one servo to move the jaw . I
    Anyone any help please

  • @e22Olivier
    @e22Olivier Рік тому

    Hi kevin your video is awsome ,im new to micropython and programing, im having trouble selecting each servo individually on the pca 9685 and how to get them to move separetly .. when i plug the servo index 0 and the 15 the two servos does the same thing even when i tell them to do different degrees... do you have any ideas or tuto to help me figure it out ? Thx for your time.

  • @havecannonwilltravel1007
    @havecannonwilltravel1007 3 роки тому +1

    My board when I scan shows [65, 112]
    I'm having trouble figuring out what the 65 needs to be converted to in HEX = 0x41 maybe? Then where do you put that info to make it talk to the PCA9685?
    Thanks

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Hi - when you create a PCA9685 object, you can pass the address parameter e.g. pca = PCA9685(i2c=i2c, address=0x41)
      Hope this helps.

    • @JohnSpeight
      @JohnSpeight 3 роки тому +1

      The servo Library creates a PCA9685 object for you... In Kevin's code: "servo = Servos(i2c=i2c)" you just need to override the "address" parameter, so try "servo = Servos(i2c=i2c, address = 0x41)". Should work fine!! This is great if you need to daisy-chain PCA9685 boards together - you can have one "servo" object per board...

  • @CyberOne
    @CyberOne 3 роки тому +1

    The guy who built the computer on bread boards was Ben Eater.
    His latest is adding a PS2 keyboard to his computer :-)

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Thanks for sharing the info @Cyber_One - Here is a link the Ben Eaters 8bit breadboard computer playlist - ua-cam.com/play/PLowKtXNTBypGqImE405J2565dvjafglHU.html

  • @emilioaxelsanchezcorona5975
    @emilioaxelsanchezcorona5975 9 місяців тому

    Can it works with a program made with C? How would it be?

  • @CyberOne
    @CyberOne 3 роки тому +3

    Did you know the PCA9685 was originally created to control LED lighting?
    Turns out it also works well for driving servos :-)

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      I did not know that - I knew you could use if to control LEDs (albeit it with a much quicker frequency of 1000hz), but not that it was originally intended for LED lighting control

  • @George24577
    @George24577 Рік тому +1

    Thank you very much, I've been following your videos for a while
    I resume my project and I have a question.
    How do I reset the positions on the PCA?
    apparently they are saved and start simultaneously
    try servo.release(index) but the position is maintained
    It would be a great help
    sorry for my english, i speak spanish

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      To reset the positions you will need to set them in code

    • @George24577
      @George24577 Рік тому +1

      @@kevinmcaleer28 I mean to erase the memory of the PCA
      so that when turning on the PCA, the written positions are not started :(
      Gracias

    • @kevinmcaleer28
      @kevinmcaleer28  Рік тому

      @@George24577 pca has no memory. You should initialise the servo positions in your code

  • @dominikswies2219
    @dominikswies2219 6 місяців тому

    Can I use two of these boards and connect them to Pico W to use more than 16 servos? I need to use 18 servos for a hexapod project and I can't find a solution for that

    • @kevinmcaleer28
      @kevinmcaleer28  6 місяців тому

      Have you checked out the Pimoroni Servo 2040? It has 18 Servo headers and is based on the RP2040? If you get one, don't forget to add 'kevin' as the coupon code and I'll thank you later

    • @dominikswies2219
      @dominikswies2219 6 місяців тому

      @@kevinmcaleer28 that actually looks great! I'll read a bit more into that and probably buy it, thanks a lot

    • @dominikswies2219
      @dominikswies2219 6 місяців тому

      @@kevinmcaleer28 so im currently checking out what the board can do and I cant find anything about any type of remote controll whether it would be radio controll, wifi or bluetooth. I was wondering if you could tell me if there's a way to remotely controll it

  • @Videogame9559
    @Videogame9559 11 місяців тому

    I'm getting no pca ?

  • @PontusThePilot
    @PontusThePilot 3 роки тому +1

    Hi!
    I'm trying to follow this but when I try to do the step at 37:40, I get this:
    >>> pca = PCA9685(i2c=i2c)
    Traceback (most recent call last):
    File "", line 1, in
    NameError: name 'PCA9685' isn't defined
    Do you know why this could be?
    I´ve clicked on both pca9685.py and servo.py and then the upload button att the bottom to upload them to the pico
    I also get this when trying to import servo:
    >>> from servo import Servos
    Traceback (most recent call last):
    File "", line 1, in
    File "servo.py", line 7, in
    ImportError: no module named 'transition'
    Is it so that I've missed something in the setup or haven't uploaded the files/project correctly?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Try upload ing one file at a time - I don't think you can select both to upload. To check what files are on the pico you can
      list the files using:
      import os
      print(os.listdir())
      You should then be able to see the files on the board.

    • @PontusThePilot
      @PontusThePilot 3 роки тому +1

      @@kevinmcaleer28 I've tried that now and I tried uploading the project by right-clicking and press "upload project" and still get errors.
      Here is the terminal printout:
      >>>
      Uploading project (main folder)...
      Not safe booting, disabled in settings
      Uploading to / ...
      Reading file status
      Creating dir Archive
      [1/27] Writing file 'Archive/_pca9685.py' (2 kB)
      ....
      [27/27] Writing file 'vl53l0x.py' (22 kB)
      Upload done, resetting board...
      OK
      >>> import os
      >>> print(os.listdir())
      ['Archive', 'OpenCat.py', 'code.py', 'machine.py', 'pca9685.py', 'picocat.py', 'project.pico-go', 'servo.py', 'test_suite.py', 'trans_test.py', 'transition.py', 'utils.py', 'vl53l0x.py']
      >>> from machine import I2C, Pin, PWM
      >>> sda = Pin(0)
      >>> scl = Pin(1)
      >>> id = 0
      >>> i2c = I2C(id = id, sda = sda, scl = scl)
      >>> i2c.scan()
      [64, 112]
      >>> pca = PCA9685(i2c = i2c)
      Traceback (most recent call last):
      File "", line 1, in
      NameError: name 'PCA9685' isn't defined
      >>>
      I'm on a Mac just like you, I've downloaded VSCode, added the extensions CMake-tools and Pico-Go.
      I haven't changed anything else.
      Is there something else I have to set up maybe to make it work?

    • @PontusThePilot
      @PontusThePilot 3 роки тому +2

      or am I using a newer version of your git repository where you changed stuff since this video and that's why I can't follow step by step?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      @@PontusThePilot when you run the code - how are you running it? Using the run command at the bottom of the screen or the green play button at the top of the screen?

    • @PontusThePilot
      @PontusThePilot 3 роки тому

      @@kevinmcaleer28 I've tried via the terminal following the steps you do in the video, I've tried the run button at the bottom and also right click "Pico-Go -> Run current file"
      I also tried running the same files in Thonny but still got the same error. There must be something I do wrong with the pca.py file because "from servo import Servos" and "from pca9685 import PCA9685" doesn't give me any errors.
      I'm kinda clueless of what isn't right since I tried troubleshooting all possible mistakes I could have done.
      It's not my first time coding in Python but It's my first time using a pi pico and micro Python

  • @George24577
    @George24577 3 роки тому +1

    How do I get it to stay in a position after a sequence?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      The servos will hold their position - if they are strong enough.

  • @prathampandey9898
    @prathampandey9898 2 роки тому +1

    Can we control normal 6v dc motor with it as well?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      Probably best with a slightly different board that is designed for that, but yes you could

    • @prathampandey9898
      @prathampandey9898 2 роки тому

      @@kevinmcaleer28 I need to control 2 dc motor and 2 servo. Can you suggest a better motor driver?

  • @Steven-jf4cs
    @Steven-jf4cs 2 роки тому +1

    Anybody got a quick solution to the problem of Thonny returns error that "pca not recognized". Is there a micropip install package available?

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      Hi Steven, if you're working from the Git repository, you can right-click on the pca9685.py file and upload it to the pico, and it should work fine (Thonny makes this easy). I've updated the description for the show, and if you scroll down, you'll find a link to the code there.

    • @Steven-jf4cs
      @Steven-jf4cs 2 роки тому +1

      Got it - I though it might be a naming convention. appreciate the help and my little spiderbot is at least standing on it's little legs now :)

    • @tannar4607
      @tannar4607 2 роки тому +1

      Not working for me. i get no module named pca, or no module namedpca9685

    • @kevinmcaleer28
      @kevinmcaleer28  2 роки тому

      @@tannar4607 Have you copied the pca9865.py file from the github repository that's in the video description - you'll need to copy that the pico for it to work

    • @tannar4607
      @tannar4607 2 роки тому

      @@kevinmcaleer28 yes I did. Still doesn’t work.

  • @MrEdwardhartmann
    @MrEdwardhartmann 3 роки тому +1

    Has anyone said when more Pico's will be in stock at the resellers? Last I heard was late Feb, but that has come and gone.

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Hi Edward - I’ve ordered a couple more Pico’s no issue, which region are you in -I’ll help you look

  • @Imatarget-kb8xv
    @Imatarget-kb8xv 3 роки тому +1

    Have you ganged any PCA9685 boards together for more devices?

    • @kevinmcaleer28
      @kevinmcaleer28  3 роки тому

      Not tried that yet, should be pretty straight forward if you have one working

  • @Steven-jf4cs
    @Steven-jf4cs 2 роки тому

    WORKING AGAIN!!! PCA9685 not working...it may be a bad product and not code.
    I had recently ordered two new PCA9685's from Amazon and put my 'old' PCA9685 way in a junk drawer. Why? because I had 'new' ones!! Then....disaster struck as both were bad out of the box. I've switched back to my 'old' one from the junk drawer and VIOLA Kevin's code works like magic!
    Not sure if there's a library or hardware issue but one of my two PCA9685 worked on my Arduino UNO perfectly fine the other was NRFI (not ready for issue) out of the box
    Maybe purchasing a high quality PCA9685 could do the trick?

    • @derekhayesdesigns
      @derekhayesdesigns Рік тому

      I’ve got the same problem but tried it with a fresh PCA board and still the no module pca message happens. The board shows up on a scan. Any ideas?

    • @derekhayesdesigns
      @derekhayesdesigns Рік тому

      Just realised that all the progs should say 'from pca9685' not 'from pca …'
      No error message returned. I’ll let you know if it doesn’t work now.