pozzugno
Newbie level 3
Hi all,
I explain my problem. Please give me some ideas.
I have a signal from a sensor. The signal has pulses each 20ms. Each pulse has a duration of about 100us.
I want to design a very fast circuit that compare the maximum value of the signal with a digitally controlled threshold. When only one pulse is higher than the threshold, the circuit must switch off (in 1us maximum) the source of the signal (I need a simple open collector to control the source of the signal).
Of course I can use a comparator with the threshold generated by a DAC on minus input and the signal on the plus of the signal.
Unfortunately there's another point. That circuit should work like a trigger, so it must remain in the OFF state after a high pulse event, even if the input signal goes to zero. It's a matter of the microcontroller to unblock the circuit.
So I use a diode between output and positive input of the comparator so, when the comparator triggers (its output is low), the threshold at the positive input is 0.7V. In order to have a greater voltage even if Vs is zero, I connect +5V (power supply) with signal and threshold from DAC by two resistors 8k2/33k. When Vs is zero (after comparator switch off the source of the signal), the threshold at positive input is 0.7V and threshold at negative input is 1V, so the comparator remains off.
Furthermore, the maximum value of the pules from the sensor must be converted in digital by an ADC, after conditioning. As I don't know the input signal amplitude and I want to digitally adjust it to 4V (when it is at a nominal value), I designed a circuit with a peak detector and DAC. The DAC is used as a digital trimmer: the signal after the peak detector is the reference for the DAC.
Considering all the conditioning circuit, I have
Vadc = Vs * (1 + 2k/1024)
where Vadc is the voltage to ADC input, Vs is the signal from the sensor, k is the code programmed into the DAC and 1024 is the DAC resolution.
In this way, changing k I can have a gain in the range 1..3, and it is good for me.
ADC and DAC have the same resolution and reference (except the DAC used as digital trimmer, with the signal after peak detector as the reference).
So if the ADC measure x points, I can convert it in watt (the signal is power). If I want to set a threshold at Pt (in Watt), I calculate the points I read if there is really Pf (say xt) and programm the DAC threshold with xt/(1+2k/1024).
I mounted a sample board and I have a problem.
If I program "trimmer DAC" with k=0, I don't have exactly Vadc=Vs. I don't know if the problem is the tolerance of the resistors, the opamp precision or DAC precision. So if I read 4V by ADC, really Vs is about 4.2V and it is an error.
Moreover, if I set 4.2V threshold (with the second DAC), the comparator switches when I read only 4V (because in this condition Vs is really 4.2V).
One solution to this problem is to compare the signal after the peak detector and "trimmer DAC" with the threshold set by the second DAC. But in this case I loose the speed of the comparator...
Excuse me for the long post, but the problem is very complicated. Let me know what you think.
I explain my problem. Please give me some ideas.
I have a signal from a sensor. The signal has pulses each 20ms. Each pulse has a duration of about 100us.
I want to design a very fast circuit that compare the maximum value of the signal with a digitally controlled threshold. When only one pulse is higher than the threshold, the circuit must switch off (in 1us maximum) the source of the signal (I need a simple open collector to control the source of the signal).
Of course I can use a comparator with the threshold generated by a DAC on minus input and the signal on the plus of the signal.
Unfortunately there's another point. That circuit should work like a trigger, so it must remain in the OFF state after a high pulse event, even if the input signal goes to zero. It's a matter of the microcontroller to unblock the circuit.
So I use a diode between output and positive input of the comparator so, when the comparator triggers (its output is low), the threshold at the positive input is 0.7V. In order to have a greater voltage even if Vs is zero, I connect +5V (power supply) with signal and threshold from DAC by two resistors 8k2/33k. When Vs is zero (after comparator switch off the source of the signal), the threshold at positive input is 0.7V and threshold at negative input is 1V, so the comparator remains off.
Furthermore, the maximum value of the pules from the sensor must be converted in digital by an ADC, after conditioning. As I don't know the input signal amplitude and I want to digitally adjust it to 4V (when it is at a nominal value), I designed a circuit with a peak detector and DAC. The DAC is used as a digital trimmer: the signal after the peak detector is the reference for the DAC.
Considering all the conditioning circuit, I have
Vadc = Vs * (1 + 2k/1024)
where Vadc is the voltage to ADC input, Vs is the signal from the sensor, k is the code programmed into the DAC and 1024 is the DAC resolution.
In this way, changing k I can have a gain in the range 1..3, and it is good for me.
ADC and DAC have the same resolution and reference (except the DAC used as digital trimmer, with the signal after peak detector as the reference).
So if the ADC measure x points, I can convert it in watt (the signal is power). If I want to set a threshold at Pt (in Watt), I calculate the points I read if there is really Pf (say xt) and programm the DAC threshold with xt/(1+2k/1024).
I mounted a sample board and I have a problem.
If I program "trimmer DAC" with k=0, I don't have exactly Vadc=Vs. I don't know if the problem is the tolerance of the resistors, the opamp precision or DAC precision. So if I read 4V by ADC, really Vs is about 4.2V and it is an error.
Moreover, if I set 4.2V threshold (with the second DAC), the comparator switches when I read only 4V (because in this condition Vs is really 4.2V).
One solution to this problem is to compare the signal after the peak detector and "trimmer DAC" with the threshold set by the second DAC. But in this case I loose the speed of the comparator...
Excuse me for the long post, but the problem is very complicated. Let me know what you think.