I have a sensor that outputs a value not higher than 8,19mA +/- 8%, and down to 0.01V. I use a pull-down resistor with a value of 330ohm to get a voltage U=R*I<3,4V (less than 3,4V).
I want to connect this output to the non-inverting input on the analog comparator integrated in the ATmega128RFA1. I want to use a voltage of 0.5V on the inverting input on the comparator.
Regarding this, I have two questions:
- When I measure the voltage at the output of the sensor (with no signal on the sensor) without connecting it to the STK600, I get as expected 0,01V. I should then expect that the comparator outputs 0. The problem is that when I connects it to the AIN0-pin and measure the voltage, I actually have 0,7V, which is higher than 0,5V and I get "1" on the comparator output. When I increase the inverting voltage to 0,8V, I get "0" output.
If I measure the voltage on the AIN0-pin with nothing connected to it, I measure a voltage of 0,9V. All this is without pull-up resistor enabeled. If I enable the pull-up, I measure 3,4V on the AIN0-pin.
The solution I made for that, is to use an external op-amp as a buffer-circuit. I connect the output of the sensor to the non-inverting input of the external op-amp. The inverting input of the external op-amp is connected to the output of the op-amp, and the output of the op-amp is also connected to the non-inverting input of the built-in analog comparator. This is working perfectly, but I would like to know why I has to do it this way, and if there are a better solution.
- At this site at the bottom, you can read that I should use a security-resistor at the input to avoid current above 1mA. Is this necessary when I already has calibrated the pull-down resistor of 330ohm described in the introduction? And is it necessary when/if I use the external op-amp?
If I need it, would it be correct that it should be R=Umax/Imax=3,4V/1mA=3400 ohm?
Thanks for answers :D
PS: Please ask if you want any clarification of what I wrote.