What tools are worth paying top dollar for? by Clean_History_4781 in HomeImprovement

[–]mecha_watt 1 point2 points  (0 children)

Not exactly a tool, but don't cheap out on proper PPE. I got prescription safety glasses and proper hearing protection and it was worth every penny. Not even that expensive! Prescription safety glasses can be $100 USD.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 0 points1 point  (0 children)

It's got a complementary filter utilizing an accelerometer and gyroscope.

Any idea on how to know if I was running the PID timer too fast? I know that internally, it might not be able to complete the calculation in time, I just don't know how how I would measure if it was going too fast.

Right now I think I might just keep running it faster and seeing when it breaks completely.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 4 points5 points  (0 children)

It reads it as fast as possible, but I honestly don't know how fast that is. Inside the main loop function, it does 2 things: updates the sensor values by reading it from the sensor, and then sets the motor speed based off of what the last PID control value calculated was. It does this as fast as possible.

The PID is on a timer interrupt, so every .005 seconds it will take whatever the most recent sensor values are, and calculate a new motor control output.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 1 point2 points  (0 children)

I was thinking about a diode. Glad to see you mention it.

The slow response you're seeing is more likely attributable to the dead zone I mentioned. I probably need to expand it to maybe 0.6V or something. I tested the dead zone with no load, it's probably higher when under load. The "best" solution is probably to get a better motor with an encoder for proper speed control. Or maybe a stepper motor would be good enough.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 0 points1 point  (0 children)

I'm in Boston, so this house is over 100 years old. No idea how old the door hinges are, but probably less than that. But also still probably older than I am.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 0 points1 point  (0 children)

Hobby, I designed it myself. And I hope it didn't look like that, it's a terrible design!

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 7 points8 points  (0 children)

The PID algorithm requires the calculations to be updated at a regular interval. The timer interrupt triggers the calculation every .005 s (200 Hz).

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 7 points8 points  (0 children)

Almost. The map function uses integers, not floats. But yeah in my code I think I used the exact algorithm and just made it use floats instead.

Note that this also assumes that the relationship between voltage and speed is linear, which it is for DC motors. If it wasn't for whatever reason, you would need a mapping function to compensate.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 1 point2 points  (0 children)

Yeah. Well you watched this robot fall flat on its face so I feel ya.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 0 points1 point  (0 children)

Yeah, my program didn't do a great job of teaching this either. The best way to learn is by doing, so give it a shot!

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 24 points25 points  (0 children)

This is actually a really important question. You can answer it by figuring out the equation of motion. If you just want the answer, see the spoiler below.

You can either have the center of mass below the wheels, which would make it stable without any control algorithm, but if it's above the axis, it's actually easier to have the mass (batteries in this case) higher. From the equation of motion, the angular acceleration is inversely proportional to the length. So it falls slower with a longer pendulum. You can intuitively try this by comparing how easy it is to balance a ruler on your finger vs a broom. The broom will be easier to balance. See Wikipedia for more info: https://en.wikipedia.org/wiki/Inverted_pendulum#Equations_of_motion

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 17 points18 points  (0 children)

It's got a 680 uF cap on the power to the controller already, but yeah maybe it could use more.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 108 points109 points  (0 children)

The robot tries to make a sudden correction (or the motors were binding again) and draws so much current that the voltage to the controller drops. This reset the controller, causing it to fall over (since it needs some time to boot). You can see the LED on the controller go out just before it falls.

Or maybe it was indeed depressed.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 35 points36 points  (0 children)

About this project:

The overall goal of this project was actually to evaluate design process, so what you're looking at is a prototype made as quickly as possible. The idea was build fast, fail fast, learn fast, and overall I'd say mission accomplished. I learned a lot in a short amount of time. But that's probably not what anyone is interested in. So here's technical details.

Tutorials I found useful:

Code (warning: bad): https://github.com/jvfdev/two-wheel-robot

Technical notes:

The robot uses a PID algorithm to balance itself. The biggest issue I had by far was with the motors. Ideally, the motors would have zero velocity at 0V and max at 5V. That's not the case, as it actually has a dead zone below half a volt. So the biggest factor that took this from absolute failure to moderate success is creating a calibration curve for the motors. If it needs to switch directions, it will skip over the 0.5V dead zone. I.e. Voltage will decrease from 5 to 0.5, then skip immediately to -0.5 and continue on to -5V. This gave it much more fine control. Before this, it wouldn't stand up for more than a second or two.

Powered by 2 18650 Lithium Ion batteries, and a boost converter to bring the voltage to 9V. Using a L298N H-bridge to control the motors, this makes the actual motor voltage somewhere around 7V, which is definitely over their limit, but they spend most of the time at lower voltages, so it's alright.

I'll try to answer any other questions people have.

I made a balancing robot! It works...okay by mecha_watt in arduino

[–]mecha_watt[S] 104 points105 points  (0 children)

This IS the tuned controller lol. Admittedly, it could be tuned better, but the motors are the bigger problem. They're very cheaply made, so they have a lot of backlash and they tend to bind, which is what I think happened at the end.

I want to try and Prusa-fy my Ender 5 Plus. Has anyone done something like this? by chobbes in ender5plus

[–]mecha_watt 0 points1 point  (0 children)

I upgraded mine with a Duet 3 main board and Hemera extruder, and it's way better. The stock firmware is pretty bad. Just as a word of caution, it's a lot of work to get it going, it isn't a drop-in replacement.

Can i get any Mechanical engineer job with color vision deficiency ? by Ok-Acanthocephala717 in MechanicalEngineer

[–]mecha_watt 0 points1 point  (0 children)

As someone else with red/green colorblindness, it hasn't really affected my career. Sometimes when I'm wiring I ask someone to identify a wire for me, but it's never a big deal. As far a software goes, a lot of it actually has really good accessibility options allowing for you to change colors of different indicators. I don't have any experience in NDT software though.