This is my first time posting here, so hopefully I'm doing it correctly.

I've build a circuit which uses a USB-connected FTDI-UMFT240XA. http://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_UMFT240XA.pdf

Basically I'm sending 1-byte packets of information to the controller, which are then used to turn on and off transistors, which then will turn on and off relays. I am using the DATA I/O pins to send the logic signals to the transistors.

The problem I'm having is that when I switch the relay on and off via the circuit multiple times, I find that every once in a while, the microcontroller just shuts off. This only seems to happen when I introduce the relay into the circuit. I can switch LEDs on and off without a problem.

I have tried both NPN and N-Channel MOSFET transistors and both yield the same behavior. I have it hooked up as follows:

  • Gate (or base) of transistor hooked up to digital logic signal (DATA 0, a 3.3V signal)

  • Source (or emitter) of transistor hooked up to ground

  • Drain (or collector) of transistor hooked up to the relay in parallel with a flyback diode, both of which connect to positive voltage (+5V)

The gate also has a 1M pull-down resistor hooked to ground.

At first I thought perhaps the USB bus was not able to supply enough power to the circuit, and was therefor being shut off, however this does not seem to be the case, as I have removed the two solder jumpers on the chip and connected an external power supply (using a 5v and 3.3v regulator in place of the USB power, as described in the self-powered configuration in the above pdf)

The ONLY way I seem to be able to avoid this dying of the microcontroller is by connecting the DATA 0 to the gate with a diode, rather than a straight wire or a resistor. The problem with this is that upon connecting the circuit like this, it takes a long time for the voltage on the gate to drop far enough to turn the transistor back off. (about 5-7 seconds).

Am I missing something here? Am I using one of these components incorrectly?


I don't have a schematic, but here's a look at the breadboard with some labeling. picture of the breadboard

  • 2
    \$\begingroup\$ Is the micro powered from the same 5V source as the relays? And when you ask questions here, please post schematics. Intuition says add more capacitance to the micro power pins. \$\endgroup\$ – Matt Young Dec 2 '13 at 21:52
  • \$\begingroup\$ Yes it is. (more explanation) The microcontroller requires both a 5v and 3.3v supply (normally from USB, but can be switched to an external source to provide more current). The 5v regulator I'm using powers the relays and the micro itself. Additionally, the 3.3v regulator provides the 3.3v supply for the chip, and the reference voltage for the DATA pins. \$\endgroup\$ – Harvtronix Dec 2 '13 at 21:58
  • 1
    \$\begingroup\$ Your picture looks correct, but you have Drain and Source mixed up in your description. Your description should be: "Source (or emitter) of transistor hooked up to ground. Drain (or collector) of transistor hooked up to the relay ...". Also if you use an NPN transistor, you need a series resistor from the digital logic signal to the base. \$\endgroup\$ – Tut Dec 3 '13 at 20:33
  • 1
    \$\begingroup\$ It may just be the picture, but the 10K pull-down resistor looks like 10 ohms. Can you confirm that it really is 10K? You may also want to consider a MOSFET with a lower Vgs_on ... Look at Figure 3 in the datasheet for NTD4858N \$\endgroup\$ – Tut Dec 3 '13 at 21:24
  • 1
    \$\begingroup\$ Regarding the MOSFET ... FET's gate thresholds can vary greatly. The figures in the datasheet are typical values, but can be worse. For a 3.3V circuit, it is especially important to choose one with a low threshold. One device to consider is IRLML2502, but you should read the data-sheet to determine it's suitability. The part you have may be fine for a one-off project ... as long as it works and does not get too hot. \$\endgroup\$ – Tut Dec 4 '13 at 11:53

As Matt says, the first thing that jumps out is more capacitance needed.

Breadboards are terrible for stray inductance/capacitance so you really need to try and keep wires as short as possible, keep sensitive signals away from higher current/voltage/fast changing signals, and add plenty of bypass and bulk capacitance around the circuit.

I would start with a couple of >100uF electrolytics on each power rail and near the FET, with a few 100nF or higher ceramic caps on the power pins of the ICs.

Another thing to look at is using a separate rail for the relay, and routing the ground return separately from the uC's ground. Of course they need to be tied together, but you can ensure the high current return does not flow through the uC board's ground this way.

  • \$\begingroup\$ +1 on the grounding considerations. Proper grounding is all too often neglected. \$\endgroup\$ – Matt Young Dec 3 '13 at 4:59
  • \$\begingroup\$ Thanks very much for the input. I have done a partial rebuild of the circuit and have taken your comments into careful consideration. \$\endgroup\$ – Harvtronix Dec 3 '13 at 16:09

After thorough testing, I have decided that making the following change has fixed this problem:

Use the EEPROM flash utility for the chip (available from ftdichip.com) to increase the current output of the DATA pins from 4mA to 8mA.

enter image description here

I believe that there were times when more than 4mA were being drawn from by the MOSFET (or NPN BJT) gate/base, causing the chip to defensively react by shutting down the DATA pins.

The chip never actually lost USB connectivity, so most of the chip was still on, but the DATA pins themselves had been switched off from the current overdraw.


All Microcontrollers or any other programmable controllers are very good sinking source, they cant source much current, which is essential while driving components such as a relay. Use current drivers such as ULN2003 or IC's which can allow such loads.


Not the answer you're looking for? Browse other questions tagged or ask your own question.