Detecting current (yes/no) in circuit. AC current mirror?  - Page 1
Forum section: electronics / projects

author: conducteur
author_rank: Regular Contributor
timestamp: November 27, 2014, 09:28:54 pm
content: See image in attachments:Everybody knows this is a current mirror. Now, if you chose R3 great enough (let's say 10kohm), then even with low currents the transistor goes into saturation. (at 0,5mA current with 10K i have 5V). So I get a logic level at point A. That's what i want... My only problem: it's a square wave between +18 and -18 V (at +/- 15 kHz) ... Is there something like a current mirror for AC signals?It's for model trains... There are many circuits around on the web, but they're often "complex" or use "expensive" components like an optocoupler. This is not ideal if you need to make a bunch of these things. My idea with the modified current mirror uses only 2 transistors and a resistor, but is not sufficient when i need to detect AC currents...I'm not interested in how many current that flows, just Yes there's current flowing to a train, or "no" there's no train in that section on the layout. Need to detect 0,5mA to 1A in a reliable way

author: tom66
author_rank: Super Contributor
timestamp: November 27, 2014, 09:36:31 pm
content: So you want to measure AC current flow, could you just insert a series ~few ohm resistor, and watch for a small drop? Perhaps use a comparator or transistor circuit to detect this.

author: conducteur
author_rank: Regular Contributor
timestamp: November 27, 2014, 09:42:39 pm
content: If you only have a current of 0,5mA, trough a 2 ohm resistor, gives me 1mV. Can you detect that without detecting "noise". You need to take care about that. There are lots of motors and electromagnets one a layout that can cause trouble... 1A trough that resistor is a loss of 2V, and that's not what we want. If we go to 5 ohm, things get even worse. Not a solution i think.

author: tom66
author_rank: Super Contributor
timestamp: November 27, 2014, 09:44:39 pm
content: Ok, well if it's only 0.5mA use a ~2.2k ohm resistor. Voltage drop of 1V will be detectable but will probably not interfere with train control.

author: conducteur
author_rank: Regular Contributor
timestamp: November 27, 2014, 09:51:32 pm
content: Yeah, but 1A throug a 2,2K ? Don't have 2200V supply here.

author: edavid
author_rank: Super Contributor
timestamp: November 27, 2014, 09:54:37 pm
content: A simple current mirror won't do the job unless you make it big enough to pass the locomotive current, which is not very practical.So then you have to shunt the sensing side, probably with a diode. At that point it probably makes more sense to use voltage sensing rather than current sensing.Also, there's not much reason to build a large number of this type of detector... how many isolated track blocks are you going to have? How many locomotives running at once?BTW, optocouplers are very cheap.

author: tom66
author_rank: Super Contributor
timestamp: November 27, 2014, 09:56:19 pm
content: Quote from: conducteur on November 27, 2014, 09:51:32 pmI'm lost as to exactly what you want to detect. You first said any current, then 0.5mA. But sometimes 1A? You are aware of course that the slightest leakage current due to contamination will trigger your circuit if it has a threshold at 0.5mA but should also pass 1A. It is very hard to design such a circuit which will have such good noise immunity.You should define: Minimum current (more than zero amps is not useful), maximum typical current expected and tolerable voltage drop under maximum/minimum currents. Also might help to define the output signal, whether you want a logic level swing, or can deal with some kind of open collector/open drain drive.

author: conducteur
author_rank: Regular Contributor
timestamp: November 27, 2014, 10:43:58 pm
content: A complete train, engine with motor and coaches with interior lighting takes more current from the layout than just than one wheel fitted with a 10k resistor.Need at least 50 of these for one layout in our club.

author: tom66
author_rank: Super Contributor
timestamp: November 27, 2014, 11:08:00 pm
content: So, do you need to detect the train... or the 10k resistor? What about the other questions, even rough values will give some idea. Currently, you circuit will not work well as the current path is through a non-saturated switch which will lead to a lot of power dissipation and an unhappy transistor / melted blob of plastic.

author: pmbrunelle
author_rank: Regular Contributor
timestamp: November 28, 2014, 01:05:14 am
content: Quote from: edavid on November 27, 2014, 09:54:37 pmDiodes in parallel (but reversed in polarity with respect to each other) would make sense as a series element.Then, connect a step-up transformer across the diodes, and do something with the secondary elsewhere.I don't see why the power side couldn't be monitored.

author: conducteur
author_rank: Regular Contributor
timestamp: November 28, 2014, 11:33:27 am
content: A complete train, needs about 0.5 to 1A to run on the layout. That is easy to detect with a resistor. But i need to detect a single freight wagon to... and that's only a few mA with a 10K resistor as "load" to detect.

author: tom66
author_rank: Super Contributor
timestamp: November 28, 2014, 11:44:15 am
content: It's a tricky challenge but with the right design ought to be possible. But, thinking about this another way, couldn't you change the freight train's resistor to increase the effective load? If you had something like 100:1 measurement span, it's nice and easy to do. 10,000:1 is a lot harder (not impossible of course - the very fact that 20,000+ count multimeters exist proves this is possible, but it's much more expensive and difficult to implement.)

author: conducteur
author_rank: Regular Contributor
timestamp: November 28, 2014, 11:57:47 am
content: It's possible to lower that resistor value, but one problem: a complete train with 20 resistors in parallel... To much current just to detect a train... Not efficient.

author: Zero999
author_rank: Super Contributor
timestamp: November 28, 2014, 12:02:08 pm
content: If it's AC then why not use a current transformer?If you wind 100 turns on a ferrite core for the secondary and wrap the wire carrying the current for the train round it once to form the primary, there will be 10mA on the secondary, per Amp on the primary. A 100R burden resistor connected across the secondary should give you about 1VAC per Amp on the secondary. It can then be biased at half the 5V supply to give you an AC signal oscillating about 2.5V, which can easily be detected by a microcontroller.

author: edavid
author_rank: Super Contributor
timestamp: November 28, 2014, 04:13:32 pm
content: Quote from: conducteur on November 28, 2014, 11:33:27 amThis is why you need a nonlinear sense impedance... resistor with diode across it. Have you noticed that that's what all the published circuits use?http://home.cogeco.ca/~rpaisley4/CircuitIndex.html#65P.S. If you have so many blocks, wouldn't it be cheaper to use a camera above the layout?

author: conducteur
author_rank: Regular Contributor
timestamp: November 28, 2014, 04:56:50 pm
content: I don't think my pc-software can handle train detection using camera's...

author: timb
author_rank: Super Contributor
timestamp: November 28, 2014, 05:29:48 pm
content: A Raspberry Pi could do it using OpenCV.Here's an idea: Use a Hall Effect based current sensor IC like the ACS712. (https://www.sparkfun.com/products/8882)That will give you a direct voltage output in relation to the current. Monitor it with the ADC of an MCUS or use a comparator to trip a TTL output. Boom, done.Sent from my Smartphone

author: conducteur
author_rank: Regular Contributor
timestamp: November 28, 2014, 05:58:08 pm
content: I do have a Raspberry Pi, but don't think that's a good solution. And the hall-sensor = expensive when you need 50 of them. (need 2 sensors for 1 track section: at the beginning and at the end (at least))

author: edavid
author_rank: Super Contributor
timestamp: November 28, 2014, 07:07:04 pm
content: Quote from: conducteur on November 28, 2014, 05:58:08 pmHe was proposing using a Hall current sensor, so you would only need one of them per section. I don't see why that's better than a resistor + diode though, unless it helps with the AC/DC level shift problem.Hall sensors cost about $0.50 each. What's your budget for the project? Do you already have metal wheels and brushes on all of your cars?

author: timb
author_rank: Super Contributor
timestamp: November 28, 2014, 08:31:23 pm
content: Well, the IC I linked (ACS712) can will convert 0 to 5A (AC or DC) to a 0 to 5V analog output (or a +-2.5V output at 2.5VCM if you need to sense the direction of the current). The advantage there is you get your 0.5A to 5A resolution without needing huge resistors on each car to load the rails down.The other idea that comes to mind is to to use a simple Hall Effect sensor (just a sensor, not the IC linked above) to detect when a train is passing by, assuming the wheels are metallic. You'd get a pulse as each wheel passed by. You could even place the sensor between the rails, in the middle of (or under) the track and attach metal coins or magnets to the bottom of each car and engine; this way you can count the cars by counting pulses on the output!You could do the same with IR using an IR TX/RX module. Place it under the track pointing straight up and paint a white mark on the bottoms of the cars/engines. You'll get a pulse as each goes overhead.(You could make a very small PCB that fits snugly between the rails, with plated pads on the sides so it would actually be self-powered! Use a small SMD IR LED and photo-diode plus a tiny op-amp and you'd be set.)Sent from my Smartphone