this post was submitted on 18 Jul 2023
19 points (100.0% liked)

Arduino

537 readers
1 users here now

This is an UNOFFICIAL Arduino community.

Everyone who uses Arduino board or their clones or associated boards and/or the Arduino IDE is welcome here. If it involves Arduino hardware or software it's welcome here. If it connects to Arduino hardware it's welcome here. If you're building your own boards that you use with an Arduino it's welcome here. There will be no Arduino elitist bullshit in this community.

You may also be interested in:

AVR

RULES:

  1. It's always a floating input.

  2. All Lemmy.ca rules apply here.

  3. Everyone (see rule 98) is welcome.

  4. If you’ve seen a question 100 times answer it the 101st time or ignore it. Even better, write a complete, detailed answer and suggest that the mod(s) pin it to the community.

[Did you actually think there were 98 rules?]

  1. If you present something as fact and are asked to provide proof or a source provide proof or a source. Proof must be from a reliable source. If you fail to provide proof or a source your post or comment may be removed.

  2. Don’t be a dick. Yes, this is a catch-all rule.

  3. The mod(s) have the final say.

founded 1 year ago
MODERATORS
 

I got some bread boards and a kit full of resistors, caps, LEDs, etc. On Amazon, and 3 esp32s (dfRobot boards) from digikey. Very exciting! I already blew an LED (current limiting resistor? Never heard of her!)

top 12 comments
sorted by: hot top controversial new old
[–] dragontamer@lemmy.world 3 points 1 year ago (1 children)

Kits are to be used quite differently than other electronics. I think kits are very helpful for precise calibration of analog components. Manual trimming as some people would say.

So lets say you want a 1000 Ohm +/- 0.1% resistor. Well, you don't just pull out brown-black-red (10 * 10^2) resistor out of the kit, because your kit is only 5%, maybe 1% accurate. So what do you do? Well to start, +/- 0.1% means hitting 999 Ohms to 1001 Ohms. Is this even possible?

You pull out the 1000 Ohm resistor as a base, your "starting guess". Lets say its 958.5 Ohms, as measured by your multimeter (which commonly have 3.5digit accuracy). You then add a 47-ohm resistor, except the 47-ohm resistor is off as well because I'm assuming a 5% kit. Lets say its 49.1 Ohms. In series, the two are now 1007.6 Ohms.

You now add a 132578 Ohm resistor in parallel, but E12 means the best you can do is a 120,000 Ohm resistor. When you put them in parallel, you get... 999.21 Ohms.

Done and done. You've achieved 0.1% accuracy by "trimming" your resistor and measuring the results with your Ohmmeter.


Since you have a large variety of resistors available, you always know you can perform this trimming (series to increase resistance, parallel to trim-down). A large variety of analog circuits require highly-accurate resistors, and even if you only have an E12 kit +/- 5%, you know that within 3ish resistors of trimming will always result in 0.1% accuracy.

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago* (last edited 1 year ago) (1 children)

Yep, I already ran into this stepping down the 5.3v to ~3v.

I knew that they'd likely be a little rough, but they were cheap and available ($80), so i decided that I could make whatever showed up at my door work. I'm just happy that I haven't found any DOA components yet

Thanks for the detailed advice on manual trimming, that's great to have as a reference!

Kit also includes trim pots!

[–] dragontamer@lemmy.world 2 points 1 year ago* (last edited 1 year ago) (1 children)

Yep, I already ran into this stepping down the 5.3v to ~3v.

Wait....

You're using a voltage regulator... right? Not resistors for that? Resistors is definitely not how you change voltage in practice and is a common beginner mistake.

I think in some very simple situations, you might be able to make due with resistors for level-shifting, but its a minority of cases where that's legitimate.

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago (1 children)

Yes I have vrms. I used the resistor because I was super excited to see if the stuff worked, so I haven't read the docs for them yet.

