Electronic – How to detect AC signal and use as logic-level input to microcontroller

npnswitchestransistors

schematic diagram

Hi community, what I'm trying to do with this circuit is to get a 5V signal on the output whenever an input AC signal is present. That simple. It works perfectly with 9VAC on the input but when it goes down to around 5VAC, the transistor starts supplying the regulator less (around 4-5Volts) and output voltage goes down to 3Volts.

I am still learning electronics and just found out that I have to limit the current going into the base of the transistor with a resistor. What else am I missing here? Any comment would help. Seemed like an easy application.

Best Answer

Your initial difficulty is that the 7805 regulator has a dropout voltage (below which it no longer regulates) of about 2 V. Look at the datasheet.
This means to get regulated 5 V from your 12 V supply the input needs to be greater than 7 V.

Your second difficulty is whether you need a simple level detector or more. Since what you show is a half wave rectifier, you will get approximately 0.8 V less than the positive peak voltage.

If you want an accurate level detection, then you should use a comparator to drive a BJT switch to turn on your 12 V input.

I notice in your comment that you don't need power ...you simply want a signal into an Arduino. Then all you need is a peak detector and comparator, and feed that signal into the Arduino. You wouldn't even need the 12 V supply.