User Tools

Site Tools


LocoNet Opcode Summary

LocoNet® Personal Use Edition 1.0 SPECIFICATION:
Digitrax Inc., Norcross GA 30071
October 16, 1997
©Copyrighted material, all rights reserved.

This Wiki page is based on loconetpersonaledition.pdf.


The data bytes on LocoNet® are defined as 8 bit data with the most significant bit (transmitted last in the 8 bit octet) as an OPCODE flag bit. If the MS bit , D7, is 1 the 7 least significant bits are interpreted as a network OPCODE . The opcode byte may only occur once in a valid message and is the FIRST byte of a message. All the remaining bytes in the message must have a most significant bit of 0 , including the last CHECKSUM byte. The CHECKSUM is the 1's COMPLEMENT of the byte wise Exclusive Or of all the bytes in the message, except the CHECKSUM itself. To validate data accuracy, all the bytes in a correctly formatted message are Exclusive Or'ed. If this resulting byte value is "FF" hexadecimal, the message data is accepted as good.

Message Length

The OPCODES may be examined to determine message length and if subsequent response message is required. Data bits D6 and D5 encode the message length. D3=1 implies Follow-on message/reply:

D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 F D C B A Message is 2 bytes, including Checksum
1 0 1 F D C B A Message is 4 bytes, inc. checksum
1 1 0 F D C B A Message is 6 bytes, inc checksum
1 1 1 F D C B A Message in N bytes, where next byte in message is a 7 bit BYTE COUNT.

The A,B,C,D,F are bits available to encode 32 OPCODES per message length.

Refresh Slots

The model of the MASTER refresh stack is an array of up to 120 read/write refresh SLOTS. The slot address is a principal component and is generally the second byte or 1st argument of a message to the master. The refresh SLOT contains up to 10 data bytes relating to a Locomotive and also controls a task in the Track DCC refresh stack. Most mobile decoder or Locomotive operations process the SLOT associated with the Locomotive to be controlled. The SLOT number is a similar shorthand ID# to a "file handle" used to mark and process files in a DOS PC environment. Slot addresses 120-127 ARE reserved for System and Master control. Slot #124 ($7C) is allocated for read/write access to the DCS100 programming track, and the format of the 10 data bytes is not the same as a "normal" slot. See later.

Standard Address Selection

To request a MOBILE or LOCOMOTIVE decoder task in the refresh stack, a Throttle device requests a LOCOMOTIVE address for use,( opcode <BF>,<loco adr hi>,<loco adr lo>, <chk> ). The Master ( or PC in a Limited Master environment) responds with a SLOT DATA READ for the SLOT ,( opcode <E7>,,) ,that contains this Locomotive address and all of its state information. If the address is currently not in any SLOT, the master will load this NEW locomotive address into a new SLOT ,[speed=0, FWD, Lite/Functions OFF and 128 step mode]and return this as a SLOT DATA READ. If no inactive slots are free to load the NEW locomotive address, the response will be the Long Acknowledgment ,(opcode <B4>,) , with a "fail" code, 0.
Note that regular "SHORT" 7 bit NMRA addresses are denoted by <loco-adr hi>=0. The Analog , Zero stretched, loco is selected when both <loco adr hi>=<loco adr lo>=0. <Loco adr lo> is always a 7 bit value. If <loco adr hi> is non-zero then the Master will generate NMRA type 14 bit or "LONG" address packets using all 14 bits from <loco adr hi> and <loco adr lo> with Loco adr Hi being the MOST significant address bits. Note that a DT200 Master does NOT process 14 bit adr requests and will consider the <loco adr hi> to always zero. You can check the <TRK> return bits to see if the Master is a DT200.

The throttle must then examine the SLOT READ DATA bytes to work out how to process the Master response. If the STATUS1 byte shows the SLOT to be COMMON, IDLE or NEW the throttle may change the SLOT to IN_USE by performing a NULL MOVE instruction ,(opcode <BA>,<slotX>,<slotX>,<chk> ) on this SLOT. This activation mechanism is used to guarantee proper SLOT usage interlocking in a multi-user asynchronous environment.

