You're reading ...
Hardware

Using an IR sensor for train detection > Arduino S88 > ECoS

The video shows the use of an IR optical detector for train detection. It is connected to the Arduino that serves as an S88 interface, which in turn is connected to the ECoS via the S88 bus.

The Arduino used as an S88 interface was described in this post.

Detailed info on how to connect the IR sensors is available on the hardware page.

About RudyB

Hobbyist

Discussion

14 thoughts on “Using an IR sensor for train detection > Arduino S88 > ECoS

  1. Hi Ruud,

    Are you still using the IR sensors on the track? Did you solve the interference problem of the sunlight? I am also working on a sensor doing that but then with the cheap diode and IR photo transistor as you started, it also detects black so no need for white stickers. If you are interested let me know.

    Groet,
    Gert-Jan

    Like

    Posted by Gert-Jan van Schaik | December 21, 2017, 20:57
  2. Hi Ruud,

    Very neat approach. I am just on a project that requires direction sensitive sensors. I order to do this, I thought it could be done by reeds located on each side of the track (in front of each other). So one would be on the left and the other on the right of the track.
    The loco would have two magnets located on each side. Each magnet would be placed a way such that only the reed on the corresponding side would be closed. The two magnets would also be placed at a distance from each other so that they close the reed at a different moment.
    The signal generated by the two reeds would then be connected to a NAND, XOR or whatever in a way that two output signals would be available at the Arduino.

    Any suggestion or hint ?
    Thanks,

    Jacques

    Like

    Posted by Jacques Hoste | January 28, 2017, 20:46
    • I’m not sure if a 2 magnet approach would give a reliable solution. They would need to be really small magnets not to trigger the opposite side reed, but that small they might also unreliably trigger the right reed? Only a test will give you certainty.

      I’m curious by the way why you would want to be able to decuct the driving direction from the sensors? Are you using train control software? If you do … all software I know of know by themselves which direction the trains are going, no need to have additional sensor logic to deduct that.

      Like

      Posted by RudyB | January 29, 2017, 14:59
  3. Hell Rudy,

    Would this method work with a photoresistor? I’m thinking that it could be mounted between the rails and as the train passes over it, the photoresistor blocks the ambient light and triggers the Arduino pin.

    Thanks,
    Lucian

    Like

    Posted by Lucian | October 29, 2016, 19:10
    • It’s worth a try, I doubt if it will be reliable enough. I use small reed switches between the rails and little magnets under the rolling stock, that is easy, cheap and 100% reliable.

      Like

      Posted by RudyB | October 29, 2016, 20:23
      • I tried also with reed switches and it works 100%, I ordered some photoresistors and I will experiment.

        I will let you know about the results (when they arrive from china a month from now 🙂 )

        Like

        Posted by Lucian | October 29, 2016, 20:47
      • Hello Rudy,

        Photoresistors arrived a while ago but I didn’t had the time to make the tests. For this purpose I used a small test layout and I got some interesting results. I put a video link below.

        I placed two photo resistors under the track and I ran a locomotive over them. Using the code as it is, the analog inputs don’t work reliable enough but the digital inputs work very well… under certain conditions (the logic of the digital pins needs to be changed though). With normal room light it works very well (this part is not in the video), with direct light from above it works perfect and while simulating night time with a blue light coming from an RGB led strip, it does not work at all. I will try tomorrow direct sunlight.

        In my opinion it can be used if the layout is in an artificially lit room and if a blue RGB led strip is used for night conditions, the photoresitors might be reliable if there are some streetlights over them.

        You might wonder why I am going through all this trouble and not just use the reed switches, the answer is that I am using N scale and placing reed switches on the track and magnets under the rolling stock might not be visually pleasent and maybe not even possible in case of some locomotives.

        Thank you,
        Lucian

        Like

        Posted by Lucian | February 28, 2017, 20:42
  4. Hi, Your website is a real inspiration!

    I’d like to know if the infrared detector and arduino, can be used with the Märklin central station? I’m at the stage of deciding whether to get the CS2 or the Ecos ESU, and I’d like to try out some of your ideas.

    Thanks

    Like

    Posted by Peter Bradbury | November 11, 2015, 14:16
    • The Arduino uses the standard S88 for transmitting the train detection signals, it can be used with any system that has an S88 interface. Personally I went for reed switches and magnets under the rolling stock in stead of the infrared detector, the IR detectors turned out to be less reliable.

      Like

      Posted by RudyB | November 11, 2015, 15:57
  5. Hello!
    Thanks for all of your amazing videos! I was wondering if you know if there is any way of connecting an Arduino directly to my computer running Traincontroller Gold and use this for reading block sensors. I was wondering this because I have a Lenz digital system and the feedback modules is about €50 and I haven’t found any way of replacing this with an Arduino, as you have done for your ESU counterpart.

    Like

    Posted by Karl-Fredrik | August 29, 2015, 20:04
    • An adapter will be needed like e.g. loconet-S88 or xpressnet-S88. If you’d Google some on these I bet you’ll come across several possbilities and ideas. The cheap Arduino’s can be used on the S88 bus. The loconet or xpressnet can be connected to the PC via a USB adapter, or maybe via the Command Station. Then it also depends on the PC software you use if, and what type, of adapters are supported.

      Like

      Posted by RudyB | August 29, 2015, 21:01
  6. hallo
    kun je de invloed van het omgevingslicht niet uitschakelen door de led mbv de arduino te pulsen en de door de arduino gemeten waarde van de transistor zonder ir licht af te trekken van de waarde met ir licht. ??
    een simpel algoritme wat op dit principe gebaseerd is werkt bij mij prima met een cy reflextie senor

    Like

    Posted by dick koning | October 12, 2014, 16:33
    • Hallo Dick. Iets dergelijks is wellicht in de software te doen, ipv met 38khz hardware zender en ontvanger. Om waarden van elkaar af te kunnen trekken moeten wel de analoge ingangen gebruikt worden en daar zijn er maar 6 van, da’s dan een nadeel.

      Like

      Posted by rudyb2014 | October 12, 2014, 17:17

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Archive of all posts

Categories

%d bloggers like this: