April 5th, 2010
ZigBee-based Wireless S88 Feedback Module
Two years ago I started building a wireless S88 feedback module. The first design had some drawbacks, but now I finished the second version. It uses a ZigBee RF transceiver for wireless communication between the transmitter module located at the track and the receiver module which interfaces with the S88 bus. Several transmitter modules can operate with only a single receiver module. The transmitter module simultaneously acts as a repeater for other transmitter modules so that the distances between transmitters and the receivers can be large in indoor environments.
The transmitter consists of a small PCB and an XBee module. Each transmitter has 4 feedback ports. I designed the PCB to fit under a Märklin C-track, only the XBee module and wires to parallel tracks are visible. Theoretically the XBee module fits under the track as well when the pins are cut off, but I hesitated to cut off the pins of a 25€ component. The module gets power from the track and the four feedback inputs are connected like any other S88 module.
The receiver module is build with a AVR ATtiny 2313 microcontroller and an XBee module. In contrast to the first version, the receiver module is a full S88 module and can be at any position within the S88 bus. It can emulate any number of standard 16-port S88 modules, depending on the number of transmitter modules and the firmware. E.g. when using 6 transmitter modules with a total of 6×4=24 ports, the receiver can act as two 16-port S88 modules.
Schematics
The transmitter power-supply is based on an LP2950 voltage regulator. On the input side of the regulator, I used a diode and two large capacitors to convert AC to DC and two resistors to reduce the input voltage. The feedback input circuitry is straightforward compared to other S88 feedback modules. The XBee module has internal pull-up resistors for digital inputs but these are too small, so I added 100k pull-ups.
The receiver module schematics are rather simple. I just put together the Adafruit XBee Adapter and the Tinkerlog Tiny2313 Header.
Transmitter Parts List
| Position | Description | Distributor |
|---|---|---|
| D1 | Diode 1N4148 SOD-323 SMD | DigiKey |
| C1, C2 | Capacitor 47µF 25V 7343 SMD | DigiKey |
| C3 | Capacitor 22µF 6.3V 3528 SMD | DigiKey |
| C4 | Capacitor 8.2pF 50V 1206 SMD | DigiKey |
| C5, C6, C7, C8 | Capacitor 10µF 10V 1206 SMD | DigiKey |
| R1, R2 | Resistor 137Ohm 1/2W 1210 SMD | DigiKey |
| R3, R4, R5, R6 | Resistor 10kOhm 1/8W 0805 SMD | DigiKey |
| R7, R8, R9, R10 | Resistor 100kOhm 1/8W 0805 SMD | DigiKey |
| IC1 | Voltage Regulator LP2950 3.3V TO-92 SMD | DigiKey |
| XBee Series 2.5 OEM Module Chip Antenna | SparkFun |
Receiver Part List
| Position | Description | Distributor |
|---|---|---|
| Tinkerlog Tiny2313 Header Kit | Tinkerlog | |
| Adafruit XBee Adapter Kit | Adafruit | |
| JP1, JP2 | Male Breakaway Header Straight 2.54mm | DigiKey |
Additionally you need an FTDI cable (SparkFun) to program the XBee modules and an AVR programmer (DigiKey) to program the microcontroller.
Firmware
I am using Digi’s X-CTU tool to modify the XBee module’s firmware settings. For the receiver, I use the XB24-ZB firmware version 2164 with default settings. The transmitter’s XBee runs the XB24-ZB firmware version 2364 with default settings except for the following:
| Setting | Value | Description |
|---|---|---|
| D0 | 0×03 | digital input |
| D1 | 0×03 | digital input |
| D2 | 0×03 | digital input |
| D3 | 0×03 | digital input |
| D5 | 0×00 | disabled |
| P0 | 0×00 | disabled |
| PR | 0×1FE1 | no internal pull-up for D0-D3 |
| IR | 0×7D | I/O sampling rate 125ms |
| IC | 0×07 | I/O change detection on D0-D3 |
The sources for the microcontroller firmware are available on GitHub. A makefile for compiling, setting the fuses and programming with an in-system programmer is included. I am using WinAVR for compiling and Atmel’s AVR tools for setting the fuses and programming.
Next Steps
Although I am very satisfied by the performance and extensibility of the current solution, there is always room for improvement. The XBee modules are quite expensive (~25€ per module). I am going to try the RFM12B modules from HopeRF which are cheaper (<5€) and smaller so that they fit under the track. Then I want to add DIP switches to the transmitter to set the transmitter’s address without having to reprogram the module. And I will add DIP switches to the receiver to set the number of transmitter’s and thereby the number of S88 modules to emulate.
