Large Scale Central

Software Nerds

Obviously I can’t be the only s/w guy who likes trains. Any C coders out there maybe interested in developing some open source wireless train control solutions?

Hmm, crickets…

http://martinsant.net/?p=1471

Shoulda got me last year. But I might get re-attached next year!

Martin Sant said:

Obviously I can’t be the only s/w guy who likes trains. Any C coders out there maybe interested in developing some open source wireless train control solutions?

Martin - I would consider myself a software guy (hardware, too!) but I am not fond of C —

I spent the last week or so fooling around with the Arduino and some of its shields & software routines and really like parts of it - I just find the programming tedious.

I would be interested in building up another wireless motor control system using newer hardware (did it some years ago with older technology) but it would likely be a PIC based system using PicBASIC Pro for the programming language.

Keep us posted on your progress. Perhaps we could share information on the hardware end.

dave

The idea is a generic wireless node using the Xbee Series 1. I’ll publish whatever datagrams I’m sending back and forth. Using Xbee, anything should be able to talk to anything else, no matter if it’s a picaxe, ardunio or whatever.

Yeah Martin, I’m well versed in the C programming language among others. not familiar with the hardware end though.
What type of code functionality do you envision for the hardware at hand?

Acceleration and braking come to mind along with speed calibration for multiple lashed locos.
Is this the type of thing required in code? Any other functionality?

Are you processing datagrams back to the controller from sensors to create some kind of automation?
I’m not up with what’s going on in wireless systems.

Andrew

Yes and yes. The idea for picking the Xbee was low power, bi-directional wireless. You can think of the xbee as a black box connected via a serial port to your microcontroller of choice.

Bascially, you form a packet of data that contains the destination address of another xbee and send it out the serial port. The Xbee takes care of all of the physical process of getting that packet to the destination.

If the destination xbee deems that it needs to, it can return data to whoever it just got it from, or also send it to a third party (say a computer monitoring things) if needed.

Xbee series 1 has a wireless range of about 300 ft. The next step up Xbees can go several miles but thats a bit overkill I think, and they cost more too.

Anyhow, I am currently sending a packet from my ‘hand-held’ prototype to a ‘client’ prototype and controlling R/C servos in real time, so all that is in place. Now I’m debating the packet structure to move forward with, I’ve thought about OpenLCB but not sure it needs to be that complicated.

I’m certainly open to suggestions on what and how much data should go back and forth. I’ve taken a stab at it, you can see it here:

http://martinsant.net/?p=1528

I’m a software dud and use C for embedded stuff. Since my training is actually in CS, I think embedded engineers suffer terribly from C. In 80’s and early 90’s, I use “Modula” for this sort of thing, but we didn’t have these incredible chips then.

I’m using NRF24L01+ 'stead of xbee 'cause they cost like 20 times less.

