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: 205
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 9 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: 205
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 7 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: 205
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: 205
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: 205
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: 205
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: 205
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: 205
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


Joined: 10/02/2006(UTC)
Posts: 3,218
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: 205
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: 205
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


Joined: 10/02/2006(UTC)
Posts: 3,218
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: 205
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
Offline DaleSchultz  
#14 Posted : 11 August 2019 03:33:42(UTC)
DaleSchultz


Joined: 10/02/2006(UTC)
Posts: 3,218
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: 205
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: 224
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: 205
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: 205
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: 6
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: 205
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


Joined: 10/02/2006(UTC)
Posts: 3,218
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: 205
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


Joined: 10/02/2006(UTC)
Posts: 3,218
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: 205
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: 205
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: 6
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 16 time(s).
Offline GaryTrooper  
#27 Posted : 14 January 2020 15:50:12(UTC)
GaryTrooper

United States   
Joined: 26/01/2018(UTC)
Posts: 205
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 16 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: 6
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 16 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: 195
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: 6
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 17 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: 6
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 9 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: 205
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 9 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: 205
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 9 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: 6
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 9 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


Users browsing this topic
OceanSpiders 2.0
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-2020, Yet Another Forum.NET
This page was generated in 1.134 seconds.