Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Hey all!!
While I was placing an order with an electronics parts company today, I decided to pick up an Arduino Uno Micro-controller to play around with. I intend to do some simple stuff to get accustomed to it and it's programming. However, I also have some ideas to turn it into a custom K83/K84 type controller. You can add prototyping "shields" to add your own circuitry to the basic board so some interesting thoughts and ideas come to mind.
The question I have, has anyone out there used a micro-controller from any manufacturer to read in the Markin digital signal?? I have links to websites talking about the make-up of the digital signal and with some time I can probably work thru working up the software to get the micro-controller to understand the digital information but if someone else has already done so and they don't mind sharing I figure why should I spend time "reinventing the wheel".
What I think I would need is the assembler level program and the type of micro-controller used. From there I think I should be able to reverse engineer the software to the Arduino commands. When I have successfully completed the ability to have the Arduino understand the Marklin digital signal, I will be happy to share with whoever is interested.
The Arduino Uno is a complete working system including free software to program it. Nothing is needed to download a program to it except a USB cable. There are 14 Digital I/O pins, 6 of which can be used for PWM output. And 6 analog inputs. The Arduino Uno has other shields available too. One allows you to control DC motors, stepping motors and servos. But first I will need to get it to read the digital signal.
Any help would be appreciated!!
Robert
|
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Well it has been a month since I posted this and no responses ... I was hoping somebody might have something. I did get my Arduino Uno. Haven't had an opportunity to play with it yet. Here is a photo ...  That is a USB connector on the upper left and a power jack below it. Although I haven't found anyone to share any code, I know the Arduino should be able to do it. Here is a pic of the PCB for Marklin's digital signal. If the detail is good enough, you can see the Atmel Mega8 chip, a little sister to the Atmel chip on the Arduino.  However what I have found are two sites with code for a DCC decoder. One has the Arduino code for a DCC receive subroutine. The other site has a number of complete C programs for DCC decoders that do different things. There is some interesting coding for setting the address and a "mode". Like some decoders where you press a programming button and then click on a item from the CS, these programs also select a mode based on which item you click from the CS2. Let's see if I can explain. Normally if you press item #5 from the keyboard menu, you have chosen address #2 for the decoder. For signals, it would give you the first of four devices on address #2. With the decoder software for DCC this website shows, depending on which red or green position you click on items #5-8, you will select a mode of 0-7 and the program within the micro-controller decoder can then respond differently as to how it operates. It might allow you to control turnouts with different pulse durations, signals with different aspects, lights that turn on slowly (like simulating a sodium bulb) and more. I am going to have to dig into this some more. I am still looking for the code for Marklin's Motorola format so if anyone has anything let me know. Meanwhile when I get some time, I will look into how I can get the C program to load into the Arduino. It does look promising. Robert
|
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
|
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
|
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks Thomas!!
I am actually not into Apple Ithingies. I have a problem with people that tell me what I want and need and that is the way Steve Jobs likes to run things. LOL!!
I have been searching the web for all things Arduino. There is a ton of stuff out there. I have got a number of personal projects going on that I haven't had time to play with it too much and try the DCC decoder software I found. Most of my time is working on my project to take my floor layout and put it on wooden modules that will still sit on the floor. I am anxious to get back to running my trains!! Still looking for some code to do a Marklin/Motorola accessory decoder.
Robert
|
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
|
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks Thomas, I already have those links. I am not trying to use the Arduino to control the trains, just trying to use it as a K83/K84 substitute.
Robert
|
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
Originally Posted by: Nielsenr  Thanks Thomas, I already have those links. I am not trying to use the Arduino to control the trains, just trying to use it as a K83/K84 substitute.
Robert Got you. Have you looked on the Stummi forum? r/Thomas |
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
|
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks again Thomas, I have those sites. The opendcc.org site is where I got the code for a DCC decoder although it is in C programming. It is quite interesting. There is another site http://opendcc.sourceforge.net/They have taken the work from the opendcc.org site and converted the receive data part of the code and converted it to Arduino code. You program the Arduino with a supplied free compiler that uses a modified C++ programming. However I have also found that thru third party compilers (Eclipse), you can take regular C/C++ code, compile it and download to the Arduino. That software is free and I have downloaded it. When I get some time, I will start playing with it. Since the opendcc.org site also gives schematics of their boards based on the Atmel micro-computer, there are some electronic parts I need to pick up to interface to the DCC signal and the output circuits to drive relays, turnout motors, etc. As for the Arduino, there are a lot of sites selling stuff. I found one in China that has sensors, shields and other items at real good prices. Here is the link: http://yourduino.com/whatcanido.htmI placed and order and it arrived earlier this week. I have found shields that will control a number of motors or stepper motors. As soon as I can come up with an idea to use it with the trains, I'll order one of those. If you find a site that has the programming coding for Marklin/Motorola accessory decoders, let me know. Hex code may not necessarily work if it is for a different Atmel chip that what the Arduino has. With the programming code I would be able to modify the code to do other things. Thanks again for your help. Robert
|
|
|
|
Joined: 25/07/2001(UTC) Posts: 11,165
|
How much do these boards cost? Our member perz has designed his own decoder/controller units with pic type programming, reacting on Märklin digital signal format. Maybe you should get connected?  |
Juhan - "Webmaster", at your service... He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb] |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
I picked up my board for around $30 US. It is an official Arduino board. There are some third party vendors that you might get it a little cheaper. You also can probably build a cheaper board from scratch but this board is all ready to go for prototyping something up. And as I have said, there are many add on boards (shields) that piggy back on the board that do a lot of different things from ethernet connections, bluetooth, motors, etc. And there is a great library of already developed subroutines to control them.
Thanks for giving me perz's name. I remember reading a topic of his but spent hours looking for it and couldn't find it. I also thought I bookmarked his website but couldn't find it either. Now I should be able to find his topic and contact him.
Robert
|
|
|
|
Joined: 25/07/2001(UTC) Posts: 11,165
|
I visited perz some time ago, since he lives within "reasonable" distance from me, and when he ran his layout I was rather amazed that he had built & programmed all these hardware controllers and controlled them with commands from a "command window" on his computer - not with a more user-friendly windowed software application... And the layout ran very nicely indeed - so if the advanced basic logic is there, you really don't need the clickable shiny flashy things that the general public see as "cool"... He's a great guy and knows "a little bit" about HW controllers & HW design since it's his daily work... |
Juhan - "Webmaster", at your service... He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb] |
|
|
|
Joined: 25/07/2001(UTC) Posts: 11,165
|
But 30$ will not make me want to go into making a "6083" out of it... I'd rather pay a little bit more to get a "real" one that works out of the box. However, a "general" cheap programmable board with sensor/driver extension possibilites is always interesting... |
Juhan - "Webmaster", at your service... He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb] |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Juhan, I understand that @$30 a out of the box K83 is the way to go. But part of the fun is in programming and see what I can make it do. Once I have a working code what if I change it so that when you put it in "programming mode", you actually assign the Arduino multiple Marklin/DCC addresses? Then you change the coding for the outputs to allow for an external multiplexor chip so that you could control multiples of 4 outputs. Take for example the boards and software shown on http://www.opendcc.de. On these decoders, 8 output pins drive the 4 sets of outputs like a K83. But change the coding so that 4 pins drive a CD4067 16 channel multiplexor and the other 4 pins drive a second CD4067. Each CD4067 could then drive 8 pairs of outputs. The 2 CD4067s could then drive a total of 16 pairs of contacts. The cost of a CD4067 is a little over $1.00. So with a few $$ of extra chips and a proto board and connectors, some reprogramming of the Arduino, and you are now controlling 16 K83 type outputs. The boards and software on the Open DCC site also do lighting effects, signals, etc. One could then make a decoder that could do some very custom things. I haven't spent much time thinking about how to do it, but I am sure you could make the Arduino drive multiple hobby signals. The hobby signals are much less expensive than the digital ones. One output could control the signal and another output could drive a relay to operate a stop section of track. And I'll bet you can have Arduino make the signals go thru a slow change of the lights too. This type of project let's me combine my hobbies of playing with trains and electronics. I understand it is not for everyone. Robert
|
|
|
|
Joined: 01/03/2009(UTC) Posts: 1,339 Location: USA
|
Robert, Keep us posted on your progress. There is a real dearth of information here in the states about Arduino and MRR. It seems your best source will be the German sites. Maybe post some questions on the Stummi board. I don't know if this is something that Clapcott dabbled in, he is always a great source for things digital. Might also look up Dale Schultz. http://modeltrain.servehttp.com/layout.nsfr/Thomas |
ETE  ECoS iTrain TouchCab C-Gleis German Era Id & IIIb USA Era IIIb SBB Era III SJ Era IV GC Era V |
 1 user liked this useful post by GSRR
