I have built this circuit to dim a lamp with a PWM signal. It had an issue where the MOSFET was getting really hot. So I wanted to know what was happening on the gate of the MOSFET.

I turned the PWM signal off and with my multimeter I measured \$V_{GS}\$ as 12V. Now confident that I can look at the waveform with my little USB-oscilloscope (rated to 20V) I connected it. Bammm, the lights go out and I'm left with a bricked oscilloscope and PC that was connected to it.

I'm quite sad about breaking my PC. However I have to know what went wrong so I'm here.

About the problem with the hot MOSFET: It turns out there was a bug in the code making the PWM frequency very high. Making sure it was 200Hz fixed the overheating and the dimmer appears to be working as intended now.



Opto-coupler: ILQ2

  • 3
    \$\begingroup\$ What is your V1, is it the mains? In that case you more or less connected your PCs groud to it. Poor PC... \$\endgroup\$ Commented Sep 25, 2016 at 19:12
  • 2
    \$\begingroup\$ @WoutervanOoijen points out, this is all about the ground reference. Your oscilloscope not only requires that the differential voltage is within an acceptable range, but that each individual input (you can also think about the common mode) absolutely referenced to ground is not too large. Yours was too large... Doesn't affect the multimeter, because it is battery operated and isolated, so has no absolute voltage reference. \$\endgroup\$
    – Ben Voigt
    Commented Sep 25, 2016 at 19:14
  • 31
    \$\begingroup\$ And may I suggest (unless you're in for a Darwin award) that you refrain from building things that are directly mains connected untill you're absolutely sure you know what you are doing? In your circuit, C1 cries out danger and don't touch me! At the very least put a bleeder resistor across its terminals, and include a resistor that limits the inrush current. \$\endgroup\$ Commented Sep 25, 2016 at 19:19
  • 6
    \$\begingroup\$ Use an isolation transformer when prototyping mains voltage circuitry instead of just directly plugging stuff to the grid. This way you and your equipment will have to touch two (as opposed to one) live conductors simultaneously to die or break, respectively. See this post for details: electronics.stackexchange.com/questions/17496/… \$\endgroup\$
    – jms
    Commented Sep 25, 2016 at 21:29
  • 4
    \$\begingroup\$ EEVblog #279 - How NOT To Blow Up Your Oscilloscope: youtube.com/watch?v=xaELqAo4kkQ \$\endgroup\$ Commented Sep 26, 2016 at 11:48

5 Answers 5


The circuit shown is AC mains connected without any kind of isolation. Measuring Vgs using a multimeter is safe because the multimeter is 'floating' with respect to the mains supply.

But a PC is not floating. The PC is normally has the grounded case, meaning the metallic shield on the USB connector is also grounded to the mains power point through the PC case.

As such, connecting the USB oscilloscope to the mains connected circuit is inevitably disastrous. When this is done, mains voltage will push current into the PC case (or into the USB data lines, depends which probe is linked) to be returned to the ground.

All mains linked circuit must be instrumented by floating equipment. You might be at safe side if you used a laptop instead of PC, but its not so safe either unless you really insulated everything around the laptop and ensured your laptop is really floating with respect to the ground.

  • 19
    \$\begingroup\$ "All mains linked circuit must be instrumented by floating equipment." - Note that this puts the entire relevant equipment at mains potential. Touching any part of it that is not properly insulated = death. \$\endgroup\$
    – marcelm
    Commented Sep 25, 2016 at 20:32
  • 4
    \$\begingroup\$ I would rather phrase it like: 'all mains liked circuits must be floated and can afterwards be measuered with properly grounded equipment' \$\endgroup\$ Commented Sep 26, 2016 at 12:29
  • \$\begingroup\$ I suppose you wanted to say 'all main linked'... Anyway, if you already float the mains linked circuit, its actually not mains linked anymore. Thus the question whether the measuring equipment is grounded or not is no longer relevant. \$\endgroup\$ Commented Sep 26, 2016 at 12:59
  • \$\begingroup\$ Curiosity: Would have first connecting the ground part of the probe to the circuit have triggered an RCD without causing (too much) harm? \$\endgroup\$ Commented Sep 27, 2016 at 8:12


simulate this circuit – Schematic created using CircuitLab

Figure 1 a, b and c.

Since the circuit is not isolated the bottom line of your circuit moves around with the mains voltage.

  • On positive half-cycles (b) the bottom of M2 would normally be held at about 0.7 V above neutral voltage. Since this is connected to mains earth - that's 0.7 V above earth. Since the oscilloscope and PC provide a lower resistance path to earth than the diode the current will flow through them rather than the diode. Your equipment might survive 0.7 V if the cable resistance is high enough to limit the current.
  • On negative half-cycles (c) the bottom of M3 is pulled to -170 V peak (if you're on 120 V supply). A high current will flow from the PC / oscilloscope ground as it is providing a short circuit from earth. This current likely burnt up several ground traces on the PCBs it ran through. Once they were gone the voltage would have been applied to the chips, etc., and they were destroyed as well.

It's a tough lesson so learn it well. Make sure you understand the logic of the explanation above. If you can do that you will have learned more for the cost of replacing your equipment than many do at fee-paying courses.

Since the problem of using oscilloscopes on mains circuits comes up frequently on EE.SE the following may be of help.

enter image description here enter image description here

Figure 1 and 2. Fluke Scopemeter and probe set. Note insulated "BNC" connector and leads including black plug on earth clip lead (which plugs into side of probe). The meter comes with a PSU jack that doesn't make contact with the internals until after the exposed metal has been inserted. An optical serial port is visible on the side of the scope.

Instruments such as the scopemeter in Figure 2 are fully insulated. As a result the scope ground can be connected to any point on the circuit under investigation including the rectified negative line of Figure 1. Even when on charge the device is fully isolated from mains earth. The only point to watch is that the earth clips of the supplied A and B channel probes are not connected to two different potentials.


So close, yet disaster. Web resources should be double-checked, especially where line-voltage circuits are concerned. Circuit-Lab should be notified that they've published a guaranteed PC-killer, and a possible people-killer. These expensive lessons are never forgotten by those who survive.
Kudos to you for discovering that fast PWM causes a hot MOSfet, and slow PWM is a solution. A circuit revision that reduces the 180K resistor to 10K will also help somewhat. Your solution of very slow PWM of 200Hz. is also a decent work-around. Be careful of choosing frequencies that are multiples of line frequency - for example, choosing 240 Hz. where line frequency is 60 Hz. will give an interesting optical effect.
The main revision to this circuit to avoid disaster involves completely isolating the PWM source from the MOSFET driver, like so: enter image description here One should also take care to make component choice carefully. BR1 must be rated in voltage to easily take peak-to-peak line voltage. It must also be rated to pass lamp current with some considerable head-room, since lamps require a surge current when cold, until they reach operating temperature. Diode D1 can be a small diode, because little current is required of it, but it must be rated for at least peak line voltage. It would be safer to choose a voltage rating of peak-to-peak line voltage.
Probing this circuit with any oscilloscope is a 'scope-killer. No 'scope I've used could withstand its ground connection (0v reference) going to any part of this circuit other than PWM source. If your USB oscilloscope has a spec-sheet, carefully find its common-mode voltage limit. This tells you how far from ground its input circuit can deviate before some part of it fails. Some are only a few volts. This circuit would require hundreds of volts of common-mode range. Always assume that a 'scope's 0v reference is connected directly to ground, and always keep in mind that most parts of this circuit will result in spectacular failure when grounded.


Understand that tungsten lamps have a large temp rise >3200'C and NTC of 10:1 cold to hot resistance, thus if PWM pulses at a slow rate or too fast, Ipk can reach 10x bulb rated current or have large dynamic losses and FET RdsOn with resistance may gets warmer with I^2R=Pd

Note that line and neutral are not labelled , and neither V+ or V- is at ground but we know Neutral is at least grounded at outside transformer. Thus without care, you can be connecting probe ground to rectified line instead of 2 diode drops from neutral.

This requires two 10M probes rated for 400v in differential A-B mode.

  • \$\begingroup\$ This is actually an important point - and "kids these days" may not necessarily understand the complexities of how differently a real tungsten filament might behave. Radiative cooling, thermal inertia combined with the dramatic swing in resistance make for fun science but not for a simple equivalent circuit. \$\endgroup\$
    – uhoh
    Commented Sep 26, 2016 at 13:35

Consider that your PC sacrificed itself to save your life.

As a sidenote, such measurements can be done using so-called isolated USB hubs: enter image description here

These allow several kV between your PC (which is usually grounded and safe to touch) and equipment like USB scopes which may become live. Of course, you should still know what you're doing (e.g. only touch the scope when the power is disconnected and all HV caps have been discharged).

  • \$\begingroup\$ Um, I doubt that they are designed for this purpose. I imagine they are designed to break ground-loops between devices rather than be deliberately connected to mains. It still looks lethal. \$\endgroup\$
    – Transistor
    Commented Sep 26, 2016 at 13:36
  • \$\begingroup\$ @Transistor How would you check the OP's circuit with a scope then? \$\endgroup\$ Commented Sep 26, 2016 at 13:45
  • 3
    \$\begingroup\$ I'd use something like a Fluke Scopemeter which is fully isolated and finger-proof (and the PSU jack is touchproof and case is appropriately rated). The "GND" input can be connected anywhere on the circuit. Option 2 is to take a differential measurement. I agree that this can be difficult if the small signal is swamped by the mains voltage. The topic of live chassis oscilloscopes has been covered here before and I've seen it done and felt most uncomfortable being near it. I wonder to any of the PicoScope range offer isolated input facilities with fully insulated probes? \$\endgroup\$
    – Transistor
    Commented Sep 26, 2016 at 13:52
  • \$\begingroup\$ @Transistor This is definitely designed for this purpose - not necessarily to protect against a cheap toy USB scope specifically, but generally for protecting any upstream equipment from field devices that may fail to HV potentials. This is an industrial grade isolated USB hub with 4kV isolation specified - OP's test would likely still have fried the scope and the hub, but it would have protected the upstream PC. These are generally used to prevent cascade failures of mission-critical upsream systems by keeping the faulting devices contained. \$\endgroup\$
    – J...
    Commented Sep 26, 2016 at 16:45
  • \$\begingroup\$ That said, it certainly won't save a misdirected experimenter from killing themselves with a dangerous circuit, so on that front it really offers no protection whatsoever. It's really not a solution to the problem of not knowing where you ought and ought not stick your probes. \$\endgroup\$
    – J...
    Commented Sep 26, 2016 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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