Тёмный

Using the Raspberry Pi Pico, PCA9685 and MicroPython for Robotics 

Kevin McAleer
Подписаться 32 тыс.
Просмотров 13 тыс.
50% 1

Do you want to control a PCA9685 board using a Raspberry Pi Pico, and use MicroPython to control up to 16 Servos? then watch this video.
For more information, tutorials, parts and more visit:
www.smarsfan.com​
Enjoy this video? Buy me a coffee!
www.buymeacoffee.com/kevinmca...
Chapters
00:00:00 How to get the Raspberry Pi Pico and PCA9685 board to work with MicroPython
00:00:37 Goals of this session
00:03:52 What is the PCA9685 board?
00:06:41 Why you shouldn't power the PCA9685 board from the Pico
00:07:42 What is I2C?
00:08:57 How to troubleshoot I2C on the Pico & MicroPython
00:12:17 How to communicate with I2C
00:13:02 What are Number-Bases - Binary, Octal, Decimal and Hexadecimal?
00:15:30 How to store Octal, Binary and Hexadecimal numbers in MicroPython
00:17:54 Upload the servo.py and pca9685.py to the Pico
00:18:14 How to solder the header pins to Raspberry Pi Pico
00:20:08 Overview of the servo.py code
00:29:32 Overview of the pca9685.py code
00:32:55 The test program, how to move a servo with the PCA9685 board and Pico in MicroPython
00:34:11 How to fix the Bad SCL Pin or Bad SDA Pin error message
00:35:38 How to use I2C in MicroPython
00:36:33 How to scan the I2C bus in MicroPython on the Pico
00:37:40 How to use a Servo with the Pico and PCA9685 board in MicroPython
00:50:20 Charlie the Cricket Robot
01:06:03 Next Steps
Music by Epidemic Sounds
www.epidemicsound.com/referra...
PicoCat MicroPython Code on GitHub:
www.github.com/kevinmcaleer/p...
Link to the PCA9685 code:
github.com/kevinmcaleer/pca96...
#Pico​ #MicroPython​ #Robotics

Развлечения

Опубликовано:

 

5 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 73   
@shockbob
@shockbob 5 месяцев назад
Thanks for the amazing video. I grabbed your code and it worked the first time!!
@LinuzoFPV
@LinuzoFPV 3 года назад
Right on Kevin! nice work
@kevinmcaleer28
@kevinmcaleer28 3 года назад
Thanks!
@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
@kuraneko_15
@kuraneko_15 3 года назад
とても参考になります。 ありがとうございます。
@kevinmcaleer28
@kevinmcaleer28 3 года назад
ありがとうございました (Thank you)
@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 Месяц назад
se puede poner el programa a un esp32?
@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.
@Videogame9559
@Videogame9559 8 месяцев назад
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 8 месяцев назад
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
@MatthewRay1
@MatthewRay1 2 месяца назад
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
@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 - ru-vid.com/group/PLowKtXNTBypGqImE405J2565dvjafglHU
@antitialaman7301
@antitialaman7301 Год назад
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.
@arunkranadeep9712
@arunkranadeep9712 4 месяца назад
Hi kevin,I got a error can you help me .this - importerror: no module named 'adafruit_servokit'
@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...
@emilioaxelsanchezcorona5975
@emilioaxelsanchezcorona5975 7 месяцев назад
Can it works with a program made with C? How would it be?
@flAlmlSlelSl
@flAlmlSlelSl 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.
@flAlmlSlelSl
@flAlmlSlelSl 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 года назад
@@flAlmlSlelSl 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
@flAlmlSlelSl
@flAlmlSlelSl 2 года назад
@@kevinmcaleer28 Oh, okay! Thank you very much!)
@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
@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.
@dominikswies2219
@dominikswies2219 4 месяца назад
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 4 месяца назад
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 4 месяца назад
@@kevinmcaleer28 that actually looks great! I'll read a bit more into that and probably buy it, thanks a lot
@dominikswies2219
@dominikswies2219 4 месяца назад
@@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
@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
@Imatarget-kb8xv
@Imatarget-kb8xv 2 года назад
Have you ganged any PCA9685 boards together for more devices?
@kevinmcaleer28
@kevinmcaleer28 2 года назад
Not tried that yet, should be pretty straight forward if you have one working
@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
@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?
@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
@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 Год назад
Not working for me. i get no module named pca, or no module namedpca9685
@kevinmcaleer28
@kevinmcaleer28 Год назад
@@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 Год назад
@@kevinmcaleer28 yes I did. Still doesn’t work.
@Videogame9559
@Videogame9559 8 месяцев назад
I'm getting no pca ?
@Steven-jf4cs
@Steven-jf4cs Год назад
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.
Далее
SMARS Mini Modular Robot!
48:03
Просмотров 2,9 тыс.
What is a BrachioGraph?
51:40
Просмотров 1,1 тыс.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Просмотров 804 тыс.
Turning a Raspberry Pi Pico into a GPU!
16:42
Просмотров 105 тыс.
Pi Pico W with the Arduino IDE | Using WiFi
49:26
Просмотров 149 тыс.
PicoMite: Running BASIC on a Raspberry Pi Pico
19:29
Просмотров 145 тыс.
Raspberry Pi Pico W: WiFi  Controlled Robot
17:56
Просмотров 88 тыс.
We Added Time Travel to Portal, it got Weird
11:41
Просмотров 369 тыс.