Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resistor divider simulation #203

Open
urish opened this issue Oct 9, 2021 · 13 comments
Open

Resistor divider simulation #203

urish opened this issue Oct 9, 2021 · 13 comments
Labels
enhancement New feature or request open for vote Vote at https://wokwi.com/features

Comments

@urish
Copy link
Contributor

urish commented Oct 9, 2021

Resistor dividers are useful for connecting multiple buttons to a single analog input pin, as described here. This is particularly useful for MCUs with limited number of IO pins, such as the ATtiny85.

Currently, Wokwi includes a very basic analog simulation: You can connect a single part (e.g. a potentiometer or an analog temperature sensor) to one or more analog input pins. However, if you add any resistors to your analog circuit, the simulator will ignore them.

Let's simulate them!

@urish urish added enhancement New feature or request open for vote Vote at https://wokwi.com/features labels Oct 9, 2021
@MykolaKyrylenko
Copy link

Great idea. I agree.
I am not great on GiHub, but is there a formal way to vote?

@urish
Copy link
Contributor Author

urish commented Oct 10, 2021

Thank you! The way the vote is on the features page, using VotePowers. You can vote for any feature as many times as you want. I'm still working on a more detailed FAQ that explains how this works, but here is a quick explainer.

@JCalvi
Copy link

JCalvi commented Jul 13, 2022

This would be great.

In the interim would it be possible to make the potentiometer have hot keys for values so we can simulate the same thing?
At the moment Home = 0, End = 1023. It would be great to add other keys and mappings for that device, eg 1 = 100, 2 = 200 etc so we can simulate buttons on a voltage divider by just connecting the potentiometer and pressing one of the hot keys?

@urish
Copy link
Contributor Author

urish commented Jul 20, 2022

In the interim would it be possible to make the potentiometer have hot keys for values so we can simulate the same thing?

Sounds like a good suggestion. There's also page-up/page-down that jump up/down, but not to a specific point. If anyone is interested in hacking on this, you can add a new keyboard event listener here, and then check if the key is 1, 2, 3, etc. and modify the value accordingly.

@urish
Copy link
Contributor Author

urish commented Aug 12, 2022

While waiting for this, there's some workaround: you can achieve a similar functionality by implementing a custom chip (see #301 for details). Here's one example showing how to use a custom chip to simulate multiple analog buttons connected to a single analog input:

https://wokwi.com/projects/339700374803841619

@JCalvi
Copy link

JCalvi commented Dec 12, 2022

The custom chip works well BTW. Thanks for the suggestion.

@kubark42
Copy link

kubark42 commented Mar 3, 2023

Oddball suggestion, but instead of implementing further simulation in the backend, maybe borrow the simulator from https://github.com/SEVA77/circuitjs1?

P.S. This is an awesome project. I'm so glad I found it.

@urish
Copy link
Contributor Author

urish commented Aug 1, 2023

Thanks for the suggestion @kubark42!

The funny thing about "circuitjs1" is that it's actually implemented in Java and compiled to JavaScript.

In any case, we already have a solution for the analog simulation part of this feature. The main challenge is how to integrate it into the existing simulation framework while keeping the performance high and not breaking existing projects which rely on the current behavior of resistors.

Right now, this feature is #8 in the requested feature list, let's see how long until it makes it to the top :-)

@martinius96
Copy link

2 years later, still not implemented

@urish
Copy link
Contributor Author

urish commented Sep 18, 2023

1.5 months later, and now it's number 6 on the list

@kubark42
Copy link

Prioritization should happen for important things and urgent things. It isn't a great optic when it takes 2 years to do something as simple as a resistor divider. Maybe it's a heck of a lot of work on the backend, and that's why it isn't happening. But if prioritization comes down only to votes, then low-hanging fruit never gets prioritized. Typos and documentation errors will endure effectively indefinitely if only the most highly voted features get implemented.

Looking at the prio list, some things are jaw-droppingly difficult, such as an offline simulator. Le'ts hope that resistor dividers are easy and can find their way into the queue before the devs tackle offline support and its almost infinite number of computer configurations.

@urish
Copy link
Contributor Author

urish commented Sep 19, 2023

I'm wondering - how much work time do you estimate the resistor divider would take?

@martinius96
Copy link

Nothing against you, but this functionality of voltage dividers is already in the worst simulator TinkerCAD...
That does not have other important features for which I switched to Wokwi.

Dont know how simulation in Wokwi works, if it is not like "circuit" simulation, but more cpu only simulation with peripherals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request open for vote Vote at https://wokwi.com/features
Projects
None yet
Development

No branches or pull requests

5 participants