Since I use AVR, not PIC, you might have to keep me and Dave separated (http://www.outsidetrains.com/smile/mischief.gif)

Hmm, they do? Cost less I mean. Are they FCC approved? What is the range? Mouser has them for $40 in qty 1. Xbee is $19.

In the 80s and 90s I was coding ASM for 8 bit micros with C for the RTOS layer. We thought we were fancy pants compared to the DOS developers, ha. Never tried ‘Modula’ so I can’t comment on that.

I’m a big AVR fan, you just can’t beat the free compiler and cheap dev tools. Plus it looks like Visual Studio to me so that’s a bonus.

Wow.I see. Mouser must think they’re rare and valuable. I get them this way: http://www.ebay.com/itm/10pcs-NRF24L01-2-4GHz-Antenna-Wireless-Transceiver-Module-Black-/121207860989?&_trksid=p2056016.l4276

Range varies in surprising ways. I have a bunch of this style

(http://www.barefootelectronics.com/nordica.jpg)

And these can go 150 to 200 ft outside. With one sitting on my table, I can take another out the door, down the stairs, out the front door and a good ways down the driveway. How’s that for scientific? If I set one on the corroding concrete pig and start walking east, there’s an area behind the 2nd house to the east where it can’t get a signal through, but beyond that, it works again, all the way to the asphault place.

I got some of this style

(http://www.barefootelectronics.com/nordicb.jpg)

figuring they’d go a LONG way, but they work about half as far as the cheap kind. Friends speculate as to whether they put antennas on them for the wrong band or something.

Hmm. Not really an ebay fan but now I do see Sparkfun has them for about the same as Xbee. That’s odd, usually Mouser is pretty competitive. Ah well.

How do you manage the network, is it point to multi-point? What sort of addressing? I do like the top speed of 2mbs, I can only get 250kbs out of the Xbee. Is it FCC approved?

I’m getting good results from the Xbee for now but I would like to get the transfer between the Attiny and the xbee up to 115.2K. I’m pretty sure I’ll have to put an xtal on it for that or de-rate the onboard speed- neither of which I’d like to do.

Anyhow, thanks for the link- neat device. Do you have a data packet design you are sending over the air? I’d be interested in your ideas.

Interesting transciever. What kind of control boards are available to attach to it? Is it possible to control six or eight LEDs from one of them? Hmmm

A bit of poking around, it looks like the xbee has 10 i/o pins, so it might be useful to me.

I’m driving my Xbee with an Attiny 1634 microcontroller. As such, I put the Xbee into ‘API mode’ where I can send it commands via one of the serial ports on the Attiny. This gives me access to the Attiny i/o ports, the Xbee ports plus the Xbee radio modem.

For what I would need something like this for (and the price) the XBee seems a bit pricey. I have the need for approximately 20 ‘nodes’, each carrying 10 or so pins of I/O data. Doing this with XBees would mean 40 pieces, at around $17 a piece. I’d really like a unit price of half that.

Not sure I understand why you need 40? As an rf network node, it functions in point to multi-point, so one xbee can act as a master to thousands of slaves if you want. I would think you could latch a subset of the outputs to get the 10 you need.

XBee has a pretty powerful network protocol built in that can organize a network of thousands of nodes. To work it with a micro, all you need is a uart to talk to it serially. UART is pretty easy: If it’s not communicating, you probably have the speed set wrong.

NRF’s (I call them “Nordics”) are much more basic. You talk to them with SPI, which is native to AVRprocessors and easy to implement with anything else. You load a 1 to 5 byte address and a channel number, and it listens on that channel for a packet with that address. To send a message, you set the address to the node you want to send to and send the message. I don’t use the 6 address feature as it can work pretty well up to 6 nodes, but the 7th causes confusion. If your processor has an accurate clock, you can even do frequency hopping with a little code.

Trainfest:

I took my hand-built touch screen remote, which is actually broken, and a cobbled together receiver in my beat-up Bachmann Annie to Trainfest. I expected Buster Keyton style comedy as it ran away, refused to move, glitched and did rediculous things, but that silly, barely functional, jury-rigged setup operated nearly flawlessly all weekend. If I bumped the loco into something, the receiver tended to get stuck and needed rebooting, and I had to be a little deliberate in changing direction, but man, it worked smoothly. Probably if I’d actually mounted it instead of stuffing it in the tender and letting it bounce around, it would work better. Somebody wanted to know how far it worked, so I started walking away until the remote lost contact with the loco. I found a place where I could step back and loose contact, forward and regain contact. I was 320 ft away.

I left the old TE in Madam Mallet as I wanted a train I knew would run, but actually played more with the Annie.

http://www.avrfreaks.net/modules/PNphpBB2/files/comingtogether_197.jpg

I have existing (and standardized) hardware that provides logic I/O pins (could be a few hundred bits). I’m looking to extend the range of those pins up to a couple hundred feet. Multiplexing the output to an XBee (or two, one input, one output) on the local side would be acceptable, but I’d need some sort of board using many chips like a CD74HC4067 or similar.

Um. Yea. What kind of signals on these many io pins? High frequency or pretty close to DC?

I think you’d want something like a bunch of 74HC165 on the “read” side, and a bunch of 74HC595 on the write side. Chain them together 4 or 8 long, and put like 8 of these chains.

This would let 1 chip scan the inputs in serially. It would then put together an xbee or nordic message. The other side would receive the message and clock the bits back out.

Nordic messages are 32 bytes, that’s 256 bits. Might take more than one message to send a “few hundred.” I don’t remember off hand what xbee’s packet size is.

If the signals aren’t too fast, you might scan for changes and make the messages like “Bit 327 on” or “Bit 42 off.”

Xbee is 100 bytes per packet max. I’m running 16 bytes of payload for 25 bytes total packet size and getting a message every 10ms. I have the protocol ack turned off.

http://martinsant.net/?p=1563

http://martinsant.net/?p=1576