in my actual project I do get a triangular signal between 100mV and 300mV at 50 to 50000 Hz.
Since I did not manage to use the internal Comparator (chapter 27 in the ATMega328P-Manual) I bought two external comparators LM311P and LM393N. I put the wiring on my breadboard with both different comparators, however I am not happy with the output:
I connected Port (1) of the LM393N with my digital input as well as with a pull-up (at the beginning I used 10kOhm like described in http://www.ti.com/lit/ds/symlink/lm393-n.pdf, finally I ended with a poti to be able to change the increasing slope of the peak), Port (2) was connected to my triangular signal, Port (3) is connected to a Poti at about 200mV, Port (4) is grounded and Port (8) was connected to 5V.
Finally I got a nice looking digital signal. However the logical "1" is not at 5V like I expected - instead it is at about 3V. That's why my Arduino Nano does not see a logical "1" and does not count my pulses. Does anyone have an idea how to solve my problem?
10k may be too weak - 2k2 is commonly used for fast response from an open-collector comparator.
An LM393 doesn't have ports, I have no idea how you connected it, but if you add a pull-up
resistor to 5V the output will rise to 5V. comparators have inverting and non-inverting input pins, and
an output pin (normally open-collector).
If you measured that 3V with a multimeter it might be that the output is oscillating (multimeters average
over time and can't see such things).
Fast comparator chips must be decoupled well, 100nF ceramic capacitor directly across the power and
ground pins is always required. Failure to do this will likely cause high speed oscillation.
Normally you would add a little positive feedback in a comparator circuit (hysteresis), for stable operation.
Try adding something of the order of several 100k between the output and the non-inverting input pin.
thank you very much for your replies, both of them have been very useful!
Finally I noticed, that the Arduino Nano I used seems to have a problem with its voltage (supplied via USB). After using an external power supply the signal comes out like expected, and the Nano is counting properly.
However I will have to find out something about the problem of the Nano...