Advice on programming a accessory decoder for a computer controlle train layout.

raschemmel:
If it isn't too much trouble can you post your project details for others who wish to follow in your footsteps,

Once I get some stuff together, sure. I have a hand full of different things I'm trying to make, but nothing is really constructed yet since I'm waiting for various parts to arrive. No use in going on about it until I've got something worth showing.

I dumped the need for a MM powered decoder since upon further investigation I found I could operate DCC and MM accessories alongside each other. This is great news for me! Robin2's stripped out source for the decoder is invaluable though and I think it'd be important for anyone that wants to go beyond prepackaged solutions.

I've expanded my scope some, utilizing the idea of Arduino in further ways. I was toying with the idea of RFID tags. Originally I was just going to use a simple reed switches. The idea was that I could have passenger trains that'd trip them and automatically pull into stations. I expanded this idea further though as I found too many limitations with such a simple system. If I could use an RFID tag, I could track specific trains and have them act accordingly. Thus, I could have a mainline with an express passenger train doesn't stop at the branch line. A regional passenger train that does. I could then also have long haul freight trains that pass by, and then trains that service the branch line that'd pull in automatically.

It seems a rather trivial affair to make. I've looked into RFID on Arduino briefly and found enough information. Some simple if/else statements, and I could have it trip a relay that's hooked up to a S88.

There's a few things I'm unsure about though. There's the issue of range, there's the issue of the size of the RFID reader, and there's the issue of the size of the RFID chip.

I thought something under the track would be best, but I realized maybe I couldn't do that so easily with my floor layout. I can't very well cut a dent into my floor to house it, hehe. Maybe something that sits track side? Which would help with the size issue, since if it sat next to the track it wouldn't have to be as compact.

I found these, which would be ideal. https://www.sparkfun.com/products/9416 They are small and compact. Sparkfun has some suitable RFID readers, but I think the cost is too high for my application. I've been looking on eBay for some finely made chinese RFID readers, but I'm not sure what would be a good one to try. I don't know enough yet to know about compatibility.

I was thinking about using Arduino Mini Pros since they're cheaply acquired, but I don't know. I'm thinking about powering them and that's what worries me. I could get a regulated 5v power supply. That'd work, yeah? Otherwise the Nano seemed a good way to go since it has the USB connection. I could plug that into an idevice type plug couldn't I? (USB Wall Charger - 5V, 1A (Black) - TOL-11456 - SparkFun Electronics , Like this I guess, or apple's, which I have a hand full cluttering up my place. http://store.apple.com/us/product/MD810LL/A/apple-5w-usb-power-adapter.) I could source something like that off ebay, though, the chinese products in that regard scare me a little. Though the joke in the circle is that it all comes from the same factory.

Josheh-digi:
I've expanded my scope some, utilizing the idea of Arduino in further ways. I was toying with the idea of RFID tags.

I've also been looking into RFID tags. There appear to be 3 different kinds. Low frequency, high frequency and UHF. Many of the tags I've seen don't specify which of these they use. :0
I've been recommended some very small tags, about the size of a grain of rice, that are used as pet (cat and dog) chips. They come with an 'injector' (which we wouldn't need) and cost £3.00 (about 3.30 Euros) each. I'm trying to find out if they are low frequency types, whether they can be bought without the injector and if they are programmable or their code is fixed. I'll need over 30 of them for my automatic hump shunting yard.

Originally I was just going to use a simple reed switches. The idea was that I could have passenger trains that'd trip them and automatically pull into stations. I expanded this idea further though as I found too many limitations with such a simple system.

Depending on what scale you're working in, it's possible to use reed switches to identify a small number of different trains by using two magnets, at different distances apart, on each train. You wire the reed switches in series and if the distance between the reeds matches the distance between the magnets, both of them will be closed at the same time. You need only n+1 reeds to detect n different trains, as one reed is common to all the others.

I could get a regulated 5v power supply.

http://www.ebay.com/itm/5V-2A-10W-AC-DC-Universal-Regulated-Switching-Power-Supply-PSU-/231044263519?pt=LH_DefaultDomain_0&hash=item35cb4fae5f

