Shop OBEX P1 Docs P2 Docs Learn Events
Simple DAC — Parallax Forums

Simple DAC

HughHugh Posts: 362
edited 2010-01-15 22:22 in Propeller 1
If I want to do some simple DAC, are there any reasons why the Prop couldn't be used with a resistor ladder network?

Thanks

Hugh

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.
«1

Comments

  • BradCBradC Posts: 2,601
    edited 2010-01-11 14:01
    None at all. It will work perfectly well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
  • HughHugh Posts: 362
    edited 2010-01-11 14:15
    Excellent. Thanks for the response.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • SamMishalSamMishal Posts: 468
    edited 2010-01-11 15:15
    Hugh said...
    If I want to do some simple DAC, are there any reasons why the Prop couldn't be used with a resistor ladder network?
    You can do that....BUT....there is a much more effective method which is also and a LOT EASIER and needs much less parts
    and offers·a MUCH higher resolution......also utilizes 1 I/O pin only.
    ·
    This is the method of using a Counter in the Duty Mode.
    ·
    It REALLY IS SIMPLE don't be afraid of the fact that it is a counter.
    ·
    All you have to do is set the counter to the right mode with the desired pin and then set the FrqA/B register to the right value.
    ·
    So to get a DAC using Counter A and using·a pin defined as a constant called DAC_Pin·for instance you would do
    ·
    · ctra[noparse][[/noparse]30..26] := %00110···················· ' Set ctra to DUTY mode
    · ctra[noparse][[/noparse]5..0] := DAC_Pin·······················' Set ctra's APIN
    · dira[noparse][[/noparse]DAC_Pin]~~···························· ' Set Pin to output
    ·
    Then you need to set the Duty mode....you can change this at any time by changing the value in the FrqA register
    ·
    There is a bit of a simple calculation that is needed to calculate the value to put in the FrqA
    ·
    First you need to decide on the resolution 8 bit or 16 bit or whatever....lets put that in a constant called Resolution
    then also you set the duty as a variable call it Duty which varies from 0 to maximum resolution so if you have 16 bits
    then that is 0 to 65536 .... 65535 if you want to be strict and then you will never get 100%
    ·
    So now to set the DAC output you say
    · Scale := |< (32-Resolution)··· 'this needs to be done only once this equivalent to Scale := (2^32) / (2^Resolution)
    · FrqA := Duty * Scale·········· 'change this every time you need to change the DAC output
    ·
    So now the DAC output will be 3.3V * Duty/Resolution .....so if Duty is 2350 and Resolution is 16 i.e. 65536 then
    the DAC output would be 0.1183 V
    ·
    If you want 8 bits resolution and you set the Duty to 200 then the DAC outputs 3.3*200/256 = 2.578 V
    ·
    So you can see all you need is to decide on the resolution and the Duty level you want in terms of 0 to 2^Resolution
    to get a range from 0% to 100% of 3.3V.
    ·
    You can read about this in the Propeller Education Kit Manual pages 127 to 132
    ·
    I really do think that this is EASY and much more efficient and accurate a DAC than the resistor ladder.
    ·

    P.S. you may want to filter the output with and RC low pass filter...again this is described in the manual.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com


    Post Edited (SamMishal) : 1/11/2010 3:21:21 PM GMT
  • heaterheater Posts: 3,370
    edited 2010-01-11 15:25
    What is the maximum frequency of DAC output one can get out of the counter in duty mode method? I.E. if one were synthesizing sine waves.

    I suspect the resistor ladder DAC can go higher, not sure.

    What frequency do you want out Hugh?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • SamMishalSamMishal Posts: 468
    edited 2010-01-11 16:09
    heater said...
    What is the maximum frequency of DAC output one can get out of the counter in duty mode method? I.E. if one were synthesizing sine waves.

    I suspect the resistor ladder DAC can go higher, not sure.

    What frequency do you want out Hugh?

    The Duty method is not like the PWM method. The DAC will function at 80MHz, but of course the rate of change of the
    Duty variable is what determines the dV/dt· thus the maximum frequency you can get is determined by the rate with which
    you can change the variable Duty and perform the calculation FrqA := Duty*Scale either in SPIN or PASM.
    ·
    I don't see how the resistor Ladder can be faster since you have to change all the necessary pins and also STILL
    do the calculations that determine what pins have to be set high.
    ·
    I am not sure if it would be any higher than the Duty mode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • heaterheater Posts: 3,370
    edited 2010-01-11 16:31
    Let's say you want to generate a simple sine wave using an 8 bit resistor ladder DAC.
    All you need is a table of 8 bit sine values. Say 256 of them.
    Now you just pick up a sine value from the table and write it to the pins. BANG there goes one sample out.
    Now loop round picking up sequential table elements and outputting them to the pins, looping back to the beginning of the table when you hit the end. BANG you have a sine wave output.
    Now you want a higher frequency. Easy, instead of incrementing the index into the table at each sample period you add on some bigger number, 2, 3, 4... Ensuring you wrap around the table when you get to the end, which is easy, just AND the index with some mask. BINGO you have a higher frequency sine wave.

    This is called "Direct Digital Synthesis". Here is a nice example of doing it with an AVR up to about 300KHz www.myplace.nu/avr/minidds/index.htm

    No idea if the Prop can do it faster in PASM or if the duty method would be quicker/better.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • HughHugh Posts: 362
    edited 2010-01-11 17:30
    That is fantastic - thanks!

    I was looking to produce an output at lesss than 1Hz, so I will give this a try.

    Cheers
    Hugh

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • Toby SeckshundToby Seckshund Posts: 2,027
    edited 2010-01-11 17:40
    OOPS cross threaded. Forgive me, I've got "man flu"

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Style and grace : Nil point

    Post Edited (Toby Seckshund) : 1/11/2010 5:46:43 PM GMT
  • LeonLeon Posts: 7,620
    edited 2010-01-11 17:44
    Heater:

    That's not really a DDS. A true DDS uses a 16-bit or 32-bit phase accumulator, and can give fractional Hz resolution:

    webspace.webring.com/people/jl/leon_heller/minidds.html

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • SamMishalSamMishal Posts: 468
    edited 2010-01-11 20:22
    heater said...No idea if the Prop can do it faster in PASM or if the duty method would be quicker/better.
    You can do the VERY EXACT same thing....but your 256 entries in the sin table would be
    a precalculated value for Duty*Scale instead of just Duty.
    ·
    So then you would do the exact same thing of looking up the right value and instead of setting
    the 8 I/O pins you would set FrqA.
    ·
    This way you have saved yourself 7 pins and also all the resistors. But also you can have a much better
    resolution using 16 bits not just 8 and also you can use the Propeller's built in sine tables...but this might
    be a bit slower....since you have to convert to the right quadrant.
    ·
    But the method you described will actually not work quite right. What you need is to Increment a Sampling
    rate counter and depending on the frequency required this register is accumulated at the right time which will
    then give the Theta for the sin wave which is then used to look up in the table.
    ·
    There is a very good description of all this in the Hydra manual.
    ·
    ·
    But basically setting the FrqA or setting the OutA[noparse][[/noparse]n..m] is the same as long as you have the right value
    to be set to the FrqA.....but the Duty mode saves LOTS of pins and components. And since it is a counter
    then it does not even need a separate Cog.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • heaterheater Posts: 3,370
    edited 2010-01-11 20:46
    Leon and Sam: Yes you are right. I did not want to complicate my explanation but I did point in the right direction.

    However the question remains in my mind - Is it better to do this with a ladder or the counters? Up to what frequency?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • heaterheater Posts: 3,370
    edited 2010-01-11 20:49
    Hugh, at less than 1Hz looks for sure like using the counters is a better way to go. If only because it is using only one pin and your output does not depend on the tolerance of any external resistors.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Bill HenningBill Henning Posts: 6,445
    edited 2010-01-11 21:05
    Best guess:

    Using the counters, a full "cycle" would be (timer osc frequency)/(2^bits_of_resolution)

    This means 500Khz updates are possible at 8 bits using a 128MHz oscillator

    50khz updates at 10 bits

    <2khz updates at 16 bits

    So take the numbers above, and divide by 10 if you are using 10 samples to represent a sine wave.

    This means a maximum sine wave frequency of 50KHz at 8 bits (using 10 sample approximation of a sine wave)

    I could however be misunderstanding this duty cycle mode...

    As for parallel mode with resistors, with a single cog with pre-loaded sin table(without using video circuitry or multiple cogs):

    20Mhz / 256 samples = 78,125 "waves" per second, with a nice 256 byte sample.

    loop:
    mov outa, #sample1
    mov outa, #sample2
    ...
    mov outa, #sample256
    jmp #loop

    Not very practical code, but it would work.

    5MHz / 256 samples (waveform table in hub memory) = 17Khz
    5MHz / 128 samples (waveform table in hub memory) = 34Khz <--- sweet spot I think

    Summary:

    Parallel is faster, reproduces waveforms with more samples, but takes more pins and is not as precise.

    One pin takes fewer pins, can get you more bits of resolution, but you cannot reproduce higher frequency waves with any real "waveform" precision.

    Your mileage may vary.

    For myself, I tend to prefer the one pin approach for low frequency / high precision D/A, and parallel R2R for high frequency work.

    Note there is another approach - use a serial codec, LOTS of 16 and 24 bit dual stereo ones out there, cheap...
    heater said...
    Leon and Sam: Yes you are right. I did not want to complicate my explanation but I did point in the right direction.

    However the question remains in my mind - Is it better to do this with a ladder or the counters? Up to what frequency?
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
    Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller

    Post Edited (Bill Henning) : 1/11/2010 9:13:19 PM GMT
  • BradCBradC Posts: 2,601
    edited 2010-01-12 08:57
    The R2R DAC may have less resolution than the DUTY based 1 pin DAC, but it will be cleaner.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
  • Alex41Alex41 Posts: 112
    edited 2010-01-12 15:33
    Since the propeller will only output 3.3 volts on a pin, what if I wanted to do a DAC in the range of 0-5 volts?

    Would I have the Prop pin run a transistor that would switch 5 volts? Then have the RC on the output of the transistor?

    I'm going through the Prop Education Kit now, hope to be up to the above section in a day or two.

    Thanks

    Alex
  • SamMishalSamMishal Posts: 468
    edited 2010-01-12 17:29
    Alex,

    Yes that would work NICELY......

    HOWEVER....a better solution is to use an OPAMP set up as an AMPLIFIER
    which then can give you any voltage level you desire and would also be a better
    current source as well as you may not even need the RC circuit if the OpAmp
    is also set up as a LOW PASS filter too.

    OpAmps can provide Amplification as well as Filtering as well as Current sourcing
    and they would not be much more trouble to set up than a Transistor with an RC
    low pass filter circuit.....I think they are a better alternative

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • Alex41Alex41 Posts: 112
    edited 2010-01-13 02:35
    Samuel,

    I've been trying to run a DAC with the SX-28. That thread is here,

    http://forums.parallax.com/forums/default.aspx?f=7&m=411203

    With that I did use an Op-Amp to amplify the voltage from the DAC chip. I think I got that part down, but maybe a low pass filter would help. How do you set up the low pass filter? Where can I read up on this?

    Thanks,
    Alex
  • SamMishalSamMishal Posts: 468
    edited 2010-01-13 03:13
    Hi Alex,

    The two pictures below are two designs for· LPF Inverting Amp and None Inverting Amp.

    Both have a gain of 10 and are 2nd order and have been designed for a 30KHz cutoff.

    They are the output of the program that is also attached below.

    The program does A LOT MORE than just design Analogue filters but one of its functions is that.
    There is a button that is called "Analogue Filters Design"....press that and have fun.

    I made the program AGES ago and it was for my own use and therefore does not have much
    help....but all you need is to use the Analogue filters design process.

    ·

    I hope that helps

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    676 x 405 - 141K
    674 x 403 - 143K
  • Alex41Alex41 Posts: 112
    edited 2010-01-13 14:30
    Samuel,

    Thats a great program! Of course·I only understand a small part of it, but your examples are a great help to get me started. I'll do some more research on OpAmps. My electronics experience is still at the Forrest Mimms Radio Shack book level.

    Thanks for your help,

    Alex
  • SamMishalSamMishal Posts: 468
    edited 2010-01-13 16:37
    Alex41 said...Thanks for your help,
    You are welcome.... here is a simpler circuit...but it is only first order .... I don't have the formulas for calculating
    the Gain and the cut off frequency off the top of my head.... I will look it up in my books when I go home...

    Of course...remember that these are schematics and that the actual real circuits may require more work.
    Also one of the resistors should really be a rheostat to allow for adjusting the gain due to component tolerances.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    504 x 583 - 72K
  • SamMishalSamMishal Posts: 468
    edited 2010-01-13 20:49
    SamMishal said...
    ·I will look it up in my books when I go home...
    Gain = -(R2 / R1)
    ·
    Cutoff Freq = 1 / (2π R2C2)


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • Alex41Alex41 Posts: 112
    edited 2010-01-14 18:27
    Samuel,

    I've been reading up on Op Amps on various sites that I can find. I understand the concept and inverting vs. non-inverting.

    My main point of confusion is talking about frequency. Is this the rate at which the Op Amp updates/calculates the output? If that is true then what is "cutoff freq"?

    I want the prop to make an output freq in the range of 0-5volts as cleanly as realistically possible. The output doesn't need to be able to change very fast (relative to audio signals anyway) maybe from 0 to 5 volts in 1/10th of a sec. I just got to the section on counters in the "Prop Ed Kit Lab" and finished the PWM section. Of course thats far from fully understanding it, so I'll try to apply what I've learned to what I need to do.

    Thanks,

    Alex
  • Alex41Alex41 Posts: 112
    edited 2010-01-15 00:13
    OK, I did some more research. I looked at the datasheet for the LM741. It shows a typical Bandwidth of 1.5Mhz.

    So the typical signal coming into the Op Amp needs to be updated at 1.5 Mhz for it to work correctly?

    I'll be making a fairly steady voltage on the input to the Op Amp that would probably change slowly, will that still work? I understand these seem to be designed for faster signals. A slower, more steady signal is OK?

    Thanks,

    Alex
  • heaterheater Posts: 3,370
    edited 2010-01-15 04:11
    No, no, no, Alex.

    The op amp does not require you to update the signal at 1.5MHz. "Bandwidth" is the frequency at which the opamps output has dropped by half. It's dropped because the thing just won't work faster than that. There are other op amps that will work up to much higher frequencies.

    You are wanting a DC or very slow signal. The LM741 is OK for that.

    Do consider that you may well need both positive and negative power supplies at high enough voltages to allow for your maximum output swing. You can find schematics for single power supply amplifiers with op amps though.

    Also be aware that as you need work at zero hertz you will need a DC coupled circuit. No capacitors carrying the input in or the output out.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • SamMishalSamMishal Posts: 468
    edited 2010-01-15 11:15
    Alex,

    In order to answer your question you need to be familiar with a few concepts. Here is a brief primer.
    ·
    There are TWO separate things we are doing when we design A Low-Pass 2nd order Active filter:
    1-···· Filtering
    2-···· Amplification (normally using an OpAmp…but can be transistors…see later).
    ·
    Signals

    A SIGNAL is a VOLTAGE that changes over time in a certain manner. The PUREST signals are SIN/COS waves. Where the Voltage changes over time in a SINUSOIDAL manner. These are called PURE HARMONICS. A Cos wave is really just a Sin wave that is SHIFTED (time wise) by +/-90˚.
    ·
    Sin/Cos waves have a FREQUENCY and an AMPLITUDE. Freq is the rate at which the voltage level swings from the Maximum to the minimum level and the amplitude is the range between the maximum and minimum (Peak to Peak Voltage).
    ·
    ALL signals that are NOT SIN/COS waves can be thought of as the SUM of an infinite series of SIN and COS waves with varying HARMONICS of certain AMPLITUDES. Harmonics are Sin/Cos waves of frequencies that are multiples of each other. So if you have a Sin wave of frequency 1000 Hz then 2000 Hz and 3000 Hz are the next harmonics (musicians have a different meaning and they use octaves etc)
    ·
    The above fact has been proven a while ago (1750s) by a French mathematician/engineer called Fourier…thus the Fourier Series/Transform. When we talk about a Fourier Analysis (Analog or Digital and Fast or Normal) we are talking about a MATHEMATICAL method of figuring out the AMPLITUDES and FREQUENCIES of these Sin/Cos waves that make up the signal…..ie the Harmonics of the signal.
    ·
    A sin/cos wave is called a PURE HARMONIC and is just ONE FREQUENCY. However all other signals (e.g. Square, Saw-tooth, Triangle or Human Vocal signal) are made up of many harmonics.
    ·
    Putting an Input signal through an Electronics Circuit and getting an Output signal that has been manipulated in some manner is called Signal Processing
    ·
    The electronics circuit may be a pure analogue circuit, or it may be a digital one that uses an ADC and then a microprocessor and then a DAC. Thus the terms Analogue Signal Processing (ASP) and Digital Signal Processing (DSP). ADCs and DACs are actually analogue circuits so really there is no such thing as a pure digital signal processor.
    ·
    There are many ways we can Process a signal. The two things that concern us here are to AMPLIFY it and to FILTER it.
    ·
    The reason we usually need to filter the output of something like a PWM or a DAC is because SQUARE WAVES have numerous harmonics that are above what we desire in for instance a Sound Generator. Most digital systems (e.g. Propeller) simulate an Analog system using On/Off output (i.e square waves). Thus we usually filter the harmonics that are above a certain frequency to maintain a better fidelity of the final sound output. Thus we use a Low Pass filter (ie cut off any frequencies above a certain level usually 30-40 Khz).
    ·
    Another example is when we use a microcontroller to generate a Sine wave. If we just use the microcontroller output with the PWM scheme to generate a sin wave then we will get many more sine waves than just the one we want. Thus if we use a Band Pass filter that removes all but the frequency we want then we will get a pure sine wave.
    ·
    Filters

    Signal FILTERING has to do with filtering the harmonics of a signal. There are 4 kinds of filters (as far as frequency response):
    1-···· Low Pass….. removes all harmonics above a certain CUT OFF frequency
    2-···· High Pass…..removes all harmonics below a certain CUT OFF frequency
    3-···· Band Pass…..removes all harmonics that are above or below a range of frequencies (Band width).
    4-···· Notch ….removes all harmonics that are within a band width.
    ·
    AMPLIFYING a signal has to do with increasing the Peak to Peak Voltage levels (Vpp). We can do this amplification using:
    1-···· Transistors.
    2-···· Operational Amplifiers (OpAmp) which are really nothing but a combination of transistors resistors and capacitors.
    ·
    There are two classes of filters:
    -········ Passive filters….these use only resistors, capacitors and sometimes inductors.
    -········ Active filters….these are passive filters that also add a transistor or Opamp to the circuit to achieve Amplification.
    ·
    Another categorization of filters is the ORDER of the filtering circuit. This has to do with the way the resistors/capacitors/inductors are combined so as to achieve the filtering style. Generally the higher the order of a filter the better it is at filtering. However, the higher the order the harder it is to design the filter to avoid side-effects. Some side effects for example are oscillation and stability.
    ·
    There are many techniques used to ANALYZE dynamic systems such as filters. These include Mathematical tools such as Laplace Transforms (another French scientist 1810), Bode Plots (American-Dutch 1930), Zero-Pole plots and many others.
    ·
    ·
    For an IDEAL FILTER when we talk about a Cutoff Frequency (fc), we are talking about the frequency at which the amplitude of the signal will be ATTENUATED to Zero (i.e. filtered). For a Low-Pass filter then any frequency above fc will be also filtered. For a High-pass filter then any frequency below fc will be filtered. For a Band-pass filter then any frequency below the Lower fc and above the Upper fc will be filtered. For a Band-Reject (Notch) filter then any frequency above the Lower fc and below the Upper fc will be filtered.
    ·
    HOWEVER, no filter is an ideal filter, thus there is no vertical cut off. Usually the voltage level starts to drop and slopes off getting lower and lower. The higher the order of the filter the steeper the slope. Thus we usually take the fc to be where the power of the signal has dropped by half [noparse][[/noparse]10Log(0.5) = -3 dB].

    Passive filters will cause the input signal to ALWAYS lose power (i.e. amplitude). This is because the components will dissipate some of that power in heat. This is why we then Amplify the output from the passive filter using an OpAmp (or we could do it with a Transistor). This then becomes an Active Filter.
    ·
    In an active filter we are concerned with the following characteristics
    -········ Gain….that is the ratio of the output voltage level to the input voltage level…this is the amount of amplification we achieve.
    -········ Cutoff frequency ….as explained above.
    -········ Stability … ie the filter does not oscillate or cascade at any frequency.
    -········ The rate of drop off (ie slope of voltage drop) outside the cutoff.
    -········ There are other things but they are not easy to explain without reference to a Bode plot and understanding of Pole-Zero and Transfer Functions….all these are too mathematical to explain here….but they are of secondary concerns.
    ·
    We can use a pure passive filter design and then amplify it and this is done in some designs and works quite fine. However, when we use an OpAmp we normally have to set it up with some Feed Back circuitry (we do this to limit and control the gain). So the normal practice is to use the Feed Back circuitry to also achieve filtering at the same time as amplification. This is easily done when you consider the Transfer Function of the feedback circuitry. But I am not go into this here either.
    ·
    OpAmps
    ·
    OpAmps are made up of capacitors and resistors with transistors and diodes etc. Thus the circuit which constitutes the OpAmp·functionality is in itself not ideal either.
    ·
    An IDEAL OpAmp will have the following characteristics:
    -········ Infinite INPUT resistance
    -········ Zero output resistance
    -········ Zero input voltage gives 0 output voltage
    -········ Infinite Common Mode Rejection Ratio
    -········ Infinite· Slew Rate.
    ·
    I am not going to explain these terms…However, suffice it to say that the above characteristics of· non-ideal OpAmp depend on the FREQUENCY of the input signal.
    ·
    That is the higher the frequency of the INPUT the less ideal the OpAmp becomes and thus the above characteristics become further away from ideal and thus affecting the characteristics of the overall Active Filter Circuit and changing its design characteristics.
    ·
    So when you read the data sheet of an OpAm like the LM741 and you read that it has a bandwidth of 1.5 MHz that is talking about the frequency at which the OpAm starts to lose its close to ideal characteristics….nothing to do with the filter cutoff frequency as described earlier.
    ·
    Also the 1.5 MHz value is usually quoted for the opamp without any feedback circuitry. When you use it to amplify in a practical circuit then the 1.5 MHz will become less depending on the Gain…the higher the gain of the amplifier circuit the lower the bandwidth of the OpAmp becomes. That is the higher the gain the lower the frequency at which the opam will start behaving badly.
    ·
    The bandwidth of the Opamp limits the MAXIMUM frequency at which the opamp can be used. But the Filter Cutoff Frequency is what controls what frequencies are Filtered/Passed through the circuit.
    ·
    So for example using the LM741 with a gain of 10 you will be limited to a maximum frequency with which you can use it of around 100 KHz. With a gain of 40 you are limited to 10 KHz.
    ·
    This means that if you use the LM741 to design a Low Pass Filter with a gain of 10 then you can have a cutoff frequency of say 50 KHz and the op amp will still be quite functional. But if you raise the gain to 40 then you will not be able to design a filter with cutoff frequency of 50 KHz since the opamp will stop functioning correctly above 10 KHz.
    ·
    Summary
    ·
    Active filters use an Opamp with feed back circuitry that will achieve GAIN (amplification) as well as Cutoff Frequency (filtering).
    ·
    You design the components to achieve the Gain and Cutoff frequency and other characteristics of the overall active filter.
    ·
    You must know the characteristics and limitation of the Opamp you use so as to not exceed its bandwidth. You must·ensure·that the filter frequency and gain keep the opam within its functioning range. Different opamps have different characteristics and some have higher bandwidths than others
    ·
    I hope this lengthy primer has not confused you even further.
    ·
    ·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com


    Post Edited (SamMishal) : 1/15/2010 11:36:12 AM GMT
  • Alex41Alex41 Posts: 112
    edited 2010-01-15 15:21
    Samuel,

    Thanks a lot for taking the time to post that comprehensive info. It doesn't confuse me - quite the opposite, it helps me to understand the datasheets and basic terms so I can do more research and learn more about how the Op Amp and filters work.

    Alex
  • SamMishalSamMishal Posts: 468
    edited 2010-01-15 20:04
    Alex41 said...
    Thanks a lot for taking the time to post that comprehensive info. It doesn't confuse me - quite the opposite, it helps me to understand the datasheets and basic terms so I can do more research and learn more about how the Op Amp and filters work.
    You are welcome and I am glad you found it useful....It makes me feel good that my explanation is not too complicated....the subject is a·complex one and it is too mathematical and thus is hard to explain without all the math and complicated terms etc.
    ·
    Here is a list of books that I have in my library regarding OpAmps and Filtering etc. I will list in the order of Simplest to most complicated. I am not sure which ones are even still in print....I am so old that even the books in my library are obsolete. cry.gif·
    ·
    -·· Electronic Circuit Guidebook Volume 3 Op Amps by Joseph J. Carr ... Prompt Publication
    This is a simple and a practical book with many circuits.
    -·· Op Amps - Design Application, And Troubleshooting by David L. Terrell ... Butterworth-Heinemenn Publication
    This is my second favorite and is very practical and is a great reference for circuits and is not too complicated electronically or mathematically.
    -·· Op-Amps And Linear Integrated Circuits by Ramakant A. Gayakwad...Prentice Hall
    This book is electronically complicated ....but extremely good for learning about how OpAmps work on the inside and outside and is very good for learning about the mathematics of designing OpAmps.
    -·· Transform Analysis and Electronic Networks with Applications by Joseph Kulathinal... McMillan Publishing
    This one is complicated mathematically but is EXTREMELY good for design and circuitry. It is a great book for learning about the Mathematics of designing Filters and other circuits and is my favorite.
    ·
    ···

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
  • LeonLeon Posts: 7,620
    edited 2010-01-15 20:31
    The LM741 is a very old device, much better op amps are available.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
  • Alex41Alex41 Posts: 112
    edited 2010-01-15 21:13
    I used the LM741 as an example because it is what Forrest Mims has as an example in his "Op Amp IC Circuits" booklet that I have been studying.

    Any suggestions on a better replacement? I have a couple of LM358's, but I hear they are best for audio signals.

    I'd like the Prop to create an output voltage in the 0-5 volt range. It would be a voltage to interface with vehicle ECU sensors. The change would be relatively slow - Imagine how fast your foot presses on the accelerator. No fast response like an audio signal.

    Alex
  • SamMishalSamMishal Posts: 468
    edited 2010-01-15 22:22
    Alex41 said...
    I used the LM741 as an example because it is what Forrest Mims has as an example in his "Op Amp IC Circuits" booklet that I have been studying.

    Any suggestions on a better replacement? I have a couple of LM358's, but I hear they are best for audio signals.

    I'd like the Prop to create an output voltage in the 0-5 volt range. It would be a voltage to interface with vehicle ECU sensors. The change would be relatively slow - Imagine how fast your foot presses on the accelerator. No fast response like an audio signal.

    Alex
    Alex,
    ·
    If you were doing Audio filtering then you would need something better than LM741 and the LM358 would be better.
    ·
    But.....for what you are trying to do...an LM471 is adequate AND also the LM358 is good too.
    ·
    The reason is (as I explained above) that you are not going to be operating to anywhere close to the limitations of the opamp (either one).
    ·
    Thus you can SAFELY design the Low Pass filter to filter out the HIGH HARMONICS due to the fact that the DAC is putting out SQUARE WAVES which as I explained above are made up of many harmonics and since we do not want these harmonics to cause NOISE in the final output we then LOW-PASS filter the output.
    ·
    We also AMPLIFY the output to make the voltage levels higher.
    ·
    We also can benefit from the HIGHER CURRENT DRAW of the op amp compared to the current that can drawn from the pins of the propeller.
    ·
    Additionally since we know that the overall SIGNAL we want to generate has a low frequency as you say a few Hertz then you then can
    1-···· Design the Op Amp so as to give you the GAIN you need
    2-···· Design the Cutoff Frequency to be say 100 Hz
    3-···· Check to see does a 100 Hz at your gain level violate the OpAmps limits....no since the LM741 is capable of outputting close to 10 KHz at a Gain of 40 then 100 Hz is way inside tolerances.
    ·
    So again do not be confused by the frequency of the filter and the limits of the opamp.
    ·
    When they sat that the LM358 is better for Audio frequencies they mean that is good for frequencies UP TO and including the Audio frequencies....so lower frequencies will also be just fine.
    ·
    The LM741 will also be good for audio frequencies if you do NOT design it for a high gain...i.e. if you keep the gain less than 10 then the LM741 is just fine for audio frequencies too.
    ·
    When they say the LM358 is better for audio they mean that you can have more gain at higher frequencies.
    ·
    Thus the LM741 is limited to a gain less than 10 at the audio range while the LM358 can have higher gain (I don't know what...I do not have the data sheet here)...but say 30.
    ·
    BUT.....both will be JUST FINE for low frequencies and at higher gain.
    ·
    Other things that affect the quality for things like audio are the Slew·Rate·and the other characteristics I mentioned earlier and the LM358·has better characteristics at the higher frequencies than the LM741.....but again for your application this is not a consideration since you do not have an audio range of frequencies.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Samuel

    www.RobotBASIC.com
    ·
Sign In or Register to comment.