byte is 1 iff there is another byte in the message.
First Second ASCII Message Brief
- Byte byte etc. name description
+ Byte byte etc. or hex name description
From host to PIC:
- > 1 0100 TTT 0 TTTTTTT POINT Point T fire
- > 1 1111 111 .... NMRADATA NMRA data
- > 1 0001 XXX 0 XXXXXXX PING Ping `X' (please Pong `X')
- > 1 0010 RRR E RRR... POLARITY Set polarity
- > 0 0100 001 ON Power on
- > 0 0100 000 OFF Power off
+ > 1 0100 TTT 0 TTTTTTT (a0) POINT Point T fire
+ > 1 1111 111 .... (ff) NMRADATA NMRA data
+ > 1 0001 XXX 0 XXXXXXX (88+) PING Ping `X' (please Pong `X')
+ > 1 0010 RRR E RRR... (90+) POLARITY Set polarity
+ > 1 0011 000 0 MMMMMMM (98+) WATCHDOG W'dog reset, t/o <M*16>ms from now
+ > 0 0010 001 (11) ON Power on
+ > 0 0010 000 (10) OFF Power off
+
+;> 00000000 CRASHED Acknowledge panic, go to readout mode
+;> 00001010 (0a) TELLMODE Confirm mode - say HELLO or CRASHED
+; if crashed, undoes the effect of ack
+
+; In crash readout mode:
+;
+; 00000000 MS Select crash readout mode if not already
+; Reset crash readout pointer to 0
+;
+; 00001000 Acknowledge RS232 framing error or overrun
+; 00001001 Reboot
+;
+; 1vvvvvvv M Prepare byte 0vvvvvvv for transmission to the slave
+;
+; 00000nnn M (n>0) prepare to receive nnnn bytes from slave
+; 0001nnnn M (n>0) transmit nnnn bytes of our own from the
+; readout pointer
+;
+; 001sssss M Select slave S^0x10. Then:
+; After 1vvvvvvv
+; Transmit just 0vvvvvvv to slave
+; and then send some some unspecified byte to host
+; After 0000nnnn
+; Receive nnnn bytes, forwarding each one
+; to the host.
+; After the transaction is complete, 1vvvvvvv
+; or 0000nnnn must be specified again before
+; 001sssss is repeated.
+;
+; 01bbbbbb MS Supply 6 bits for crash readout pointer
+; (crash readout mode only)
+; Effect is FSR << 6; FSR |= bbbbbb
From PIC to host:
- < 1 001Y SSS 0 SSSSSSS DETECT Train is (Y=1) or is not (Y=0) at S
- < 1 0001 XXX 0 XXXXXXX PONG Pong `X' (reply to Ping `X')
+ < 1 001Y SSS 0 SSSSSSS (9?) DETECT Train is (Y=1) or is not (Y=0) at S
+ < 1 0001 XXX 0 XXXXXXX (88+) PONG Pong `X' (reply to Ping `X')
+ < 1 100 0001 0 NNNNNNN (ENQ) SPURIOUS Number of spurious fault interrupts
< 0 000 1001 (HT) HELLO I am booted
< 0 000 1011 (VT) AAARGH Followed by debug chars (only)
+ < 0 000 1101 (CR) WTIMEOUT Watchdog timeout happened
< 0 000 0111 (BEL) FAULT Fault exists
< 0 000 0110 (ACK) FIXED Fault now fixed
- < 0 000 0100 POLARISED Set polarity done
- < 0 0100 PPP POINTED Point change done using capacitor P
- < 0 0101 PPP CHARGED Point capacitor P is now charged
- < 0 00000 FF NMRAFULL F pending NMRA messages
+ < 0 0100 PPP (20+) POINTED Point change done using capacitor P
+ < 0 0101 PPP (28+) CHARGED Point capacitor P is now charged
+ < 0 00000 FF NMRADONE Have processed F NMRADATA message(s)
< 0000 1010 (LF) } debugging output 0x0a (newline) and
< 001C CCCC } (works with terminal 0x20-0x7e
The host can send ON and OFF to turn the track (and various other
stuff) on and off. After ON, the track power should be enabled and
-transmitting NMRA idle, and the CDU should be enabled. (ON - or the
-things that might precede ON such as FAULT etc. - should clear the
-data from any previous NMRADATA commands.)
+transmitting NMRA idle, and the CDU should be enabled.
If the power is ON, and a track power short circuit is detected, the
PIC should send FAULT. When the short circuit is removed, the PIC
Track and CDU Track and CDU
disabled -------ON-------> enabled
- . (clears NMRA
- /|\ buffers) |
+ .
+ /|\ |
| |Short circuit detected
\ |
\FIXED FAULT
(User Fault indicator lit)
+If OFF is issued in the first 500ms following a short circuit, it will
+be ignored; if the short circuit persists, OFF during the following
+period will go to the `Track and CDU disabled' state without sending
+FIXED.
+
POINTS and CDU
--------------
is recharging <----POINTED---- Point is changing
+Note that OFF will turn the CDU off, and a short circuit (FAULT) will
+turn it off 500ms later (this delay avoids losing races where the host
+sends a point change instruction just before a short happens).
+
PING and PONG
-------------
Each byte after the first contains 7 more R bits. The first R bit
(most significant R bit in the first byte) corresponds to track
-detection segment 1; The next bit (2nd most significant bit in the
-first byte) corresponds to track detection segment 2; and so on.
+reversal segment 1; The next bit (2nd most significant bit in the
+first byte) corresponds to track reversal segment 2; and so on.
-Bits which do not correspond to defined track detection segments will
-be sent as 0 by the host but may be ignored by the PICs. The host
-must send exactly as many bytes as are necessary to include all of the
-defined segments.
+Bits which do not correspond to defined reversal segments will be
+ignored by the PICs. The host must send exactly as many bytes as are
+necessary to include all of the reversal segments for each reversers
+board (for every potential reversal segment, regardless of whether
+that segment is a defined segment corresponding to some actual track;
+however a board with _no_ reversers segments used does not count).
-For example, if there are 14 detection segments (numbered 1 to 14)
+For example, if there are 14 reversible segments (numbered 1 to 14)
then the following message
1 0010 000 1 000 1000 0 111 1010 Actual message
(E RRR) (E RRR RRRR) (E RRR R---) } helpful annotations
1 111 1111 } and commentary
123 456 7890 123 4567 }
specifies to reverse segments 7 and 11 to 14. The trailing bits are
-for segments 15 to 17 and are ignored.
+for segments 15 to 17 and are ignored. (Note that the assignment of
+physical segments to segment numbers is complex due to bit-twiddling.
+see detpic/reverse.asm and layout/data2safety.)
The PIC will reply to POLARITY with POLARISED when the polarity change
is complete. The host must not send another POLARITY until then.