Page 1 of 1

finally a new Feedbacksystem: SpaßCAN

Posted: 13.09.2016, 13:40
by MrGShumway
Hi everyone,
minor things first (because in every board on the internet, you have to start with a couple of excuses why you have to start a new thread on a completely irrelevant topic). I'm using rocrail for a while on our gardenrailway, and it's simply fantastic - if you do it right - as always. And as always, the railway had to grow, and the technical infrastructure set to many limitations.
After coding and constructing a few open-source DCC decoders for large scales over at the Spaßbahn-Forum (Especially the Einzelweichendecoder is still making me proud), I felt self-confident enough to start thinking about a self-developed bussystem for feedback, controlling and sensing. Yeah I know: hurray, finally a new system, some moron made-up.
But it's not as it seems (yeah, everyone says that).
After a bit of planning ( not enough), and some research (more, would have been better)
we came up with a CAN-Bus (Oh how innovative) wich should work together with most systems on CAN-Protocol. So we designed a command set, matching most feedback functions, that can be configured or changed, or even mixed with other bussystems and frequencies.
And because it all started on the Spaßbahn-Forum-Board, we gave it the working-title "SpaßCAN" (it's a bit funny, when you're from germany)

So the work began. First, we designed a simple Interfaceboard, with a power-supply for the bus-modules and a CAN-Driver with I2C Interface. we first chose a Arduino Nano as the interfacecontroller, but in the mean time the Arduino moved, and an ESP8266 got it's place. Mainly because the ESP8266 is a lot more powerful and second, because later it would be neat to use the wifipart to communicate. The first software emulated the LDT S88-HSI (I had no better ideas), to stay compatible with rocrail and other applications. But, due to the limitations of the HSI-Protocol, the most functions wouldn't work.
So there had to be a native protocoll, for all purpose. Until now it works quite well.

On the other side, we constructed a simple (sensing) feedback module with 16 Inputs, to use with different methods of collecting data. We’re using it with the good known „four-diodes-per-port-sensing“ sensor and with Halleffectchips, as well with contactracks. The busmodules are bus-programmable, and maybe later equipped with a CAN-bootloader. (some images could be seen on my homepage: )

To reuse our old feedbackmodules, we developed a s88toCAN-board, which reads the s88 datastream and translate it to the CAN bus.

the last ready-to-use module is a RFIDtoCAN-reader on 125 KHz. Guess what it does. It transmits the ChipID as a 32bit number, without the need to recode or decode.

I started to code a busmaster-application, to programm the busmodules and test the businstallation, but it nearly got me to the edge of insanity. Do you know this little plasticballs, one can knead for relaxation? Mine flew out of the window, burning. when I was young, it was so easy to code in Visual Studio (it was before .Net) and everything was great. But now, you have to double check every threadcall and have to „invoke“ and „poke“ and it costs you hours and days.

The perk of all that is, that the busmodules (basing on pic18f-chipsets) only costs a few euro (e.g. the RFID Reader costs all in all around 5,50€ and the sensor board less then 10 €. All with a real stable transmitting bussystem over large range (we tested a buslength over 50 meters, and theoretically up to 250 meters are possible). Some development milestones can be seen on the Spaßbahn-Board: ... adID=10384

So here is my question (its about time): How to get my Interface to work together with RocRail and to make a use of the functionality? I attached the current protocol for Rs232
SpaßCAN Interface 1.0 Protokoll.pdf
(56.93 KiB) Downloaded 22 times

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 13.09.2016, 14:17
by rjversluis

I can add an extra library, SCANI, to Rocrail for this protocol if you also can provide some examples of the packet format.

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 13.09.2016, 15:26
by rjversluis
The protocol has some flaws.

1) its a mix of ASCII and binary; EOT could also be in the binary data.
2) the address offset of the 'Rückmelder' cannot be calculated. Is the CANID the offset?
3) the address of the 'RFID-Leser' cannot be calculated. Is the CANID + Port the address?

Its looks indeed like a 'Spaß' protocol which is not really suited for serial communication...
Rethink the protocol, and make a decision to use ASCII or binary.

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 13.09.2016, 20:04
by bertc3p0

for the RS232<->CAN protocol I would suggest SLCAN - easy, widely used and already implemented in Rocrail. For the CAN based protocol itself have a look at Merg or Märklin.



PS: Cheapest PC/SBC CAN interface ever - less than 5 bucks :mrgreen:

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 13.09.2016, 22:11
by MrGShumway
ups. I have to confess, that it wasn't very well thought-out.
I revised it a bit, and it got more logical.
SpaßCAN Interface Protokoll 1.2.pdf
(64.17 KiB) Downloaded 27 times

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 14.09.2016, 06:53
by rjversluis
There is no way to detect the start or end of a packet.

Xpressnet has this sequence:
1.3 Konventionen
Jeder Befehl, der an das Interface gesendet wird, muss die Sequenz 0xFF 0xFE vorangestellt bekommen. Diese Sequenz fliesst nicht in die Berechnung der Checksumme ein.
Als Beispiel, um den Befehl "Alles an" an das Interface zu senden, müssen folgende Daten übertragen werden :
0xFF 0xFE 0x21 0x81 0xA0

You can also use an existing protocol like RASCII.

Re: finally a new Feedbacksystem: SpaßCAN

Posted: 14.09.2016, 08:35
by MrGShumway
good morning,
you're right. It would be easier to read, if it sends a specific start-sequence. And I think, both approaches (xpressnet-example and the usage of RASCII) are quite promising.
I guess it's the easiest way to write it for Rascii and later switching to an own library, when wifi is implemented. (If it still exists)
Thank you for your quick response and helpful suggestions

Liebe Grüße