You're reading ...
Hardware, Project Progress

First test with sensors on the track and Arduino S88

Past few weeks progress on the layout hardware has been minimal due to the work on the Traincontroller videos. The past few days though, I picked up preparing the wiring for the S88 bus  and this afternoon the first 2 sensors have been mounted on the track. Time for a test drive!

Sensor_07

The images show how the reed switches look when mounted between the rails and when painted black. They could have been mounted 90 degrees rotated, sunk between the sleepers, but tests showed that when mounted parallel to the track the time during which they are switched on by a passing train is a bit longer. This may have a better reliability for the sofware readout of the switch.

Sensor_05
OK, they are in view, but actually it is not that bad a sight. In reality there also are devices between the rails here and there.

Sensor_09
The Arduino with the s88 software is mounted under the table. The S88 clock, PS, 5V, GND and Data are connected to the ESU ECoS via 2m cat5 cable.

Sensor_08
The locomotive has a small magnet attached under its NEM362 coupler with a small piece of sticky foam.

The video shows how the signal on the ECoS lights up when the loc runs over the sensor. The reed switch pulls an Arduino input to GND. The Arduino gathers 16 inputs and shifts them to the DATA output one by one based on the S88 clock. The Arduino sketch can be found on the Software page.

About RudyB

Hobbyist

Discussion