If the SLOT return information shows the Locomotive requested is IN_USE or UP-CONSISTED (i.e. the SL_CONUP, bit 6 of STATUS1 =1 ) the user should NOT use the SLOT. Any UP_CONSISTED locos must be UNLINKED before usage! Always process the result from the LINK and UNLINK commands, since the Master reserves the right to change the reply slot number and can reject the linking tasks under several circumstances. Verify the reply slot # and the Link UP/DN bits in STAT1 are as you expected.

The throttle will then be able to update Speed./Direction and Function information . Whenever SLOT information is changed in an active slot , the SLOT is flagged to be updated as the next DCC packet sent to the track. If the SLOT is part of linked CONSIST SLOTS the whole CONSIST chain is updated consecutively.

If a throttle is disconnected from the LocoNet®, upon reconnection (if the throttle retains the SLOT state from before disconnection) it will request the full status of the SLOT it was previously using. If the reported STATUS and Speed/Function data etc., from the master exactly matches the remembered SLOT state the throttle will continue using the SLOT. If the SLOT data does not match, the throttle will assume the SLOT was purged free by the system and will go through the setup "log on" procedure again.

With this procedure the throttle does not need to have a unique "ID number". SLOT addresses DO NOT imply they contain any particular LOCOMOTIVE address. The system can be mapped such that the SLOT address matches the LOCOMOTIVE address within, if the user directly Reads and Writes to SLOTs without using the Master to allocate Locomotive addresses


Active Locomotives (including Consist TOP) SLOTS may be released for assignment to BT2 throttles in the "DISPATCH" mode. In this case a BT2 operating in its normal mode will request a DISPATCH SLOT that has been prepared by a supervisor type device. This is included for Club type operations where simpler throttles with limited capabilities are given to Engineers (Operators) by the Hostler or Dispatcher.

To DISPATCH PUT a slot , perform a SLOT MOVE to Slot 0. In this case the Destination Slot 0 is not copied to, but the source SLOT number is marked by the system as the DISPATCH slot. This is only a "one deep stack".

To DISPATCH GET, perform a SLOT MOVE from Slot 0 (no destination needed). If there is a DISPATCH marked slot in the system, a SLOT DATA READ ( <E7>,,,) with the SLOT information will be the response. If there is NO DISPATCH slot, the response will be a LONG ACK ( opc <B4>,,) with the Fail code,00.

Future Expansion Codes

Immediate codes may be sent to the Master by a device. These are converted to DCC packets and sent as the next packet to the rails. They are not entered into any refresh stack. These are available in a system based on the DCS100/"Chief".

Opcodes for access to an auxiliary Service mode Programming Track are included. These requests are not entered in the main DCC packet stream .

Note that several confusing expansions and opcode sequences have been stripped from this LocoNet® version. An experimenter who implements this protocol correctly should have no problems running on a LocoNet® that has other expanded features. Again, we recommend resisting the temptation to "optimise" or take shortcuts with this protocol since it will lead to guaranteed future problems with your hardware and software.

2 Byte Message Opcodes


Opcode Response
Symbol Code Description Success Fail
OPC_IDLE 0x85 FORCE IDLE state, B'cast emerg. STOP - -
OPC_GPON 0x83 GLOBAL power ON request - -
OPC_GPOFF 0x82 GLOBAL power OFF req - -
OPC_BUSY 0x81 MASTER busy code, NUL - -

4 Byte Message Opcodes


