Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and S88

Post Reply
woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 19.06.2015, 11:02

Hi Laszlo,

Consider the idea linking the sensors directly to the Arduino. Atmel processors are reliable but quite sensitive to under and over voltage . Technically though to solve, but then the price advantage disappears if you make fi the s88 units, such as previously published by Elektor, by yourself. Point of interest continues to the desired/ necessary for the galvanic separation if the track tension is pseudo symmetrical i.e. no Gnd. The trade-off depends on what is already in your possession. A robust solution and implementation you never will regret. Use good quality (twisted)cables and separate trackleads and sensorleads.

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by rozsaheg » 19.06.2015, 13:27

Hi Bert,
Thanks for helping so quickly.If you do not mind I would describe my points .Feedback units are microswitches and adjustable IR detector panels ($0.9 each). No any galvanic connections with track, both are powered from a separate unit. The Arduino Mega digital pins working between 3-5 V. Arduino will receive only digital signs.
Regards
Laszlo

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 22.06.2015, 21:03

Hi Laszlo,

Sounds like simple and straight forward. The Mega does not support interrupts on all pins, so the solution should poll the pins. But that is no problem, the Arduino is fast enough ie too fast for real time reporting. A looptime of about 55 - 100 ms is fast enough.

rozsaheg
Posts: 35
Joined: 10.06.2015, 21:02

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by rozsaheg » 03.07.2015, 18:23

Hi Bert,
I have started to make a sketch which shows my idea. It is not ready. Last point is missing. I am waiting information to the message/packet form will be sent to Rocrail by USB. Hope comments are enough to understand what I want to do. Please take a look to the attached file.
Feel free to any comments suggestions. Thanks for your effort.
Laszlo
You do not have the required permissions to view the files attached to this post.

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 03.07.2015, 19:23

Hi Laszlo,

The principle of the code could work. I'm not going to debug it for the reasons I have already stated in this thread; it is a PITA without a run time monitor channel. My major remarks by this sketch: Think about removing the delay out of the inner loop. The maximum poll rate is approximately 2x per second with 48 contacts. I do not know the length of your tracks, but this would be too slow for my layout.
If you perceive a sensor change, you might 1ms wait and reconnect to poll to be sure, but this would not be necessary.
When a change is detected, send the packet immediate and continue with polling of the series. This instead of queueing the changes. If you have a next difference persist this message and check if 10ms have passed. Limit the number of events to max 100 per second in case of a SoD situation.
Rocrail doesn't like a same sensor change within 50ms and this limitation has a reason. Then verify that the total loop lasted at least 50 - 100 ms. After this time has passed, then begin a new poll cycle.
you have still to decide which protocol library you want to apply to register the sensor events to Rocrail. Optionally, you can optimize your poll schedule on that library.

If you have questions about an Arduino sketch ask them in the Arduino forum, if it is about interfacing to Rocrail then this forum is the right place to be.

You'd be doing me a favor if you create a new thread for this interface.

bob61ch
Posts: 4
Joined: 23.08.2015, 17:40

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by bob61ch » 26.08.2015, 20:10

Hi Bert,
you have done a amazing work on this interface. I am trying to use the CAN_USB_gwV15Q_GFP_CSP10 sketch with Rocrail. The interface is able to recognize mfx locos and register them in Rocrail, see the change of status of the switches and also the loco's speed when I control them through the MS2. But no way to send any command through rocrail to the loco's and switches.
It is reacting let say in one way.
Could you give me some hints why I have this behaviour ?
Thanks for your feed-back
Bob

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 26.08.2015, 21:35

Hi Bob,

Thanks for your interest in the project. The USB sketches are very hard to debug, thats the reason why I recommend the ethernet sketches. When having communication problems that is mostly due to cabling errors or too long cables or an improper terminated CAN bus.

It is nearly impossible to perform diagnostics without a second CAN bus controller for sniffing or an W5100 Ethernetinterface. The only thing to determine any errors is to monitor the serial/USB input via a Byte level trace in Rocrail. If you aren't able to send any byte from, in the most lucky way you get an error devided in more packets back from the Arduino. In that case it is most probably that there is a problem reading the interrupt line of the CAN controller. Or that the CAN controller is not able to send a packet due to a bad terminated CAN bus.

Please describe your Arduino configuration/type/CAN shield, cable length/type, version of Arduino soaftware. If your problem is persistent please upload an info + byte level trace. I can't promise it contains any valuable information but you can give it a try.

bob61ch
Posts: 4
Joined: 23.08.2015, 17:40

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by bob61ch » 27.08.2015, 20:13