|
|
|
Joined: 17/09/2006(UTC) Posts: 18,778 Location: New Zealand
|
Originally Posted by: GSRR  I don't know if this is something that Clapcott dabbled in, he is always a great source for things digital. Peter is going to be away shortly for a while, but is around this weekend. Best to get hold of him sooner rather than later!
|
|
|
|
Joined: 26/03/2006(UTC) Posts: 1,423 Location: Brisbane, QLD
|
If you're interested in the Arduino project, you might like to have a look at NXP's LPCXpresso program. It's a similar thing, but exclusively using NXP's ARM microcontrollers (mostly Cortex-M3 and -M0, and a few ARM7) The hardware is made by Embedded Artists, and the C compiler by Code-redThe boards are all €20, with an "expansion board" at €12. Since I Use the LPC2214 at work, (and we're moving to the LPC1788 Coretex-M3), I rather like this range of cheap developement boards. |
Cheers, Damon |
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks for the info Damon, it looks to be a similar concept as the Arduino. Pricing seems to be similar too. I'll have to do some research on it. Have you done any work on getting one to read Marklin/Motorola or DCC data streams?
Robert
|
|
|
|
Joined: 26/03/2006(UTC) Posts: 1,423 Location: Brisbane, QLD
|
Originally Posted by: Nielsenr  Thanks for the info Damon, it looks to be a similar concept as the Arduino. Pricing seems to be similar too. I'll have to do some research on it. Have you done any work on getting one to read Marklin/Motorola or DCC data streams?
Robert Robert, I'm afraid I haven't used them at all. I'm interested in them because I'm planning to use the LPC1788 in the next version of our product at work, and money for development toys is very tight at the moment  . However, I don't think it would be very hard to port those axamples you listed to this platform -- the ARM micros are surprisingly powerful for their cost and power consumption, and each of them (within the same core) are essentially variations on a theme -- once you get the code running on one, moving to a different variant is simple. I may well buy some for myself to play with... |
Cheers, Damon |
|
|
|
Joined: 28/04/2003(UTC) Posts: 757 Location: Wawa, Ontario
|
Originally Posted by: Nielsenr  Juhan,
This type of project let's me combine my hobbies of playing with trains and electronics. I understand it is not for everyone.
Robert I agree, but it sure keeps the mind occupied and there is always more than one way to get the same end result but with less dollars. Matthew
|
|
|
|
Joined: 03/10/2010(UTC) Posts: 1,298 Location: Cape Town, South Africa
|
Robert, I want to ask you about your progress with the Arduino, please. Can you provide me with an update on how far you have got ? I am beginning to become interested and fascinated by this technology. Regards, John
|
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Hi John,
Unfortunately I have not had the time to get into this project. Shortly after I posted this, I got a client who wanted a Lionel O Gauge layout built. I started on a single level 10' x 7' layout that while building it, grew to a two level 12' x 7' layout. As soon as it was finished, the client wanted a 6' x 7' expansion added to it. These were all finished by the end of 2012. Then he had me add a small upgrade a few months later. Then around May 2013, we moved the layout from his house to a warehouse and I have been expanding it to 37.5' x 15'. This construction has been keeping me very busy.
I still want to do something with the Arduino. I keep looking for sources of code to read the Marklin digital signal, but no luck so far. As said previously in this thread, I do have code to read DCC so when I finally get an opportunity to work on this project, I amy go the DCC route.
Robert
|
|
|
|
Joined: 25/07/2001(UTC) Posts: 11,165
|
There is "CAN bus shield" for the Arduino, right? Should be possible to code some examples with the help of the CAN documentation from Märklin...
I am very tempted to give it a try... But have to find the time for it, which makes it a wish only right now...
|
Juhan - "Webmaster", at your service... He who asks a question is a fool for five minutes. He who does not ask a question remains a fool forever. [Old Chinese Proverb] |
 2 users liked this useful post by Webmaster
|
|
|
Joined: 14/10/2013(UTC) Posts: 34
|
|
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks Juhan, I hadn't thought about the CAN bus. When I get time I'll look into it. Yea, right, when I have time!! LOL!!! Busy, busy, busy ...
aswap5, yes, I know of Railuino from the posts on the forum. But it is acting as a controller, generating the digital signal. I just want to read the existing signal from the CS2 with the Arduino. I haven't had the time to look over the code to see if I can reverse engineer the receiving code from the generating code. And in fact, last June I posted a question to Yaasan in his thread and never really got a response to my question.
Robert
|
|
|
|
Joined: 17/09/2006(UTC) Posts: 18,778 Location: New Zealand
|
I don't know if any of these books are any use, but they have articles on using various types of sensors with Arduino, as well as using servos, etc. Edited by user 08 February 2014 20:58:47(UTC)
| Reason: eBooks uploaded to forum
|
 1 user liked this useful post by Bigdaddynz
|
|
|
Joined: 06/10/2010(UTC) Posts: 883 Location: Fort Lauderdale, FL
|
Thanks Bigdaddy!
I downloaded both although the first download wouldn't work in Firefox and I had to switch to Chrome. I'll go over them when I have some time.
Robert
|
|
|
|
Joined: 17/09/2006(UTC) Posts: 18,778 Location: New Zealand
|
I downloaded them both using Firefox.....
At any rate, Juhan has now fixed the large file upload issue with the forum, so I have uploaded the eBooks directly to the forum.
|
 1 user liked this useful post by Bigdaddynz
|
|
|
Joined: 01/06/2013(UTC) Posts: 99 Location: Tokyo
|
Hi Nielsenr, I'm very sorry for that. I may forget to answer your question. You mean you want to analyze and decode DCC or MM2 pulse, right? I recommend you to check some decoder examples.  Above image means pulse input(EDGE_POS) circuit with power supply from rail. EDGE_POS signal need to connect to a MCU's external interrupt pin. MCU can count pulse interval using internal timer. The time can use to identify the data bit on the rail. If you have a question, please send me message. Best regards, Yaasan Originally Posted by: Nielsenr  Thanks Juhan, I hadn't thought about the CAN bus. When I get time I'll look into it. Yea, right, when I have time!! LOL!!! Busy, busy, busy ...
aswap5, yes, I know of Railuino from the posts on the forum. But it is acting as a controller, generating the digital signal. I just want to read the existing signal from the CS2 with the Arduino. I haven't had the time to look over the code to see if I can reverse engineer the receiving code from the generating code. And in fact, last June I posted a question to Yaasan in his thread and never really got a response to my question.
Robert
|
 1 user liked this useful post by Yaasan
|
|
|
Joined: 12/04/2008(UTC) Posts: 119 Location: Alimos
|
Originally Posted by: Nielsenr  Hey all!!
While I was placing an order with an electronics parts company today, I decided to pick up an Arduino Uno Micro-controller to play around with. I intend to do some simple stuff to get accustomed to it and it's programming. However, I also have some ideas to turn it into a custom K83/K84 type controller. You can add prototyping "shields" to add your own circuitry to the basic board so some interesting thoughts and ideas come to mind.
The question I have, has anyone out there used a micro-controller from any manufacturer to read in the Markin digital signal?? I have links to websites talking about the make-up of the digital signal and with some time I can probably work thru working up the software to get the micro-controller to understand the digital information but if someone else has already done so and they don't mind sharing I figure why should I spend time "reinventing the wheel".
What I think I would need is the assembler level program and the type of micro-controller used. From there I think I should be able to reverse engineer the software to the Arduino commands. When I have successfully completed the ability to have the Arduino understand the Marklin digital signal, I will be happy to share with whoever is interested.
The Arduino Uno is a complete working system including free software to program it. Nothing is needed to download a program to it except a USB cable. There are 14 Digital I/O pins, 6 of which can be used for PWM output. And 6 analog inputs. The Arduino Uno has other shields available too. One allows you to control DC motors, stepping motors and servos. But first I will need to get it to read the digital signal.
Any help would be appreciated!!
Robert Hi Nielsenr, We have exactly the same interest. I'm looking to find a way to use Arduino as a decoder to manage whatever I want, from servos to change turnouts, the House lights, signals, etc. I think it would be more cheaper to manage many servos (16 ) with one Arduino Uno, than using other decoder. The way I'm trying to find a solution is to use the same can bus that marklin offer for any interconnection. In that case i hope i can use the 60125 for distance "controllers" or I'll use I2C between other arduinos to manage devices. The bad issue as i think, is the addressing, and probably I have to "name" each one before i use it on a layout. Dimitris |
|
 1 user liked this useful post by Dgriman
|
|
|
Joined: 15/03/2003(UTC) Views messages in topic : 9,603 Location: Australia
|
Miss 16 and I have a few of the Arduino (including the awesome Nano) and Raspberry boards. This is a picture of her first solo Arduino project done a year or so ago - something from Make magazine (from memory)..  She won't dismantle this one, which is one of the reasons why we have so many of these boards at home... Sigh! If the eCOS ever blows up (God forbid while knocking on wood), I am sure that I could get by using Yassan's Arduino project..  |
Adrian Australia flag by abFlags.com |
 1 user liked this useful post by xxup
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.