MRH

9-07-p84.jpg 

Read this issue!

Please post any comments or questions you have here.

Reply 0
vggrek

Why the lower voltage output

Why the lower voltage output is related with the sensitivity? The lower output voltage (when all the other parameters are constant) can't mean more sensitivity. The zero voltage is not readable.
Have in mind that the current at the output of the CT is proportional related to the number of turns of the signal conductor, proportional related to the current in the primary and inverted proportional to the turns of the CT. A  CT has to be always "shorted" with a resistor to act as CT, otherwise acts as a stepup transformer. 
https://www.electronics-tutorials.ws/transformer/current-transformer.html
/> Anyway the detection problem is a current sensing problem, that means the circuit has to give a readable output when the track of the block is bridged, when flows current in the track. The only thing I have to know is that the current flows, simply any current means the block is occupied. A simple comparator is enough. Also there are simple ways to hold the output up for a time even if the cars left the block. With an arduino is even more easy.
Another "problem" is when the bridging resistors on the track becomes a lot (a lot of axles with resistors) the current becomes bigger. The thought that the output has to be enough below the 5v with the upper number of resistor axles on the track, leads to have bigger axle resistors and consequently very low (and maybe not detectable) output when only one resistor bridges the the track. The Paisley's or Myler's haven't expensive parts and are quite good and the additional price of 4 resistors and a timer is 1-2$. Another option is  ACS712sensor with a comparator or opamp alogread (Hal sensor, input -10 A to 10A, output 0V to 5V from china for less than 2$) connected to the arduino. 

Reply 0
greg ciurpita gregc

circuit description ?

I don't understand why the article doesn't include the text describing how the circuit works (??).

Quote:
Why the lower voltage output is related with the sensitivity?

When the block is not occupied and no pulse are generated, the capacitor charges thru the pull-up resistor and is at it maximum voltage.

Since a DCC signal is constantly reversing polarity, each reversal of current causes the transformer to generate a pulse proportional to the change in current. Negative pulses flow thru the diode. Positive pulses flow thru the base-emitter path of the transistor causing it to conduct.   Current flowing thru the collector drains charge from the capacitor, reducing its voltage.

The transistor conducts during the fraction of time (~usec) that the pulse is above the base-emitter voltage threshold. The collector current is the base current multiplied by the beta value of the transistor.

Since a limited amount of charge can be drained during a single pulse, many pulses are needed to sufficiently reduce the capacitor value.  DCC produces a pulse approximately every 100 usec or 10,000/sec. But the capacitor is constantly being re-charged, the reduction in capacitor voltage depends on the current drawn thru the block and the size of the pulse.

in other words, the circuit recognizes that the block is occupied when the capacitor voltage is below the threshold of the digital input (see below).

 

The advantage of the NMRA detector circuit is that it provides power to the block through a bridge rectifier that creates a 1.4V (2 diode) drop and there is sufficient current to drive an LED in an optical detector.

 

The Paisley circuit uses the trigger and threshold inputs of the 556 to detect when the capacitor voltage is low and high. The 556 trigger and threshold inputs are comparators that switch when the trigger is less than 1/3 Vcc and threshold is above 2/3 Vcc. The 556 has both a common and open collector outputs. The 556 not used for debouncing.

What makes the "simple detector" simple is that is uses the pull-up resistor in the processor and the relatively high switching threshold of an Arduino, 2.4V as a high and 2.1V as a low.   Without an active component (i.e. 556) it requires no power connection.    but, too each his own

 

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 1
Neil Erickson NeilEr

NMRA detector circuit?

@Greg - Is that what this is called or different from the “simple detector”?

I have been collecting components for Chubb’s DCCOC but hope the output will allow an arduino to read and inform JMRI. My guess is that with either detector one must tell JMRI where it is and label the detector. A whole separate article may exist but I’m struggling with the basics of understanding components and finding the right parts to fit the boards. It is rewarding to learn new stuff so I plug along despite having a bunch of components that I may never need through order errors or guesses for comparability! 

So ... any pointers as to where to learn more about I/O with JMRI? This doesn’t really address the hardware:  http://www.jmri.org/help/en/html/tools/Sensors.shtml

