Model Train-related Notes Blog -- these are personal notes and musings on the subject of model train control, automation, electronics, or whatever I find interesting. I also have more posts in a blog dedicated to the maintenance of the Randall Museum Model Railroad.
2019-09-29 - NCE AIU and NCE EB1 Circuit Breakers
Category NCE
One issue I have on the Randall layout is that operators or automation sometimes short the layout. Then the NCE EB1 circuit breakers take over and of course shut down their corresponding power district. Then operators or staff ask me why things do not work, yet a lot of them fail to check the circuit breakers to see if they are shorting.
One idea I had a while ago was to use an NCE AIU01 to monitor the NCE EB1 circuit breakers. Then I could feed that into my automation software and get reporting of actual shorts right on my status web page.
The proposed solution is to use dual-channel optocouplers to connect the EB1 LED output to the AIU inputs.
Here are the details, as updated on 2020-02-04:
- HCPL2630/TLP2630/VO2630 dual-channel optocouplers.
- The NCE EB1 has a 4-position terminal. Positions 3 and 4 are designed to connect an external LED. According to the EB1 doc there’s already a 300Ω resistor, and it outputs 5 V, thus around 17 mA.
- The NCE AIU01 inputs are actually pull-ups, activated when driven to ground. This is a perfect match for the output of these optocouplers.
Details on the EB1:
- The EB1 doc indicates a LED (-) should be on terminal pos 4 (outer side) and thus logically the (+) on the inner terminal pos 3. Contrary to what the EB1 doc says, on the EB1 I took to experiment with, Terminal 3 (inner, lower) is LED -, and Terminal 4 (outer, lower) is LED +.
- The on-board LED and the external LED terminal are connected to a PIC 12F683 (pdf link) on Pin 7 (GP0). The on-board LED is connected between that same pin and Vdd (positive power supply) [Reminder: Vss=Ground, Vdd=+Voltage]. Thus keeping GP0 low would by default light up the LED, which seems to be the default behavior.
- EB1 LED is ON by default (no short) ⇒ Opto output = Low ⇒ AIU bit == 1.
- According to the EB1 doc: “300Ω 5 V” = 17 mA.
Details for the optocouplers:
- Toshiba TLP2630 (direct download datasheet) or Vishnay VO2630 (datasheet).
- IF max is 20 mA. Recommended input current is 5 ~ 6.3 mA..
- Experimentation shows that a 470Ω resistor worked well to activate the LED side of the optocoupler.
- The optocoupler output is an open-drain. In practice that means it needs to be pulled up to Vcc, and it is grounded when activated.
- Experimentation shows a pull-up of 1kΩ or 2.2kΩ worked well.
- The AIU has a 10kΩ pull-up on each input. My 2.2kΩ pull-up thus goes in parallel, and makes for an equivalent 1.8kΩ resistor. At 5V, that’s 2.7 mA. The datasheet recommends the output pull-up resistor to be in the 330-4.4kΩ range and a typical sinking current of 13 mA.
- Like the 6N137 (its single channel counterpart), the 2630 optocoupler works as an inverter, that is the output is low when the input is high.
Since the EB1 LED is on by default, the optocoupler output will be low by default, which is seen as a 1 by the AIU. My preference would be to have them reversed, that is I’d prefer the AIU input to be high by default to avoid sinking current through the optocoupler all the time.
With all this into account, the schematic is thus the following:
When there’s a short, the EB1 turns off the status LED, and thus the AIU input is read as a 0. However, being a self-reset device, the EB1 just keeps trying to re-apply power every few seconds, which makes its status LED blink briefly -- this has a nice side effect allowing for easier visual identification. Due to the NCE cab bus pathetic refresh rate for these AIU01 cards, there is a tiny possibility that each AIU read would be aligned on the time where the LED blinks, and thus the shorting status would be missed. This needs to be identified and tested first. If that’s an issue, it can be solved by just adding a capacitor on the output like I did to solve the missed button presses issue.
This is the 2630 optocoupler I plan to use (the prefix name depends on the supplier):
It’s also possible to use the 6N137 single-channel optocouplers instead, one per EB1 output to monitor.
Two EB1 are connected to each opto-coupler as follows:
- EB1 #1 terminal 4 (outer) = LED+ ⇒ 470Ω ⇒ Opto pin 1 // pin 7 ⇒ AIU pin 1
- EB1 #1 terminal 3 (inner) = LED- ⇒ Opto pin 2
- EB1 #2 terminal 4 (outer) = LED+ ⇒ 470Ω ⇒ Opto pin 4 // pin 6 ⇒ AIU pin 2
- EB1 #2 terminal 3 (inner) = LED- ⇒ Opto pin 3
- Opto pin 8 Vcc to AIU +5V from 7805
- Opto pin 5 GND to AIU GND
AIU01 address: 62
JMRI Address / Number = (AIU01 address - 1) * 16 + (AIU01 input - 1)
JMRI Address from 976 (62:1) up to 989 (62:14), included.
Mapping from NCE AIU to EB1 (or others):
JMRI address |
AIU pin |
EB1 |
Optocoupler |
976 |
1 |
P1 V1 |
O1 pin 1+2⇒7 |
977 |
2 |
P1 STKYD |
O1 pin 3+4⇒6 |
978 |
3 |
P2 V2 |
O2 pin 1+2⇒7 |
979 |
4 |
P2 NAPA |
O2 pin 3+4⇒6 |
980 |
5 |
P2 TOWN LODI |
O3 pin 1+2⇒7 |
981 |
6 |
P2 FAIRFIELD (*) |
O3 pin 3+4⇒6 |
982 |
7 |
P3 MTN |
O4 pin 1+2⇒7 |
983 |
8 |
P3 BRN RCH-2 |
O4 pin 3+4⇒6 |
984 |
9 |
P4 MTN-2 |
O5 pin 1+2⇒7 |
985 |
10 |
P4 BRPORT |
O5 pin 3+4⇒6 |
986 |
11 |
P4 SIA RND |
O6 pin 1+2⇒7 |
987 |
12 |
P4 STK STN (*) |
O6 pin 3+4⇒6 |
988 |
13 |
O7 pin 1+2⇒7 |
|
989 |
14 |
O7 pin 3+4⇒6 |
The AIU has 2 terminals of 8 positions each (1 GND + 7 inputs). I’d like to find 7 or 8-wire ribbon cables and use that to connect a little board containing all the optocouplers to the AIU and attach them both together. I should look at old floppy or ATA ribbon cables that I have around.
Originally I was going to use AIU inputs 13 and 14 to monitor mains voltage. One for the layout mains, and the other for the DCC switch. Instantly that reminded me of the is_computer_on() API joke… since this AIU will be read by the PC that is powered by the DCC switch, there’s little point. They would always be on. Still I should wire optocoupler #7 in case I want to add 2 inputs later.
(*) EB1 for P2 Fairfield does not exist yet, and my original plan was to mount it next to Fairfield, not by the DCC command station. I decided to place it with the other EB1s for consistency.
(*) EB1 for P4 Stockton Station does not exist yet, however the plan is to have it with the other EB1s.