Arduino Stepper Motor Clock
16:34
3 ай бұрын
Custom G-Code with Rust!
27:31
5 ай бұрын
Ruby to Rust - Marching Squares
35:19
Advent of Code 2023 - Day 21
17:13
Advent of Code 2023 - Day 20
19:22
Advent of Code 2023 - Day 19
29:20
Advent of Code 2023 - Day 18
22:56
Advent of Code 2023 - Day 16
23:21
Irish Makers Secret Santa 2023
17:12
Advent of Code 2023 - Day 15
17:08
Advent of Code 2023 - Day 14
36:25
Advent of Code 2023 - Day 13
20:11
Advent of Code 2023 - Day 11
14:29
Advent of Code 2023 - Day 10
27:45
Advent of Code 2023 - Day 9
17:20
7 ай бұрын
Advent of Code 2023 - Day 8
19:39
7 ай бұрын
Advent of Code 2023 - Day 7
26:03
7 ай бұрын
Advent of Code 2023 - Day 6
18:50
7 ай бұрын
Advent of Code 2023 - Day 5
25:40
7 ай бұрын
Advent of Code 2023 - Day 4
18:18
7 ай бұрын
Advent of Code 2023 - Day 3
25:51
7 ай бұрын
Advent of Code 2023 - Day 2
15:39
7 ай бұрын
Пікірлер
@derrickadusei7987
@derrickadusei7987 Күн бұрын
This is an amazing content . i wish there was a quick way to calculate the pid values and tune them quickly since as an engineer you have dead lines to meet
@careyian
@careyian Күн бұрын
Great point, real engineers can build actual models of these things and simulate different PID values, it’s never going to be 100%, there is a trade off of detailed models and the time it takes to build etc. There are also methods for tuning PID controllers. However, it might end up being faster to do it manually. You also have to think about if you are building a product, the base tuning might come from a model and simulation, you only need to build that once, then you can tweak and tune it afterwards.
@JeffBird766
@JeffBird766 3 күн бұрын
Have you ever considered micromouse? I came across the UKMARS yt channel and am now hooked! I'll be building my own soon but thought it might be up your alley as well. I've watched your videos a lot, I like your problem solving style!
@careyian
@careyian 3 күн бұрын
Ahhhh, I’ve seen them, they are super cool, I’d love to make one some day!
@celestinemachuca2339
@celestinemachuca2339 12 күн бұрын
Do a Julia set with rust now and sweep thru the imaginary plane :) it is awesome project to learn.
@careyian
@careyian 12 күн бұрын
Oooooh, nice, I'll add that to my list!!
@ZapOKill
@ZapOKill 13 күн бұрын
if ((alive | population ) == 3){ // set next iteration to alive } this weirdly handles all cases
@careyian
@careyian 13 күн бұрын
Ha! That's so great, love it!
@local.interloper
@local.interloper 13 күн бұрын
Fun fact: For keeping the state of active cells you can use a hash set of touples that represent coordinates. and then use a matcher to progress the game. It's incredibly fast.
@careyian
@careyian 13 күн бұрын
I actually refactored my code since to use the tuples, it's much nicer! The string keys came from my previous experience building larger hash keys with more params while doing advent of code in Ruby. It can be handy to easily print for visually debug them. For this project, the tuple keys are much better.
@user-jt7cy6nv3z
@user-jt7cy6nv3z 13 күн бұрын
This is awesome, I am teaching myself C++ and OpenGL and conway's game of life is my first project. I would love to learn Rust one day. Keep up the great content!
@careyian
@careyian 13 күн бұрын
Hey, thanks a lot! Good luck with your project!
@misterwoody_
@misterwoody_ 13 күн бұрын
Was the rust code removed from the repository as a matter of interest? I only see a ruby version now. Many thanks
@careyian
@careyian 13 күн бұрын
Hey, they are both there, two folders, one called Ruby and one called Rust, should all be there unless I made a mistake let me check
@careyian
@careyian 13 күн бұрын
Ahhhh I made a mistake copying it!!! I’ll fix that now
@careyian
@careyian 13 күн бұрын
Fixed now, thanks for pointing that out, I managed to delete it while reorganising the repo!!
@yigglesmoto
@yigglesmoto 13 күн бұрын
The optimization to only check live / neighboring dead cells is interesting, but depending on the state is short-lived, no? It's never removing entries, so a single glider going across the grid would end up leaving a ton of dead cells with no live neighbors in the HashMap. Is there also a reason you initialize to a default hashmap in main, then immediately reassign? It seems like `seed_grid` should just be the initializer, or take the `grid` as an `&mut` so you don't need to reassign the value
@careyian
@careyian 13 күн бұрын
Oh yeah, there is no need to reassign after the initial, seed_grid can re assign it. As for your first observation, note at the start of the loop, we recreate a new empty grid each time and only then fill it with the next set of live cells and their adjacent dead ones.
@yigglesmoto
@yigglesmoto 13 күн бұрын
@@careyian Ah, I totally forgot about the new_grid! Great optimization. Something about using Strings as keys for the coordinates still bothers me, for some reason. I wonder if a simple struct with two i32s would be more efficient? But this is all still very neat. You can probably use `std::mem::swap` on the two grids instead of cloning when you reassign. I'm imagining a 2nd iteration on this where you could either "move" the view of the grid (i.e. WASD and be able to follow a glider), or use the `print_area` to either have it wrap around or stop storing cells out of bounds
@careyian
@careyian 13 күн бұрын
@@yigglesmoto I actually just did a few tweaks to the code there and published my Ruby example of doing it too. I actually realised I didn't need to clone, I think I had it in while debugging because I had some compiler error at some point, but it wasn't needed anyway. On the string keys, there probably is a better way, it's a pattern I have used tonnes while doing advent of code for creating hashing keys of many different params, so it's just the first thing that occured to me. That said, it works well in Ruby, but isn't as nice in Rust.
@laurenvickers8615
@laurenvickers8615 14 күн бұрын
Do not pass go
@careyian
@careyian 14 күн бұрын
@@laurenvickers8615 that one is next week
@laurenvickers8615
@laurenvickers8615 14 күн бұрын
Not too rusty … heh heh
@laurenvickers8615
@laurenvickers8615 14 күн бұрын
YAYYYYYY A NEW VIDEO
@careyian
@careyian 14 күн бұрын
IKR?!?!
@careyian
@careyian 15 күн бұрын
Lots of fun writing this super simple simulation of Conway's Game of Life! Check out the full video for more!
@laurenvickers8615
@laurenvickers8615 14 күн бұрын
Oh wait…game of life…not monopoly
@careyian
@careyian 15 күн бұрын
I have been crazy busy recently and haven't had as much time as I'd like to work on my projects. I plan to jump back into my recent robotics project soon, but this was a welcome for me to just code up something fun and I hope you guys learn something from it! Edit: Thanks for all the comments folks, between your comments here and some comments on Reddit I have refactored some of the code which you can see in the GitHub link in the description. The main thing I changed was swapping from string keys in the hash to tuple keys for the coords, it's much cleaner this way! The string keys came from my previous experience building larger hash keys with more params while doing advent of code in Ruby. It can be handy to easily print for visually debug them. For this project, the tuple keys are much better. I also added my Ruby solution there too. Thanks for the comments folks!!
@abdoelzohiery2133
@abdoelzohiery2133 22 күн бұрын
That's a great explanation; however, I think we should consider making the PID gains more adaptive to enhance the code's generality and accuracy. Would this improvement be beneficial or will it add unnecessary overhead to the code?
@careyian
@careyian 22 күн бұрын
Hey there, what do you mean by adaptive?
@abdoelzohiery2133
@abdoelzohiery2133 20 күн бұрын
@@careyian I mean if we can make a simple method that changes the gains within the runtime based on the time the system takes to reach its steady state. Therefore we will have a better gains for the next time.
@careyian
@careyian 20 күн бұрын
Yeah, I guess you could do something like that if you wanted to. This is just example code, I have no plans to do anything more with it.
@reshari5368
@reshari5368 23 күн бұрын
The robot turned out to be cool, don't you have a visual connection diagram?
@careyian
@careyian 23 күн бұрын
What is a visual connection diagram?
@reshari5368
@reshari5368 23 күн бұрын
@@careyian this is a drawing with pin markings where the boards will be connected to each other through wires. This makes it easier to navigate in which rem you need to connect the boards
@reshari5368
@reshari5368 23 күн бұрын
@@careyian I just want to erase your robot for training, but I'm a little confused about which pins to insert the wires into.
@careyian
@careyian 23 күн бұрын
Erase it??
@careyian
@careyian 23 күн бұрын
Ahhh you mean a schematic, no, I don’t have one I’m afraid
@laurenvickers8615
@laurenvickers8615 26 күн бұрын
So beautiful
@careyian
@careyian 26 күн бұрын
IKR?!?!
@laurenvickers8615
@laurenvickers8615 26 күн бұрын
Rumour has it, you couldn’t locate your black tape…
@careyian
@careyian 26 күн бұрын
Rumor has it I never had any…
@laurenvickers8615
@laurenvickers8615 26 күн бұрын
Lots of ambient light
@careyian
@careyian 26 күн бұрын
Tooooooo much
@opticonor
@opticonor 27 күн бұрын
Comment for the algo 🤖 This reminds me of a project we did back in college, except it was using Lego/Technic and a light sensor - had to build a robot that would go looking for lit candles and try to extinguish them 🔥 Looking forward to part 2!
@careyian
@careyian 27 күн бұрын
Haha, class! That sounds like a fun project. This was actually inspired by a project I did in college to monitor and control the speed of a spinning disc. Strip of black tape on a white disc, read the pulses from an LDR. Then use a PID controller to match the speed to differing breaking forces on the disc.
@careyian
@careyian 28 күн бұрын
Woop, lots of fun building this! Check out the full video for more!
@careyian
@careyian 28 күн бұрын
Pretty impressed with how well this thing worked. Had no idea if it would, nice to surprise yourself sometimes!
@laurenvickers8615
@laurenvickers8615 Ай бұрын
Brother … ew
@careyian
@careyian Ай бұрын
What’s that brother???
@mietekgpz
@mietekgpz Ай бұрын
PID have three values. "P" ,"I" and "D". It's very confusing when you call all of them "gain". I've watched it three times and still got confused what is what:/
@careyian
@careyian Ай бұрын
Oh well, sorry about that, I thought it was clear enough
@LOLWUT281
@LOLWUT281 Ай бұрын
Why 32k and not the 32.768k(?) one? Internal crystal for most the STM32's I've seen are already tuned for the inferior 32k clocks. And Do you mean to say that on the low speed pins, your original board had the wrong clocks at 16MHz? Finally, with such low volume, just get an active circuit, single clock oscillator. Dealing with caps and impedance tuning on such low volume made in china boards is just annoying at best and a waste of time at worst. Also if you fuck up and put the wrong speed, you can easily just pop off that oscillator and put the right one on. Regardless, doing your own board and messing up like 20 times really is the best way to learn.
@careyian
@careyian Ай бұрын
Ahhh sorry, I’m just rounding it off when I say 32k, just easier to say than the decimals, I also keep forgetting what the decimal points are! Originally I had a 16Mhz resonator connected to the same pins, basically didn’t read the docs properly at all… You are also totally right about the external modules for this, this specific STM32 actually only even supports the HSE via one of those type of modules, so in future I’ll probably go with one of them if I come to need it. However, like you say, this was a great way to learn
@logigen
@logigen Ай бұрын
One thing I’ve had to come to accept is that if it works, don’t touch it
@Perfect-Idiot
@Perfect-Idiot Ай бұрын
I know right, accidentally bend a small peice and it only works half the time lol
@careyian
@careyian Ай бұрын
So damn true!!
@careyian
@careyian Ай бұрын
Well… at least it does work half the time!!
@logigen
@logigen Ай бұрын
A win is a win
@Graham_Wideman
@Graham_Wideman Ай бұрын
LSE apparently means "Low Speed External".... oscillator.
@careyian
@careyian Ай бұрын
Yep, that is correct
@laurenvickers8615
@laurenvickers8615 Ай бұрын
The hanky janky
@careyian
@careyian Ай бұрын
THE hanky jankiest
@careyian
@careyian Ай бұрын
Learning the hard way, nothing like it!! 😂
@laurenvickers8615
@laurenvickers8615 Ай бұрын
Very interesting way to approach this problem…
@dragonalias
@dragonalias Ай бұрын
hey, cool video. saw your post on reddit, and was interested because ive been thinking of getting into embedded programming using rust. do you have an idea of where i could start to learn the basics?
@careyian
@careyian Ай бұрын
Hey, honestly it’s hard to say, without knowing what background you have in either embedded or Rust it’s hard for me to say what you should do. I’d Google tutorials in both Rust and Embedded programming and use your own judgement as to what you should look at next
@laurenvickers8615
@laurenvickers8615 Ай бұрын
I’m working laaaaaate…with my electronics 🎉
@laurenvickers8615
@laurenvickers8615 Ай бұрын
IT LIVES!!!
@andersl.359
@andersl.359 Ай бұрын
neat vid! stumbled on this, and while the video is great, I feel it could be amazing if there was a short and basic intro to what an STM32 even is, and what you plan to use it for Anyhow, great vid! Cheers!
@careyian
@careyian Ай бұрын
Hey, thanks for that, always nice to get feedback on content, glad you like the video, cheers!
@Elect_Ng
@Elect_Ng 2 ай бұрын
howx the encoder measures the tilt angle
@careyian
@careyian 2 ай бұрын
So there is a shaft at the base of the pendulum which runs inside bearings and is fixed to the pendulum. Onto this shaft I have mounted a quadrature encoder. So as the pendulum tilts, the shaft rotates. The encoder can measure the rotation, and so we can then work out the tilt angle.
@Elect_Ng
@Elect_Ng 2 ай бұрын
please help am doing project just like this...
@careyian
@careyian 2 ай бұрын
JLCPCB: 48-Hour Turnaround for 6 Layer PCBs! jlcpcb.com/?from=IanCarey Sign Up to Get $60 New User Coupons
@careyian
@careyian 2 ай бұрын
Had lots of fun with this one and learned loads doing it! Big shout out to JLCPCB for sponsoring this video!
@dhaufjebzjchseis3828
@dhaufjebzjchseis3828 2 ай бұрын
one thing that confuses me is when the actual goes above the set point, won't the proportional and derivative terms become negative , so couldnt there be a case where the output is negative and you try and write a negative voltage to the pin?
@careyian
@careyian 2 ай бұрын
Good spot, yes that can in theory happen here. In practice those negative values will be fighting against the accumulated positive integral error, so they aren’t likely to make the overall output negative. Specifically here a negative value being fed into analogWrite will not behave correctly as it will write the 8bit unsigned value of it directly to the register, which you wouldn’t want. What this implementation is really missing is scaling on the output to ensure that whatever the value that gets spit out, it’s always within a certain range.
@dhaufjebzjchseis3828
@dhaufjebzjchseis3828 2 ай бұрын
one of the most through explanations ive seen, so refreshing to see behind the scenes instead of someone just using a library that makes everything into a black box
@careyian
@careyian 2 ай бұрын
Thanks for your kind words! Glad you liked it!
@laurenvickers8615
@laurenvickers8615 2 ай бұрын
GREAT SUCCESS
@careyian
@careyian 2 ай бұрын
VERY NICE
@hatterfoil
@hatterfoil 2 ай бұрын
Oh, remembered one more nice to do trick. Don't do GND, VIN, VOUT. Do VIN, GND, VOUT. That way if you short out two pins with solder bridge or by corrosion due to moisture, you get input or output short to GND thus putting your lab power supply in CC mode. If you do the first order, you short in to out and burn the load with +12 instead of +5. This is actual issue in LCD cable of some MacBooks. If smallest moisture gets in, it shorts logic voltage to 57V backlight voltage burning CPU.
@careyian
@careyian 2 ай бұрын
Never would have thought about that, good idea!
@hatterfoil
@hatterfoil 2 ай бұрын
One more thing - You want an input and output cap on each LDO and you want to have them as close as possible to your LDOs. The whole idea is to get as low trace and VIA inductance as you can. Lesser trace inductance is achieved by the proximity to pin, the VIA proximity is achieved by using 2 or more in parallel.
@careyian
@careyian 2 ай бұрын
Good tip, I'll add these in V2 of the board!
@hatterfoil
@hatterfoil 2 ай бұрын
Few ideas form experience. 1. You want to add large copper array and about 1mm hole vias around it to cool down the LDOs better. 2. You might want to have LEDs on output rails not input. That way you immediately see if anything is pulling the rail down. 3. You might want to make that front supply SMPS so you can run it form higher voltage with higher power. I like AP63301 for that - super simple, cheap and stable little thing. I use them with WE LQS series inductors to keep on the cheap side while still being industrial quality.
@careyian
@careyian 2 ай бұрын
All good tips, I was thinking of doing the heat dispersing vias in this version as it happens, but I didn't in the end. Might do it for V2, especially if I notice heat as being much of an issue with these guys.
@ArcAiN6
@ArcAiN6 2 ай бұрын
Be gentle with that board. Those little AMS-1117 style LDO's can get quite hot. Also, while the "legitimate" ams-1117's datasheet tout a heafty 1A output, i feel it's misleading, as that should "peak" current. sustaining anything above 500mA and those little buggers get hot, and at 1A, they literally cook themselves. If you need higher current output, you'll want to go with a beefier packaged LDO.
@hatterfoil
@hatterfoil 2 ай бұрын
It's not the output current that makes it hot, it's the power drop = output current times (input voltage minus output voltage). It can easily handle that amp at half a volt drop. You have to look at power dissipation to predict the temperature in each particular case.
@hatterfoil
@hatterfoil 2 ай бұрын
Also, going with beefier LDO is a really bad take in current year. SMPS is so simple to implement nowadays and I see zero reason to put huge hot LDO as front PSU.
@careyian
@careyian 2 ай бұрын
Fair point, I don't plan to use these in any high current applications. So I'm not too worried. A friend of mine gave me some feedback that I could swap to a switched regulator which would be better than the LDO's. I'm gonna roll with these for a while anyway and see how they go.
@hatterfoil
@hatterfoil 2 ай бұрын
@@careyian That's what you say today, but in a short while it's like "wait, let me add this and that".. "what about adding a tft screen" and so on.. and "oh, my 12V powered motors are too weak, let me bump that to full 24V then.." and suddenly your LDO drop is 19V and it's glowing hot :) At least that's how my projects go. So I usually just put the small SMPS down as primary and then run 3.3 from LDO powered by that SMPS. And it has saved me bunch of time in redesigns in my days.
@careyian
@careyian 2 ай бұрын
Yes it worked! Still have to test it under load, but really it's never going to be running much, so I'm counting this as a success!!
@dascandy
@dascandy 2 ай бұрын
PCB layout wise, I'd be tempted to put the three connectors in a row. I'm also surprised to see Vin and the two provided rails on the same connector? Wouldn't you put power in on one side and take the gnd/5v/3.3v on the other side? I'd consider switching the pin headers for JST headers given the risk of reversing the connectors and reverse-powering your targets. I don't understand why you picked a mosfet-and-transistor setup to conduct power? Is that to avoid arcing inside the switch? It looks like it debounces the input and it reduces current through the switch. I think your 100u capacitor doesn't match the footprints I tend to see for them; usually they're the electrolytic can versions and your footprint seems to match a ceramic capacitor. For circuit design I always use Kicad; similar to what you can do in Eagle/Fusion except free, and it has separated circuit design, component footprint selection and PCB layout subprograms. It has a couple tens thousand components by default, which covers nearly all things you'd want to typically use. It has the usual components under their short names - so if you search for R, C or L you get a resistor, capacitor or inductor, but if you prefer the American style symbols you can select R_american and it'll give you the squiggly line resistor and American style capacitor drawings. Those regulators really like it if you put a capacitor on their output. Something like a 10uF and a 100nF combined usually. Not for ripple filtering, but to catch variations in your load.
@careyian
@careyian 2 ай бұрын
Having all pins on both sides is for flexibility, means it can be connected up at the top of bottom, doesn't matter which. The headers can be whatever you want them to be, the board is bare when manufactured except for the surface mount components, the headers are just a placeholder for the pins. A JST with the same bitch will fit just fine. The switch setup is so that the switch doesn't end up conduction very much of the current. I have a V2 of this that I'm going to make where there will be a switched output that will supply source voltage via the switching circuit. So if you want to power a motor or something, this switch will switch it on and off without handling the current itself. I don't know what you mean about the footprint for the cap. I have a 100u surface mount cap on there and it was assembled fine in the factory. I use the free version of Fusion. It also has loads of built in stuff, but for specific parts I like to build up my own library so I'm sure I have the specs correct etc and my supplier can assemble it. I also do other stuff in Fusion so it's nice to keep it all in one place. That's a good shout on the caps. I might add some to a future version.
@laurenvickers8615
@laurenvickers8615 2 ай бұрын
Led
@careyian
@careyian 2 ай бұрын
💡
@LQThangTD
@LQThangTD 2 ай бұрын
Hello, can you tell me the size and mass of the ball you are using in this project, I 3D printed your model and ran it and as a result it did not run correctly with the value I set, I think it's because I used a different ball in this project. Thanks.
@careyian
@careyian 2 ай бұрын
Hi there, the call is a standard sized ping pong or table tennis ball. It should be about 40mm in diameter. The weight is very light, somewhere in the region of about 3 grams.
@LQThangTD
@LQThangTD 2 ай бұрын
​@@careyian Thank you for your help. I have another question: do you use matlab simulink to detect pid parameters or detect pid manually? I tried your code and your 3d model using aruino uno r3 but it doesn't work. Exactly my desired setpoint. Thank you very much
@LQThangTD
@LQThangTD 2 ай бұрын
And why h = ball_postion - 13.5 , where do you get the parameter 13.5 from? I don't understand, please explain
@careyian
@careyian 2 ай бұрын
@@LQThangTDI don’t use Matlab to get the PID gains. I tuned them manually. You will more than likely have to do the same. Part of this project is tuning the weights. I tuned it for my setup with my motors etc. it is not going to be the same for you. Each time this is built it will have to be tuned.
@careyian
@careyian 2 ай бұрын
@@LQThangTDit’s the approximate midpoint of the beam. Since we are measuring from one end, if you subtract half the length of the beam that gives you the offset position as a plus or minus from the centre.
@laurenvickers8615
@laurenvickers8615 2 ай бұрын
Zap zap ⚡️
@careyian
@careyian 2 ай бұрын
Zaaaaaaap ⚡️
@Letter_l
@Letter_l 2 ай бұрын
doing 3rd year mechanical, and wanted to see actual application of such, this video is great.
@careyian
@careyian 2 ай бұрын
Great to hear!
@careyian
@careyian 2 ай бұрын
Oh boy, this has a fun one! Super excited to see how this one turns out when I get it back from the manufacturer!!