Opcode Arguments Response
Symbol Code Description Arg1 Arg2 Success Fail
OPC_LOCO_ADR 0xBF Request loco address, if not found master puts address in a free slot. 0 ADR OPC_SL_RD_DATA OPC_LONG_ACK
No free slot available. ACK1=0
OPC_SW_ACK 0xBD Request switch with acknoledge function. SW1 SW2 OPC_LONG_ACK, ACK1=0x7F OPC_LONG_ACK, ACK1=0x00
OPC_SW_STATE 0xBC Request state of switch. SW1 SW2 OPC_LONG_ACK, ACK1=0x7F OPC_LONG_ACK, ACK1=0x00
OPC_RQ_SL_DATA 0xBB Request slot data/status block SLOT 0 OPC_SL_RD_DATA
OPC_LINK_SLOTS 0xB9 Link slot ARG1 to slot ARG2 SL1 SL2 OPC_SL_RD_DATA
OPC_UNLINK_SLOTS 0xB8 Unlink slot ARG1 from slot ARG2 SL1 SL2 OPC_SL_RD_DATA
OPC_CONSIST_FUNC 0xB6 Set FUNC bits in a CONSIST uplink element SLOT DIRF
OPC_SLOT_STAT1 0xB5 Write slot stat1 SLOT STAT1
OPC_LONG_ACK 0xB4 Long acknowledge LOPC ACK1
OPC_INPUT_REP 0xB2 General sensor input codes IN1 IN2
OPC_SW_REP 0xB1 Turnout sensor state report SN1 SN2
OPC_SW_REQ 0xB0 Request switch function SW1 SW2 OPC_LONG_ACK, LOPC=0x30, ACK1=0x00
OPC_LOCO_SND 0xA2 Set slot sound function SLOT SND
OPC_LOCO_DIRF 0xA1 Set slot direction, function 0-4 state SLOT DIRF
OPC_LOCO_SPD 0xA0 Set slot speed SLOT SPD

6 Byte Message Opcodes


Symbol Code Description Arg1 Arg2 Arg3 Arg4 Success Fail
OPC_MULTI_SENSE 0xD0 power management and transponding type zone and section addr addr
OPC_UHLI_FUN 0xD4 Function 9-28 by Uhlenbrock 0x20 slot function group function

Variable Byte Message Opcodes


Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Arg9 Arg10 Arg11 Response
OPC_SL_RD_DATA 0xE7 Slot data response. 0x0E SLOT# STAT1 ADR SPD DIRF TRK SS2 ADR2 SND ID1 ID2 -
- 0xE6 Programming service mode aborted. 0x10/0x15

Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Arg9 Arg10 Arg11 Arg12 Arg13 Response
OPC_PEER_XFER 0xE5 Move 8 bytes peer to peer, SRC→DST. 0x10 SRC DSTL DSTH PXCT1 D1 D2 D3 D4 PXCT2 D5 D6 D7 D8 -

Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Response
OPC_LISSY_REP 0xE4 Lissy IR report 0x08 0x00 high unit, direction low unit high addr low addr - -
OPC_WHEELCNT_REP 0xE4 Wheel counter report 0x08 0x40 high unit, direction low unit high count low count - -

Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Arg9 Response
OPC_LISSY_REP 0xE4 RFID-5 report 0x0C 0x41 addr. high addr. low RFID-0 RFID-1 RFID-2 RFID-3 RFID-4 RFID-HI -

Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Arg9 Arg10 Arg11 Response
OPC_LISSY_REP 0xE4 RFID-7 report 0x0E 0x41 addr. high addr. low RFID-0 RFID-1 RFID-2 RFID-3 RFID-4 RFID-5 RFID-6 RFID-HI -

Opcode Arguments
Symbol Code Description Count Arg1 Arg2 Arg3 Arg4 Arg5 Arg6 Arg7 Arg8 Response
OPC_IMM_PACKET¹ 0xED Send n-byte packet immediate. 0x0B 0x7F REPS DH1 IM1 IM2 IM3 IM4 IM5 OPC_LONG_ACK
ACK1=0x7F if not limited
ACK1=lim if limited
ACK1=0x00 If busy

¹) The SLOT DATA bytes are, in order of TRANSMISSION for <E7> READ or <EF> WRITE NOTE SLOT 0 <E7> read will return MASTER config information bytes .

loconet/ln-pe-en.txt · Last modified: 2018/11/12 08:56 (external edit)