 Hello and welcome to the show. It's me John Park and it's time for another episode of John Park's workshop We're here in the workshop and you are right over here in the discord and in our YouTube chat So thanks so much for stopping by if you are wondering Where's the chat and you're on twitch or facebook or some other place like that and the chat seems a little quiet then head on over to Adafruit.it Discord jump into the live broadcast chat channel and you will see the likes of these people mouse Andy Calloway Jim Hendrickson Paul Cutler See Grover. Hello and welcome DJ Devon. Thanks everyone for stopping on by Janisscu. Hello. Hello. Hello Snakey maker cat. Howdy I'm glad everyone has stopped by and David S and Charles Burnford. Thanks for jumping in over on the YouTube to keep things hopping over there Let's see. We got a bunch of cool stuff to do today So first of all, I will give you a coupon code to use that's right. It's the return of the coupon code I had gone dark on coupon codes during the early quarantine pandemic But now they're back and what that means is you can place an order in the Adafruit store and With this coupon code that I'm hyping a whole bunch 10% off on anything you buy other than gift certificate subscriptions and software But any actual goods stuff that'll get shipped to you like that Here's a little hint at your coupon code. It is the very rare and exciting fourth monster cereal who hasn't really made an appearance since 1982 and then once again in 2013 But now he's back. It's fruit brute and that is today's coupon code just because I like cereal So if you type in fruit brute in the coupon code section 10% off And hurry on out to target if you want to try to find a box of this stuff I think it's exclusive. It might be with a different box at other places But if you go to target you get this nicer illustration Original style illustration so that weird horrible cg thing that they did in later years And this one is a collab with street artist cause so you can see the signature x's for eyes Look at that guy right there. There he is with the weird cause mouse guy thing fruit brute I could talk about cereal all day. So just let me know if you have any cereal questions That's right. This is phil b's favorite cereal. He loves the there is no dragon monster cereal So this is as close as we get is the fruit root Some other fruit root facts Fruit root when it got canceled and then came back came back sort of as yummy mummy Known as fruity yummy mummy. It was kind of the same cereal and not officially a monster until much later They have a weird they really just stick with frankenberry blueberry and count chocula But the fruit root and the yummy mummy have kind of come and gone as a weird. They've changed flavors too. So Watch out So let's see. Is that is that enough cereal talk? Probably Um We also have a job board that's got nothing to do with cereal if you head on over to Jobs.atafruit.com, uh, you can check out postings there. Uh, it's entirely free So you can post jobs if you're looking to hire someone and that can be anything from freelance contract part time full time Uh on site remote all of those are options and it's entirely free and entirely vetted So check on out that right there that helpful on its side and check that out. Uh at jobs.atafruit.com Uh, oh someone found a dragon cereal dragons had a cereal About that I did not know what's it taste like it looks kind of good I like cereal. Okay. So what else? Uh mentioned the jobs board. I don't know if I mentioned this Already, I think I didn't I've got a show on tuesdays Right there. It's called JP's product pick of the week and uh during the show I like to pick something from the store. Uh, in this case five somethings from the store. We had all flavors the red green blue yellow and white versions of the 14 segment Alpha numeric display backpack that now has stemma qt on it Uh, get a big discount during the show is 50 off on all of those versions of it during the show No coupon code needed during that time just throw it in the cart and get it before the show is over Here's a little recap of what we did That right there Is my product pick of the week it is the quad alpha numeric 14 segment led backpack It runs over i squared c so you know what we did we did what we always do We added a stemma qt slash quick port. There's actually two of them back there light up individual segments if you want Uh, yeah, my friend I have five of these displays each color I have them all plugged into each other on the back using the stemma qt And then I have that plugged into a little cutie pie here each of these I have set the jumpers on to uh, give them unique addresses alpha stuff. It says alpha numeric display Once you have this set up you can just throw long lines of text added or strings of numbers It knows what to do. So there's nothing you have to do to manage it It just access a single display which is terrific. The library is excellent It is the quad alpha numeric 14 segment led backpack display with stemma qt Yes, it is Uh, I have the set the display over there. You can see it on the little lego board, but it was it was uh Not agreeing with the shutter rate of that camera. So it was looking very weird I decided to turn off maybe I'll mess with that That's always a challenge to get the frame rates of shutter speeds and uh display refreshes to agree All right, so why don't we jump into a little bit of a kind of cool circuit python parsec that I've got prepared for you today. Check it out All right Let's do it For the circuit python parsec today I wanted to talk about how to light up a bunch of random pixels using bitmap in display i o So here you can see I have a single green pixel lit up in the center of this display You can barely see it there one little dot and this is a 320 by 240 display. So that's one little lonely dot So the way this is done right now and it'll get cooler a moment is I've got display i o setup This is a little tft feather wing running on a feather m4 And I am creating a bitmap object that is the width and height of the display and I'm giving it a four color palette That's how many colors it can use when it draws I've set up that palette and I've set up a tile grid to hold the bitmap and that's inside of a main group for the display I've set up my palette as these four colors black red green and blue And then right now all we're really doing is lighting up this one bitmap You can see here if I add a few more to this and hit save you're going to see four little a little cluster of four dots there Uh, it looks a little like a fuzzier bigger dot, right? But now it gets interesting when in my main loop instead of just passing What i'm going to do is use randomness to pick a random x y location on the bitmap because the bitmap covers the whole screen in this case So i'm going to pick one pixel at a time and i'm going to randomize my color among the four choices of the palette And then i'll display it with a tiny little bit of time and repeat. So if I save this now you're going to see We get this nice sort of snow Pattern kind of like tv snow. I don't have white in there. So so it doesn't look quite like snow But that is a really simple way to scatter a whole bunch of pixels around just using one bitmap The bitmap is used for drawing things lines boxes and so on They're all just routines or loops inside of the bitmap to pick which pixels you're showing And this is a really nice way to randomize that. So this is how you can display some multicolored snow Using bitmap inside of circuit python and that is your circuit python parsec By the way, I appreciate johnny burgdoll in the chat said and now jp will magically light up two dots. Whoo four How much patience would you have for me to one by one add every Pixel that could take hours Uh, I guess if we wrote a loop for it, it wouldn't and you can see actually this is still still lighting up there It's kind of a cool look. Uh, there's so much you can do and uh, this came from a suggestion By the way from todd bot who's had questions from people about how can you use display io to just light up a single pixel And while there isn't really a pixel Routine the choice of which pixel to light up inside of a single bitmap acts like that. So you can you can Graph out your your display. You can try a smiley face if you had the right routine And then there are other convenience routines that let you do things like rectangles and triangles and stuff so you don't have to Cook that up yourself every time So Let's see. Oh, yeah, uh dj devin in the chat said that We could do the star field from the windows 98 screensaver with this sort of thing Oh, yeah, halloween nice idea some some red and maroon drops. I dig it Hey, yiniscu. Thanks for the thanks for the gif. All right. That's that's the nice snow right there All right, uh, let's see what is next. I want to Jump back to this display here uh Go over a couple things. So one, okay We've got larz has made an appearance on a box of cereal, which is ridiculous. So thanks for that andy calloway. There's dragons with uh with larzes instead um I wanted to Jump over to the learn guides section here And show you inside of the new guides section. I'll just hit view all I published this guide right here, which is the walk person guide It's a collaboration with noe ruiz who did the 3d printed case and by the way, he's got a really nice uh Addendum to the case there. You can see that purple one He realized that since I was lighting up the four neopixels that are on the neokey there he could do a uh Different material pause feed in some more light diffusing material Print a few layers like that and then go back to that purple. And so now you have this kind of display, which is really cool looking on top So guide is out. You can check that out over on learn dot adafruit.com Going through this we have the parts Explosion there that know I put together the cad part list and all the stl's there as well as the source files if you want those infusion And then if we head over to There's install circuit python. I'll skip that there's code the walk person this goes through The code as well as preparing a little link for preparing your mp3 files naming conventions, which are also important for making your little sd card Mix tapes and then I have a little code explainer here that tells you sort of what each main section of the code is and how those are used And if we scroll down we've got the section on building the circuit So I put this on a couple of diagrams one is a breadboard diagram Which is actually a really good way to build it at first to make sure you understand how everything's working together Before you go and solder it. I do recommend put it together on a breadboard I sometimes skip this step in a rush and then regret it later. So kind of kind of important I find to Sort of verify things work before you solder them down And then I have this version of it that looks a little more like what the the real PCBs will look like when you put it on to a Featherwing doubler as I did with some of the connections still wired there And then I have the photos that I took here And actually I was experimenting a little bit with shooting photos. Usually I shoot them here on the workbench But last week when I was shooting these photos It was when we had the heat wave here in southern california and I didn't really want to run this ac and and Run up the bill and potentially contribute to crushing our electrical grid. So I Set up my indoor space. I have a another workshop smaller workshop and did the photos in there So I think they turned out. Well, you probably wouldn't notice the difference too much Uh Here we have some of the Soldering onto the feather Doubler and I love using these because you get a bunch of connections for free to the feather as well as some little bits of prototyping area that you can use Setting up my headphone out. I also like doing this. Uh, this little trick here. You can see Go to the full size photo even though that little i2s amplifier has a Terminal block that comes with a little screw terminal block that you're supposed to solder in there for ease of assembly And since this isn't really gonna get shaken around too much. Uh, at least I don't think it should I opted instead to just use this little tiny bit of socket header Soldered in and bent down at a 9 degree angle so I could just push dupont Cables into the back there Also, you'll notice, uh I like these If you take a look at this right here Go to the full-scale view of it. I really like using our, um premium silicon jumpers In projects like this where I'll leave one half. So again, you can see here I wanted to be able to do some interconnect But I didn't want to assemble all those cables by hand So I just cut some of my cables in half and in this case. I think they had Socket on one end and pin on the other So now I have those to use in projects You'll see that I've done that again here today for for today's project Uh, but that allows me to use a allows me to use silicon wire Which is great in a cramped space like this because it doesn't uh, it's not so difficult to bend as our pvc More typical wire the premium stuff is silicone covered really flexi Uh, and then I get all of those those connections One issue as you'll see that I have to deal with here is we only sell them in packs of four colors So it's uh, let me see I have A set of them here Uh, these are some of the ones that are female female or socket socket Uh, so we only have them in red blue yellow and black So what I did in this case was Just put some uh Heat shrink over the ends of them so that I could tell which one was which when I was soldering on the other end Or plugging it in I asked lady aida and mary who does a lot of our sourcing if we could have some made up in other colors And I don't know what the status of is of that is right now But I believe we are gonna at some point get some more unique colors, which would be great I would love to get you know, if you if you take a look at your typical um rainbow Jumper wire sets you get you can see this that's repeating uh like three times there But you get a lot of colors you get I would love to have like 10 or 12 colors to work with it be amazing um And you can do that by the way if you use just our silicone wire, uh, we've got just these spools of These come in a bunch of colors in a couple of different um diameters or gauges, but the um Not having to crimp on wire connectors Is fantastic. So especially when you're breadboarding doing a bunch of breadboarding Uh, these are great. So, oh, yeah, Todd says over in the chat. That's why I have black and silver sharpies on hand I put black stripes or silver stripes on each end of the cables to disambiguate. That's smart Uh, and let's see other stuff. I wanted to show you in here And by the way if anyone puts one of these together and has any questions along the way Please reach out on our discord for project help Uh, I know that no way put put one together and so he's got one that he built based, uh, I think just on the diagrams I don't even think I had these photos up yet, but he he got it all working just off the diagrams, which is great And we've got the little on off switch there. There's also this very clever little, uh captive Slide switch holder you can see that little white part at the bottom there that takes one of our little, uh spd t switches slide switches and Clips it in and then you can screw that to the case, which is really nice Uh, here you can see actually this is a nice view of Me getting ready to sandwich all those wires down so that board is going to sit on top of that board and having the The silicone jump versus and it would be great to use thinner ones thinner wire would be good um Also looking forward to iSpy displays because that's other than the sd card Pins on that wiring that's all Display stuff and it would be it would be great to just use the iSpy thin little ribbon cable and Here you can see the Headphone jack there in action just plugged into that i2s amplifier mounting the buttons Mounting the rotary encoder Using our little sd card extender. Here's a good view of The extender to give us the distance that we need there to get outside of the case so you can swap out sd cards And Final assembly so i've got a group of Stem aqt connections there i probably could have gone with a shorter cable on this one I could have gone with like the 50 millimeter instead of the 100 millimeter for that connection from the keys to the rotary encoder Uh, I didn't have one on hand. So I didn't but this worked out and then final assembly here. You can see we've got it all Snapped fit together with that case and there it is so Go check that out and the files are up there So i'd love to see some examples of people picking their favorite color ways to do a beautiful looking walk person Uh DJ Devin asks do we stock that extender? Yes, we do In fact, if you i'm just going to widen this page a little bit so that The side shows up uh over here on the side are all the products that are in it all the part products that are in it um, and so if you scroll I guess if we hit view all yeah, so a fewer feature, but if we hit view all that'll take us to the full list And the extender doesn't look like the extender in in the picture because it's actually connected to a raspberry pi So you're not you won't see what you think you're looking for, but that's the extender. It's four dollars fifty cents. It has A very simple It's not a spring-loaded connector The the extension end goes into whatever and on a lot of devices that is spring-loaded but on the little end where you'll put the sd card. That's just uh Sprung from the contacts, but there isn't that click click click. You just pull it out or push it in So yeah, there's 77 of them in stock and they're four dollars and fifty cents. So you there you go Go grab a bunch of those we have some other sd card extenders for other types of projects that use a ribbon cable So if you're trying to get something real far away, the ribbon cable is like this long In fact, let me let me find that sd Extender Let me go to the store and not learn. There we go sd So this is a sd card extender and is a micro sd card extender It's a little more expensive because they have more parts, but um Depending on the type of build you're doing these are great gives you a A nice extra reach for your sd card. All right, let's see let's uh Move on now to that's enough on the walk person. Let's move on now to Next project. So, uh, first of all, you remember a few weeks ago. I put out a guide on using motorized faders called the flying faders guide You can go check that out. In fact, let me I'll bring that back up real quick Learn flying faders So this shows you how to tell a motorized Slide potentiometer to go to a particular position As well as read it if you're moving it and use the capacitive touch to Disengage the motor when you want to touch it and move it to a new position and also have some presets so you can use buttons so The basic idea is that a slide potentiometer is a linear version of a servo motor a hobby servo Essentially, it has a dc motor That is controlled usually with pulse width modulation They usually run somewhere around five to ten volts dc and They can go Forward or reverse so you need to use some sort of an h-bridge driver that can send the voltage in either direction And then the potentiometer is being read on one of the analog ports of your microcontroller And if you look at those two things you can say okay when I get to a certain position I can stop moving the motors. This is what allows you to stop right in the middle by If we use that sort of typical zero to 255 range you could say okay I want to go to 127 and the motor will stop when it reads that servo feedback from the From the slide potentiometer So I was just noticing mouse said oh no not the flying faders again. I have managed to resist buying them so far Please do not torture me anymore. Actually, I don't know. I don't know if they're in stock at the moment Let me let me look and see. Uh, yeah, it's out of stock. So no danger right now But I picked up a few of these when when we first came out with them and Lamor saw a cool desktop sculpture that massimo banzi posted on his Twitter feed massimo who's one of the founders of arduino and it was a set of three Sort of ball screw linear actuators with stepper motors So you know a piece of a gantry from a cnc or a 3d printer type of thing and it was just pretty to watch these ball screw actuators moving There were three of them and they were moving a little 3d printed block looking thing up and down I should find find that tweet. Um, if anyone finds it put it in the chat and I'll uh I'll show that and Lady I said hey, why don't you do something like that with faders instead of a linear actuator? We've got these little slide pots and they essentially are linear actuators um, so The first thing I did was Went over to fritzing where I had originally laid out my um diagram for doing just just the single one and Multiplied it by four. So let me Jump over to that page and I'll go to the breadboard view here. So here you can see This is sort of the origin of the project for me as I started out with I have a feather rp 2040 on here and this would work with pretty much any microcontroller that has um I squared C because I'm going to be using the motor feather wing which communicates over I squared C Touch we want capacitive touch on there So we can touch and communicate with these or maybe not You could cut maybe if you're just going to have it moving as a perpetual sculpture You won't you won't need the touch at all, but I've got that working here um And on the feather rp 2040 pretty much any of the gpio pins can be a touch pin so long As you ground the pin to one uh to with a one mega ohm resistor so that there's the cap touch pin and then it's it's being sent to ground um the Other thing you'll need is four analog ins So analog to digital converters because we're going to read four of those uh sliders And if you look here, I have sort of mocked up We don't have a fritzing object for these but I've kind of mocked them up by using an existing fader object I added a little piece of perf board Right here. So this is a fritzing object that's uh perf board and it can be Adjusted for the number of columns and rows that you want So Is it going to let me there we go you have to hit the set board size button So you can just use these the smallest I think you can get them as down to five one by five for some reason So I use those when I don't have something to connect to and that's because the Slide potentiometer we're using uh grab one right now has one extra connection on it at One end here. So instead of just having the Positive voltage of the voltage divider and the wiper we also have that touch pin that I've I've got I'm using a blue wire there on Um and then I just put a fritzing DC motor down here. So This this here just makes it easier to keep track of that part if I move stuff around um, and then I'm running the You can see the cap touch of all four going into these pins 12 11 10 and 9 and I have the 1 mega ohm resistor there and then I have a power and ground Which are used for uh, both the positive side of the voltage divider and the Ground side of that voltage divider. That is what the the potentiometer is doing And then I also have a pin here running to an analog in And then you'll notice the motors are running nowhere near that because I plopped a Feather wing right here in the middle. This is the dc motor stepper Feather wing so it can drive dc motors and four of them in two directions Or you can use this for steppers So this normally is going to live right on top of Your feather but just to make the the wiring a little clearer I've got it down here so One thing I do I tend to do now in fritzing is also Make sure that I have the schematic looking clean. It helps Helps keep things straight and some people might want to refer to that Instead so I might include that in the guide as well Also, by the way, that makes life easier if you think you want to go and do a pcb you can do pcb's inside of Fritzing you just have to make sure you get your schematic Straight first. You can't just go from breadboard to To there or at least maybe you can but I wouldn't advise it The reality check of of the Schematic view is helpful also lets you do things like create ground plane objects and not have to run all the wires everywhere So I have little little breadboard objects or schematic objects for things like ground and power all right, so Then the next thing was to put this together. So let me jump over to the bench And oh, sorry, I've got uh I've got a little blocker. I forgot to put up that keeps some of that air conditioning wind off of the camera mount over my bench Let me see if that'll Settle that camera down one second That might divert. Yeah, I think that worked good All right, uh, so let me just bring up my discord over here um Here's the assembly so Just like in the diagram there. I've got my motor feather wing And You can see if I pull it apart here. The only thing it's connected to is and I've just got one I don't have all four faders connected. I've just got the one fader With its motor. It's dc motor and again, you can see here. I'm using these uh Hacked up silicone Jumper wires, which allows me to Have some nice little attachments there and color coding so I can Get this in and out of an enclosure or any other type of work I'm I'm going to do with it. It'll make life easier and so those run to One of the motor outputs of the motor feather wing And then the motor feather wing it has also Point here. So we've got these four outputs So four pairs for four motors Uh, and then this is the power input So motor feather wing does not use the three volt power the usb power the barry powder power that's coming off of your Feather wing we instead have an external dc input And so for that i'm using One of our little breakouts here for a typical dc barrel jack and plug And the plug here is coming from some DC adapter I found in my pile of dc adapters that is a nine volt one amp And I think I measured We'll see if that's adequate because I measured one of the Motors here at about half an amp. So I think I may need something beefier like four four amps would be nice on this But we'll see we'll see what I can get away with with uh with less at first so that's Power and control and the way the dc Sorry, what the way the motor feather wing works is it is a pulse width modulation of the voltage so you can choose The frequency Of your duty cycle of the pulses which we'll get into in a little bit You can choose the decay style of the of the motor if it's essentially breaking or coasting And you can choose what is the Uh the voltage Sorry, there's the frequency of the pwm and then there's essentially the voltage or the duty cycle of it So all of that we can do either iarduino or in circuit python i'm doing it in circuit python So now you can see if we if we get into the next little bits of this thing i've got a Feather And i'm using these nice stacky header pins So these these are uh both a socket and a pin just goes through you solder them in place It can drop into a breadboard or any other thing, but it still has the sockets on on the top of it And the reason I want that is so that I can Plug it into this guy right here, which is my little favorite friend the screw terminal feather wing And this gives us a few things that are that are helpful here for one thing When we plug the motor shield on top of or the motor feather wing on top of the feather If we want to still plug in our Touch pin and the voltage and ground and analog read of the potentiometer We're going to need to either add some headers on top. There's a little little spot here to add headers But that can get a little tricky because we we need like five or four of the voltage output And we need four grounds and we only have one or two of those on here So by adding this we first of all get nice screw terminals to hook up those output outputs So again, it's kind of convenient for for putting it together We also get some more duplicates of things we have multiple three volt multiple ground We have some prototyping area here So if we need to add Something or other like I'm going to have these four one mega ohm resistors that go From ground to the pin that I'm plugging touch into the 12 11 10 and 9 This gives you a nice little neat place to do that You're not going to build anything huge on there, but it's pretty good And it also gives you a nice on off switch So I'm a fan of of using this in this type of application You could probably also do all of this on a feather tripler Maybe put feather motor wings side by side and then have that third spot for all your connections And a little bit of a circuit, but I'm going with this so far seems like it It's going to be a nice way to do it also gives me some some nice big m3 mounting screws Only word of warning is you have to be a little careful the stacking header Is a skinny header compared to your typical header. It's quite thin So they're they're flexi and a pain in the neck to to get into there sometimes you got to push on just right So if we plug all that together And right now I don't have the One mega ohm resistor hooked up for the Touch and I don't have any touch Code going on so so code Code for touch doesn't been written. It's not going to do anything But what I have started with is just the basics of moving this thing As slowly and as smoothly as I can so this is going to be a desk sculpture. I'm going to end up with Multiple of these I think mounted vertically And I'm not quite sure what the enclosure is going to look like or what I'll connect to the ends If I'm going to just leave these fader caps on Or if I'm going to string some I don't know I might light up some of our little led nudes between them to do sort of a little wave pattern That's that glows would be kind of cool Um, but whatever it is. I want these to move somewhat elegantly So, uh, these love to move fast these will zip around But what I what I was working on was how to get them moving pretty smoothly smoothly as I could So I'll I'll show you how well I did And talk about talk about the approach to that so Uh, I just plugged in power for the Let me turn this off. Uh, yeah, so power for the motor feather wing. We get a led lighting up saying, okay This power input right here. That's that's live. So we so we have power on it. That's one thing Uh, second thing is I need to power the feather Uh, so that's usbc into this feather rp20 40 And then last thing is I've got this on off switch and I forget about this a lot when I haven't used these in a while I plug in my feather and I go why is it not working? And then at some point thankfully at some point I remember that this thing has an on off switch that might be in the opposition Um, so I'll turn that on And now you see turn it this way we get this nice smooth back and forth of of this it's not Stepping or chattering too much. It's uh, not making a ton of noise and all of these things can be a struggle to achieve with With the dc motor. So I was happy to be able to arrive at that and What I'll what I'll say is I would Not have gotten there if it weren't for jan ghoul's b c grover's guide on working with dc motors in Circuit python actually it might just be on microcontrollers. He has some arduino sections as well So what I wanted to do was Uh, I'll I'll turn this off now. Let's flip this off switch and Show you that guide because I knew it was there and I knew it was going to be important someday and that day came so uh I will Jump back over to the learn section here and See improved brushed dc motor performance is the guide um So this is terrific. It gives you some uh theory some code Uh, a real understanding of what you're trying to solve here and why Uh jan originally approached this because he has a long Standing tradition of designing and racing these string racer cars against his brother and he's got a Strong desire to win. So uh, he put his engineering skills to use and coming up with optimal Code for for telling these dc motors how to how to perform talks about both the Uh physical construction of the motor how they work And how that relates to controlling them This section here duty cycle Talks about how you Generally in our libraries give it a negative one up through a positive one Float value that equates to the duty cycle how how often a square wave is at its peak And then it also talks about the decay mode which has to do with Some internal circuitry on these motor drivers and motors that allow them to either coast or break using sort of regenerative braking type of generator mode And then also how the the pwm frequency Impacts this now interesting thing is I'll I'll hook that up in a second and we'll we'll mess around with this the default pwm frequency of the motor kit, which is what i'm using with that motor driver is 1600 hertz and uh At that pwm you need to give it a lot of juice And it has very little torque, but it moves fast and that was actually not at all what I was looking for So only when I dropped it all the way down to 50 hertz, which is a really good starting point using Using some of these motors and motor drivers Did I start to get the performance that I wanted and then I then it was a matter of just kind of tuning things until I liked it But that doesn't mean that's the only way to do it jan also has some discussion of measuring motor performance so that you can Actually understand the performance graph based on different pwm frequency duty cycle And decay modes And there are some practical code examples here for using Code inside of the different cricket motor drivers The feather wing and motor shield which are very similar And I think there are some other examples here some breakout boards and h h bridge chips if you're just using those So this is a lifesaver also some ideas that todd curt gave me It's Allowed me to to approach it this way so I'll thank both Todd and jan for the big help in in making this work And what I'll do is I will jump into a this view And I'll move my Little snowy display hey that's gotten good and snowy hasn't it it's still chugging along still adding pixels But some of them are black so it's never going to finish so let me grab Both my dc power And the gizmo And I have never had a great understanding of the pwm and the frequency and the the duty cycle And I still don't have a great one, but it's definitely improved. So I want Thanks to jan and thanks for lady eight asking me to do this project to make me Have to figure out how to get these things to to move gently. All right. I'm going to unplug that little snowy display and I will Fire up this feather again this focus Oh, that is a real warm white balance back that off there we go uh It doesn't love that orientation because there's some weight actually to that That'll end there and some torque that it's causing what I'll do actually let me See if I can set it Somewhere that it'll stay mostly put Uh-oh There we go. It's back Focus looks decent. Yeah good, so Let me open the code for that Okay, uh, so what am I doing? Oh, I'm printing out my Potentiometer this the faders reading when it reaches The target so I think I've told it to go 255 to zero. It's getting close. It's going 253 to about two or three So that's not bad Looking at the code here what I've got going on is I'm importing both motor And motor kit library. So motor kit is what lets you use the this specific board over i-squared c so the motor feather wing over i-squared c also the Motor shield so they use motor kit which bundles up makes a bunch of things convenient So you can see the setup is pretty simple. The reason I'm bringing in motor is that I need it to be able to Specify decay mode which as it turns out I really like the default So I don't need this the default is fast decay, but I want to show you both And this is some of the the crucial stuff here. So I've set up the motor wing over i-squared c These are based on jans sample code here The ideas on on how to implement the frequency here. So I'm setting up my frequency to be 80 80 hertz This is creating the motor object And then I'm setting the decay mode there. That's the default and then I'm setting my throttle that that breaks it setting it to zero is a break Setting it to false. I think is what the coast is if I remember I've got in this case just a couple saved positions and let me leave I'll leave those we can mess with that more later The rest of this is really similar to what I was doing before in the last project So I'm reading an analog input here, which is the fader. I'm creating a remap of the 16-bit value it uses internally and setting that to be 256 zero to 255 I have a little state object here state variable for the fader position Then I have a little clamping function. I'm actually not using that anymore and get rid of that Uh, and then this is my go to position which is much simplified compared to The previous version because I'm not doing any sort of PID stuff to slow down Because I'm already moving so slow. I don't overshoot before I was moving quickly and so I had to Use some PID code to Taper off the the speed as I near the destination otherwise we would overshoot and sort of oscillate chatter So what's happening inside of this function is we have a variable called fader position Which is where the fader is right now Based on this little getting an integer version of Subdividing the fader value by 256 into 256 chunks That's what i'm printing Then I have the Check for Are we moving up or down? Are we are we Lower than or higher than the new position that we're trying to head to and that just determines if we essentially move positive or negative directions Uh, I set my throttle speed here. This is something I was tuning. So I've set this quite low Uh, so I have a throttle of 0.125. So that is um I don't know roughly A little less than a volt because i'm feeding this nine volts if I have if i'm Thinking of this properly and please check the the discord because jan is there so you go over. Thank you if you see Uh glaring Problems, please let us know and then if i'm Smaller than the new position that i'm going to go in the opposite direction which happens to be negative You would swap those if you swapped the wiring on it. It's uh, you you can go either way then uh Not doing that anymore Here is all that's happening in the code right now is I check how many saved positions I have in that list There's just two right now and I go to them. So I go to one I go to the other. I'm not even pausing So check this out if I Will remember that number 80. I liked it, but if I do the default Which is 1600 or if I just don't bother setting it at all, but I'll I'll go ahead and set it explicitly So 1600 hertz is the default Uh, and I'll hit save it's just sitting there struggling Because I have such a low voltage that i'm sending it Uh that it just can't get going when it tries to ping the motor that quickly So now I've got to juice this, uh Throttle speed up Let's remember that point one two five actually i'm gonna Just comment that and negative comment those So now let's spring it up to one and negative one. That's the defaults Bam bam bam bam bam bam. Look at that thing go It's too fast That's kind of what happens when you first use the defaults. Let's let's cut that down a bit. Let's go to 0.7 Whoo Hey better Now you can see why I needed the Pid code before when I was operating at high frequencies or even if I wasn't if I wanted to move fast If I wanted to send it pretty pretty close to my maximum voltage Then I need to slow that speed down as I near the target or we you can hear i'm clicking on the ends What i'll do I will make the Stop points shorter. Let's go to 220 and 20 Or and 30 how about no not 300. Whoops Okay, so now i'm not clicking against the ends. I'm guessing you could hear that terrible noise Yeah, the tommy gun fader it's Scary, uh, so that thing's moving fast. It's nice. I mean if you're using this in a Another type of project where you want to get somewhere quickly awesome Um, let's see how it does if I tell it to go to the halfway point. Uh, let's say what is that about one? Let's say 127 So we'll go We'll go to the halfway points Shouldn't look any different, right? What if we pause while once we get there? Okay, so you know it's kind of overshooting that middle position should be the same every time And it depending on the direction it's going there's just inertia um So a couple things about that one is use the pid code like before other is what if we change this Decay mode So a fast decay essentially just goes into coasting. It tells the motor. Hey just lay off the slow decay mode Kind of does regenerative braking it uses the it cuts the power, but it keeps the connection and so it Treats the motor like a generator and you know how hard it is to turn a generator when it's not getting power So let's see how it does with that Okay, it's different it bounces a lot though. Here's where I don't know what the answer is other than going slower or trying to use that pid code Um, but I'd be curious, uh, if jan has any ideas in the chat about that How you would go about dealing with this and for for me? Yeah, there's there's nuance right the the nuance that I found is Trying these modes changing the frequency and adjusting the the speed value that throttle value So let's see what happens if we go drop the frequency in half Better right it's not overshooting quite as much But it still has a lot of inertia there. I said it doesn't doesn't really slow it down that well But I I don't see the bounces at the ends either So Naturally you'd be like hey, let's just drop the power but pretty quickly here At these high frequencies. It just starts to stall So let's go how about point three can it do it? That's kind of nice I don't hate that it's still faster than I want for my sculpture, but um the point being depending on what you're doing. It's not, uh A really quick and easy recipe to getting the motors to behave the way that you want them to I like this now one thing with mine is that with my projects is I want this to be vertical I don't need it to pull much of a load, but even being vertical I started to notice the speed was Uh struggling fast fast struggle struggle so gravity actually really helps it Um and hurts it when it's heading back up. So here you could say okay, let's let's change what the values are Um now says use a p.i.d. Is it always the right answer? um could be Pid code is confusing and tricky um, so Let's drop this frequency What happens at half of that? Okay, what happens if I make the upper voltages Lower hey, it's starting to move sort of slow, but sort of hinky Uh What if I drop this way down? Let's go down to 25 hurts Now you can see the steps right it goes My camera a little I'll put the sideways again because I think it's a little easier to see Will it work? Yeah Again, I apologize if the video frame rate isn't enough I'm not quite sure what how it's uh looking on your end, but I see a little Just because the steps are so big with this low low frequency Uh, I think 24 is the bottom end of of what this motor wing can do. Uh, so if I Double that let's say to 50 which is a really nice starting point Okay, it's a little chattery still And this was the game I went through to get to around 90 80 or 90 um Let's drop this even more Now it moves pretty smoothly Really smoothly in real life. I'm seeing some some uh framerate stuff on My feed, uh, and then I found that this fast decay actually Felt slower and smoother Uh, and you can imagine I'll be tuning this more, uh, if I if I feel like it's not quite enough oomph we get more torque as we drop that um That frequency And this is nice right here. So I so that's that's how I arrived at that um, but big, uh Oh good. Thank you. DJ Devon said it's smooth on your end. Yeah, I think it's just the preview that I see here Gets gets stuttery Yeah, in fact if I make my broadcast software have, uh Uh focus then it then it looks better. So this is looking nice. Uh, like I said, this is drawing about 0.6 Amps So to do four of these I'm going to need a bigger supply Uh, and I I have not done this but typical trick is to put a little capacitor across the leads on the Uh on the motor too, which can help with smoothing. I'm not sure in this case if that's a good or a bad idea But I might try that out So I just wanted to share that because that was my process of of saying can I get one of these Faders to act like a much slower smoother happier Linear actuator Uh, and the answer is yes, and the answers are right there in jan's guide. So thank you again so much for this This is a a huge help. Like I said, I knew it was there waiting in the wings I just uh, hadn't had the project yet where I where I was going to spend the time looking through it But it was a a terrific help. So thanks jan for that Uh, so here's a nice big view of of the motor there. Oh, it's not so as in focus as I thought Now that I see it large There we go Uh at the speed too, it's kind of nice you can see The little belt right here It's a little toothed belt rubber toothed belt that's driving From the gear At the end of the shaft Pulling the Actuator and then there's a pulley on the other end that it's that it goes through so that's how that works There's a little bit of vibration there, but that's uh to be expected with these low low frequencies on the PWM All right. Well, I think that's all I got uh to show you about that, but I will be putting together um The rest of the code figuring out how I'm getting four of these to work together nicely from a power standpoint As well as trying to create an input for maybe some different animations different speeds waves I'm planning to use four of them. It would probably look nice with three as well And see if I can do sine wave things and you know Shapes and and things like that which if I connect them with some some flexible something or other Especially those led nudes that might look really cool. Um, give it some some sort of extra motion to it So that is it. That's the genesis of the fader sculpture project. Thanks everyone for stopping by that's going to do it for Uh my workshop show for the week. Don't forget Run out and buy fruit brute cereal because it's healthy and delicious It's one of those it's delicious. Uh, and That coupon code right there fruit brute will get you 10 off in the ate a fruit store So do that first and if you have any money left over go to target and get your get your fruit brute This is not at all sponsored by general mills or target in any way by the way. I just am a fan 10 off in the store that applies to anything you can get except for software gift certificates and subscriptions But throw some stuff in your cart Chuck that fruit brute code in there and save a little bit of money get some cool stuff Uh, thanks everyone so much for stopping by today. It was a lot of fun and I look forward to seeing you all next week Don't forget. We've got uh Deep dive with foamy guy tim c coming up tomorrow. I believe maybe even saturday as well. There's some cool stuff going on with flip number displays happening as well as uh, I think the octopus game and watch project Wrapped up recently. It might be other work on that and then next week we start all over again with I'll have my project pick of the week on tuesday. We'll have 3d hangouts on wednesday. We'll have show and tell wednesday evening We'll have ask an engineer after that then this show again and uh Repeat and repeat and repeat. Thanks everyone for making that possible. I'll see you next time for ate a fruit industries This has been john park for eight fruit industries with john park's workshop. Yeah, that's me. Bye