For the coming cold winter days I bought used Märklin Maerklin C-tracks a simple oval with a track connector box (as a starting point).
One digital locomotive (with fmx decoder) some wagons and two old Maerklin Mobile Stations all together for 70 bugs :-)
Than I connected my oscilloscope and detected the protocol (*) is a bunch of CAN 2B extended frames with 29 bit ID's (CAN standard used only 11 bit frame ID's)
I found cheap MCP2515 CAN controllers with ISP interface.
Amazon https://www.amazon.com/s?k=MCP2515+CAN+ ... nb_sb_noss
In case of Linux PC or Raspberry Pi the MCP2515 is supported by the kernel via ISP module.
I will use a tiny Arduino for the CAN ISP interface connected via USB to a Windows/Linux PC.
Maybe FLT-C or Windows9 for the GUI.
(*) the two connected mobile stations are a pair of Master and Slave CAN devices and used the CAN bus for data transfer.
In case of Mobile Station II the track connector box used the CAN bus also.
(The cheapest solution is a used track connector box II (20-40$) with the CAN bus connector.)
But for hacking the CAN protocol you need at least two old Mobile Stations (MASTER and SLAVE)
or one Mobile Station II/III or any modern Central Station (not only from Maerklin)
Do you control your digital model railway via FreeBASIC or micro controller ?
Joshy
Of course in case of Maerklin you can buy a 800$ control station with touchscreen but hey where is the fun of hacking :)
datasheet: MCP2515-Stand-Alone-CAN-Controller-with-SPI
Does anyone control the digital model railway with FreeBASIC ?
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Does anyone control the digital model railway with FreeBASIC ?
Last edited by D.J.Peters on Oct 18, 2021 3:33, edited 1 time in total.
Re: Does anyone control the digital model railway with FreeBASIC ?
If you manage to do that, publish it on hackaday.com, too. They seem to have a lot of similar projects (and it would be always good to add one made in FreeBasic)
Re: Does anyone control the digital model railway with FreeBASIC ?
Note that there are many places where you can buy cheap mcp2515 based can analysers (the usual Chinese vendors). These are a bit bandwidth limited because they usually communicate to PC over USB serial, but I assume the bitrates on the railroad are not that high. Probably their USB-to-serial chip is an ATMEL or a PIC18F
I've used those to develop my own CAN boards(dspic33EP512MU8xx based)
I've used those to develop my own CAN boards(dspic33EP512MU8xx based)
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Does anyone control the digital model railway with FreeBASIC ?
@angros47 Other coders used the by Märklin well documented Central Station 2 protocol with a rail track CAN Box and Mobile Station 2.
The CS2 protocol is totally different than the none documented Central Station 1 i will try to hack.
@marcov The ISP speed of the MCP2515 to the external micro controller is up to 10MHz and the CAN traffic is up to 1MBit.
The Maerklin protocol of Central Station 1 (the father of the mobile station 1) used 250 KBits so it's fast enough.
The micro controller can send and receive all commands for the CAN traffic over USB/RS232 connected to a PC or Raspberry Pi with a FreeBASIC program.
Joshy
The CS2 protocol is totally different than the none documented Central Station 1 i will try to hack.
@marcov The ISP speed of the MCP2515 to the external micro controller is up to 10MHz and the CAN traffic is up to 1MBit.
The Maerklin protocol of Central Station 1 (the father of the mobile station 1) used 250 KBits so it's fast enough.
The micro controller can send and receive all commands for the CAN traffic over USB/RS232 connected to a PC or Raspberry Pi with a FreeBASIC program.
Joshy
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Does anyone control the digital model railway with FreeBASIC ?
Good news :-)
I was thinking how to control a model railway with any device like:
IOS or Android smartphones and tablets, Windows / Linux PCs and Macbook, ARM devices like Raspberry PI, Beaglebone, Odroid etc.
On all this devices you can use any Web Browser and the same HTML5 base for a modern GUI.
But how would you communicate for example with FreeBASIC and a Web Browser on any device ?
The solution are WebSocket so I implemented the web socket protocol in SNC (my simple network connection BI file)
wikipedia: WebSocket
specification: rfc6455
This way you can connect your Arduino or other Robot project with your web browser and of course FreeBASIC also.
Joshy
I was thinking how to control a model railway with any device like:
IOS or Android smartphones and tablets, Windows / Linux PCs and Macbook, ARM devices like Raspberry PI, Beaglebone, Odroid etc.
On all this devices you can use any Web Browser and the same HTML5 base for a modern GUI.
But how would you communicate for example with FreeBASIC and a Web Browser on any device ?
The solution are WebSocket so I implemented the web socket protocol in SNC (my simple network connection BI file)
wikipedia: WebSocket
specification: rfc6455
This way you can connect your Arduino or other Robot project with your web browser and of course FreeBASIC also.
Joshy
Re: Does anyone control the digital model railway with FreeBASIC ?
WebSocket for a simple GUI? Dealing with low level stuff like vulnerability or hash functions?
Did you check fcgi? A standard web server does all the low level stuff, the FB module only cares about the controller interaction.
BTW: I recommend to run separate programs for controller and fcgi module, connected by shared memory. That way the controller doesn't block in case of network problems.
Did you check fcgi? A standard web server does all the low level stuff, the FB module only cares about the controller interaction.
BTW: I recommend to run separate programs for controller and fcgi module, connected by shared memory. That way the controller doesn't block in case of network problems.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Re: Does anyone control the digital model railway with FreeBASIC ?
@TJF WebSocket is a realtime async 2 byte header only protocol and implemented in every HTML5 browser and full Event driven.
Howerver you can implement the WebSockets on any 1$ mirco controller and this is perfect for model railway stuff.
I have done CGI last 3 decades I love the new stuff also.
Joshy
Howerver you can implement the WebSockets on any 1$ mirco controller and this is perfect for model railway stuff.
I have done CGI last 3 decades I love the new stuff also.
Joshy