Chubs Universal Interface or Dr. Geoff’s arduino interface? ( https://forum.mrhmag.com/post/sma29-jmri-turnout-channels-%E2%80%93-direct-jmri-to-arduino-communications-simple-support-for-lots-of-12210817)

Thanks for taking time to explain all this. Admittedly a novice here. 

Neil Erickson, Hawai’i 

My Blogs

Reply 0
greg ciurpita gregc

interfaces

i think you're asking about the interface between a detector and system using the block occupancy information

the NMRA detection circuit using the NEC 2506 has an active-low open-collector output.    Open collector outputs simply turn-on an output transistor to pull the output low.   The circuit it drives is responsible for providing a pull-up resistor.   Since the detector simply drives the output to ground, it can be compatible with circuits operating at different voltages.

it would be common for a block occupancy detector to have a TTL level output compatible with a processor or digital I/O card.    The output could be active high (~Vcc) or low (~ gnd).   Presumably the system (e.g. JMRI) can be configured to recognize a sensor input as active high or low.   An open-collector output can also be used with a pull-up resistor.

my understanding of Chubb's approach is to have I/O nodes distributed throughout the layout that provide inputs (e.g. block occupancy, turnout position) and output (e.g. signals, turnout route).    A block detector would need to be compatible with the I/O node hardware which may be a processor (e.g, PIC, Atmel/Arduino) or some I/O expander (e.g. MCP23017, 74LS165).

the simple detector is not standalone, the circuit doesn't include a resistor to charge the capacitor and doesn't provide a digital (binary) output.   Instead, it uses the pull-up resistor now common on most processor input circuits and relies that the switching thresholds of at least an Atmel/Arduino processor to detect when the capacitor is low enough indicating the block is occupied.

The simple detector may not be well suited for use with an MPC23017 because the pull-up is 100k and the low input voltage is 0.2V.   The 100k resistor means charge time for the capacitor will be longer and the low input voltage means the capacitor must be well discharged such that it's voltage is < 0.2V.   However, it could work, and because of the long charge time, the clear indication would be delayed.   (now I'm curious)

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
Ken Rice

Clever circuit

Nice detector circuit Greg.  I like that it’s so simple.

I’m having a little trouble thinking about your findings with the transformer.  I’d guess there are two factors at play - you get better coupling with more turns, and the ratio of the turn counts affects how much of a voltage pulse you get at the base of the transistor.  I’d guess that even with 6 turns on the track side (6:50) you’re still solidly in the territory where the better coupling counts more than the lower transistor base voltage.  I’d bet that if you went massively overboard and did 5000 turns on the track side to the 50 turns on the transistor side (100:1), it might have gone past the point of peak sensitivity.  Is that right, or is there more to it?

Reply 0
greg ciurpita gregc

it's a current, not voltage

it's really just half a circuit

A transistor amplifies the current thru it's base, not voltage.   The transistor base voltage is limited to Vbe.   The more current flowing thru the transistor, the more charge is drained from the capacitor.

you want to maximize current, not voltage, in the output pulse.   The output voltage is proportional to the number of turns on the secondary (coil) / primary (number of feeder loops).   The output current is the opposite, you want a coil with a smaller number of turns and a larger number of feeders.

increasing the number of times the feeder wire passes thru the coil increases sensitivity, this is consistent with increasing the current in the output pulse.

since I didn't have different types of coils to experiment with, but happened to have toroids, i made my own with a smaller number of windings to confirm my understanding.

Quote:
I’d guess that even with 6 turns on the track side (6:50) you’re still solidly in the territory where the better coupling counts more than the lower transistor base voltage.  I’d bet that if you went massively overboard and did 5000 turns on the track side to the 50 turns on the transistor side (100:1), it might have gone past the point of peak sensitivity.  Is that right, or is there more to it?

i don't know, which is part of the reason i built the circuit and tested it.

My data (see table in article) for the 50T coil suggests that each additional turn reduces the voltage by half, up to 4 turns.    The Vitec data shows a dramatic improvement with a 6th turn.   

I don't know enough to explain this.  Perhaps the transformer windings are impeding the DCC polarity reversals?

with respect to coupling, i will note that the feed must go thru the coil at least twice, creating a complete loop around the coil.

thanks for the questions, always help me understand things better

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
Raphael

Thanks for the description

Thanks for adding the circuit description in this comments, Greg. I really liked how you're using the arduino pull-up as the source of power.

