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

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, 17:30

Hallo Tom,

ich versuche es.
Es sind nur wenige Aktionen:
Power ON
Light ON/OFF
Loc forward
Power OFF

Hilft das?

Best regards
Lindi
Attachments
rocview.009.trc
(10.33 KiB) Downloaded 13 times

smitt48
Moderator
Posts: 5858
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:53

Hi Lindi,

Ich weiss nicht, aber vielleicht fuer die Experten!

mfg Tom

LDG
Site Admin
Posts: 2672
Joined: 18.10.2010, 00:03
Location: near Karlsruhe/Germany

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

Post by LDG » 03.09.2015, 18:41

Hallo Lindi,

Du hast ein Trace der Oberfläche (Rocview) eingestellt. Das hilft bei Problemen mit der Zentrale nicht weiter.

Bitte aktuelles Trace des Servers: rocrail.*.trc einstellen (* sind Nummern zwischen 000 und 009).

Gruß,
Lothar

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, 19:21

Hallo Lothar,

danke für den Hinweis. Da merkt man die fehlende Routine mit Rocrail.
Jetzt ist es hoffentlich die richtige Datei.

Viele Grüße
Lindi
Attachments
rocrail.009.trc
(26.14 KiB) Downloaded 13 times

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

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

Post by woodyboy » 03.09.2015, 20:02

Hi Lindi,

The trace is ok, but nothing is received from the arduino. Not even an error message :wink: The missing information is the used sketch version and the arduino build environment.
Reading your post with the configuration information I recommend the CAN_USB_gwV15Q_GFP_CSP10 sketch, build with Arduino 1.5.6-2. That is a proven combination.

Lindi
Posts: 10
Joined: 24.08.2015, 16:29

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

Post by Lindi » 04.09.2015, 16:38

Hi Bert,

as I mentioned "I tried to consider every hint you gave in this thread.".
Therefore I used the sketch CAN_USB_gwV15Q_GFP_CSP10 and compiled it with Arduino 1.5.6 R2.
I also changed the Arduino board, the CANdiy shield and the cables.
As next try I ordered an Arduino Leonardo since I own only UNOs so far. Hopefully it arrives soon.

Interesting that you recognized no response from the Arduino. Maybe I could try to insert some sort of debugging in your sketch e.g. LED blinking when receiving and sending. Or do you have any other idea?

Regards
Lindi

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

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

Post by woodyboy » 04.09.2015, 17:41

Hi Lindi,

If desktopstation is functioning well, change nothing with your hardware configuration. Use the CAN_USB_gwV15Q_GFP_CSP10 sketch, check if the necessary libraries gatewayCSP10 and QueueArray are installed in the right directories and compile with Arduino 1.5.6 R2.

A Leonardo does not solve this problem. Debugging with LED's gives too few information. I had some experiments with it but is very hard to see and can only be used in one position in the sketch. It is something like to play at blindman's buff...

If debugging information is appreciated then I recommend a W5100 Ethernet shield for the Arduino. The cost is less as € 5 and some patience or some more € on the local shop and less patience :wink: .
The trade off using an Ethernet shield is the rerouting of pin 10 of the CAN shield. But it is really the best you can do, for sure in a trouble shooting situation .

bob61ch
Posts: 4
Joined: 23.08.2015, 17:40

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

Post by bob61ch » 04.09.2015, 18:27

Hi Lindi
as you are confirming that your hardware is working with Desktopstation, and you compiled with Arduino 1.5.6 R2 by using CAN_USB_gwV15Q_GFP_CSP10, the only thing that I see is the rocrail controller, because I use the same configuration than you. Try to use the mgbox controller (see the settings that are working for me)
ScreenShot059.jpg
ScreenShot059.jpg (69.18 KiB) Viewed 325 times

Lindi
Posts: 10
Joined: 24.08.2015, 16:29

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

Post by Lindi » 04.09.2015, 20:02

Hi Bert and Bob,

thank you very much for your help so far.

