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

op amp freaking out in differentiator #82

Open
dragoncoder047 opened this issue Apr 4, 2024 · 4 comments
Open

op amp freaking out in differentiator #82

dragoncoder047 opened this issue Apr 4, 2024 · 4 comments

Comments

@dragoncoder047
Copy link

image

Standard differentiator circuit, just different values than the example. Scope is of the op amp output. When I toggle the logic input, I expect a sharp pulse in the opposite direction from the op amp and then silence. Instead it freaks out.

Interesting to note that when I bring up the example (5k resistor, 2µ cap) and change the triangle wave to square wave, it does not freak out like this. When I change it to 1k and pulse wave, it freaks out when it's 5V and ok when it's 0V

@pfalstad
Copy link
Owner

pfalstad commented Apr 5, 2024

Hmm, that's weird. If you make the timestep smaller (like 3u) it fixes it. Or adjust the values.

Do you have "trapezoidal approximation" unchecked? You could check that, and it fixes it for me. That's weird, because usually trapezoidal is less stable.

@dragoncoder047
Copy link
Author

I left everything besides the component values the default. So trapezoidal was checked on the capacitor.

If it has anything to do with it, here's my chrome://version:

122.0.6261.89 (Official Build) Built on Raspbian , running on Raspbian 11 (32-bit)

Perhaps it's 32-bit vs. 64-bit floating point error.

@pfalstad
Copy link
Owner

pfalstad commented Apr 5, 2024

I thought javascript floating point always used double precision. Otherwise lots of examples would not work, I think.

@dragoncoder047
Copy link
Author

As a reference, I made the same circuit, set time step to 3µs, and it still freaked out.

Other machine chrome://version:

114.0.5735.119 (Official Build) (64-bit) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants