0
\$\begingroup\$

I'm designing a circuit that is going to sense the existence of high voltage DC(400V+) via microcontroller. I've already designed it for AC voltage using an optocoupler; however, I will not able to use an isolation component for DC detection. I'm planning to use a resistor and high voltage diode pair at the input level, and open collector npn transistor for the microcontroller end; but, I don't have an idea how to convert that high voltage to TTL level.

I appreciate any help or guidance to this problem.

edit: As requested, I add schematics of my AC detection circuit.

enter image description here

\$\endgroup\$
7
  • \$\begingroup\$ Why can't you use an optocoupler for DC? \$\endgroup\$ Commented Mar 12, 2015 at 6:57
  • \$\begingroup\$ just a restriction. @IgnacioVazquez-Abrams \$\endgroup\$ Commented Mar 12, 2015 at 7:00
  • \$\begingroup\$ shrug I'd still isolate it, even if I had to use a LED, a phototransistor, and a piece of heatshrink tubing. \$\endgroup\$ Commented Mar 12, 2015 at 7:02
  • \$\begingroup\$ Can you post a schematic of both your AC and DC circuits and show how you want to interface them to the MCU, please? \$\endgroup\$
    – EM Fields
    Commented Mar 12, 2015 at 7:34
  • \$\begingroup\$ I added the AC detection schematic. DC is what I'm asking :) @EMFields \$\endgroup\$ Commented Mar 12, 2015 at 7:39

2 Answers 2

1
\$\begingroup\$

Here's the LTspice schematic, with the code following it if you want to play with the circuit. R1, R2, and R3 are used instead of a single resistor because of the maximum voltage allowed across a single resistor, something like 150V peak.

Check the voltage spec's of the resistors you want to use and make sure it won't be exceeded regardless of the input voltage or the tolerances of the resistors.

enter image description here

Version 4
SHEET 1 2680 692
WIRE -672 -2176 -1440 -2176
WIRE -576 -2176 -672 -2176
WIRE -672 -2144 -672 -2176
WIRE -672 -2032 -672 -2064
WIRE -576 -2032 -672 -2032
WIRE -672 -1984 -672 -2032
WIRE -1280 -1936 -1344 -1936
WIRE -1152 -1936 -1200 -1936
WIRE -1024 -1936 -1072 -1936
WIRE -880 -1936 -944 -1936
WIRE -800 -1936 -880 -1936
WIRE -736 -1936 -800 -1936
WIRE -1440 -1872 -1440 -2176
WIRE -1344 -1872 -1344 -1936
WIRE -880 -1872 -880 -1936
WIRE -800 -1872 -800 -1936
WIRE -1440 -1744 -1440 -1792
WIRE -1344 -1744 -1344 -1792
WIRE -1344 -1744 -1440 -1744
WIRE -880 -1744 -880 -1808
WIRE -880 -1744 -1344 -1744
WIRE -800 -1744 -800 -1792
WIRE -800 -1744 -880 -1744
WIRE -672 -1744 -672 -1888
WIRE -672 -1744 -800 -1744
WIRE -576 -1744 -672 -1744
WIRE -1440 -1680 -1440 -1744
FLAG -1440 -1680 0
FLAG -576 -2176 MCU_Vcc
FLAG -576 -2032 MCU_I/O
FLAG -576 -1744 MCU_GND
SYMBOL res -1184 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R1
SYMATTR Value 1Meg
SYMBOL npn -736 -1984 R0
SYMATTR InstName Q1
SYMATTR Value 2N3904
SYMBOL res -688 -2160 R0
SYMATTR InstName R4
SYMATTR Value 10k
SYMBOL res -816 -1888 R0
SYMATTR InstName R5
SYMATTR Value 10k
SYMBOL voltage -1344 -1888 R0
WINDOW 3 24 96 Invisible 2
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V1
SYMATTR Value PULSE(0 400 1 1ms 1ms 100ms)
SYMBOL diode -864 -1808 R180
WINDOW 0 24 64 Left 2
WINDOW 3 24 0 Left 2
SYMATTR InstName D1
SYMATTR Value 1N4148
SYMBOL voltage -1440 -1888 R0
WINDOW 123 0 0 Left 2
WINDOW 39 0 0 Left 2
SYMATTR InstName V2
SYMATTR Value 5
SYMBOL res -1056 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R2
SYMATTR Value 1Meg
SYMBOL res -928 -1952 R90
WINDOW 0 0 56 VBottom 2
WINDOW 3 32 56 VTop 2
SYMATTR InstName R3
SYMATTR Value 1Meg
TEXT -1426 -1712 Left 2 !.tran 2 startup uic
\$\endgroup\$
5
  • \$\begingroup\$ I'm not that much experienced with LTSpice (generally using spice of CAD drawing). Could you tell me how to operate this code piece? I'm getting an error "Multiple Instance of Flag". \$\endgroup\$ Commented Mar 12, 2015 at 9:38
  • 1
    \$\begingroup\$ @vilacikovski: Sure. First, go here and download LTspice IV. Then copy the code I posted as a file with any name you want and a suffix of.asc into a folder of your choice. Left click on the file amd LTspice should start up, find the file, and display the schematic. To run the simulation, right click anywhere on the background of the schematic and then left click on "Run" \$\endgroup\$
    – EM Fields
    Commented Mar 12, 2015 at 10:04
  • \$\begingroup\$ One final question I'd like to ask. Using 1Meg resistor keep 134V. Considering the peak voltage for 805 package resistor is 150V, isn't the safe margin is a bit low? 4 resistors seem safer. What do you think? \$\endgroup\$ Commented Mar 12, 2015 at 12:02
  • \$\begingroup\$ @vilacikovski: I think you're right! You should also check how much power the resistors will dissipate and make sure they're rated properly. \$\endgroup\$
    – EM Fields
    Commented Mar 12, 2015 at 12:14
  • \$\begingroup\$ As long as at least two resistors are connected, power dissipation wouldn't be a problem. 22mW/125mW for 4 resistors, safe enough. Total 0.1~0.2W of power will be consumed. \$\endgroup\$ Commented Mar 12, 2015 at 12:28
0
\$\begingroup\$

You don't. Enable the internal pullup resistor on the MCU input and use the transistor to pull it to ground. That way you don't need to worry about what voltage the MCU uses.

\$\endgroup\$
14
  • \$\begingroup\$ So, is it enough to drive a power transistor with open collector configuration? \$\endgroup\$ Commented Mar 12, 2015 at 7:01
  • \$\begingroup\$ You shouldn't need a power transistor for this. The collector current itself only needs to be about 50mA, but even saturating it won't dissipate much power. \$\endgroup\$ Commented Mar 12, 2015 at 7:04
  • \$\begingroup\$ Applying 400V directly to transistor still makes no sense to me. Am I missing something? \$\endgroup\$ Commented Mar 12, 2015 at 7:20
  • \$\begingroup\$ @IgnacioVazquez-Abrams: 50mA seems like a lot for an MCU's internal pullup, yes? \$\endgroup\$
    – EM Fields
    Commented Mar 12, 2015 at 7:36
  • \$\begingroup\$ @vilacikovski: Earlier you said that the 400VDC was to be applied to an open-collector NPN through a resistance and - presumably - an anti-parallel diode pair from the base to GND. Has that changed? \$\endgroup\$
    – EM Fields
    Commented Mar 12, 2015 at 7:40

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.