Output voltage ramp up and down for input voltage window - Page 1
Forum section: electronics / projects

author: harnon
author_rank: Regular Contributor
timestamp: May 08, 2019, 06:08:23 am
content: Sorry for the horrible topic title, but I've got a slightly random fun project idea where I want an output that become active if the input is within a given voltage window. In other words, if the input voltage is less than V1, or greater than V2, then the output should be 0V. In between these values the voltage should increase to Vdd up to the midpoint then decrease afterwards. As its a fun project, I'd like to do this without a microcontroller.The idea eventually would be to chain a bunch of these together so that, i.e. it could for instance control a wave of LEDs fading in and out as the input voltage sweeps. I suppose something similar to the battery level indicator video Dave did but with the voltage ramps and probably quite 2-5A currentsI can do the left hand half of the ramp using a single supply opamp and a voltage divider the reference voltage, however I'm not sure how to cut over to a downward ramp the voltage back down to 0 output above Vmid.Is this even possible without a uC? I'd like to try and solve this by myself for The Learning, any hints or things to learn about to get me started?

author: Ian.M
author_rank: Super Contributor
timestamp: May 08, 2019, 09:32:11 am
content: You'll need a whole mess of OPAMPs configured asdifferential amplifiers for level shifting, aprecision full-wave rectifier(but diodes reversed for negative output) to get your triangular ramp up then down, and aprecision half wave rectifierto cut off the skirts of the triangle where they cross 0V. Better bulk buy the matched resistors you'll need, A pack of 100K 0.1% should do nicely. Keywords for Google in bold, search:OPAMP<keyword_string>LTspice solution attached. Download it *AFTER* you've figured it out for yourself!@All: If you want to comment on or improve my solution, out of respect for the O.P's desire to figure it out for them self, please be careful what you say in your post. Full, un-censored comments can be attached instead.Edit: Sim needs a load resistor - see below

author: harnon
author_rank: Regular Contributor
timestamp: May 08, 2019, 10:10:56 am
content: Thanks Ian, sounds like a lot of googling and pondering on the cards for me

author: Ian.M
author_rank: Super Contributor
timestamp: May 08, 2019, 10:17:45 am
content: N.B. The problem is complex enough with split supplies. I wouldn't recommend attempting a single supply version until you fully understand all the OPAMP circuits I suggested Googling, and have built and tested a split supply version.Also, if you want to fade LEDs you'll need an OPAMP V=>I converter stage on the output.

author: lordvader88
author_rank: Frequent Contributor
timestamp: May 08, 2019, 11:14:28 am
content: As for timing when to cross the peak of the triangle, I'm sure some way could use derivatives. But what about timing how long it takes to get 1/2 way, then have some transistor turn on/off and shut down a positive ramp. And at the same time a decreasing ramp gets turned on. Maybe some peak detector triggers a 555 that flips 1 ramp off and 1 ramp on.IDK, I should play around more.A lot of electronics is an awful lot like mechanics and machines. No wonder we love electronics too

author: Ian.M
author_rank: Super Contributor
timestamp: May 08, 2019, 12:44:35 pm
content: That would do nicely if you were always generating a triangle waveform with a fixed period but if you have an arbitrary input signal e.g. a DC level from a pot, you can't do it by timing.

author: harnon
author_rank: Regular Contributor
timestamp: May 08, 2019, 03:52:41 pm
content: Attached is my first proper attempt (without reading any further comments or looking at Ian's Spice file). Its not perfect yet but its quite late so I'm done for the night!I haven't used a FULL BRIDGE RECTIFIER, so I'm guessing my solution is a bit different. I think I could remove one of the inverters and I don't think the on/off levels are quite right, although you probably can't see that in the screenshot. I'm happy as a first attempt.* Simulation done in circuitjs as I find the UI a bit easier for messing about in, although the simulator can be a bit dodgy. The top scope is the input voltage (0-5 triangle wave) and the bottom is the output - peak is around 5V with the 10k feedback there.

author: harnon
author_rank: Regular Contributor
timestamp: May 08, 2019, 03:56:11 pm
content: Also I think I will probably rejig a little bit to see if I can get rid of Vmid and instead just use V1 and V2.

author: Ian.M
author_rank: Super Contributor
timestamp: May 08, 2019, 06:53:21 pm
content: Hmm. I thought mine was complicated with four OPAMPs and seven resistors in the signal path + an extra OPAMP and four more resistors to subtract one bias from the other to make the peak and center offset control voltages independent.Also, you've got a fair bit of distortion going on, visible as rounding of the peak and flaring of the skirt of the output waveform. I haven't done any analysis, but I'd bet that would be due to the non-ideal diodes, as you haven't used any precision rectifiers.

author: harnon
author_rank: Regular Contributor
timestamp: May 08, 2019, 09:30:29 pm
content: Yes the non linearity is from the diodes. It's more obvious in some of the test point traces. Ok now I have component counts... I will try again tonight!PS The whole thing is overly complicated... but that's becoming a theme for my projectsAt least I'm entertained!

author: Ian.M
author_rank: Super Contributor
timestamp: May 09, 2019, 04:34:05 am
content: Quote from: harnon on May 08, 2019, 09:30:29 pmMe too!I found a bug in my first solution: I forgot the load resistor after the ideal diode at the output. Add 100K to ground to fix it.Here's another version, with non-railing precision rectifiers to reduce the glitches due to slew rate limiting at each transition at higher input frequencies. It ended up needing a *LOT* more parts with a whole extra OPAMP. I also have parameterised the resistors and diodes to make the use of realistic component models easier, and swapped the generic OPAMPs for LT1001, an older LT one. Unfortunately even with the non-railing rectifiers, it still gets pretty crappy above 10KHz. Its also a lot slower to simulate using LT1001 OPAMPs and BAT54 diodes rather than the original UniversalOpamp2 and generic 'D' diodes.

author: harnon
author_rank: Regular Contributor
timestamp: May 10, 2019, 12:20:57 am
content: Ok I had another go at it last night and I think I'm a bit closer - I still haven't looked at your spice template. The V1/V2 values aren't quite right but I think I'm on the right track now