@ Bert
The Leonardo arrived already but didn't really help. My other sketches didn't work with it too. So, you were right. Could you please give me some information about the Ethernet shield. I found only the Arduino Ethernet for about € 46.

@ Bob
I tried MGBOX and got different messages but the same behavior, see attached trace file.

Regards
Lindi
Attachments
rocrail.008.trc
(25.76 KiB) Downloaded 12 times

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

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

Post by woodyboy » 05.09.2015, 09:17

Dear forummembers,

The attached file contains an updated version of the CAN USB variant. The V15 variant contained a definition error resulting in misuse :oops: of a boolean. The bug results in echoing the last command from the CAN bus to the CAN bus when receiving a new datagram on the Serial. Resulting that a command from Rocrail never reaches the Gleisbox. :( . Arduino versions above 1.5.6-2 seems to handle the boolean more strict. The attached version is tested with Arduino IDE version 1.6.5-r5 and an Arduino Uno.

This version suits an Arduino with a CAN shield with MCP2515 CS line on pin 10, ie the CAN DIY without pin rerouting.

Edit: attachment changed to match queuedepth in sketch and libraries
Attachments
CAN_USB_gwV17Q_GFP_CSP10.zip
necessary libraries included
(35.01 KiB) Downloaded 36 times
Last edited by woodyboy on 07.09.2015, 16:43, edited 3 times in total.

bertc3p0
Posts: 310
Joined: 25.04.2012, 20:19
Location: near Frankfurt Germany

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

Post by bertc3p0 » 05.09.2015, 15:02

Hi Lindi,
Lindi wrote: The Leonardo arrived already but didn't really help. My other sketches didn't work with it too. So, you were right. Could you please give me some information about the Ethernet shield. I found only the Arduino Ethernet for about € 46.
an Arduino Ethernet shield seems to be the next logical step, but 46 Euro for this ? You can get an BananaPi for less money. You only need to add a CAN transceiver (e.g. MCP2562) to the BPi and you have a high performance, bullet proofed CAN Interface + a dual core 1 GHz server. Can-utils providing valuable debugging tools. And: the Rocrail-Server runs on the Bpi using can2lan just fine :

Code: Select all

BusyBox v1.23.2 (2015-09-03 18:15:52 CEST) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 CHAOS CALMER (Bleeding Edge, r46778)
 -----------------------------------------------------
  * 1 1/2 oz Gin            Shake with a glassful
  * 1/4 oz Triple Sec       of broken ice and pour
  * 3/4 oz Lime Juice       unstrained into a goblet.
  * 1 1/2 oz Orange Juice
  * 1 tsp. Grenadine Syrup
 -----------------------------------------------------
root@BananaPi:~# uname -a
Linux BananaPi 4.1.6 #3 SMP PREEMPT Thu Sep 3 18:40:50 CEST 2015 armv7l GNU/Linux

root@BananaPi:~# ip -s -d link show can0
4: can0@NONE: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 1 
	  bitrate 250000 sample-point 0.875 
	  tq 250 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
	  sunxi_can: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
	  clock 24000000
	  re-started bus-errors arbit-lost error-warn error-pass bus-off
	  0          0          0          0          0          0         
    RX: bytes  packets  errors  dropped overrun mcast   
    150284     18802    0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns 
    225538     37606    0       0       0       0       

root@BananaPi:~# head -70 /opt/rocrail/rocrail.005.trc
--------------------------------------------------
                                            lll   
                                        iii lll   
                                            lll   
 rrrrrr   ooooo   ccccc rrrrrr   aaaaaa iii lll   
 rrr rrr ooo ooo ccc    rrr rrr aaa aaa iii lll   
 rrr     ooo ooo ccc    rrr     aaa aaa iii lll   
 rrr      ooooo   ccccc rrr      aaaaaa iii  lll  
--------------------------------------------------
 TM and Copyright 2002-2015 Robert Jan Versluis.
 All Rights Reserved.
   r.j.versluis@rocrail.net
   http://www.rocrail.net
--------------------------------------------------
 Rocrail 9817 [3ffdac128a3a30ca87a1e4e80c5baa68bfd4b3c6]
 Build: Sep  5 2015 03:01:34
 librocs 2.0-0 build Sep  5 2015 03:01:26
 processid = 1148
       mac = 02030A4306440200
--------------------------------------------------
20150905.142722.691 r9999I main     OSystem  0551 unlimited key for version 2.0
20150905.142722.691 r9999I main     OApp     0967 dpIID = []
20150905.142722.692 r9999I main     OApp     0968 ptIID = []
20150905.142722.692 r9999I main     OApp     0969 svIID = []
20150905.142722.692 r9999I main     OApp     0970 lcIID = []
20150905.142722.693 r9999I main     OModel   0440 parsePlan file: plan.xml
20150905.142722.698 r9999I main     OAnalyse 10749 MRD[100] ExtChk: basic[1]c[0] block[1]c[0] route[1]c[0] action[1]c[0]
20150905.142722.698 r9999I main     OAnalyse 8396 checking plan health...
20150905.142722.699 r9999I main     OAnalyse 8776 Starting zlevel check
20150905.142722.700 r9999I main     OAnalyse 3620 zlevel check: 1 items
20150905.142722.700 r9999I main     OAnalyse 8813 objectmap is empty
20150905.142722.701 r9999I main     OAnalyse 8823 Plan is healthy
20150905.142722.701 r9999I main     OAnalyse 0191 cleaning up the ANALYSER...
20150905.142722.701 r9999I main     OAnalyse 0258 ANALYSER is cleaned up
20150905.142722.702 r9999I main     OModel   0504 parsePlan title: New Plan
20150905.142722.702 r9999I main     OModel   3782 init clearingMaps...
20150905.142722.702 r9999I main     OModel   3807 init creatingMaps...
20150905.142722.703 r9999I main     OModel   3811 init creatingFbAddrMap...
20150905.142722.703 r9999I main     OModel   2592 createFbAddrMap: size=0.
20150905.142722.704 r9999I main     OLoc     4337 no restore wanted: reset speed for loco [335 105-3 DB]
20150905.142722.704 r9999I main     OLoc     4341 no restore wanted: reset functions for loco [335 105-3 DB]
20150905.142722.707 r9999I main     OLcDrive 0706 LcDriver 2.0.0 loaded for 335 105-3 DB
20150905.142722.707 r9999I main     OLoc     4367 loco [335 105-3 DB] enterside=[+]
20150905.142722.708 r9999I main     OModel   3835 init creatingFbAddrMap...
20150905.142722.708 r9999I main     OModel   2614 createSwAddrMap: size=0.
20150905.142722.709 r9999I main     OModel   2635 createCoAddrMap: size=0.
20150905.142722.709 r9999I main     OModel   5670 loading occupancy file [occ.xml]
20150905.142722.710 r9999I main     OModel   3840 init blocks...
20150905.142722.712 r9999I main     OControl 2176 devices: ""
20150905.142722.712 r9999I main     OControl 1751 initDigInts lib="mgbox" idd="BPi"
20150905.142722.714 r9999I main     OMCS2    2734 ----------------------------------------
20150905.142722.715 r9999I main     OMCS2    2735 MGBOX 2.0.0
20150905.142722.715 r9999I main     OMCS2    2736 ----------------------------------------
20150905.142722.716 r9999I main     OMCS2    2737   s88 modules      [0]
20150905.142722.716 r9999I main     OMCS2    2738   version          [0]
20150905.142722.716 r9999I main     OMCS2    2739   sensor device ID [0]
20150905.142722.717 r9999I main     OMCS2    2740   command pause    [10]ms
20150905.142722.717 r9999I main     OMCS2    2741   sensor range     [0-0]
20150905.142722.717 r9999I main     OMCS2    2742   hash             [0x2F20]
20150905.142722.718 r9999I main     OMCS2    2744   system info      [yes]
20150905.142722.718 r9999I main     OMCS2    2745   discovery        [yes]
20150905.142722.718 r9999I main     OMCS2    2746   bind             [yes]
20150905.142722.719 r9999I main     OMCS2    2747   report state     [yes]
20150905.142722.719 r9999I main     OMCS2    2751   sublib           [default]
20150905.142722.719 r9999I main     OMCS2    2757   udp address      [192.168.0.159]
20150905.142722.720 r9999I main     OMCS2    2758   udp tx port      [15731]
20150905.142722.720 r9999I main     OMCS2    2759   udp rx port      [15730]
20150905.142722.720 r9999I main     OMCS2    2760 ----------------------------------------
20150905.142722.721 r9999I gbxreade OMCS2    2101 MGBOX reader started.
20150905.142722.722 r9999I main     OControl 1794 send loco list to digint...
20150905.142722.721 r9999I gbxwrite OMCS2    2648 MGBOX writer started with hash: 0x2F20
20150905.142722.723 r9999I mgboxsvc OMCS2    2500 CAN device detection started on interface: BPi.
20150905.142722.723 r9999c mgboxsvc OMCS2    2502 Request CAN configuration by ping
20150905.142722.725 r9999I main     OMCS2    0610 locolist received
20150905.142722.725 r9999I main     OControl 1820 initDigInts OK
20150905.142722.725 r9999I main     OPowerMa 0558 Power Manager instantiated.
20150905.142722.726 r9999I main     OControl 0179 Init short circuit sensor...
20150905.142722.727 r9999I makeWeat OWeather 0812 make weather started...
20150905.142722.728 r9999I main     OClntCon 0592 ClientConnection started on port 8051.
20150905.142722.726 r9999I checker  OControl 2100 Checker started.
20150905.142722.728 r9999I clocktic OControl 2016 ClockTicker started.
20150905.142722.728 r9999I broadcas OClntCon 0482 Broadcaster started.
20150905.142722.729 r9999I cconmngr OClntCon 0363 Manager started.
20150905.142722.729 r9999I gbxreade OMCS2    1082 Ping type: 0x0010 -> Gleisbox UID: 0x47437B11 stored for hash: 0x533C
20150905.142722.730 r9999I gbxreade OMCS2    1087 Gleisbox firmware version = 1.39
20150905.142722.730 r9999I hts00F30 OHttp    0101 HttpService started on 1200.
20150905.142722.731 r9999I gbxreade OMCS2    1170 mcs2gfpUID: 0x00000000  mcs2guiUID: 0x00000000 ms2UID: 0x00000000 gbUID: 0x47437B11 on interface BPi
20150905.142722.731 r9999I htm00F30 OHttp    0148 HTTPManager started on 1200.
20150905.142722.731 r9999I main     OSystem  0551 unlimited key for version 2.0
20150905.142722.732 r9999I phtm00F3 OHttp    0331 Rocweb manager started on 8088.
20150905.142722.733 r9999I phts00F3 OHttp    0193 Rocweb service started on 8088.
20150905.142722.735 r9999I main     OSystem  0551 unlimited key for version 2.0
20150905.142722.736 r9999I main     OArchive 0504 ------------------------------------------------------------
20150905.142722.736 r9999I main     OArchive 0505 @Box
20150905.142722.736 r9999I main     OArchive 0506   home     = [abox]
20150905.142722.737 r9999I main     OArchive 0507   readonly = [false]
20150905.142722.738 r9999I main     OArchive 0508   Copyright (c) 2002-2015 Robert Jan Versluis, Rocrail.net
20150905.142722.738 r9999I main     OArchive 0509   All rights reserved.
20150905.142722.739 r9999I main     OArchive 0510 ------------------------------------------------------------
20150905.142722.739 r9999I main     OArchive 0397 read ini [abox/rocabox.ini]
Regards,

Gerd

PS: your Arduino wouldn't be obsolet - it's perfect for feedback or S88 gateway or something like that ...

Lindi
Posts: 10
Joined: 24.08.2015, 16:29

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

Post by Lindi » 05.09.2015, 15:50

Hi Bert,

good news :D . It works. Your Version 17 in combination with Arduino 1.6.5 does what is expected to do:
The power gets on the track,
lights of the locomotive are on,
and it drives forwards and backwards.
It is like christmas. Thank you very much. Hopefully I can help you once too.

I'm looking forward to exploring Rocrail step by step.

Regards,
Lindi

Lindi
Posts: 10
Joined: 24.08.2015, 16:29

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

Post by Lindi » 05.09.2015, 16:52

Hi Gerd,

sounds interesting to me. My next step would have been to install the Rocrail server on a Raspberry Pi. Maybe I could overtake this step and face directly the Banana Pi variant.
But in this case I would have a bunch of questions for you e.g.
- How to "add" the CAN transceiver?
- How to get the Gleisbox connected?
- What exactly is CAN-utils?

Regards,
Lindi

bertc3p0
Posts: 310
Joined: 25.04.2012, 20:19
Location: near Frankfurt Germany

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

Post by bertc3p0 » 05.09.2015, 18:34

Hi Lindi,
Lindi wrote:Hi Gerd,

sounds interesting to me. My next step would have been to install the Rocrail server on a Raspberry Pi. Maybe I could overtake this step and face directly the Banana Pi variant.
But in this case I would have a bunch of questions for you e.g.
- How to "add" the CAN transceiver?
quite simple using a MCP2562

Code: Select all

BPi    MCP2562
5V     Vdd
GND    GND
3V3    Vio
PIN16  CANTX
PIN18  CANRX
EDIT: MCP2562 PIN 8 also needs connection to GND:

Code: Select all

STDBY: GND
/EDIT
- How to get the Gleisbox connected?
similar to existing environment with GND, CANL and CANH
- What exactly is CAN-utils?
Linux-CAN / SocketCAN user space applications e.g. candump (dumping CAN traffic)

Code: Select all

root@BananaPi:~# candump -tA -xe can0,0:0,#FFFFFFFF
 (2015-09-05 19:23:12.331310)  can0  TX - -  00304711   [0] 
 (2015-09-05 19:23:12.331897)  can0  RX - -  0031533C   [8]  47 43 7B 11 01 27 00 10
sent a CAN-Ping to the Gleisbox:

Code: Select all

root@BananaPi:~# cansend can0 00304711#
Here a disruption (the cable to the Gleisbox was cut):

Code: Select all

	controller-problem{tx-error-warning}
	protocol-violation{{frame-format-error,error-on-tx}{}}
	bus-error
	error-counter-tx-rx{{96}{0}}
 (2015-09-05 19:24:14.704756)  can0  RX - -  20000088   [8]  00 00 82 00 00 00 00 00   ERRORFRAME
	protocol-violation{{frame-format-error,error-on-tx}{}}
	bus-error
 (2015-09-05 19:24:14.705958)  can0  RX - -  2000008C   [8]  00 20 82 00 00 00 80 00   ERRORFRAME
	controller-problem{tx-error-passive}
	protocol-violation{{frame-format-error,error-on-tx}{}}
	bus-error
	error-counter-tx-rx{{128}{0}}
 (2015-09-05 19:24:14.705963)  can0  RX - -  20000088   [8]  00 00 82 00 00 00 00 00   ERRORFRAME
	protocol-violation{{frame-format-error,error-on-tx}{}}
	bus-error
These tools are handy to evaluate a CAN-Bus Problem.

It's on my TODO list to describe it in detail. Nevertheless a picture:
Image
I didn't had a MCP2562 in my stock so I used a MCP2551 (with voltage divider).

Regards

Gerd
Last edited by bertc3p0 on 08.11.2015, 16:04, edited 4 times in total.

woodyboy
Posts: 628
Joined: 18.11.2013, 16:01

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

Post by woodyboy » 06.09.2015, 14:01

Attached the sketch and libraries with integrated S88 support. Remark the S88 support is limited to 32 sensors and supports only the S88 bus and compatible devices. The used pinnumbers are the same as for S88 interface shield (although this is conflicting with SD card usage).
Attachments
CAN_USB_gw_S88_V17Q_GFP_CSP10.zip
necessary libraries included
(36.51 KiB) Downloaded 43 times

Post Reply

Return to “DIY Hardware”