Contact

Daniel Spilker

Blog

April 25th, 2011

ISPtouch for AVR Microcontrollers

When I started designing PCBs which should fit under Märklin C-Track, I soon realized that a standard 6-pin ISP header for AVR microcontrollers exceeds the height limitation of 4.5mm. My first idea was to press a 6-pin SMD header on the PCB pads for programming. But this method does not ensure sufficient contact for all pins. After searching the internet and browsing serveral print catalogs, I found the AVX 9188 Staggered SOLO Stacker in DigiKey’s print catalog. Its spring-loaded contacts provide a good connection for all pins. The idea for the ISPtouch was born.

Unfortunately I could not find the AVX connector in any Eagle CAD library, so I had to create my own Eagle parts for the AVX connector first. I then designed a small adapter board with a SMD 6-pin header for a standard AVR programmer on one side and the AVX connector on the other side. I added two single pin headers for guidance when pressing the adapter on a PCB for programming. Soldering the adapter, especially the AVX connector is a bit tricky, but doable. I had to cut off a bit of the guiding pins so that they do not collide with the programmer’s connector. To use the adapter in a PCB design I created an Eagle part which features the pads for the connector and two holes for the guiding pins. Pin 1 is marked on both the adapter and the ISPtouch library part with a small “1”. You can find the ISPtouch part along with the AVX Stagged SOLO Stacker parts for the solder and the mating sides in my Eagle library.


Up to now I have used ISPtouch in two designs and flashed many boards. It works flawlessly. Due to the staggered design of the AVX connector, it can only be used in one orientation and will not cause any harm when connected in the wrong way. To flash a board, you need two hands. One hand to press the ISPtouch adapter to the target PCB and one hand to start the programming.

As a nice by-product of the ISPtouch design the target PCB does not require any part to be soldered for the ISP. This safes time and money.


To build an ISPtouch adapter you need the AVX 9188 Staggered SOLO Stacker (e.g. DigiKey 478-5491-1-ND), a 6-pin SMD header (e.g. DigiKey WM17449-ND or DigiKey WM17455-ND) and two single pin headers (e.g. DigiKey 609-3368-ND). You can download the Eagle project for the ISPtouch adapter and the Eagle library for the ISPtouch header on GitHub.



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.

November 8th, 2008

Wireless S88 Feedback Module

My temporary model railroad layout stretches from the office through the hall into the living room. The PC which I use to control the trains is in the office. How do I detect that a train arrived in the living room without any wires running across the hall? I designed a RF transmitter module and a RF receiver module to monitor contacts remotely. The transmitter can sense 4 contacts, encodes the state to a serial data stream and transmits the data. The receiver decodes the serial data into 4 separate lines and feeds them into the S88 bus. The receiver is a semi-complete S88 module and can be connected directly to the S88 bus, but has to be the last module on the bus. The transmitter takes power directly from the track and needs no additional power supply.

It uses a bridge rectifier and a voltage regulator to transform the track voltage to +5V and decouples the sensed contacts with an optocoupler from the encoder/transmitter part. I choose the Linx ICs and modules because of the small package, simple surrounding circuitry and interoperability. The transmitter/receiver modules have the advantage of 8 selectable channels. I hope to reduce the size of the transmitter so that it will fit under Märklin C-track. The transmitter module is connected to a SMD chip antenna and the receiver uses a 1/4 wave length wire antenna. It works well over a distance of 5m and through 1 wall.

The advantages of this design is that it the data is fed directly into the S88 bus so that no modification to existing control hard- and software are required. Furthermore it requires no microprocessor programming so that you can put the parts together and you are ready to go. By adding more transmitter/receiver pairs it is possible to monitor up to 32 contacts.

On the downside, one need to have an extra transmitter/receiver pair for every four contacts to sense. It will get rather expensive when many contacts should be monitored. Despite the advantage that the data is feed directly into the S88 bus, it is also an disadvantage. The S88 is rather unstable and I am not certain how many current one can pull from the S88 bus. The receiver module pulls 20mA which is more than a usual S88 module pulls. But it works fine on my Märklin 6051 Interface.

Transmitter Module

Connect pin 1 of JP1 to the brown wire of the digital power circuit and pin 2 to the red wire. Connect JP2 to the contacts to monitor.

Parts

B1 Bridge Rectifier 50V 1.5A DIP-4 DigiKey DF005M-ND
IC1 Voltage Regulator 78L05 TO-92 DigiKey MC78L05BP-APMSCT-ND
IC2 Optocoupler AC 4-Channel DIP-16 DigiKey 751-1372-5-ND
IC3 Linx LS Series Encoder DIP-8 DigiKey LICAL-ENC-LS001-ND
JP3 Linx RF Transmitter 900MHz 8-Channel DigiKey TXM-900-HP3-PPO-ND
C1 Capacitor Tantal 330nF 35V DigiKey 399-4593-ND
C2 Capacitor Tantal 100nF 35V DigiKey 399-4596-ND
R1, R2, R3, R4 Resistor 100k 0.25W Metal Film DigiKey 100KXBK-ND
R5, R6, R7, R8 Resistor 200k 0.25W Metal Film DigiKey 200KXBK-ND
ANT1 Ceramic Chip Antenna 916MHz SMD DigiKey ANT-916-CHPCT-ND

Receiver Module

Connect JP1 to the S88 bus. Pin 1 is +5V, pin 2 is reset, pin 3 is load, pin 4 is clock, pin 5 is ground and pin 6 is data.

Parts

IC1 4041 8-stage shift register DigiKey MC14094BCPOS-ND
IC2 4043 Quad R/S Latches DIP-16 DigiKey MC14043BCPGOS-ND
IC3 Linx LS Series Decoder DIP-8 DigiKey LICAL-DEC-LS001-ND
JP2 Linx RF Receiver 900MHz 8-Channel DigiKey RXM-900-HP3-PPO_-ND
C1 Capacitor Tantal 100nF 35V DigiKey 399-4596-ND
R1, R2, R3, R4 Resistor 100k 0.25W Metal Film DigiKey 100KXBK-ND

Future

The current design has some drawbacks due to the instability of the S88 bus, the limitation to 4 data lines per transmitter/receiver pair, the high current consumption on the S88 bus and because it is operating on a frequency which is not free in Europe.

I already have some ideas to use a ZigBee network for data transmission. The XBee modules from Digi can monitor 12 digital inputs and the data can be transmitted from multiple module to a single receiver module which is connected to the PC via USB. The range of the network can be extended by adding router modules.