If the movement of the trains is controlled by a computer program you wouldn't need any ID mechanism on individual trains because the software could deduce which train it is which just from the fact that it knows which train(s) have been commanded to move on what tracks. All that would be needed is something (an LDR should be suitable) to detect that a train is at location X.

In theory this could extend to identifying individual vehicles if the detector was capable of counting them as they go past.

...R

Robin2:
If the movement of the trains is controlled by a computer program you wouldn't need any ID mechanism on individual trains because the software could deduce which train it is which just from the fact that it knows which train(s) have been commanded to move on what tracks. All that would be needed is something (an LDR should be suitable) to detect that a train is at location X.

In theory this could extend to identifying individual vehicles if the detector was capable of counting them as they go past.

...R

I'm trying to avoid bringing a full on computer into this. The simpler I can get the logic, the better. I want a mix of automated and manual control. I want to be able to pull a train from the mainline onto a branch line and do my shunting. But then send it back out onto the mainline and have it incorporate. All the while having traffic on the mainline that's buzzing around. Hence the use of RFID.

If you do find more information about RFID stuff, I'd be keen to know.

raschemmel:

I could get a regulated 5v power supply.

http://www.ebay.com/itm/5V-2A-10W-AC-DC-Universal-Regulated-Switching-Power-Supply-PSU-/231044263519?pt=LH_DefaultDomain_0&hash=item35cb4fae5f

Oh cool, I didn't think to look for something like that.

I tried out the code shared in the following post, to emulator a S88 using an Arduino. I ran into an issue though, I'm not sure, but it seems the sort of issue that the author of the post was having.

http://forum.arduino.cc/index.php?topic=226538.msg1639859#msg1639859

So if I have a string of bits, 01001001
Sometimes it seems like it'd send this instead 101001001

You see, an extra one is added on to the end, while the last bit is also shifted to the first spot.

I cut his code down to the basics of what it would be. I don't think there's a specific amount of bits that you need to send. The S88 usually has 16 inputs, there are some with 8 input devices too. I had success with sending two bits. I'd send it as 01, but sometimes it'd send 101.

I wonder if it's not sending the data fast enough, if the Arduino isn't responding fast enough? It's odd. And it'll go along sending 01 fine for a little bit, then it'll start sending 101 for a little bit, then it'll switch back to 01. That's to say it's not off just once, it'll send the incorrect bits several times before switching back to the correct sequence.

His source code seems to be based on the following project. S88NAVR/S88ArduinoProMini.ino at master · dirkjankrijnders/S88NAVR · GitHub

I've come across that before and it looked pretty out there to me. I couldn't understand it. After the first guy's post though I was able to start understand what's going on. I haven't had a chance to delve further though.

A little info on S88

I tried using serial.print to see if anything gets moved around funky, but it doesn't seem so. I'm not sure if the issue is with the software or hardware. I'm not sure if the better approach would be to use the one as the fella in the second link did. There's parts of the code I don't really understand though, what's happening, with his. I mostly understand the code in the first link provided, from the guy that posted up on the forums here.

I can't make sense of S88 from that link and I'm not sufficiently interested to do a whole lot of research myself. If you can explain it I will try to help. At first glance it seems that the code I wrote to detect DCC signals could be adapted to detect the S88 signals. But I don't know whether you could do both on the same Arduino.

Apart from the question of how S88 works I don't understand what it is used for. Perhaps there is an easier way to do the same thing with Arduinos.

...R

The S88 doesn't have anything to do with DCC.

It's a device that's built up of two shift registers and IC's that capture input. The 4044N chips capture the input, the 4014N chips are the shift registers. The shift registers are controlled by the controller, the CS2 in this instance.


Out of the 6 pins, I only really use 3. Data Out, Clock (Which is an input connected to an interrupt), and Load(Which is another input connected to an interrupt). There's no need to connect to the reset pin as that's for releasing the 4044N latches, which isn't needed in software emulation.

So, this problem with the S88 is all about emulating a shift register chip.

Sorry, but I think I am going to have to drop out of this conversation. We are not at all on the same wavelength. You are describing details to someone who has no idea of the big picture.

I know it is not DCC, but I still have no idea why one would use it at all.

...R