Welcome to the forum   
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Share
Options
View
Go to last post in this topic Go to first unread post in this topic
Offline GaryTrooper  
#1 Posted : 03 November 2018 05:46:45(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
I do know Marklin M track solenoids can be operated on DC. I just felt like driving them with AC. This was the first successful trial.

G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 11 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#2 Posted : 22 November 2018 03:56:23(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
20181121_174612~2.jpg

Arduino Due control of 13 switches and 12 Signals.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 9 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#3 Posted : 26 November 2018 00:49:46(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho


Control bugs worked out today which includes a reset button for setting the switches and signals into the "all trains parked" positions.




G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 5 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#4 Posted : 30 November 2018 04:14:11(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho




Refining the controls with the addition of "run" and "park" routines for 12 sidings. The next step will be to add feedback so the trains can consecutively trigger each other.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 2 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#5 Posted : 09 December 2018 18:14:26(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Today the AC to DC optoisolator circuit bugs were worked between the Marklin ~17 VAC input and the Arduino analog inputs. I chose to use the analog inputs to maximize the digital in/out pins for output control. Now the system is capable of feedback for knowing where the trains are.

If anyone wants to see the Arduino code or the Processing code let me know and I'll post it. I'm sure there are skilled programmers out there who could greatly streamline my patchwork of simple code routines.

G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 3 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#6 Posted : 26 January 2019 16:34:33(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
velpicjoincollage20190126_082354.jpg

I finally added feedback sensors. Now the trains can sequentially trigger each other to run.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 4 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#7 Posted : 29 January 2019 02:21:31(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho


Coded a few sequential trains. Several more to go. Soon it will be time to continue on level two.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 4 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#8 Posted : 18 February 2019 23:11:08(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho


12 train control with sequential operation maxes out the Arduino Due. The 12 train sequence is now becoming more and more reliable. Just a few more grade and sensor tweaks are needed before moving up a level.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline DaleSchultz  
#9 Posted : 19 February 2019 00:38:11(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
so you are controlling the turnouts, but are the trains being controlled digitally or are you switching track current on and off using the Duo?

For the turnouts are you using MOSFETs or simple relays?
Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
Offline GaryTrooper  
#10 Posted : 19 February 2019 02:42:59(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: DaleSchultz Go to Quoted Post
so you are controlling the turnouts, but are the trains being controlled digitally or are you switching track current on and off using the Duo?

For the turnouts are you using MOSFETs or simple relays?



I'm not controlling track voltage with the Arduino. Only the signals and turnouts. I'm running the locomotives using analog, directly from the transformers. Some day I may convert the locomotives to digital but there are many and I want to get the layout built up.

The turnouts and signals are AC driven using TRIACs controled by the Arduino.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 2 users liked this useful post by GaryTrooper
Offline GaryTrooper  
#11 Posted : 24 March 2019 22:08:11(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
velpicjoincollage20190324_125934.jpg

I've been replacing the homemade track sensors with the old style contact tracks. The old style contact track is a much better solution.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline DaleSchultz  
#12 Posted : 10 August 2019 21:50:08(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
what optoisolator are you using ?
would you share your circuit showing track switching -> to GPIO pin input?
Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
Offline GaryTrooper  
#13 Posted : 11 August 2019 03:19:22(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: DaleSchultz Go to Quoted Post
what optoisolator are you using ?
would you share your circuit showing track switching -> to GPIO pin input?


Here are photos of the sensor circuit, data, and parts. Take a look. It should describe the circuit pretty well. Let me know if you have any questions. I'll try to answer as best I can.

Screenshot_20190810-190919_Drive~2.jpg

Screenshot_20190810-183350_Photos~2.jpg

20190810_182427~2.jpg

Regards,

Gary
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline DaleSchultz  
#14 Posted : 11 August 2019 03:33:42(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
great info, thanks, yes a couple of questions...

The data sheet says to install a 0.1μF capacitor between pins 5 and 8. I don't see it on your diagram - why? (You have 10μF between 5 and 6 though)