One thing to note is the issue of ending the article with "once you have the signal in an arduino you're good to go". Although for some of us this is the "easy/fun" part to figure/tinker about, I tend to see this as the main issue for most people who just want a plug'n'play system. The next question is often "I was told to interface with JMRI but I have no idea how to do that nor even how to articulate the question". For this kind of person, I often tell them to go generic and stick with off-the-shelf commercial components. Sure it may look more expensive upfront but let them concentrate on whatever makes the hobby fun for them. 

 

Ralf~
[ web site ]

Reply 0
greg ciurpita gregc

DIYer vs off-the-self

Quote:
For this kind of person, I often tell them to go generic and stick with off-the-shelf commercial components. Sure it may look more expensive upfront but let them concentrate on whatever makes the hobby fun for them. 

agree.   there are several approaches for building a signaling, dispatching or CTC system:

  •  those that don't understand technology that well and must rely on off-the-self components
  •  those that prefer not to spend their time building components for such systems and prefer to buy off-the-self components
  •  those that understand technology and prefer to design/build their systems (for some, to save $$)

of course there are different types of DIYers (scratch builders):
 - electronics (including software)
 - hand laid track/turnouts
 - structures (including signals)
 - rolling stock
 - locomotives

scratch building has the benefits of saving money, building just what you need and the satisfaction developing new skills and building it yourself.    Of course, a layout is scratch built.

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
vggrek

Thank you Greg for the

Thank you Greg for the explanation. I have simulated all the circuits based on the CT's and I saw how they work under DCC pulse with a frequency 10~20kHz . I have fixed in my mind the sensitivity in relationship with the sensed current in the primary coil. I understand the sensitivity as the bigger single resistor sensed, because the bigger resistors have less power consumption. (a block occupied with axle resistors of 1k consume ~ 2 watt per meter of the block).
It wasn't clear to me what load you had on the rails, the 1kohm you mentioned? For the 1x1k(?)  resistor load it is weird  that no reacts even for 2 turns on vitec. The Talema as-103 has 300 turns with 280mH inductance and maybe would be more sensitive. Maybe the core of the vitec is smaller in diameter and therefore far from the primary turns. The primary inductance, approximatelly because of the wire used in primary and its distance from the core, is  (Lprimary/Lsecondary)=(turns of primary / turns secondary)^2.Even for a forth of the calculated value for the vitec the output voltage would have to be less than 3.4V. I have the feeling that the choice of a CT with less secondary turns may not leads to a bigger current and better response. I mean there are more factors like the design frequency range, saturation...?  A primary coil with more turns on a CT with bigger Lsec/(sec. turns), it seems a better solution.

Anyway, good job. 
PS I feel the need to add a linguistic link too. :> )  "Pragma" beside the use in C
http://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.04.0057:entry=pra=gma

 

Reply 0
jelnicky

Arduino Input

Greg, 

Thanks for pointing me to this article. It seems like an effective, cheap block detection sensor for an Arduino. Currently I am using CT coils and a 910 ohm "burden resistor" as my sensor. My circuit lacks the transistor, diode and cap. The issue I am having is my sensors are too sensitive. All the sensors are attached to feeders on the shared track bus, but are isolated with gaps in the rails. When one is sensing current in its block, the others next to it often go off as well. It was suggested to me to mulitplex the sensor signal and grounds to my sensors, so they are more isolated. I haven't tried this yet but will soon. Have you had any issues like this with your sensors? I'm trying to find a more robust design. 

Also, was this sensor intended to be used as an analog input or digital input? or either? 

Thanks, 

Justin

Reply 0
Jim at BSME

Sensors

Neil, I think you want the other article of Geoff's:  SMA28 JMRI Sensor Channels – Direct Arduino to JMRI Communications - Simple Support for Lots of Detectors

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
greg ciurpita gregc

analog/digital input and sensitivity

@justin   

if by analog, you mean DC, no.   the pulse transformers only work with DCC

 

re: sensitivity

i hadn't noticed any problems with occupied nearby blocks causing false detections.  of course you should keep the wires for different blocks separate from one another.   

Before the pandemic, i was working on someone else's layout using the full-featured NMRA detectors, trying to figure out why 2 out of ~30 always indicate occupied.    I had learned that C1 is needed, but that didn't fix the problem in the 2 detectors falsely indicating occupied.

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
jelnicky

Arduino Input

@gregc

 

I'll try building the circuit and see what happens. I'm excited to try it. 

