Thanks for your question. Erectile dysfunction has many underlying causes but in your case it seems that mental stress, nervousness, fearing troubled relationship with your wife or psychological distress due a single episode of sexual failure may be the causes. I would suggest you to go for meditation starting with half an hour initially and gradually increasing the time. It is necessary for both of you to consult a psychologist to avoid any further damage in your relationship. Tackle each situation with the attention it deserves instead of pondering over multiple problems. Try to have fun even for a few minutes each day may be with your children or by watching movies. Indulge yourself in creative activity through either playing music, writing or painting your garden fence. I hope you will be able to overcome all problems.