Why not invert the signal in the code instead of inverting the signal with a second chip? (Perhaps I don't understand what it does.)

Your contact track puzzles me a bit. It shows AC power going to the inputs of the optocoupler, but normally we isolate one side of a section of the running rail and simply ground that by running an axle onto the section, so I am looking to detect connection to ground. I guess I could simply run a few volts to ground to create enough current in the input side of the opto.

Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
Offline GaryTrooper  
#15 Posted : 11 August 2019 04:01:58(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: DaleSchultz Go to Quoted Post
great info, thanks, yes a couple of questions...

The data sheet says to install a 0.1μF capacitor between pins 5 and 8. I don't see it on your diagram - why? (You have 10μF between 5 and 6 though)

Why not invert the signal in the code instead of inverting the signal with a second chip? (Perhaps I don't understand what it does.)

Your contact track puzzles me a bit. It shows AC power going to the inputs of the optocoupler, but normally we isolate one side of a section of the running rail and simply ground that by running an axle onto the section, so I am looking to detect connection to ground. I guess I could simply run a few volts to ground to create enough current in the input side of the opto.



I found that a 10 uF capacitors works better than 0.1 uF. It provides better debounce (for lack of a better term) due to less sensitivity. The circuit works if the capacitor is connected across pins 5 and 6 or across pins 5 and 8. It was easier to build the homemade circuit board using pins 5 and 6.

It is possible to invert the logic in code rather than a chip yes, but the output of the optoisolator will not drive the input of the Arduino. I needed a chip to drive the input of the Arduino. A hex inverter has the most number of logic gates in one chip.

The old style contact tract is shown in the schematic as a switch. The contact track does complete the AC portion of the circuit when the wheels and axle roll over the contact track, making a connection between the insulated rail and the non-insulated rail. I do generally think of the M track metal base as a "ground bus" even though its AC.

Edited by user 11 August 2019 07:39:48(UTC)  | Reason: Not specified

G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline tiono  
#16 Posted : 11 August 2019 13:34:07(UTC)
tiono

United States   
Joined: 09/02/2010(UTC)
Posts: 234
Originally Posted by: GaryTrooper Go to Quoted Post

It is possible to invert the logic in code rather than a chip yes, but the output of the optoisolator will not drive the input of the Arduino. I needed a chip to drive the input of the Arduino. A hex inverter has the most number of logic gates in one chip.


According to datasheet; the optoisolator use open-collector output.
It can drive the input of Arduino directly without additional chip. Simply by configuring the input to use internal pull-up resistor.
Inside the Arduino setup, use: pinMode( input_pin, INPUT_PULLUP);


thanks 1 user liked this useful post by tiono
Offline GaryTrooper  
#17 Posted : 11 August 2019 14:30:40(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Thanks, I'll try pinMode( input_pin, INPUT_PULLUP) on the next project.

Gary
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline GaryTrooper  
#18 Posted : 09 December 2019 00:57:30(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: tiono Go to Quoted Post
Originally Posted by: GaryTrooper Go to Quoted Post

It is possible to invert the logic in code rather than a chip yes, but the output of the optoisolator will not drive the input of the Arduino. I needed a chip to drive the input of the Arduino. A hex inverter has the most number of logic gates in one chip.


According to datasheet; the optoisolator use open-collector output.
It can drive the input of Arduino directly without additional chip. Simply by configuring the input to use internal pull-up resistor.
Inside the Arduino setup, use: pinMode( input_pin, INPUT_PULLUP);




So I'm back into the Arduio to add some controls to the layout and I realized that I didn't give complete information during the last conversation. All of the input signals are employing the analog input pins as all the digital pins are being used for output signals. That's why the use of the gated chip before the input pins. Is there code for pulling up, or down an analog input pin? I'm guessing no as that would defeat the purpose of the analog input pin.

Thanks,

Gary
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline Holz1  
#19 Posted : 08 January 2020 19:57:11(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: GaryTrooper Go to Quoted Post
I do know Marklin M track solenoids can be operated on DC. I just felt like driving them with AC. This was the first successful trial. 12 volt



Hello Gary
I am interested in the way you drive the turnouts. I am now in my 3rd month of exploring the web how to switch the turnouts with an arduino uno. But I am on a wrong end.

I was able to switch the turnouts :

1. semi digital by means of ir gates through an opto coupler to be switched by a TIP120, 12 volt DC and through a diode and 2200uF cap to rectify the Ac to ACDC current

2. ir gates to be switched by arduino and a bistable 5 volts dc relay for the feedback of the tunrout, with the proper sketch to switch the 2 IR gates and read the the signal

3. The last fase I have built were various switches with different opto couplers
7 volt input with button to switch optocoupler ( dc isolated from rest of the circuit) to an array 2803 darlington to be switched by the optocoupler output and the output of the 2803 to the blue connections of the Marklin turnout. This works fine, however!!!

I am not able to write the correct lines
for the sketch for arduino in which the arduino receives the input signal of the IR gates and then Output to switch the turnouts. Is it possible for you to send me the electronic scheme/layout of the circuit you have used and hopefully you will include the Arduino sketch.

I can also send you some circuits which I use. I tried to include some sketches but this site does not accept INO and TinyCad enclosures
Thanx in advance
Henry
Offline GaryTrooper  
#20 Posted : 08 January 2020 20:54:59(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: Holz1 Go to Quoted Post


Hello Gary
I am interested in the way you drive the turnouts. I am now in my 3rd month of exploring the web how to switch the turnouts with an arduino uno. But I am on a wrong end.

I was able to switch the turnouts :

1. semi digital by means of ir gates through an opto coupler to be switched by a TIP120, 12 volt DC and through a diode and 2200uF cap to rectify the Ac to ACDC current

2. ir gates to be switched by arduino and a bistable 5 volts dc relay for the feedback of the tunrout, with the proper sketch to switch the 2 IR gates and read the the signal

3. The last fase I have built were various switches with different opto couplers
7 volt input with button to switch optocoupler ( dc isolated from rest of the circuit) to an array 2803 darlington to be switched by the optocoupler output and the output of the 2803 to the blue connections of the Marklin turnout. This works fine, however!!!

I am not able to write the correct lines
for the sketch for arduino in which the arduino receives the input signal of the IR gates and then Output to switch the turnouts. Is it possible for you to send me the electronic scheme/layout of the circuit you have used and hopefully you will include the Arduino sketch.

I can also send you some circuits which I use. I tried to include some sketches but this site does not accept INO and TinyCad enclosures
Thanx in advance
Henry



I am using an AC optoisolator an a TRIAC from Radio Shack. If you need lots of TRIACs you can get them in bulk from digikey.

I can draw out the circuit for you this weekend.

The optoisolator replaces the switch in the TRIAC schematic.

Screenshot_20200108-124718_Write on PDF.jpgScreenshot_20200108-125332_Photos.jpg




G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline DaleSchultz  
#21 Posted : 08 January 2020 21:44:29(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
Using a triac and opto isolator seems to be an expensive route (but certainly robust looking)

Tiono (from this forum) kindly send me his diagram for switching turnouts...

74491_driver.png

His design uses 6 resistors, two transistors and two diodes for each turnout.

I can get 8 outputs from an ESP8266 essentially creating a K83 using 4 copies of his diagram, but I have not yet tried his circuit.
Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
Offline GaryTrooper  
#22 Posted : 08 January 2020 21:56:04(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: DaleSchultz Go to Quoted Post
Using a triac and opto isolator seems to be an expensive route (but certainly robust looking)

Tiono (from this forum) kindly send me his diagram for switching turnouts...

74491_driver.png

His design uses 6 resistors, two transistors and two diodes for each turnout.

I can get outputs from an ESP8266 essentially creating a K83 using 4 copies of his diagram, but I have not yet tried his circuit.




What is the purpose of the inputs to the Arduino? Is that for feedback to know that Arduino output has gone high?
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline DaleSchultz  
#23 Posted : 08 January 2020 21:58:31(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
yes, he get confirmation that it has triggered. I would not bother as it is only on the electrical side, one still does not know that the mechanism threw...

so in fact those 4 resistors are not needed....
Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
Offline GaryTrooper  
#24 Posted : 09 January 2020 01:47:23(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: DaleSchultz Go to Quoted Post
yes, he get confirmation that it has triggered. I would not bother as it is only on the electrical side, one still does not know that the mechanism threw...

so in fact those 4 resistors are not needed....


Well here is my Arduino code. Most of the control code is in the Processing code and the Arduino is just passing control bits between the electronics and the Processing software. I am not using electrical feedback to know when the Arduino output has gone high. Maybe this will help. Of course the copy paste code looses all the forming.Blink

int Val;
int myPins[] = {3, 2, 5, 4, 6, 7, 8, 9, 11, 10, 13, 12, 21, 20, 22, 23, 24, 25, 15, 14, 16, 17, 19, 18, 51, 50, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 49, 48, 52, 53};
// switch number| 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
// signal number | 5(34) | 9(36) | 10(37)| 11(38)| 7(39) | 12(40)| 13(41)| 14(42)| 15(43)| 16(44)| 17(45)| 18(46)| 52 and 53 = ramp speed
int n = 52; // array size
int ind[52];
String Arraydata[52];
int Trigger[51];
int Triggered = 0;
String readString; //main captured String
int Waiting = 0;
int Timer[3] = {0, 0, 0}; // Timer for loop time length, three elements declared for some Arduino thing
int MaxL = 20; // 32766 Maximum time Delay for Arduino hardware
int switchstate;
int sensorValue[12];

void setup() {
for (int i = 0; i < n; i++) {
pinMode(myPins[i], OUTPUT); // Set pin as OUTPUT
}
Serial.begin(9600);
establishContact(); // send a byte to establish contact until receiver responds
}

void loop()
{
for (int i = 54; i < 66; i++) {
sensorValue[i - 54] = analogRead(i);
}


if (Serial.available() > 0) { // If data is available to read,

char c = Serial.read(); //gets one byte from serial buffer
if (c == '*') {
Triggered = 1;
Waiting = 0;
//Serial.print("captured String is : ");
//Serial.println(readString); //prints string to serial port out

for (int i = 0; i < n ; i++) {
if (i == 0) {
ind[i] = readString.indexOf(',');
Arraydata[i] = readString.substring(i, ind[i]);
} else if (i > 0 && i < n) { // - 1) {
ind[i] = readString.indexOf(',', ind[i - 1] + 1 );
Arraydata[i] = readString.substring(ind[i - 1] + 1, ind[i]);
} else if (i == n - 1) { //if (i == n - 1) {
ind[i] = readString.indexOf(',', ind[i - 1] + 1 );
Arraydata[i] = readString.substring(ind[i - 1], ind[i]);
}
if (Triggered == 1) {
Trigger[i] = Arraydata[i].toInt();
}
Arraydata[i] = "";
}

for (int i = 0; i < n; i++) {
if (Trigger[i] == 1) {
digitalWrite(myPins[i], HIGH);
Trigger[i] = 0;
}
}

readString = "";

}
else {
readString += c; //makes the string readString
}

//delay(5);
}
else {

for (int i = 0; i < 12; i++) {
if (sensorValue[i] < 900) { // was 500. uped it to 900 for false trigger security
sensorValue[i] = 0;
} else {
sensorValue[i] = 1;
}
Serial.print(sensorValue[i]);
}
if (Waiting == 0) {

//Serial.println("Waiting for Data"); //send back to processing
Waiting = 1;
}
Serial.println("");
delay(5);

}

if (Triggered == 1) {
Timer[1] = Timer[1] + 1;
if (Timer[1] > MaxL) {
Timer[1] = 0;
Timer[2] = 1;
}
if (Timer[2] == 1) {
for (int i = 0; i < n; i++) {
Trigger[i] = 0;
digitalWrite(myPins[i], LOW);
}
for (int i = 0; i < n; i++) {
Trigger[i] = 0;
}
Timer[2] = 0;
Triggered = 0;

}
}

}

void establishContact() {
while (Serial.available() <= 0) {
Serial.println("A"); // send a capital A
delay(50);
}
}
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline GaryTrooper  
#25 Posted : 12 January 2020 23:08:46(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Here is the AC TRIAC driver circuit schematic I am using.

20200112_150340~2.jpg
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 2 users liked this useful post by GaryTrooper
Offline Holz1  
#26 Posted : 14 January 2020 10:13:54(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: GaryTrooper Go to Quoted Post
Here is the AC TRIAC driver circuit schematic I am using.

20200112_150340~2.jpg


BigGrin
Thanx very much. I am going to build this circuit (after having obtained the components) and I will let you know in due course.

I have built a circuit using CNY17 OptoCouplers and TIP120 Darlington NPN.
I am using 2 INFRARED gates, which are the INPUTs for the ARDUINO UNO.

The Arduino output will trigger the optocouplers and finally the Marklin M electric turnouts.
The next problem is programming the Arduino sketch and as I am a beginner you will certainly know what the problems are.

I am enclosing a file containing the drawing of the afore mentioned circuit and I hope I have contributed to your webpage and further expansion of knowledge and hobby

Regards
Henry

Marklin M turnout switched by Arduino CNY17 TIP120.odt (84kb) downloaded 53 time(s).
Offline GaryTrooper  
#27 Posted : 14 January 2020 15:50:12(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: Holz1 Go to Quoted Post
[

I am enclosing a file containing the drawing of the afore mentioned circuit and I hope I have contributed to your webpage and further expansion of knowledge and hobby

Regards
Henry

Marklin M turnout switched by Arduino CNY17 TIP120.odt (84kb) downloaded 53 time(s).



Unfortunately I am unable to see the photo of the schematic imbedded in the file.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline Holz1  
#28 Posted : 15 January 2020 09:53:45(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: Holz1 Go to Quoted Post
[

I am enclosing a file containing the drawing of the afore mentioned circuit and I hope I have contributed to your webpage and further expansion of knowledge and hobby

Regards
Henry

Marklin M turnout switched by Arduino CNY17 TIP120.odt (84kb) downloaded 53 time(s).



Unfortunately I am unable to see the photo of the schematic imbedded in the file.


The enclosed file is an odt/Word file, written with OpenOffice 4.1.6 edition.
When I click the button the document is downloaded and can be opened with OpenOffice or with Word Microsoft

rgds
Henry
Offline mario54i  
#29 Posted : 15 January 2020 10:22:12(UTC)
mario54i

Italy   
Joined: 28/03/2007(UTC)
Posts: 283
Location: Torino,
I open it with Word13 and I don't see the picture, only text
regards
Offline Holz1  
#30 Posted : 15 January 2020 11:14:17(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: mario54i Go to Quoted Post
I open it with Word13 and I don't see the picture, only text
regards


Okè I understand the problem.
I enclose the pdf file of the circuit. Upon checking the values of the different components, I saw I have made some mistakes in calculating the forward current and the respective value of the resistors. So please recalulate the values before installing the module on your Arduino or Marklin M turnout switched by Arduino CNY17 TIP120 (1).pdf (153kb) downloaded 53 time(s).Micro uA
thanks 1 user liked this useful post by Holz1
Offline Holz1  
#31 Posted : 19 January 2020 17:22:01(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: GaryTrooper Go to Quoted Post
I do know Marklin M track solenoids can be operated on DC. I just felt like driving them with AC. This was the first successful trial.



Good afternoon

As I already indicated my knowledge of programming with ARDUINo is nill.
I have made a sketch for switching a MArklin M electric turnout (double coils AC) by means of 2 infrared gates, 1 bistable HONGFA relay for indication of turnout position, and/or separate leds (on a breadboard) . I tried to use state change lines as you will see in the enclosed sketch.

When all is coupled, the IR gate1 wil switch the turnout1 and when passing ir gate 2 will switch back . After that nothong happens further.

Can you help with the missing parts INFRARED GATES switching Marklin Turnouts 19 jan 2020.pdf (46kb) downloaded 63 time(s).

Regards Henry
The Netherlands
Offline GaryTrooper  
#32 Posted : 19 January 2020 23:58:38(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: Holz1 Go to Quoted Post


Good afternoon

As I already indicated my knowledge of programming with ARDUINo is nill.
I have made a sketch for switching a MArklin M electric turnout (double coils AC) by means of 2 infrared gates, 1 bistable HONGFA relay for indication of turnout position, and/or separate leds (on a breadboard) . I tried to use state change lines as you will see in the enclosed sketch.

When all is coupled, the IR gate1 wil switch the turnout1 and when passing ir gate 2 will switch back . After that nothong happens further.

Can you help with the missing parts INFRARED GATES switching Marklin Turnouts 19 jan 2020.pdf (46kb) downloaded 63 time(s).

Regards Henry
The Netherlands


First thing. Can you make your physical circuit work to switch the track without the Arduino? What I mean is if you apply 5 volts to where the Arduino output pins 8 or 9 would be connected, does the track switch between straight and bending and back?

It is going to take me a little while to get through your code.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline GaryTrooper  
#33 Posted : 20 January 2020 00:36:57(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: Holz1 Go to Quoted Post


Good afternoon

As I already indicated my knowledge of programming with ARDUINo is nill.
I have made a sketch for switching a MArklin M electric turnout (double coils AC) by means of 2 infrared gates, 1 bistable HONGFA relay for indication of turnout position, and/or separate leds (on a breadboard) . I tried to use state change lines as you will see in the enclosed sketch.

When all is coupled, the IR gate1 wil switch the turnout1 and when passing ir gate 2 will switch back . After that nothong happens further.

Can you help with the missing parts INFRARED GATES switching Marklin Turnouts 19 jan 2020.pdf (46kb) downloaded 63 time(s).

Regards Henry
The Netherlands


First thing. Can you make your physical circuit work to switch the track without the Arduino? What I mean is if you apply 5 volts to where the Arduino output pins 8 or 9 would be connected, does the track switch between straight and bending and back?

It is going to take me a little while to get through your code.


I didn't go through the logic of your code but I did notice the IF statement brackets were out of alignment. I realigned the IF statement brackets and got the code to compile. See if this gets you anywhere. If not I would have to build a similar type test circuit.

/*Forum name Holz1
Author: Henry The Netherlands 19th January 2020
INFRARED GATES are switching Marklin M electric TURNOUTS (AC Double COIL) by means of a module based on Opto Couplers and Darlington NPN transistor. A separate
HONGFA //BiStable Relay 12V-DC, LEDs (RED and Green) can be turned on for indication of the turnout position.

The SKETCH is as follows:
*/

//Declaration of the 2 INFRARED Sensor Gates
const int IRS1 = 6; // de (INFRARED Gate) INFRAROOD sluis 1(IRS1) is op pin 6 PWM van de Arduino aangesloten
const int IRS2 = 7; // de (INFRARED Gate) INFRAROOD sluis 2 (IRS2)is op pin 7 PWM van de Arduino aangesloten

// Declaration of the IR sensor states
int IRsensorState1 = 0; // de huidige (present state) status van IRS 1 wordt bewaard
int IRsensorState2 = 0; //de huidige (present state)status van IRS 2 wordt bewaard

// Declaration of the LAST state of the LAST IR states
int lastSensorState1 = 0; // de (previous state) vorige status van de IRSluis 1
int lastSensorState2 = 0; // de (previous state) vorige status van de IRSluis 2

// Declaration of the HONGFA BI-STABLE relay for LED indication of turnout position: LED RED (BENDING) and LED GREEN (STRAIGHT)
#define relais1 2 // PWM pin 2 van de Arduino wordt op het relais pole 6 aangesloten
#define relais2 3 // PWM pin 3 van de Arduino wordt op het relais pole 7 aangesloten

// Separate LEDs can be installed on pin 11 (RED) en 12 (GREEN)
// The Marklin Turnouts are declared
#define Wissel_1 8 //Digitale pin 8 wordt op Märklin Wissel 1 aangesloten en is OUTPUT
#define Wissel_2 9 //Digitale pin 9 wordt op Märklin Wissel 2 aangesloten en is OUTPUT
#define RELAY_TIME_MS 150 // The time to switch is milliseconds for switching the
//MARKLIN Double AC COIL

void setup() {
// The IR gates are declared as INPUT /dit zijn de Infrarood lichtsluizen
pinMode(IRS1, INPUT); // IR sluis 1 is op input PWM pin 6 aangesloten
pinMode(IRS2, INPUT); // IR sluis 2 is op input PWM pin 7 aangesloten

// The MÄRKLIN TURNOUTS are declared as OUTPUT
pinMode(Wissel_1, OUTPUT); // Pin 8 schakelt Märklin Wissel 1 rechtdoor
pinMode(Wissel_2, OUTPUT); // Pin 9 schakelt Märklin Wissel 2 afbuigend

// The HONGFA relay is declared as OUTPUT and switches Green LED or RED LED /dit is bistabliele relais voor wisselstand terugmelding
pinMode(relais1, OUTPUT); // Wanneer IRS1 wordt gepasseerd, schakelt het relais1 op rood
pinMode(relais2, OUTPUT); // Wanneer IRS2 wordt gepasseerd, schakelt het relais2 op blauw
}

void loop() {

// The signal of the IR Sensors are read / het signaal van de IR sluizen wordt gelezen
int readsen1 = digitalRead (IRS1);
int readsen2 = digitalRead (IRS2);
IRsensorState1 = digitalRead (IRS1); // The IR sensor states are read for recovery and
//comparison of the last IR states
IRsensorState2 = digitalRead (IRS2);
if (readsen1 == HIGH && readsen2 == LOW) { // If IRS1 is HIGH and the IR Gate 2 is NOT
if (IRsensorState1 != lastSensorState1) { // ????????
digitalWrite(Wissel_1, HIGH); //Turnout 1 is switched / De Märklin wissel 1 schakelt naar //afbuigen
delay(RELAY_TIME_MS);
}
// save SensorState for next comparison: //???????????

lastSensorState1 = IRsensorState1; // ????????


// LED RED (BENDING) and LED GREEN (STRAIGHT)/ deze leds kunnen via pin 11 en 12 //apart worden aangesloten
digitalWrite(11, HIGH); // The Turnout position leds are switched through the HONGFA relay
digitalWrite(12, LOW); //digitalWrite zet led aan en brandt, analogWrite blijft led uit

// When The Turnout 1 is switched the HONGFA relay will switch the RED LED light to Bending/het relais ontvangt signaal en wordt geschakeld
digitalWrite(relais1, HIGH);
// The TURNOUT will be switch to BENDING/ De Märklin wissel 1 wordt geschakeld
digitalWrite(Wissel_1, HIGH); //Turnout 1 is switched De Märklin wissel 1 schakelt naar //afbuigen
delay(RELAY_TIME_MS);
digitalWrite(relais2, LOW); //????????
delay(RELAY_TIME_MS);
}


if (readsen2 == HIGH && readsen1 == LOW ) {
if (IRsensorState2 != lastSensorState2) {
digitalWrite(Wissel_2, HIGH); //The TURNOUT 2 is switched when the IRS2 is passed/ De
//Märklin wissel 2 schakelt naar afbuigen
delay(RELAY_TIME_MS);
}

// save SensorState for next comparison: lastSensorState2 = IRsensorState2; //???????????
// LED RED (BENDING) and LED GREEN (STRAIGHT)/deze leds kunnen via pin 11 en 12
//apart worden aangesloten
digitalWrite(11, LOW); // de IR sluis niet wordt gepasseerd brandt LED baanvak vrij
digitalWrite(12, HIGH); // de bezet melding is uit
digitalWrite(relais2, HIGH); // The Turnout position leds are switched through the HONGFA

//relay/ het relais schakelt het baanvak vrij in: de groene led brandt
delay(RELAY_TIME_MS);
digitalWrite(Wissel_2, HIGH); // The Turnout is switched to STRAIGHT /De Märklin wissel

//2 schakelt naar rechtdoor
delay(RELAY_TIME_MS);
digitalWrite(Wissel_1, LOW);
delay(RELAY_TIME_MS);
digitalWrite(relais1, LOW); // The HONGFA relay is switched : GREEN LED is on! /het relais
//schakelt de bezetmelding uit: de rode led is uit
}
}
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline Holz1  
#34 Posted : 20 January 2020 10:07:29(UTC)
Holz1

Netherlands   
Joined: 08/01/2020(UTC)
Posts: 12
Location: Zuid-Holland, Den Haag
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: Holz1 Go to Quoted Post


Good afternoon

As I already indicated my knowledge of programming with ARDUINo is nill.
I have made a sketch for switching a MArklin M electric turnout (double coils AC) by means of 2 infrared gates, 1 bistable HONGFA relay for indication of turnout position, and/or separate leds (on a breadboard) . I tried to use state change lines as you will see in the enclosed sketch.

When all is coupled, the IR gate1 wil switch the turnout1 and when passing ir gate 2 will switch back . After that nothong happens further.

Can you help with the missing parts INFRARED GATES switching Marklin Turnouts 19 jan 2020.pdf (46kb) downloaded 63 time(s).

Regards Henry
The Netherlands


First thing. Can you make your physical circuit work to switch the track without the Arduino? What I mean is if you apply 5 volts to where the Arduino output pins 8 or 9 would be connected, does the track switch between straight and bending and back?

It is going to take me a little while to get through your code.


Good morning!
Thanks for the reply. I made this module also for switching turnouts without the Arduino. 1 gate is passed , turnout switches. 2nd gate is passed, turnout switches back. The module can also be operated for 2 or more turnouts with 3 ,4 or 5 IR gates and can also be switched at the same time however the ELCo value must be 4700uF.

Back to Arduino. I tried to switch the turnout by buttons attached to the Arduino and turnouts are functioning well. They are switching back and forth.
So technically and electrically the button signals are coming through because the turnouts are switching.

As indicated above, switching with ARDUINO by means of the IR gates, the first pass IR gate1 the turnout switches and the 2nd pass IR gate 2 the turnout switches back and then all is stopped when to pass IR gate 1 again, I hear the coil wants to do something but it won't move.

Yesterday evening I tried another sketch for switching 2 IR gates and I noticed this sketch is using "Else if" statements. So I will try this sketch in my program.
I will keep you informed
Greetings Henry


thanks 1 user liked this useful post by Holz1
Offline mfaris01  
#35 Posted : 12 March 2020 15:27:18(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
Hi guys,

I'm new here although I've been a Marklin advocate for more than 50 years. I'm strictly old school, M-track, analog, AC. I live in China and so obtaining stuff is either very expensive or not feasible due to shipping costs. I have no signals or connect tracks and being that most of the worlds electronic components are made here, they are very very cheap to buy, I decided to just make my own.

I was interested in arduino and after reading this thread, I ordered a nano to arrive in a couple of days. Luckily, I teach C/C++ in a local university. I decided to try using IR for train sensing and wondered how you use the sensors on your layouts. I did some experimenting using some 3mm LEDs as an esthetic test and it came out pretty good. I used the existing screw hole in the M-track and then drilled it out to 3.2mm. I added an additional hole on the other side of the center rail. For testing purposes, I used 3mm green LEDs just to see how it looked. My IRs will also be arriving shortly. I checked for clearance, whether the shoe would be hindered, how much they stuck out of the track, etc. I added a piece of electrical tape to the bottom of the track to help with the reflectivity of the underside of the M-track. Looks pretty good to me. I plan on gluing a piece of foil on the bottom of the locomotive either in the front or the back to trigger the IRs.

I plan to try out Holz's code as it looks pretty solid and I'm interested in expanding it to include turnout controls.

What do you guys think?

Thanks for the feedback
Michael in Tianjin, China.

IMG_5523.jpgIMG_5525.jpgIMG_5521.jpgIMG_5522.jpgIMG_5519.jpgIMG_5517.jpgIMG_5515.jpg
thanks 3 users liked this useful post by mfaris01
Offline JohnjeanB  
#36 Posted : 12 March 2020 16:03:17(UTC)
JohnjeanB

France   
Joined: 04/02/2011(UTC)
Posts: 3,083
Location: Paris, France
Hi Michael and welcome to the forum.
Jean
Offline mfaris01  
#37 Posted : 12 March 2020 16:13:33(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
Thanks Jean!
Offline GaryTrooper  
#38 Posted : 13 March 2020 05:21:04(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: mfaris01 Go to Quoted Post
Hi guys,


I plan to try out Holz's code as it looks pretty solid and I'm interested in expanding it to include turnout controls.

What do you guys think?



Looks interesting. I use IR sensors on the N scale layout and I use contact tracks for sensors on the Marklin HO Layout. IR Sensors can be tricky and can falsely trigger by changes in ambient light so you have to make sure you shield the IR detector from all unwanted ambient light.

What is you plan for the two IR devices in track? Is one an emitter and the other a detector? If so, I assume the plan is two bounce the lR light off the bottom of the train into the detector as the train passes over. You may have to put tubes around the IR detector to keep stary IR light from falsely triggering the detector due to the close proximity of the emitter.

The other thing you're going to have to program is how the space between train cars effects the IR detector. You may be able to count the the cars of train or you might need a dropout delay so the space between the cars doesn't register. That will be a trial and error deal. At least it was for me. IR works constantly once you have eliminated all the variables. Contact tracks are way easier, in my humble opinion, but you need electronics due to the AC/DC conversion.

I have seen people use reflectors on the bottom of the train so only one or two points on the train trigger the sensor. I have also seen people put the emitter on the train and the detector on the track, or next to the track. My N scale layout uses two emitter/detector pairs per sensor point and they are or'ed with a drop out time delay. The sensors don't penetrate through the track, they cross track horizontally.
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline GaryTrooper  
#39 Posted : 13 March 2020 05:31:36(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
This is another option for cheap contacts. I smashed flat the end of a small diameter brass rod. This has actually worked surprisingly successfully for over a year now.

20200312_222626~2.jpg20200312_222612~2.jpg
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
thanks 1 user liked this useful post by GaryTrooper
Offline mfaris01  
#40 Posted : 13 March 2020 14:44:42(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: mfaris01 Go to Quoted Post
Hi guys,



Looks interesting. I use IR sensors on the N scale layout and I use contact tracks for sensors on the Marklin HO Layout. IR Sensors can be tricky and can falsely trigger by changes in ambient light so you have to make sure you shield the IR detector from all unwanted ambient light.

What is you plan for the two IR devices in track? Is one an emitter and the other a detector? If so, I assume the plan is two bounce the lR light off the bottom of the train into the detector as the train passes over. You may have to put tubes around the IR detector to keep stary IR light from falsely triggering the detector due to the close proximity of the emitter.

The other thing you're going to have to program is how the space between train cars effects the IR detector. You may be able to count the the cars of train or you might need a dropout delay so the space between the cars doesn't register. That will be a trial and error deal. At least it was for me. IR works constantly once you have eliminated all the variables. Contact tracks are way easier, in my humble opinion, but you need electronics due to the AC/DC conversion.

I have seen people use reflectors on the bottom of the train so only one or two points on the train trigger the sensor. I have also seen people put the emitter on the train and the detector on the track, or next to the track. My N scale layout uses two emitter/detector pairs per sensor point and they are or'ed with a drop out time delay. The sensors don't penetrate through the track, they cross track horizontally.


I saw a video where the guy used a piece of foil under the locomotive to trigger the sensors. He also had them side by side and mentioned ambient lighting. I'm "trains on the floor" guy, so your latter solution wouldn't work for me although I've seen something like that used in backyard railroading (Walt Disney style). Thanks for the input and I agree it will be a trail and error and I plan to put variable resistor or potentiometer to adjust the sensitivity.

I'll keep everyone posted.
thanks 1 user liked this useful post by mfaris01
Offline DaleSchultz  
#41 Posted : 13 March 2020 18:54:55(UTC)
DaleSchultz

United States   
Joined: 10/02/2006(UTC)
Posts: 3,997
Antonio Martinez of this forum has a nice solution to adding a sensor in hidden areas.

I used it very successfully on my old layout: https://cabin-layout.mixmox.com/2004/02/Martinez-type-contact.html (That link also shows an earlier idea I had, which I abandoned.)

Martinez solution

One can take the output of such a switch and connect it to a pin of the Arduino type processor.

Dale
Intellibox + own software, K-Track
My current layout: https://cabin-layout.mixmox.com
Arrival and Departure signs: https://remotesign.mixmox.com
thanks 1 user liked this useful post by DaleSchultz
Offline mfaris01  
#42 Posted : 18 March 2020 11:35:09(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
Hi guys!

I recently made a video simulating a track block (breadboard) with train detection and signals using IR sensors and Arduino Nano.
IR simulation

I ended up writing my own code for it. Feel free to hack it and improve on it.
--- Start of code ---
// Assigning the LEDs
int sig1Grn = 2;
int sig1Red = 3;
int sig2Grn = 4;
int sig2Red = 5;

// Assign the IR sensors
int IR1 = A0;
int IR2 = A1;

// Last known IR sensor state
int lastStateIR1 = 0;
int lastStateIR2 = 0;

// Sensor variables for the function IRscan(x)
int IR_1 = 0;
int IR_2 = 0;


void setup() {
// Assign pin modes
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
pinMode(sig1Grn, OUTPUT);
pinMode(sig1Red, OUTPUT);
pinMode(sig2Grn, OUTPUT);
pinMode(sig2Red, OUTPUT);

// Turn both signals to green initially
changeLED(sig1Red, sig1Grn);
changeLED(sig2Red, sig2Grn);

}

void loop() {

// Scan for a train either on the first or second IR pair location
while((IR_1 = IRscan(IR1)) || (IR_2 = IRscan(IR2))){
if(IR_1) { // if IR1 is triggered
changeLED(sig1Grn, sig1Red); // Switch to Red LED
lastStateIR1 = 1;
if(lastStateIR2 == 0) { // If IR2 has not been triggered yet, wait.
lastStateIR1 = 1;
delay(3000);
}
IR_1 = 0; // reset the IR_1 variable to zero so the while loop will ignore it, unless it is triggered again.
}
if(IR_2) { // If the second IR pair is triggered
changeLED(sig2Grn, sig2Red); // Switch the second set of LEDs to Red
delay(3000); // Wait 3 seconds for the train to leave the block.
lastStateIR1 = lastStateIR2 = 0; // Reset the last known state for each IR pair.
changeLED(sig1Red, sig1Grn); // Change the first signal back to green
delay(1000);
changeLED(sig2Red, sig2Grn); // Change the second signal back to green.
IR_1 = IR_2 = 0; // Reset both IR variables back to zero to keep from a false trigger.
}
}
}


// This function will switch one LED to LOW and the other to HIGH
void changeLED(int toLow, int toHigh) {
digitalWrite(toLow, LOW);
digitalWrite(toHigh, HIGH);
}

// This function reads the state of the IR port passed to it and if the level is equal to or above 100 it returns TRUE
int IRscan(int IRnum) {
int IRread = 0;
if((IRread = analogRead(IRnum)) >= 100)
return 1;
else
return 0;
}
--- End of Code ---


thanks 1 user liked this useful post by mfaris01
Offline mfaris01  
#43 Posted : 18 March 2020 17:25:28(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
I have some updates with pics for my IR M-Track.

I adjusted the sensitivity on the IR sensors using resistors. Some said use 10k Ohms, but that was too much. I had to touch a piece of foil against the LEDs to make them detect. So I tried 3k Ohm resistors. That triggered around 4cm with my hand. I found that 4.7k Ohm resistors worked perfectly with a piece of foil taped to the underside of the locomotive before or after the shoe and rolling stock did not trigger the IR sensor.

Here are some pics of the finished track sections.
IMG_5616.JPGIMG_5617.JPGIMG_5618.JPG
thanks 3 users liked this useful post by mfaris01
Offline mfaris01  
#44 Posted : 23 March 2020 11:37:17(UTC)
mfaris01

China   
Joined: 18/02/2020(UTC)
Posts: 11
Location: Tianjin
Here's my schematic. I am still working on the code for turnouts and isolation tracks. Each component has been tested and works beautifully!

Schematic_Train Control w-o LEDs_Sheet_2_20200323183330.png
thanks 3 users liked this useful post by mfaris01
Offline PaulDistel  
#45 Posted : 29 December 2020 00:42:07(UTC)
PaulDistel

Netherlands   
Joined: 25/12/2020(UTC)
Posts: 1
Location: Zuid Holland
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: DaleSchultz Go to Quoted Post
so you are controlling the turnouts, but are the trains being controlled digitally or are you switching track current on and off using the Duo?

For the turnouts are you using MOSFETs or simple relays?



I'm not controlling track voltage with the Arduino. Only the signals and turnouts. I'm running the locomotives using analog, directly from the transformers. Some day I may convert the locomotives to digital but there are many and I want to get the layout built up.

The turnouts and signals are AC driven using TRIACs controled by the Arduino.

HI Gary,

Just started exploring the options with Arduino and model trains. In the past I used MOC3020/3040 optocouplers. They have a triac inside. I don't think you can eliminate additional triacs because of current limitations but maybe the schematic can be simplified?

I haven't read all your posts but I would love to combine the Arduino and the Märklin digital system. Any thoughts on that for signaling and switching?

Regards,

Paul
Offline GaryTrooper  
#46 Posted : 29 December 2020 01:50:30(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 390
Location: Hailey, Idaho
Originally Posted by: PaulDistel Go to Quoted Post
Originally Posted by: GaryTrooper Go to Quoted Post
Originally Posted by: DaleSchultz Go to Quoted Post
so you are controlling the turnouts, but are the trains being controlled digitally or are you switching track current on and off using the Duo?

For the turnouts are you using MOSFETs or simple relays?



I'm not controlling track voltage with the Arduino. Only the signals and turnouts. I'm running the locomotives using analog, directly from the transformers. Some day I may convert the locomotives to digital but there are many and I want to get the layout built up.

The turnouts and signals are AC driven using TRIACs controled by the Arduino.

HI Gary,

Just started exploring the options with Arduino and model trains. In the past I used MOC3020/3040 optocouplers. They have a triac inside. I don't think you can eliminate additional triacs because of current limitations but maybe the schematic can be simplified?

I haven't read all your posts but I would love to combine the Arduino and the Märklin digital system. Any thoughts on that for signaling and switching?

Regards,

Paul



Paul,

Interfacing an Arduino to Marklin's digital system is quite a bit above my current level of digital control understanding. My simplified approach to computer control is just a course control of the analog solenoids for the switches and the signals. Track power is supplied by several different transformers and Marklin's universal relays depending which direction a train is either going up or going down a ramp.

I am using TRIACs. Marklin solenoids can be powered by DC so you can use a FETs to simplify things if you wish.


20200112_150340_2.jpg


Regards,

Gary
G - LGB
O - Lionel and MTH
HO - Marklin
N - Mix of manufacturers mostly Kato
Offline river6109  
#47 Posted : 29 December 2020 01:51:33(UTC)
river6109

Australia   
Joined: 22/01/2009(UTC)
Posts: 14,635
Location: On 1965 Märklin Boulevard just around from Roco Square
Hi Guys, well I've been tinkering with this idea for years and given away the switching track as it was not 100% reliable nor the newer version with C-track, I use K-track and noticed the last post made holes into the M-track, one could say I use a more simpler version and have come up with opto couplers which are placed between the sleepers and are triggered by the slider, but you only have a 1 way detection, which means your trains have to run always in one direction., my option could be placed by making a hole close to the middle stud track and so long the slider picks up the infra red signal you shouldn't have any problems with it. the opto coupler I'm using have a range of 8mm from the same level as the sleepers., it doesn't pick up any axles.

John
https://www.youtube.com/river6109
https://www.youtube.com/6109river
5 years in Destruction mode
50 years in Repairing mode
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

| Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 1.633 seconds.