Referring to my one of my original questions about the output of this block detector-I was wondering if the output of the sensor was intended to be connected to a digital pin on the Arduino, or an ADC pin (A0, A1..) 

Thanks, 

Justin

Reply 0
greg ciurpita gregc

connect output to digital pin

the capacitor voltage is expected to be either fully charged or discharged.   it takes longer to discharge with the pulse transformer than an opto, but should get close to zero, certainly < the 2.1 threshold of the digital I/O pin.

but you probably need to add software hysterisis to deal with glitches.   presumably this is cheaper than having a 555, less work to solder and less space. 

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
jelnicky

Not getting signal change on output

@gregc

I built this circuit as instructed this week and tested it out a few days ago. I also used the pullup resistor internal to the Arduino, which I found out has a value of 20K. I wasn't able to get a signal "LOW" on the output of the circuit. The CT sensor I used has 1000 winds, which I know isn't ideal. Could this be my issue? I thought the more winds  the CT sensor had, the more sensitive it was, but I'm not getting any change in output. I plan on buying some more with 50 turns if I have to. 

Thanks, 

Justin

Reply 0
Jim at BSME

Transformer

I'm sure Greg will give the explanation about transformer sensitivity, but has to do with the ratio of the turns between the primary and secondary, and the more turns of the primary (track feeder) the more current is induced in the secondary.

The original article used a 300 turn secondary and 4 - 6 turn primary (track feeder) at least that is the best I can tell from looking at his picture and a table of output voltage provided in the article. So that makes the ratio 1:75 - 1:50 to get that with a 1000 turn secondary you would need 13 to 20 turns on the primary (track feeder).

 

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
greg ciurpita gregc

current, Not voltage

on page 7 of the article i discuss building my own coil with only 50 turns.    i think (!) what may be important is to minimize the amount of wire and its resistance to maximize the current flow.   a transistor amplifies current and we want each pulse to bleed as much charge from the capacitor as possible.

also the higher the pull-up resistance the better.   less current is available to recharge the capacitor.

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
jelnicky

50 Turn CT

Thanks for the quick responses guys, I will pick up some 50 turn CT coils and try them out. There's no way i'm going to get more than 5 turns of track feeder in that little CT coil. I'm sure that's the issue. Everything else seems to be in place.

 

Justin

Reply 0
Jim at BSME

Voltage or Current

Just to be clear understand it is current we are concerned about and not the voltage. However, the table you created on page 7 of the article lists voltages and that is what I was referring to when I said 'table of output voltage provided in the article.'

- Jim B.
Baltimore Society of Model Engineers, Estd. 1932
O & HO Scale model railroading
Check out BSME on: FacebookInstagram
Reply 0
greg ciurpita gregc

.

yes jim.    detection is based on the capacitor voltage.    current thru the pull-up resistor adds charge to the capacitor increasing its voltage and every pulse, energizes the transistor to bleed off some charge.

i think the irony is that while lowering the turns ratio actually increases the current,  the transistor bleeds more current the longer the voltage across the base emitter junction exceeds 0.7V.    hence having a larger voltage is good and minimizing the amount of wire increases current.

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
jelnicky

50:1 turns ratio too sensitive?

Tonight I was able to get a 50:1 CT soldered up to the circuit, but now I have the opposite problem than I had before. Instead of getting no output change at all, the output seems to be too sensitive. Even just placing a loco on the track (anywhere on the layout) will trigger a occupied block. I did gap my block and check to see if it was isolated. This is a problem because once on the layout, because of the shared bus, the noise triggered a "LOW" anywhere on the layout. I also tried only 1 loop of bus wire around the coil, and even no loop at all, just straight through. Still was triggering and was too sensitive. Any suggestions to remedy this? could the only one be getting a 200-300 turn coil? 

 

Justin

Reply 0
greg ciurpita gregc

too sensitive

  • reduce the # of loops of track feeder
  • increase the size of the capacitor.
  • use a lower value external resistor

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
jelnicky

Lower Value Resistor

@gregc

Thanks, I'll try these.

By lower value external resistor, do you mean the pullup resistor? I am currently using the built in 20K pullup in the Arduino. 

 

Thanks,

Justin

Reply 0
greg ciurpita gregc

yes, lower external resistor

so that that capacitor get recharged faster.

so either a larger cap or lower resistance

greg - LaVale, MD     --   MRH Blogs --  Rocky Hill Website  -- Google Site

Reply 0
Reply