Gradually ramping from one voltage to another? Op amps?

Discussion in 'The Projects Forum' started by autorelease, Feb 17, 2009.

  1. autorelease

    Thread Starter Active Member

    Jan 26, 2009
    39
    0
    I'm using an AVR microcontroller and a 10-bit quad DAC to draw lines on an oscilloscope in XY mode. I'm using two DAC channels, one for X and one for Y. To draw a line, the microcontroller steps from the starting point to the ending point using Bresenham's algorithm, gradually increasing/decreasing the output voltages in discrete steps.

    However, for long lines, Bresenham's algorithm is slow. If I use the full 10-bit precision of the DAC, 1,024 points will be plotted to draw a horizontal line that spans the full width of the screen. Since it takes about 2.5 microseconds to plot a point (checked with a digital scope), it will take almost 3 milliseconds to draw the line, which is too long. If I limit coordinates to 8 bits, the lines look pixelated, which is obviously not the effect I'm trying to achieve on an analog scope. :p

    I've tried adding capacitors on the outputs, they just make the lines blurry.

    Since the DAC has four channels, I can output both starting and ending X and Y voltages if necessary. Maybe I could build a circuit like this (apologies for crude diagram) to :
    Code ( (Unknown Language)):
    1.                    Trigger
    2.                       |
    3.                      _|_
    4. Start X voltage ----|   |
    5.                     | ? |---- Output X voltage
    6. End X voltage ------|___|
    where a pulse on the trigger line causes the output to ramp from the start voltage to the end voltage. I'm not sure how to build such a circuit or what it would be called. Op amps come to mind (maybe a unity-gain differential amp fed into an integrator?) but it's been a while since I've used them. Any ideas?
     
  2. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
  3. autorelease

    Thread Starter Active Member

    Jan 26, 2009
    39
    0
    Here's a circuit I drafted, I attached a schematic. Haven't built it yet, any feedback would be appreciated!

    It uses a lot of op-amps: all four in an LM324 and two comparators in an LM336. In my application, Vstart and Vend will be between 0 and about 2.4 volts, and the op amps will be powered by +5V and -5V supplies.

    First, the difference (Vend - Vstart) is computed, to determine the velocity. Then it is integrated (with resistor R and capacitor C controlling the rate) and added to Vstart. (This requires a summing op-amp and an unity-gain inverter.)

    Two comparators are used. The first compares Vout with Vend. The output of the second comparator is high if Vout > Vend and low if Vout < Vend.

    To determine if Vout has exceeded Vend in the proper direction, the second comparator is needed to determine the. direction of travel. It compares (Vend - Vstart) with 0V. The output of this comparator is low if Vout is increasing and high if it is decreasing.

    The outputs of the comparators are XOR'd together. If the ramp is positive and Vout > Vend, or if the ramp is negative and Vout < Vend, the DONE line goes high, flipping an analog switch and grounding the integrator's inverting input. This halts the ramp.

    To execute a ramp, first the START line is set high, discharging the capacitor. This resets the integrator's accumulated output to 0 and prevents it from accumulating anything from the inverting input. (the integrator is now just a voltage follower). Next, the appropriate voltages are put on the Vstart and Vend lines. Since the output from the integrator should be 0, Vout jumps to Vstart. Finally, the START line is set low, opening the switch and starting the ramp.

    As I said before, I just designed this off the top of my head and haven't built it yet, so I don't know if it'll actually do what I say. Anything else I should take into consideration, or modifications I should make? Advice would be great!
     
  4. beenthere

    Retired Moderator

    Apr 20, 2004
    15,815
    282
    Looks like it will work, as long as the slewing is relatively slow. LM324's are ancient devices, and there are modern op amps that can replace them with the ability to operate at higher frequencies. If you have upper frequency problems, look at an LT1113.

    Do you have a simulator? Or a breadboard? Nothing like some experimentation before you nail it down.
     
  5. autorelease

    Thread Starter Active Member

    Jan 26, 2009
    39
    0
    I've got a breadboard, just need to finish getting the parts.

    As for the slew rate, how slow is "relatively" slow? The slew rate of an LM324 is 0.5V/μs. I'd like the ramp to last about 50 to 100 microseconds. The maximum difference between Vstart and Vend will be ±2.4V. So in the application (assuming 100μs ramp duration), the slew rate will never need to be higher than 0.024V/μs. Am I covered?
     
  6. autorelease

    Thread Starter Active Member

    Jan 26, 2009
    39
    0
    With a couple of modifications, my circuit works! I can post an updated schematic soon.

    I used a 5.6KΩ resistor and 10nF capacitor on the integrator, for a ramp that takes roughly 50 to 85 microseconds.

    The slew rates of the LM324 and LM339 really suck though. I need to replace them. I can get TL074's and LM319's at a local store, so I'll probably use those.
     
  7. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    On LM324-D, I'd change the 1k resistors to at least 2.2k; 10k should work just fine.

    The LM339 comparators have open-collector outputs. I suggest you connect the outputs directly to the Zener diodes, removing the 1k resistors, then adding pull-up resistors to Vcc; 250 to 333 Ohms per volt is the suggested target which will result in 3mA to 4mA sink current in the LM339 output transistor when it is conducting.
     
Loading...