Author Topic: Output voltage ramp up and down for input voltage window  (Read 2309 times)

0 Members and 1 Guest are viewing this topic.

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Output voltage ramp up and down for input voltage window
« on: May 08, 2019, 06:08:23 am »
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 currents :D

I 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?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Output voltage ramp up and down for input voltage window
« Reply #1 on: May 08, 2019, 09:32:11 am »
You'll need a whole mess of OPAMPs configured as differential amplifiers for level shifting, a precision full-wave rectifier (but diodes reversed for negative output) to get your triangular ramp up then down, and a precision half wave rectifier to 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  :palm:
« Last Edit: May 09, 2019, 04:35:34 am by Ian.M »
 

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Re: Output voltage ramp up and down for input voltage window
« Reply #2 on: May 08, 2019, 10:10:56 am »
Thanks Ian, sounds like a lot of googling and pondering on the cards for me :)
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Output voltage ramp up and down for input voltage window
« Reply #3 on: May 08, 2019, 10:17:45 am »
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.
« Last Edit: May 08, 2019, 10:20:25 am by Ian.M »
 

Offline lordvader88

  • Frequent Contributor
  • **
  • !
  • Posts: 935
  • Country: ca
Re: Output voltage ramp up and down for input voltage window
« Reply #4 on: May 08, 2019, 11:14:28 am »
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
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Output voltage ramp up and down for input voltage window
« Reply #5 on: May 08, 2019, 12:44:35 pm »
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.
 

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Re: Output voltage ramp up and down for input voltage window
« Reply #6 on: May 08, 2019, 03:52:41 pm »
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.
 

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Re: Output voltage ramp up and down for input voltage window
« Reply #7 on: May 08, 2019, 03:56:11 pm »
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.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Output voltage ramp up and down for input voltage window
« Reply #8 on: May 08, 2019, 06:53:21 pm »
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.
 

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Re: Output voltage ramp up and down for input voltage window
« Reply #9 on: May 08, 2019, 09:30:29 pm »
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 projects :) At least I'm entertained!
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13216
Re: Output voltage ramp up and down for input voltage window
« Reply #10 on: May 09, 2019, 04:34:05 am »
PS The whole thing is overly complicated... but that's becoming a theme for my projects :) At least I'm entertained!
Me  too!  :-DD

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.
 

Offline harnonTopic starter

  • Regular Contributor
  • *
  • Posts: 215
  • Country: au
  • Is this thing on?
    • My Personal Website
Re: Output voltage ramp up and down for input voltage window
« Reply #11 on: May 10, 2019, 12:20:57 am »
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 :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf