+ Post New Thread
Results 1 to 10 of 10
  1. #1
    Junior Member level 2
    Points: 2,153, Level: 10
    Achievements:
    7 years registered

    Join Date
    May 2008
    Posts
    23
    Helped
    0 / 0
    Points
    2,153
    Level
    10

    230V AC to 5V DC push button interfacing

    Hi,

    I am designing a system to control fan speeds.
    The selection of the speeds will be done using an MCU that will select the correct output to the fan.

    The selection is done by a single push button, each press changes the speed.

    This logic is working using a push-button connected directly to the MCU and the 5V supply.

    In the final system, the push button will send a ~230V AC pulse instead of a 5V DC pulses.

    I need to interface this into my 5V MCU.

    My idea is to use a diode bridge and a voltage devider like in the attched schematic.

    Will it work?

    Thanks,
    Tomer

  2. #2
    Super Moderator
    Points: 77,099, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,620
    Helped
    3559 / 3559
    Points
    77,099
    Level
    67

    Re: 230V AC to 5V DC push button interfacing

    Hi,
    Will it work?
    no way!

    * the push button short circuits mains input. In worst case the pushbutton explodes and causes fire...in best case the mains fuse trips.
    * There is only one connection to the microcontroller. Impossible to work.
    I didn't check further..

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  3. #3
    Advanced Member level 5
    Points: 13,978, Level: 28

    Join Date
    Apr 2014
    Posts
    2,180
    Helped
    876 / 876
    Points
    13,978
    Level
    28

    Re: 230V AC to 5V DC push button interfacing

    Quote Originally Posted by tomerbr View Post
    Will it work?
    I like your fuse blower switch.

    In any case, the lack of isolation from the 230V primary is a serious issue. Depending on your country, mains plugs can be reversed and the neutral/ground might actually be 230V. Plus there are failure cases where neutral isn't neutral any more, and you have 230V on that wire which connect to your output "ground". Wanna kill yourself? Stay away from mains voltage, you don't know what you are doing.
    Last edited by volker@muehlhaus; 1st August 2019 at 08:02.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 1
    Points: 2,812, Level: 12

    Join Date
    Aug 2016
    Posts
    498
    Helped
    79 / 79
    Points
    2,812
    Level
    12

    Re: 230V AC to 5V DC push button interfacing

    Hi,

    You'll need a proper power supply for your design. An offline flyback is a good option for low-power applications. You can buy a duly rated one off the shelf.

    Now taking a look at the right hand side of your schematic, assuming that the LHS is not what it is, that is not the way to implement a voltage divider. You just short-circuited resistor R1.
    -------------
    --Akanimo.


    1 members found this post helpful.

    •   AltAdvertisement

        
       

  5. #5
    Junior Member level 2
    Points: 2,153, Level: 10
    Achievements:
    7 years registered

    Join Date
    May 2008
    Posts
    23
    Helped
    0 / 0
    Points
    2,153
    Level
    10

    Re: 230V AC to 5V DC push button interfacing

    You are right, the previous schematic had a mistake.

    This is the correct schematic.

    As for powering the MCU, I do have a flyback converter directly from the AC mains to the 5V supply.
    My only issue is to translate the AC pulse from the push button.

    Will the new circuit work?

    In open state the GPIO is pulled low with R2, when the button is pressed - the GPIO should sense a voltage via R1, I will set R1, R2 values to produce around 5V through them.

    As for isolation, the DC part is installed inside the fan without any human access. is it still necessary?

    Thank,
    Tomer



  6. #6
    Advanced Member level 1
    Points: 2,812, Level: 12

    Join Date
    Aug 2016
    Posts
    498
    Helped
    79 / 79
    Points
    2,812
    Level
    12

    Re: 230V AC to 5V DC push button interfacing

    Hi,

    If you have a flyback converter already then you would not need the bridge rectifier that you still have. You can use the output DC to generate and feed the pulse to the MCU with your switch.
    -------------
    --Akanimo.



  7. #7
    Full Member level 6
    Points: 1,915, Level: 10

    Join Date
    Jan 2019
    Posts
    359
    Helped
    88 / 88
    Points
    1,915
    Level
    10

    Re: 230V AC to 5V DC push button interfacing

    Quote Originally Posted by tomerbr View Post
    Hi,

    This logic is working using a push-button connected directly to the MCU and the 5V supply.

    In the final system, the push button will send a ~230V AC pulse instead of a 5V DC pulses.
    why are you changing the switch from a nice, safe, working 5V switch and circuit
    to an untested, not so safe 230V switch and circuit?

    How are you changing the voltage/power to the fan to execute the speed change?

    One switch can only go one way - increase speed or decrease speed
    have you considered adding a second switch so one increases speed while the other decreases speed?



    •   AltAdvertisement

        
       

  8. #8
    Junior Member level 2
    Points: 2,153, Level: 10
    Achievements:
    7 years registered

    Join Date
    May 2008
    Posts
    23
    Helped
    0 / 0
    Points
    2,153
    Level
    10

    Re: 230V AC to 5V DC push button interfacing

    I will clarify,

    The 5V switch was just to test the logic.
    I cannot use it as the switch is dictated to me as 230V.

    That is why I am changing it and that is why I cannot use the flyback to feed it.

    So I ask, will it work or not?
    What are the risks?

    Thanks for the help
    Tomer



  9. #9
    Super Moderator
    Points: 77,099, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,620
    Helped
    3559 / 3559
    Points
    77,099
    Level
    67

    Re: 230V AC to 5V DC push button interfacing

    Hi,

    It may work. But it's not safe.
    The bridge rectifier does not prevent dangerous voltage to be fed to the microcontroller side.
    As soon as you touch anything of the microcontroller electronics - even GND - you risk to get an electric shock.

    --> Use a relay, a tiny transformer or an optocoupler for galvanic isolation.
    Thousands proven circuits are available online.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  10. #10
    Junior Member level 2
    Points: 2,153, Level: 10
    Achievements:
    7 years registered

    Join Date
    May 2008
    Posts
    23
    Helped
    0 / 0
    Points
    2,153
    Level
    10

    Re: 230V AC to 5V DC push button interfacing

    Quote Originally Posted by KlausST View Post
    Hi,

    It may work. But it's not safe.
    The bridge rectifier does not prevent dangerous voltage to be fed to the microcontroller side.
    As soon as you touch anything of the microcontroller electronics - even GND - you risk to get an electric shock.

    --> Use a relay, a tiny transformer or an optocoupler for galvanic isolation.
    Thousands proven circuits are available online.

    Klaus
    Thanks for that.
    I will design the circuit as you suggested and upload it here for review



--[[ ]]--