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.
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.
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
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.
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.
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.
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 UA-cam algorithm for serving me this video. I went ahead and subscribed, confident you have plenty more to teach me.
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?
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.
@@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.
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.
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.
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.
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.
@@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.
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 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.
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.
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.
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?
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.
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. :(
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.
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.
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).
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?
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.
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.
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!!
@@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.
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.
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 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
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.)
This is the Intro to PIO programming I've been looking for. Thankyou, Great Job!
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.
Thanks for this very informative video. First video I have seen that describes PIO programming.
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.
Your welcome, and good luck with your project.
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
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.
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.
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.
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 UA-cam algorithm for serving me this video. I went ahead and subscribed, confident you have plenty more to teach me.
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?
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.
@@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.
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.
Great video. I'm just starting with the PIO and this really helps. As you say "Defeating inertia" is an on-going quest!
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.
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.
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.
why isn't there a digital ground between the Pico and the stepper board, what am I missing?
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.
I guess PC and power supply have common ground through power plug but that is pretty bad way to do it and quite dangerous.
@@bumbarabun Not really. It's actually perfectly fine, you may call it bad practice but in real life it will work.
@@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.
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.
I assume he takes the 5V from the pico supply line.
@@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.
Muchas gracias por compartir tus conocimientos y excelente didáctica!
Excellent tutorial and examples, clearly explained.
Thanks!
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.
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.
Muchas gracias por la explicación. Finalmente logro comprender este tema y poder experimentar con esta funcionalidad. 🙂
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?
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.
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.
Thank you. Very good explanation.
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. :(
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.
r/rarecomplements
Nice vid. Mind me asking how can i make a counter from the encoder (counting steps motor made) using pio? Big thanks in advance
This is awesome, great video! How would you tackle ramping/acceleration?
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.
Excellent tutorial. Good pace. It would be more intuitive if you used binary constants for the pins.
Really nice. Could you do a video on connecting a I2S dac to the Raspbery pie pico using Pio?
The data sheet says 2038 full steps and you should be grounding the two together
nice little driver board. Also works on arduino I presume? never seen them so tiny, is that anew thing?
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).
Realy great. Thank you a lot.
Great video!
But how do we get the stepper motor to run in reverse?
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
super cool thanks for sharing!
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?
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.
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.
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!!
Thanks :-), that sounds like a very interesting automation project, good luck with it!
wouldn't the heavy machines disturb the radiosignals ?
@@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.
very interesting thanks
Why are there so many nops? im sure there is a more elegant way.
what is the max waight in can turn?
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.
What will happen if we won't use controller and just plug motor to raspberry pi? Is there a method to make it work?
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".
You cannot drive enough current by GPIO.
@@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
Where is your ground connection?
How do you reverse direction?
please show the codeing part and what to do
You need chapter markers. I know how stepper motors work. What time stamp does the PICO stuff start at?
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.)
How to do ramping bro?
where did you get those pork 'pie-Co' , 'pick-oh' for the win ^_~
hi mate prog will they run python or c pls
Python
Sir it is pronounced peeko
use a man driver and motor not this baby stepper!
Um, err, um, you know, um, err, erm, er, erm, erm, er,
you make me sleepy with your monotonous talk, learn from Ben Eater