My current set up is an old Motorola phone charger soldered (poorly, but I don't leave it plugged in) onto DuPont connectors which provides about 5.3v to the power bus on the bread board. I don't plan on subjecting my esp32s to this set up until I have a little more practice with power delivery. While the esp32s are cheap, there not that cheap.

[–] dragontamer@lemmy.world 3 points 1 year ago (1 children)

Just in case you didn't know...

The reason why VRMs are used is because the effective-resistance of real-life circuits change. The ESP32 sometimes draws 150mA when the radio is on (aka: sometimes its resistance is 20 Ohms), other times the ESP32 draws 20mA when idle or even less when asleep. (ie: its resistance changed to 150 Ohms).

VRMs are a device that will output 3V even if the output is 20Ohms or 150Ohms, or even 10,000 Ohms. VRMs aren't perfect, you'll see a ripple change of maybe 0.01V as the "resistance" of a circuit changes.

Transistors (and computers) are magical devices that automatically change their resistances to do many things. So you need something like the 7915 voltage-regulator to counter-act this and change its own resistance up-and-down to keep the voltage consistent. Because transistors / computers only work if they stay within a particular voltage level (ESP32 prefers 3-ish volts).

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago (1 children)

So, what's the special sauce in a vrm that allows it to compensate like that? How does it "know" what the target voltage is? Do you need a reference voltage? I still haven't read the docs

[–] dragontamer@lemmy.world 2 points 1 year ago* (last edited 1 year ago) (1 children)

So, what’s the special sauce in a vrm that allows it to compensate like that?

The full answer requires roughly a 3rd year's course in Electrical Engineering. I'll try to summarize, but I'll inevitably miss a concept or two.

  1. Transistors are the fundamental answer. Various VRMs are made from different transistors, but the core concept is that they have 3 pins: input, control, and output. The voltage on "control" controls the voltage on "output" (which is drawn from "input"). Fully understanding transistors is... difficult. So lets not talk about transistors, at least not at the beginner level.

  2. Instead of discussing raw transistors, there's a combination of transistors called an 'OpAmp', which is easier to understand. This has 5 pins: positive-voltage-source, negative-voltage-source (usually tied to ground), PlusInput, MinusInput, and output. Ideally, the OpAmp creates "output = Infinity * (PlusInput - MinusInput)". Yes, you heard me, times infinity. In practice, it is "only" times 10-million or maybe times 100-million, but just pretend its times infinity, its so much easier to understand.

  3. If you create a negative-feedback loop (that is, connect "output" to "MinusInput"), then the infinities cancel out and now PlusInput controls the voltage. Seriously, check the math. Say "A" is the gain (which is infinity), then...

  • output = A * (PlusInput - MinusInput)

Except MinusInput is output, we connected them together. So replace it with output.

  • output = A * (Plus - output)

Shuffle stuff around...

  • output = A * Plus - A * Output

  • A * Output - output = A * Plus.

  • (A - 1) * output = A * Plus

  • (A - 1) / A * output = Plus

If "A is infinity", then infinity-1 is infinity. (lol, yeah, math works like that. Infinity is a funny number), so this means that...

  • (infinity-1) / (infinity) * output = plus
  • (infinity) / (infinity) * output = plus
  • output = plus

Now no matter what the output tries to be (which is changing because of changing resistances), the OpAmp will magically "hold" the voltage from plus and react in time.

Yes, this works. Yes, it sounds stupid, the math works and I've made many creations that do this kind of analysis. In practice, since the gain is "only" 10-million, you get: 9,999,999 / 10,000,000 * output = plus, but that's small enough that we can ignore the error.

  1. To provide a "constant" voltage into the PlusInput, we use a Zener Diode. Zener Diodes work by "breaking" on purpose. As it turns out, you can manufacture diodes to "breakdown" consistently at a particular voltage. You can buy ZenerDiodes that break down at specific voltages, which means that the Zener Diode's output will always be the same voltage.

Zener Diode + OpAmp is probably the simplest conceptual design for a voltage regulator. Real life VRMs include more features, like overcurrent protection and other detection. But you can imagine how additional OpAmps with just the right magic / wiring can provide these features.

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago (1 children)

Ah ha (great band)! Zener diodes! That was the only component in my kit I was unfamiliar with (aside from the various ICs), very cool tech.

Another question:I have 5v and 9v vrms, and obviously I need 3.3v; given that a vrm guarantees a fixed voltage regardless of current draw, can I use a downstream resistor to step the voltage down to 3.3v? Or is that also gonna cause problems?

[–] dragontamer@lemmy.world 2 points 1 year ago* (last edited 1 year ago) (1 children)

I covered this a bit earlier. Lemme repeat a bit:

The reason why VRMs are used is because the effective-resistance of real-life circuits change. The ESP32 sometimes draws 150mA when the radio is on (aka: sometimes its resistance is 20 Ohms), other times the ESP32 draws 20mA when idle or even less when asleep. (ie: its resistance changed to 150 Ohms).

Which resistor can you use to turn a 5V VRM into a 3.3V VRM when the ESP32 is sometimes 20 Ohms, sometimes 150 Ohms? Answer: you can't. Not with a fixed resistor. You need a device that reacts and changes its resistance to match constantly. Aka: a VRM.

Only voltage-regulators can solve the voltage regulator problem. You can build a voltage regulator out of transistors, op-amps, or other such devices. (You can build one out of a uC like Arduino even though its really jank... but ADCs exist for a reason and capacitors + inductors do funny things at funny speeds that an Arduino can control).


Now, there are VRMs that are controlled by simple voltage dividers / aka simple resistors can control a VRM. But really, if you want 3.3V you should get a 3.3V voltage-regulator.

Alternatively, you get an "adjustable" voltage regulator (really: its a voltage-regulator with a very low set voltage, like 0.6V or something). You then use a voltage-divider (aka: 2x resistors) to control the feedback pin. Its a bit complex but you gain a "user-configurable" voltage by just changing resistors later. For example, the LM317 is nominally a 1.25V voltage regulator, but with the following circuit:

EDIT: It probably should be noted that the typical LM317 has 2V of dropout. That means 5V can turn into 3V, but not 3.5V (aka: only 1.5V of dropout). To have less dropout, you need a low-dropout voltage regulator.

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago

Oh, right. Brainfart. Thank you.

Man. These have all been very detail answers. thank you so much for your time and knowledge. Very helpful. I think I'll try to build a vrm (for fun, not for my esp32) with this info.

[–] afox@lemmy.ca 1 points 1 year ago (1 children)

Lmao every surface of every room of my house. Pray for me. That my wife doesn't take the kids and dip.

[–] MyFeetOwnMySoul@lemmy.ca 1 points 1 year ago

Lol. My bench is usually a lot tidier than this, but I have a couple projects on the go, and no where to put them.

load more comments
view more: next ›