Power, optical isolation, DCC input and microprocessor
LED and Button Controller schematic
Relay option schematic
The control code in SX/Basic can be downloaded by clicking here. Learn more about the SX chip and SX/B, the BASIC language for SX at the Parallax website.
Circuit Description
Power is input through a bridge rectifier which allows the use of DC or AC voltage. When DCC is applied one side will become ground and the other is input through the 6N137 high-speed opto-isolator which converts the DCC signal to a safe 5 volts for the microprocessor as well as preventing transients from hurting the SX. U! is an SX28AC microprocessor running at 20 MHz as set by the ceramic resonator X1. This provides the timing necessary to decode the PWM DCC signal and to precisely time the pulse-widths for the servos. The SX-Key connector can be used to program the chip from a USB port of a Windoze PC with an SX-Blitz. The more expensive SX-Key also works but the debugging features will not work on this board, so only purchase it if you are interested in other development using SX chips. The SX is a very fast chip designed to program virtual peripherals and is well suited for this application. The LCD wire was used during development to hook up a serial LCD display. It is removed in this version to because the serial code took up too much programming space. A simple LED circuit provides feedback to the user. The SX receives inputs from momentary pushbuttons (BT1-4) and outputs a TTL logic signal for controlling LEDs to indicate turnout position (SWO1-4). The control pulses for the servos (SRV1-4) are output through 3-pin connectors. A 24LC64 EEPROM memory chip communicates with the SX through an I2C serial interface. The chip can store up to 8K bytes but in this application we only use about 32 bytes, including the DCC address, the last state of the servos and routes. The relays are optional and are designed to be used to power the frogs. However, the relays can be used to control any device that draws up to 1 amp. An example would be a crossing gate that is activated when a turnout is in a particular position. The relays are buffered by a ULN2803 Darlington transistor array that also provides diode flyback protection. If the relays are used then 12-15 volts should be provided to the board to provide the proper voltage for the relay coils.