Hi Bert,
thank you for your tips. Actually I am using Arduino 1.6.5, with a Shield CAN-DIY (bought at http://shop.mchobby.be/shields/375-cand ... 03750.html), I have added a S88 Shield on top of this that I bought from (http://www.desktopstation.net/). For your information, Yasaan the owner of the site has written a piece of software DesktopStation to control Trains, switches, signals and also S88 feed-backs. My hardware actually is perfectly working with DesktopStation and I have bi-directionnal communication. Yasaan used the Railuino library to implement his software.
That's why I thought that it might be a configuration issue on my side rather than a hardware issue.
But if you don't mind and you can give me the way to provide you the information or a direction to dig, I will definitely do it.

Thanks again for your help
Best regards
Bob

ivanvan69
Posts: 1
Joined: 27.08.2015, 17:47

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by ivanvan69 » 30.08.2015, 15:18

Hello everyone.
I just started to control my train marklin via c (6 months). Now I want to handle three locomotives with Rocrail, but without having to purchase the Central Station of Marklin.
Now I have the mobile station2 Marklin. MS use to connect to the PC, Arduino + canbus with desktop-station. And everything works fine.

The problem is that it can not connect with Rocrail.

This is what I have:

Pc ----> DesktopSatition ----> Arduino UNO + cambusSerial with (CAN_UDP_gwV9Q_GFP.zip) → Serial conection→ Mobil Station .

I have made the following settings in Rocrail (MCS2 with serial) but does not work

Would you could orient me to connect Arduino with Rocrail?
Thank you very much for everything.
regards

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 30.08.2015, 16:09

Hi bob,

If your system is working with desktopstation then forget my directions for solving. Most probably is a conflicting or wrong library.

In the next days I'll try to create a package with a library. The S88 implementation on the same Arduino is a bad plan due to timing. The maximum number of S88 units is 2 to prevent CAN overruns.

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 30.08.2015, 16:12

Hi Ivan,

Please read the thread. You are using the wrong sketch. The udp versions are for a W5100 ethernetshield. Please try an USB version.

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by woodyboy » 01.09.2015, 22:20

Hi Bob,

Testing with Arduino 1.6.5 results in the same situation you experienced. At the moment it is not clear to me why this happens. Workaround is to compile the sketch with 1.5.6-r2. As I wrote, debugging the USB variant is a hell of a job. The next days I will spent some limiting time, to try to create a variant with S88 functionality.

bob61ch
Posts: 4
Joined: 23.08.2015, 17:40

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by bob61ch » 02.09.2015, 21:16

Hi Bert,
thank you for your time. I can confirm to you that the CAN_USB_gwV15Q_GFP_CSP10 sketch is working perfectly with Arduino 1.5.6-r2. The behaviour with Arduino 1.6.5 is strange. For the S88 integration, if I can be of any help for testing and validating you can count on me. I wanted to know what are the improvements that you include in your sketch version 20 ?
Thanks again
regards
Bob

Lindi
Posts: 10
Joined: 24.08.2015, 16:29

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by Lindi » 03.09.2015, 16:27

Hi Bert,

congratulations for your great job you did to manage implementing the Gleisbox as a controller.
I tried to implement your solution as well. Unfortunately, it doesn't work.
I suspect a stupid mistake and cannot find it.
I tried to consider every hint you gave in this thread.
The connection is set up with an Arduino Uno and a CANdiy shield. The cable between the CAN shield and the Gleisbox is a modified Ethernet cable like Joerg Pleumann has suggested. Simple sketches of Joerg's samples work very well. Even the combination with Desktop Station from Yasaan does what it is intended to do. But together with Rocrail nothing happens. Even the power on doesn't work. The trace of Rocrail server confirms "Opening serial[com13]... [OK]". When clicking power on Rocrail server reports "System GO" and two CAN blocks are send to the com port:
00 00 13 14 05 00 00 00 00 01 00 00 00 and
00 00 13 14 07 00 00 00 00 06 00 19 00 .
But nothing happens on the track.
Controller is mcs2 type.

Do you have any idea?

Regards
Lindi

smitt48
Moderator
Posts: 6114
Joined: 04.04.2014, 01:07
Location: Kralendijk, Bonaire - Dutch Caribbean

Re: Rocrail Arduino CAN-bus interface, MS2, Gleisbox GFP and

Post by smitt48 » 03.09.2015, 17:00

Hi Lindi,

Willkommen zu RR.

Kannst du ein *.trc Daten im Forum anhaengen?

mfg Tom

Post Reply

Return to “DIY Hardware”