30 thoughts on “First test with sensors on the track and Arduino S88

  1. Hi Rudy,
    Coming to all this with a DR5000 in 2021.
    Thanks for all your amazing work on the project.
    I am having problems with interference between the S88-N over an rj 45 cable and the arduino.
    When I turn on the track power I get some interference, but when I start to drive the locos it gets really bad.
    I have been trying so many solutions on different forums including this one, but none seem to work.
    One suggestion I saw was to put a 100ms delay into the code before reporting the result of the sensor to the S88 bus.
    I am afraid I am not a scripter so I am unable to do that myself…Is there any chance, you could explain how to adjust your code to put in a delay before reporting?
    Thanks,
    Antony

    Like

    Posted by Antony | May 7, 2021, 07:29
    • It’s been a while (multiple years) since I wrote that code … I’ll have to look into it. I’m rather busy … maybe in the course of next week I might have a look into it.

      Like

      Posted by RudyB | May 7, 2021, 18:29
      • Thanks Rudy,
        I know I am very late to the party and it’s been literally years…
        Thanks so much
        Antony

        Like

        Posted by Antony | May 8, 2021, 18:52
  2. Hi Rudy,

    I’ve tried your code on Arduino pro mini connected to the Ecos controller. All works fine as long as the Loco is moving slow (G-scale). At moderate speeds then the Ecos stop sensing the change. In my effort to degug, after minor modifications using (DDR, PIN, PORT) I have noticed that the code will sense the change at max speed but I’m still having issues with Ecos so Im guessing it is related to timing (which above my prog. skills). Any insight would be great.

    Like

    Posted by Naji Karim | July 1, 2017, 15:34
    • It could simply be that the EcOS display latency is fooling you. The display update software in the EcOS runs slow because all the other software parts that have critical timing get priority. Eventhough the EcOS screen sometimes does not show the sensor on the display, the signal is correctly sent to the PC, at least that is the situation here with Me.

      Like

      Posted by RudyB | July 13, 2017, 14:03
  3. Hi

    Is there someone that has tried this with hallsansors? i would like to us this for an dc car track. Because normal glass read sensors are very weak and brak fast.

    Casper

    Like

    Posted by Casper | March 2, 2017, 05:27
  4. Hello Rudy,
    After many months all 12 mini pros are connected to our push buttons via the S88 on the Ecos. They operate 108 turnouts.
    Would it be ok for us to change the Inputs from GND to +5v ?
    There has been the odd “turn out change over” as we turn the fluorescent strip lights on/off (we have 12!) so there is some interference going on somewhere.
    We have purchase a good quality Mains filter for the Ecos but the problem remains.

    Like

    Posted by martinkirkby | November 18, 2016, 21:52
    • It is possible to change the S88 inputs to 5V, nit of course this requires a change in logic lebels in the software … when you’d look into the code it is not difficult to figure out where. It is also needed to take care that the inputs switches between 5V and 0V, not between 5V and floating, since floating will render unpredictable results. I don’t know how you plan to do this? The way it is desgned is that the input is 5V thanks tomthe internal pull upmresistor and switches to 0V with a reed switch. I can not imagine this is very susceptible to electrcal interference.

      Like

      Posted by RudyB | November 18, 2016, 22:57
  5. Hello Rudy,

    I have been looking at the code for the Arduino DCC S88 and note that Arduino pin 2 is connected to S88 pin 3 Clock and the output pin 6 of the optocoupler also goes to pin 2 of the arduino. Could you confirm that both connections go to pin 2. I assume it has something to do with reading from the DCC track

    Thanks again

    Bernie

    Like

    Posted by Bernie Benson | February 20, 2016, 05:21
    • Bernie, for S88 you do not need a connection to DCC. It is a separate bus, connections are on the back of the ECoS according to the schematics on the blog. Hence there is no double use of pin 2, it is correct that the S88 clock is connected to it. Also the 5V power for these Arduino’s comes fron the ECoS S88 connector.

      Like

      Posted by RudyB | February 20, 2016, 08:47
  6. Hi, good work, is the arduino S88 similar to the Märklin S88 feedback modules. My command station is compatible with these. I would love to use them with it if possible. Any info appreciated.

    Like

    Posted by Alex | September 4, 2015, 18:54
    • I can’t tell with 100% certainty. If your command station sends out the S88 signals with the S88 standard specified timing (and why shouldn’t it?), it should work.

      Like

      Posted by RudyB | September 4, 2015, 20:43
      • My command station is DIY built to Paco Canada(google The Pows) design DCC_Gen. In Train Controller it is recognised as a Lenz Digital Plus/LI100(F). I’m wondering if there are any different timings with this regard. Any help greatly appreciated.

        Like

        Posted by Alex | September 5, 2015, 17:30
      • It’s difficult to diagnose Alex. The Arduino S88 sketch works according to the timing diagram as shown on the software page. And that timing is not even that critical, it is the sequence of clock and PS signals that shift the sensor bits out. All I can say is that it works well with my ECoS, with 3 S88 Arsuino’s in chain.

        Like

        Posted by RudyB | September 5, 2015, 19:47
      • Thanks Rudy i’ll keep trying different settings in software.

        Like

        Posted by Alex | September 5, 2015, 21:17
      • Would the fact that the command station can only accept 128 inputs make a difference?

        Like

        Posted by Alex | September 5, 2015, 23:00
      • In that case it should send a PS pulse after 128 clock pulses, he Arduino’s will tyen load their new sensor statuses to be sent to the CS. You could try to make a sketch that counts clock pulses between PS pulses to know for sure.

        Like

        Posted by RudyB | September 6, 2015, 07:33
      • a bit frustrated at the moment with this, will maybe try that later. Thanks for the help anyway!

        Like

        Posted by Alex | September 6, 2015, 07:45
      • Enabled serial monitor in your sketch which you marked as for test purposes. the output results with no shorts to GND was sensors=0 then 128, on shorting A0 to GND sensors=0 then 129. Might this cast any light on the subject. On my command station the feedback indication shows 5,6,7,8 flickering on address 65.

        Like

        Posted by Alex | September 6, 2015, 08:53
      • What helped with me when ever I had some flicker was to put pin 12, the input pin for the next Arduino in chain, to GND.

        Like

        Posted by RudyB | September 6, 2015, 09:19
      • Hi Rudy,
        Put the Arduino back in the S88 chain at the end, placed wire between 12 – GND flickering now on 67- 5,6,7,8

        Like

        Posted by Alex | September 6, 2015, 09:28
      • Does the values on the serial monitor seem correct?

        Like

        Posted by Alex | September 6, 2015, 09:31
      • I can’t tell Alex, it is difficult to diagnose from a distance. Flickering says signals do reach your CS though … that is positive. Can you play a bit with the clock / PS time delay that is built in?

        Like

        Posted by RudyB | September 6, 2015, 09:35
      • No its not possible to alter these settings. The current detectors already installed on the S88 bus are giving me correct outputs, perhaps its just not going to work for me. Still i’ll play around some more with it all and who knows. Anyway i’ll not keep you back any longer thanks for the help. Will let you know if I have any luck!!!

        Like

        Posted by Alex | September 6, 2015, 09:40
      • One last thing though, when the arduino is connected in it seems to prevent Train Controller from connecting to the CS when the arduino is removed connection is established.

        Like

        Posted by Alex | September 6, 2015, 09:47
      • Hi Rudy,
        Got some info about timing of my CS.
        The DCC_Gen is faster, pulses of 6us high, and 6us-8us low, to read the 128 inputs takes about 1,8ms.

        Works right with 4014 chips but maybe is too fast for a microcontroller based solution
        Don’t know if this helps.
        regards
        Alex.

        Like

        Posted by algea100 | September 8, 2015, 18:04
  7. Hi Rudy
    how did you tie in the reed switch to the arduino reed switch with 1 wire in 1 out
    what pins did you use
    thanks
    Roger

    Like

    Posted by Roger Newton | August 16, 2015, 07:37
    • Hi Roger. The Arduino inputs are configured with the internal pullup, which makes them HIGH. The reeds are connected with one side to GND and the other side to one of the Arduino inputs. The input becomes LOW (connected to GND) when the reed switches. Which inputs are used can be seen in the code, it can be downloaded from the software page.

      Like

      Posted by RudyB | August 16, 2015, 15:18
  8. Very nice work. I will use your system on my own layout soon. I am waiting for arduinos. Thanks for your job and your blog.

    Like

    Posted by Samuel | June 12, 2015, 19:29

Leave a comment

Archive of all posts