How do you know when you need a new Engine Control Module?
The car runs good most of the time but will randomly refuse to idle, run really rough and
blow black smoke.
When you get an ECM failure code most of the time. There are exceptions. Have your system tested, it sounds like you could have some sensors malfunctioning ie O2, ECT, ACT, MAF, ISC, etc. Or possibly a vacuum leak. The codes should tell the story.