1
\$\begingroup\$

I am very new to electronics field, So excuse me I sound silly in any part of my question. I have a sensor which is giving me a digital singal with the help of 2 wires (+ve and ground). The signal I am getting from my sensor and a comprator ciruit after the sensor:

enter image description here I am trying to build a DAC which takes this digital signal and converts it to analog signal. I was looking into different ways of doing this.

My first try was using a R/2R ladder circuit. enter image description here

But I am not sure how do I give binary inputs. I am looking at many other possibilities. But I am not getting a clear idea of how to give give input to my DAC. I'd be grateful if anyone points me a proper way to do this.

Edit: enter image description here

\$\endgroup\$
  • 2
    \$\begingroup\$ "have a sensor which is giving me a digital singal with the help of 2 wires" - which sensor? \$\endgroup\$ – Bruce Abbott Dec 21 '17 at 12:43
  • 2
    \$\begingroup\$ You cannot convert from a pulse train/PWM to an analog signal with a DAC. A PWM is digital, in a way, but it isn't binary. Rather, such conversions would have to be done with some manner of low-pass filter. \$\endgroup\$ – Lundin Dec 21 '17 at 12:47
  • 4
    \$\begingroup\$ I think you are asking the wrong question. What exactly are your trying to achieve? What do you want to measure and what do you want to do with the measured result. \$\endgroup\$ – Oldfart Dec 21 '17 at 12:52
  • 3
    \$\begingroup\$ I have a comparator circuit infront it As Lundlin writes: that's not digital then! What you have is PWM. You really need to be very precise about what you have because the devil is in the details. You assumed that you need a DAC but that appears to not be the case. Unfortunately, as you've noticed, electronics is not that easy, you cannot expect to "quickly" solve your problem by designing something without the proper knowledge. \$\endgroup\$ – Bimpelrekkie Dec 21 '17 at 12:53
  • 2
    \$\begingroup\$ Could you please explain what you trying to achieve? You are asking for help on what you think is the solution, but maybe your solution is not the right way. What do you want to do with the sensor output? Why are you using a comparator on the sensor output? \$\endgroup\$ – JRE Dec 21 '17 at 13:06
2
\$\begingroup\$
  1. First and foremost, try to use the signal digitally. The usual strategy is to convert analog measurements to digital early in the process, then do everything digitally from there. Digital values don't degrade over time, drift, or pick up stray noise. They can also be way more accurate than analog signals just by using sufficient numbers of bits.

    Sometimes, after all the digital processing, you still need to control a analog real-world system. However, even that is often not done by converting the final digital value to a voltage, then using that to drive the system. Nowadays, we try to drive the system with pulses, which are easy to produce directly from the digital values with PWM generators built into just about every microcontroller. Even things that appear analog, like motors and solenoids, can be controlled by pulses. In fact, driving motors and solenoids with pulses is more efficient.

  2. If you really really need to convert a digital value to a analog voltage, use a D/A chip. Others have already done the engineering and put it all in a nice and convenient package for you.

    Consider accuracy. With 1% resistors, you won't even get 7 bits. You can 12 bit and more D/A chips for very little money. There is no way you will be able to compete with those by building your own from discrete parts.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ While I won't disagree with this, it seems like it's not answering his question. \$\endgroup\$ – kjgregory Dec 21 '17 at 15:14
  • \$\begingroup\$ @kjg: It doesn't answer the question of how to build a DAC, but note that all the OP actually asked was "points me a proper way to do this". My pointer is "go buy a DAC instead of trying to make one". \$\endgroup\$ – Olin Lathrop Dec 21 '17 at 15:34
  • \$\begingroup\$ Fair enough. I think he needs to provide more info about his sensor in order for us to help him. I think what he probably should have asked is "how do I read out this sensor". My guess is the DAC is just a way for him to see the output on an oscilloscope. \$\endgroup\$ – kjgregory Dec 21 '17 at 15:38
  • \$\begingroup\$ Piling on: What - Is - The - Sensor ? ? ? \$\endgroup\$ – AnalogKid Dec 21 '17 at 20:18
  • \$\begingroup\$ @Anal: Why are you asking me? I know nothing more than what the OP wrote. \$\endgroup\$ – Olin Lathrop Dec 21 '17 at 21:26
2
\$\begingroup\$

We need a lot more information about the sensor or the sensor circuit or the sensor signal before there can be a detailed answer. But ...

A digital signal on only two wires cannot be converted to an analog signal with a D/A converter unless the digital signal actually is a serial data word of some bit length. If it is, there are some D/A converter chips that are designed for certain specific serial data formats. Or, you can grow one from scratch with a serial-to-parallel converter followed by a parallel input D/A. Both of these are difficult designs for a novice.

If it is a simple square wave, then the next question is how simple? How does the signal vary when whatever the (secret) sensor is sensing changes?

If the frequency changes but the duty cycle (percentage of time spent high and low) stays approximately constant, that is an FM signal and can be converted to an analog signal with any one of several types of FM demodulators or frequency-to-voltage converter circuits.

If the frequency stays relatively constant but the duty cycle changes, that is called pulse-width modulation, or PWM. This can be converted to an analog signal with a lowpass filter.

There are other possibilities, but those are two of the most common. Overall, what you want to do certainly can be done. The complexity involved depends on the true nature of the sensor and its signal.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for your reply. Sorry for late reply. I have edited my post with the circuit diagram of my sensor and its output. I am getting a PWM signal as the output of this entire circuit. I need to convert it to analog signal (5v)l for another purpose. This thread has already pointed me towards some direction. I Think I will be using simple low-pass filter (RLC) to convert it to analog. But if you have any other inputs, I would ve glad to hear \$\endgroup\$ – Aashu10 Dec 22 '17 at 11:36
0
\$\begingroup\$

Step 1, replace the 2903 comparator with an opamp. This will give you a symmetrical output impedance for both high and low output voltages instead of the high-impedance high and low-impedance low of an open collector output stage. A consistent source impedance is an important part of any filter design. Note that this change will affect the hysteresis trip points by approx. 1%.

Step 2 is settling on the tradeoffs of the filter. A big one is between complexity and performance. A single pole filter output will have significant ripple at the PWM freq unless the corner freq iw several octaves away from the PWM freq. But this makes the circuit slower to respond to changes in the input signal. A 2- or 3-pole active filter takes one opamp and will have better performance. There is an equal-component version that is pretty easy to implement. What are the signal freq, max and min pulse widths?

2nd order calculator:

http://www.calculatoredge.com/electronics/equal%20comp%20low%20pass.htm

Detailed design page. Scroll down for 3rd order example:

http://www.electronics-tutorials.ws/filter/filter_8.html

| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.