Raspberry Pi Pico Stepper Motors via PIO

  Рет қаралды 59,793

Tinker Tech Trove

Tinker Tech Trove

Күн бұрын

Controlling a stepper motor with the Raspberry pi pico using almost no CPU, just a nice a PIO routine. I have uploaded the code to github and you can find it here github.com/tinkertechtrove/pi... happy hacking!
Comments and feedback always welcome.

Пікірлер: 80
@JamesTitcombOSwarthoull
@JamesTitcombOSwarthoull 3 жыл бұрын
This is the Intro to PIO programming I've been looking for. Thankyou, Great Job!
@ianleitch9960
@ianleitch9960 3 жыл бұрын
PIO program intro spoon feeding is a must. Nice to see the progression and I hope to get a grasp on it after pouring over your examples. it's very different until explained. Awareness is arriving, albeit slowly. Many thanks.
@jonpinkley2844
@jonpinkley2844 3 жыл бұрын
Thanks for this very informative video. First video I have seen that describes PIO programming.
@ibexfilms3989
@ibexfilms3989 3 жыл бұрын
Excellent presentation, both in terms of stepper motor control and, particularly, the use of PIO with the Pico. I've learnt more about PIO from this video than the previous dozen that I've looked at. Thanks
@trailranger6602
@trailranger6602 Жыл бұрын
Brilliant presentation, thanks! This is my first introduction to the Pico and shows me I need to build my base knowledge a little better to fully understand some of these new concepts.
@kralcw
@kralcw Жыл бұрын
Great presentations. Thank you. It is interesting to note the current number of subscribers to your channel (3.14K) which is PI to two decimal points of accuracy in "scientific notation" (K) on a channel that is very Pi focused. Keep up the great work.
@windmillgolfer
@windmillgolfer 3 жыл бұрын
Thank you - just what I was looking for. Building a double barn-door tracker, with Pico, DRV8834 and Nema 42BYGH. 40 to 50 years since I last wrote any code or tinkered with electronics.
@tinkertechtrove2910
@tinkertechtrove2910 3 жыл бұрын
Your welcome, and good luck with your project.
@TheSlimbridge
@TheSlimbridge 2 жыл бұрын
Excellent tutorial and examples, clearly explained. Thanks!
@larrybud
@larrybud 7 ай бұрын
Good presentation. If you want to get lower level, get an oscilloscope and hook it up to see the 4 channels at the higher speeds.
@amedeeabreo7334
@amedeeabreo7334 3 жыл бұрын
Great video. I'm just starting with the PIO and this really helps. As you say "Defeating inertia" is an on-going quest!
@scienteer3562
@scienteer3562 3 жыл бұрын
Really great video. I had a go driving one of these these via basic bit banging. Haven't used PIO yet, but this is the perfect guide. I guess the other way to do this would be to dedicate a core to the task.
@MrRhysstevens
@MrRhysstevens 2 жыл бұрын
I didn't realize how good this was the first time I watched it. Since watching some other PIO tuts and now know the meaning and significance. Great video.
@leodelpo
@leodelpo 3 жыл бұрын
Muchas gracias por compartir tus conocimientos y excelente didáctica!
@AlexYeryomin
@AlexYeryomin 2 жыл бұрын
Thank you so much for a clear explanation on your PIO code! Just a note, shouldn't a common ground be between Pi Pico and ULN2003? Well, it works, but this is what ULN2003 spec requires if I am not mistaken.
@markday3145
@markday3145 Жыл бұрын
Could be that his bench top power supply and whatever was supplying power to the Pico have grounds that are close enough for it to work. But you're right, there really should be a common ground between the Pico and the ULN2003.
@goowatch
@goowatch 2 жыл бұрын
Muchas gracias por la explicación. Finalmente logro comprender este tema y poder experimentar con esta funcionalidad. 🙂
@Unknown15916
@Unknown15916 3 жыл бұрын
Thank you. Very good explanation.
@serenadenphoto
@serenadenphoto 3 жыл бұрын
This new math for decimal to digital conversion is very exciting. I've learn that decimal 8 is '1000' in binary and not '0001'. For this code it doesn't matter if you do 1, 2, 4, 8 or 8, 4, 2, 1. It just changes the direction of rotation. And many have asked, where is the common ground between the Pico and the motor driver?
@duncanwalduck7715
@duncanwalduck7715 2 жыл бұрын
It's a matter of "endianism", in this case "little-endian". The first bit in a word that any word (even word of length 1, i.e. a bit) will definitely have is the lowest-order bit - the 1's column in a numeric representation. So that bit will take care of the GPIO line "right here", and anything beyond that (i.e. numerically in the higher powers of 2) can overspill to "further on". Regarding the driver board... it ¦might¦ be a 'courtesy' to give it a common ground, but it's not a logical necessity. The reason being [I am surmising based on previous investigation] that you can drive two phases, a "forwards" and a "backwards" (with an option of "nothing") with two driven voltage sources, e.g. GPIO lines: (1,0) can be forwards, (0,1) can be backwards, and (X,X) - for consistent X as either 1 or 0 - is no drive. Just have the driver board compare the two given signal voltages for an unambiguous input. It's similar to the idea of driving an LED between *two* GPIO lines, instead of as usual between one GPIO and the high or low supply rail. Do this twice - two independent channels - to get your four phases. How the electronics downstream inside the stepper motor chassis itself expands these four into a great many more physical phases for its actual windings is something I haven't pondered properly, though.
@massimookissed1023
@massimookissed1023 2 жыл бұрын
@@duncanwalduck7715 , not with these steppers, they are 4 phase plus a common. The ULN2003 is just 7 high current transistor switches, 4 of them are used for the stepper, the other 3 are redundant. (If they'd used the ULN2803 which has 8 switches they could've made 4 pairs, doubling the current capacity.) There really should be a ground wire from the Pico to the driver board.
@lloydrmc
@lloydrmc 2 жыл бұрын
Brilliant! A complete enough framework to do something, yet plenty of room to further refine the methodology and add functionality. For instance, you built a simple state machine in the Micro Python calling routine, and the Pico still has three unused PIO state machines. Makes me want to get the hardware to start experimenting. Also, props to the KZfaq algorithm for serving me this video. I went ahead and subscribed, confident you have plenty more to teach me.
@bobweiram6321
@bobweiram6321 Жыл бұрын
Excellent tutorial. Good pace. It would be more intuitive if you used binary constants for the pins.
@williwuchtig3336
@williwuchtig3336 3 жыл бұрын
Realy great. Thank you a lot.
@pranavsreedhar1402
@pranavsreedhar1402 3 жыл бұрын
nice informative intriguing video...I have a question... shouldnt put(a) come before running any new steps? because it is the real starting point for any new step being called without memroy which in this case is the function turn...or have i missed something?
@dave-j-k
@dave-j-k 3 жыл бұрын
Great video, thanks. I'm a total noob gathering info to build a balancing robot with steppers, is this a good place for this control style or am i looking in the wrong area?? It will be controlled via the usual IMU board plus a remote of some type.
@djsbriscoe
@djsbriscoe 3 жыл бұрын
Very nice video.Have you got an example just lighting an LED and then going on to lighting a series of LED's. Are there any examples of reading a switch and lighting an LED as well. Just want to break it down even further. Thanks.
@kippie80
@kippie80 2 жыл бұрын
A fantastic video. But what a cliff-hanger! All the while, I'm thinking to myself, how to do the ramping .. only two variables to work with, can I do masks with this limited assembly? And you bring up the purpose at the end ... need to do ramping but I don't see a follow-up. :(
@WistrelChianti
@WistrelChianti 3 жыл бұрын
Did you by any chance narrate the Thomas the Tank Engine episode: Thomas and the x86 Assembly Code Cave? ;) [because if Thomas ever does learn to program, you should totally apply to be the narrator!] Great video. Really well explained (although I didn't quite follow the last bit - no mattery it was the PIO assembly I was interesting in) and so relaxing.
@thekuba9352
@thekuba9352 2 жыл бұрын
r/rarecomplements
@JohnDuthie
@JohnDuthie 2 жыл бұрын
super cool thanks for sharing!
@MartynCole
@MartynCole 3 жыл бұрын
why isn't there a digital ground between the Pico and the stepper board, what am I missing?
@UReasonIt
@UReasonIt 3 жыл бұрын
Unless the power used by both the motor and the Pico, my guess would be that at least one of the pins to the motor is always in a sinking-state and that's the GND connection. Not a good way, but probably just a small oversite on the maker's part.
@bumbarabun
@bumbarabun 3 жыл бұрын
I guess PC and power supply have common ground through power plug but that is pretty bad way to do it and quite dangerous.
@tunahankaratay1523
@tunahankaratay1523 3 жыл бұрын
@@bumbarabun Not really. It's actually perfectly fine, you may call it bad practice but in real life it will work.
@bumbarabun
@bumbarabun 3 жыл бұрын
@@tunahankaratay1523 perfectly fine? Yea have ungrounded power supply and burn USB ports on your PC or maybe motherboard as well. That does not sound fine for me.
@sin0m
@sin0m 3 жыл бұрын
This is awesome, great video! How would you tackle ramping/acceleration?
@tinkertechtrove2910
@tinkertechtrove2910 3 жыл бұрын
Thanks :-) you just need to adjust the speed that the routine cycles through the movement pattern. Maybe adding a delay into the state machine (not a lot of registers left to work with though) or having a few state machines that run at different frequencies (wasteful but maybe ok if your only working with a few steppers) I think the Pico can have 8 state machines max, but I have not tested this.
@massimookissed1023
@massimookissed1023 2 жыл бұрын
Being a nerd, I've taken one of those steppers apart and had a close look at the gearbox. Counting all the teeth on the gears, and multiplying all the gear ratios, led to an overall gear reduction of 63.SomeHorribleDecimal to 1, not 64:1 as you'd hope.
@TranscendentBen
@TranscendentBen 3 жыл бұрын
Where's your ground line between the pico and the driver board? The four signal lines aren't enough, it needs a connection between the ground connections of the boards.. Looks like you're lucking out without it, or it has the wall outlet ground as common between the driver board power supply and the computer ground to the pico on the USB connection. Neither of these is good or reliable.
@foorje
@foorje 3 жыл бұрын
I assume he takes the 5V from the pico supply line.
@TheRealWindlePoons
@TheRealWindlePoons 3 жыл бұрын
@@foorje I had a similar issue with one of my projects. I was powering all my external interface circuitry from my bench power supply and it all worked despite missing off the ground to the Pico. I actually wanted a floating interface supply - I found & removed a discrete (barely noticeable) link between 0V and ground on the bench PSU and I assume my PC's 0V (as appearing at the USB interface) is also grounded via the mains earth line. This "accidental" grounding should be avoided particularly on analogue circuits (I was using the ADC) where a "ground loop" will pick up all sorts of unwanted noise & interference.
@JonMcPhalen
@JonMcPhalen 2 жыл бұрын
Keep in mind that the ULN as an Emitter-Collector voltage drop of about 1.4 volts. Probably better to put 6V into that board.
@aleXelaMec
@aleXelaMec Жыл бұрын
Nice vid. Mind me asking how can i make a counter from the encoder (counting steps motor made) using pio? Big thanks in advance
@ralphmaasgmailcom
@ralphmaasgmailcom 3 жыл бұрын
Great video, didn't know this was possible in MicroPython. I have a question, where can I find the documentation for PIO programming (the different commands etc.)
@bryngerard4334
@bryngerard4334 3 жыл бұрын
Search for the Pico Micropython SDK (YT won't let me post the link) There is also info in the data sheet for the Pico and the C++ SDK.
@cheapnoiseinthehouse5578
@cheapnoiseinthehouse5578 2 жыл бұрын
Really nice. Could you do a video on connecting a I2S dac to the Raspbery pie pico using Pio?
@TheUnofficialMaker
@TheUnofficialMaker 3 жыл бұрын
very interesting thanks
@eliasvanderlof7391
@eliasvanderlof7391 3 жыл бұрын
I am trying to control a nema 17 stepper motor with the drv 8825 motordriver on the pico, but I can't get it to work. I also can't vind anything online on this, do you have an idea how this would work?
@captainprototype187
@captainprototype187 3 жыл бұрын
nice little driver board. Also works on arduino I presume? never seen them so tiny, is that anew thing?
@tomasparrado873
@tomasparrado873 3 жыл бұрын
Yes. You can write your own functions exactly as seen here or use the in-built library within the Arduino IDE (www.arduino.cc/en/reference/stepper). If your intention is to learn programming I'd experiment writing your own functions, however if you're attempting to build the motor into a project I'd recomend -> www.airspayce.com/mikem/arduino/AccelStepper/ as a library that can add acceleration/deceleration ramping allowing smoother, faster movements. If you're interested in writing your own accel/decel code, ww1.microchip.com/downloads/en/appnotes/doc8017.pdf is a good place to start for the base theory. Are you referring to the driver or motor being small? In either case there are smaller (better) versions of both. A good driver is www.digikey.co.uk/product-detail/en/trinamic-motion-control-gmbh/TMC2208-SILENTSTEPSTICK/1460-1201-ND/6873626 (hunt around for the best price).
@jam43
@jam43 3 жыл бұрын
Great video! But how do we get the stepper motor to run in reverse?
@tinkertechtrove2910
@tinkertechtrove2910 3 жыл бұрын
Thanks :-) I should have talked about that in the video really, all you need to do is reverse the movement pattern to change the direction
@edgeeffect
@edgeeffect 3 жыл бұрын
I've been calling it the "pee-co" (like the metric unit prefix) ... but yeah, I suppose "pie-co" (like the Raspberry Pi) really works as well... now you've got me wondering which is "correct". Just been down a rabbit hole of IPA and pronounciation... apparently "pie-co" is valid in US English... but it works so well for this particular device... Now... why was I here, oh yeah... you're gonna do some PIO... Pity there aren't binary constants in Python?.. if I'd have been "the MicroPython man" that's one of the things I'd have added to the Python core. I'm not that interested in stepper motors (well, not right now anyway) but I was VERY keen to see how PIO works... so, yeah, that was really useful.
@taranagnew436
@taranagnew436 3 жыл бұрын
what is the max waight in can turn?
@michaelmagnani3463
@michaelmagnani3463 3 жыл бұрын
The data sheet says 2038 full steps and you should be grounding the two together
@MrBobn8r
@MrBobn8r 2 жыл бұрын
How do you reverse direction?
@skf957
@skf957 3 жыл бұрын
Subscribed. Very good introduction to what is (for me at least), a complex subject. I would have liked a bit more time spent explaining some of the individual program statements, but appreciate that the video length would increase as a consequence. I am working on the "paper" design that has a Pico present in around 8 separate workshop machines (saws, drills etc.) and which use 433Mhz radio to communicate with a central Pico that will then perform certain functions - one of which will be the movement of a stepper motor. Unfortunately for me, the RadioHead library is geared towards C++ with limited functionality available on Circuit Python. BUT, CP does not support IRQ nor I suspect State Machine, so really negates the advantage of the Pico. And I REALLY don't want to learn C++ as I like the accessiblity Python and MP looks just as good. Anyway, thanks for posting this one and if you fancy doing something around the 433Mhz radios - you'll get my view and like!!
@tinkertechtrove2910
@tinkertechtrove2910 3 жыл бұрын
Thanks :-), that sounds like a very interesting automation project, good luck with it!
@jyvben1520
@jyvben1520 3 жыл бұрын
wouldn't the heavy machines disturb the radiosignals ?
@skf957
@skf957 3 жыл бұрын
@@jyvben1520 Yes, that is a distinct possibility and something that I plan on testing extensively to see how many lost radio packets there are both with and without the machine running. I suppose it depends to some extent on the quality of the machines (motor suppressor) AND the quality of the radios. But thanks for pointing it out.
@deterdamel7380
@deterdamel7380 3 жыл бұрын
Very good intro into the Pico's PIO! But in practice you will drive a stepper motor with a more integrated device and you don't have to take care about the pattern for the phases.
@hlavaatch
@hlavaatch Жыл бұрын
Where is your ground connection?
@dudesemidecent894
@dudesemidecent894 2 жыл бұрын
please show the codeing part and what to do
@bartspongebob9879
@bartspongebob9879 3 жыл бұрын
What will happen if we won't use controller and just plug motor to raspberry pi? Is there a method to make it work?
@WistrelChianti
@WistrelChianti 3 жыл бұрын
3 main options, you can control the GPIOs on the pi using shell script, C++ or python. Probably best searching for separate tutorials on that. Main thing here is to learn to use the PIO state machines on the Pico microcontroller. The only reason he is demoing the programming on a raspberry pi rather than using the pi to control the motor, is because setting up for Pico programming without a pi/linux is currently a bit "involved".
@bumbarabun
@bumbarabun 3 жыл бұрын
You cannot drive enough current by GPIO.
@WistrelChianti
@WistrelChianti 3 жыл бұрын
@@bumbarabun I think by controller they meant without micro controller rather than without the stepper interface board... Although I guess that take on things might be the intention... I guess it is ambiguous
@paulmaydaynight9925
@paulmaydaynight9925 3 жыл бұрын
where did you get those pork 'pie-Co' , 'pick-oh' for the win ^_~
@user-io2jf9bv4p
@user-io2jf9bv4p 3 ай бұрын
How to do ramping bro?
@mr1enrollment
@mr1enrollment 3 жыл бұрын
without a white board explanation of the bit setting for PIO pins in the various states,. your instructional value is poor. otherwise nice idea for instruction. I am being a honest critic - with the intention of providing you a new target for excellence. = after watching again, I like this better. white board is good, but still better than anything else I have seen on the topic.
@Alacritous
@Alacritous 3 жыл бұрын
You need chapter markers. I know how stepper motors work. What time stamp does the PICO stuff start at?
@TizzyT455
@TizzyT455 2 жыл бұрын
Why are there so many nops? im sure there is a more elegant way.
@benholroyd5221
@benholroyd5221 3 жыл бұрын
Are you pronouncing 'pico' wrong? or is this another instance of the pronunciation being different for no good reason and 99% of the time you only read it anyway so you never actually get used to the weird pronunciation (hello Gnome.)
@harnaikhothi3277
@harnaikhothi3277 3 жыл бұрын
hi mate prog will they run python or c pls
@tinkertechtrove2910
@tinkertechtrove2910 3 жыл бұрын
Python
@vizionthing
@vizionthing 2 жыл бұрын
Sir it is pronounced peeko
@qozia1370
@qozia1370 10 ай бұрын
use a man driver and motor not this baby stepper!
@MichaelKingsfordGray
@MichaelKingsfordGray 2 жыл бұрын
Um, err, um, you know, um, err, erm, er, erm, erm, er,
@cokeforever
@cokeforever Жыл бұрын
you make me sleepy with your monotonous talk, learn from Ben Eater
Raspberry Pi Pico - PIO explained
50:01
Slador
Рет қаралды 27 М.
Raspberry Pi Pico: WiFi part 2, Deep Sleep!
23:13
Tinker Tech Trove
Рет қаралды 15 М.
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 31 МЛН
마시멜로우로 체감되는 요즘 물가
00:20
진영민yeongmin
Рет қаралды 34 МЛН
Эффект Карбонаро и нестандартная коробка
01:00
История одного вокалиста
Рет қаралды 9 МЛН
Raspberry Pi Stepper Motor Tutorial
27:32
rdagger68
Рет қаралды 487 М.
HYDRAULIC PRESS VS ARMOR, USA AND RUSSIA
10:16
Crazy Hydraulic Press
Рет қаралды 115 М.
In-depth: Raspberry Pi Pico's PIO - programmable I/O!
17:19
stacksmashing
Рет қаралды 131 М.
Getting Started with Multicore Programming on the Raspberry Pi Pico
11:14
Learn Embedded Systems
Рет қаралды 44 М.
Raspberry Pi  Pico PIO  - 8 Little Processors You Can Program
31:55
Gary Explains
Рет қаралды 89 М.
Raspberry Pi Pico - Control the (I/O) World
1:03:16
DroneBot Workshop
Рет қаралды 605 М.
OpenAI's New SearchGPT Shakes Up the Industry, Google Stock CRASHES!
10:10
Raspberry Pi Pico gets WiFi via an ESP01 and UART
21:20
Tinker Tech Trove
Рет қаралды 47 М.
Raspberry Pi Pico: nRF24L01 over SPI
19:05
Tinker Tech Trove
Рет қаралды 28 М.
BEKMOBILDA Tecno Camon 30 smartfoni🔥🤩 #bekmobil
1:01
Bekmobil shorts
Рет қаралды 2,3 МЛН
Kumanda İle Bilgisayarı Yönetmek #shorts
0:29
Osman Kabadayı
Рет қаралды 1,8 МЛН
Tag her 🤭💞 #miniphone #smartphone #iphone #samsung #fyp
0:11
Pockify™
Рет қаралды 70 МЛН
Лазер против камеры смартфона
1:01
NEWTONLABS
Рет қаралды 711 М.