Using the Raspberry Pi Pico, PCA9685 and MicroPython for Robotics

  Рет қаралды 13,468

Kevin McAleer

Kevin McAleer

Күн бұрын

Пікірлер: 76
@mynamesbond
@mynamesbond 2 ай бұрын
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 2 ай бұрын
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.
@shockbob
@shockbob 8 ай бұрын
Thanks for the amazing video. I grabbed your code and it worked the first time!!
@CyberOne
@CyberOne 3 жыл бұрын
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
@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?
@LinuzoFPV
@LinuzoFPV 3 жыл бұрын
Right on Kevin! nice work
@kevinmcaleer28
@kevinmcaleer28 3 жыл бұрын
Thanks!
@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 жыл бұрын
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.
@toni-si2np
@toni-si2np 2 ай бұрын
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.
@arunkranadeep9712
@arunkranadeep9712 8 ай бұрын
Hi kevin,I got a error can you help me .this - importerror: no module named 'adafruit_servokit'
@Videogame9559
@Videogame9559 11 ай бұрын
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
@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
@emilioaxelsanchezcorona5975
@emilioaxelsanchezcorona5975 10 ай бұрын
Can it works with a program made with C? How would it be?
@Pony_Slaystation
@Pony_Slaystation 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 жыл бұрын
@@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!)
@kuraneko_15
@kuraneko_15 3 жыл бұрын
とても参考になります。 ありがとうございます。
@kevinmcaleer28
@kevinmcaleer28 3 жыл бұрын
ありがとうございました (Thank you)
@CyberOne
@CyberOne 3 жыл бұрын
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 - kzbin.info/aero/PLowKtXNTBypGqImE405J2565dvjafglHU
@havecannonwilltravel1007
@havecannonwilltravel1007 3 жыл бұрын
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 жыл бұрын
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...
@dominikswies2219
@dominikswies2219 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
@@kevinmcaleer28 that actually looks great! I'll read a bit more into that and probably buy it, thanks a lot
@dominikswies2219
@dominikswies2219 7 ай бұрын
@@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
@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.
@George24577
@George24577 Жыл бұрын
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 Жыл бұрын
@@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
@CyberOne
@CyberOne 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
@Steven-jf4cs
@Steven-jf4cs 2 жыл бұрын
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 жыл бұрын
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 жыл бұрын
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.
@prathampandey9898
@prathampandey9898 2 жыл бұрын
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?
@George24577
@George24577 3 жыл бұрын
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.
@Videogame9559
@Videogame9559 11 ай бұрын
I'm getting no pca ?
@PontusThePilot
@PontusThePilot 3 жыл бұрын
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 жыл бұрын
@@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 жыл бұрын
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
@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.
@MrEdwardhartmann
@MrEdwardhartmann 3 жыл бұрын
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 жыл бұрын
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
SMARS Mini Modular Robot!
48:03
Kevin McAleer
Рет қаралды 3 М.
Raspberry Pi Pico & VL53L0X for MicroPython
39:40
Kevin McAleer
Рет қаралды 8 М.
amazing#devil #lilith #funny #shorts
00:15
Devil Lilith
Рет қаралды 18 МЛН
Try Not To Laugh 😅 the Best of BoxtoxTv 👌
00:18
boxtoxtv
Рет қаралды 7 МЛН
Triple kill😹
00:18
GG Animation
Рет қаралды 18 МЛН
Raspberry Pi Pico PIO - PIO Interrupts using C - Ep. 19
27:15
Life with David
Рет қаралды 7 М.
Raspberry Pi Pico W: WiFi  Controlled Robot
17:56
ExplainingComputers
Рет қаралды 93 М.
Raspberry Pi Pico - Control the (I/O) World
1:03:16
DroneBot Workshop
Рет қаралды 612 М.
#370 Raspberry Pi Pico vs ESP32 (-S2) and STM32 Blackpill
15:53
Andreas Spiess
Рет қаралды 390 М.
Beginners Guide to SPI on the Raspberry Pi Pico (BMP280 Example)
14:30
Learn Embedded Systems
Рет қаралды 51 М.
CircuitPython with Raspberry Pi Pico - Getting Started
42:47
DroneBot Workshop
Рет қаралды 200 М.
My Kickstarter failed, so I open sourced it
12:20
StuckAtPrototype
Рет қаралды 616 М.
amazing#devil #lilith #funny #shorts
00:15
Devil Lilith
Рет қаралды 18 МЛН