0% found this document useful (0 votes)
7 views

unit 1 topic 1

The document outlines the design and specifications for a model train controller system that uses Digital Command Control (DCC) standards for communication between a control box and the train. It details the packet structure for transmitting commands, including error correction and addressing, as well as the roles of various classes such as Console, Formatter, Transmitter, Receiver, and Controller. The system facilitates one-way communication to control multiple trains on the same track with features like speed adjustment and emergency stop functionality.

Uploaded by

preethi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

unit 1 topic 1

The document outlines the design and specifications for a model train controller system that uses Digital Command Control (DCC) standards for communication between a control box and the train. It details the packet structure for transmitting commands, including error correction and addressing, as well as the roles of various classes such as Console, Formatter, Transmitter, Receiver, and Controller. The system facilitates one-way communication to control multiple trains on the same track with features like speed adjustment and emergency stop functionality.

Uploaded by

preethi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Model Train Controller

Topic 2

CO1: Develop a model of an


embedded system.
Model Train Controller
The user sends messages to the train with a control box attached to the
tracks. The control box may have familiar controls such as a throttle,
emergency stop button, and so on.
The train receives its electrical power from the two rails of the track, the
control box can send signals to the train over the tracks by modulating
the power supply voltage.

The control panel sends packets over the tracks to the receiver on the
train.

The train includes Analog electronics to sense the bits being transmitted
and a control system to set the train motor’s speed and direction based
on those commands.
Each packet includes an address so that the console can control several
trains on the same track, the packet also includes an error correction
code (ECC) to guard against transmission errors.
This is a one-way communication system—the model train cannot send
commands back to the user.
Model train control system.
Model train control system.
Requirements
Requirements
Digital Command Control (DCC)
 The Digital Command Control (DCC) standard was created
by the National Model Railroad Association to support
interoperable digitally-controlled model trains.
 Digital Command Control specifies some important aspects
of the system that allow equipment to interoperate.
 The DCC standard is given in two documents:

 Standard S-9.1, the DCC Electrical Standard, defines


how bits are encoded on the rails for transmission.
 Standard S-9.2, the DCC Communication Standard,
defines the packets that carry information.
Digital Command Control (DCC)
 The DCC Communication Standard describes how bits
are combined into packets and the meaning of some
important packets.
 The basic packet format as a regular expression:
PSA(sD) E
 P - Preamble (a sequence of at least 10 1 bits). The command
station should send at least 14 of these 1 bits - some of which
may be corrupted during transmission.
 S - is the packet start bit. It is a 0 bit.
 A - an address data byte that gives the address of the unit,
with the most significant bit of the address transmitted first.
An address is eight bits long. The addresses 00000000,
11111110, and 11111111 are reserved.
 s - data byte start bit, which, like the packet start bit, is a 0.
 D - data byte, which includes eight bits. A data byte may
contain an address, instruction, data, or error correction
information.
 E - packet end bit, which is a 1 bit.
Digital Command Control (DCC)
 A baseline packet is the minimum packet that must
be accepted by all DCC implementations.
 A baseline packet has three data bytes: an address
data byte that gives the intended receiver of the
packet; the instruction data byte provides a basic
instruction; and an error correction data byte is used
to detect and correct transmission errors. Bit wise
exclusive or of address & instruction byte.
 Instruction byte – 0-3(4 bit speed value), 4-additional
speed bit, 5 – direction, 7,8 set to 01 – speed and
direction.
Conceptual Specification
 A conceptual specification allows us to understand the system
a little better.
 A train control system turns commands into packets.

 A command comes from the command unit while a packet is


transmitted over the rails. Commands and packets may not be
generated in a 1-to-1 ratio.
 The DCC standard says that command units should resend
packets in case a packet is dropped during transmission.
 It has two major subsystems: command unit & train board
component. (internal structure) – relationship between them is
shown in UML Collaboration diagram.
Conceptual Specification
 The command unit and receiver represented by
objects; command unit sends a sequence of packets to
the train’s receiver.
 The notation on the arrow provides both the type of
message sent and its sequence in a flow of messages;
console sends all the messages, hence – (1..n).
 Messages are of course carried over the track. Since
the track is not a computer component and is purely
passive, it does not appear in the diagram.
Class Diagram for Train Controller Message

UML Collaboration Diagram for the Major Subsystems of Model


Train Controller
Conceptual Specification
 Break down command unit and receiver in to major
components.
 Console: 3 functions
 Read the state of the front panel on the command unit
 Format messages
 Transmit messages

 Train : 3 major functions


 Receive the message
 Interpret the message. (current speed, inertia, settings etc…)
 Actually control the motor.
Conceptual Specification
Conceptual Specification
Basic characteristics of these classes:
 The Console class describes the command unit’s front
panel, which contains the analog knobs and hardware
to interface to the digital parts of the system.
 The Formatter class includes behaviors that know how
to read the panel knobs and creates a bit stream for
the required message.
 The Transmitter class interfaces to analog electronics
to send the message along the track.
Analog components, ending with an asterisk:
 Knobs* describes the actual analog knobs, buttons,
and levers on the control panel.
 Sender* describes the analog electronics that send
bits along the track.
Conceptual Specification
The Train makes use of three other classes :
 The Receiver class knows how to turn the analog
signals on the track into digital form.
 The Controller class includes behaviors that interpret
the commands and figures out how to control the
motor.
 The Motor interface class defines how to generate the
analog signals required to control the motor.
Two classes to represent analog components:
 Detector* detects analog signals on the track and
converts them into digital form.
 Pulser* turns digital commands into the analog
signals required to control the motor speed
Detailed Specification
 Figure below shows a class diagram for these
classes; little more detail than previous figure - it
includes attributes and behaviors of these classes.
 The Panel has three knobs: train number (which train
is currently being controlled), speed (which can be
positive or negative), and inertia.
 It also has one button for emergency-stop.
 Got to change the train number setting, then got to
reset the other controls to the proper values - so
that the previous train’s control settings are not
used to change the current train’s settings.
 To do this, Knobs* must provide a set-knobs behavior
that allows the rest of the system to modify the knob
settings.
Detailed Specification
Detailed Specification
 Next figure shows the speed of electric motors is
commonly controlled using pulse-width modulation:
 Power is applied in a pulse for a fraction of some
fixed interval, with the fraction of the time that
power is applied determining the speed.
Detailed Specification
Detailed Specification
 Figure 1.21 shows the classes for the panel and motor
interfaces.
 These classes form the software interfaces to their
respective physical devices.
 The Panel class defines a behavior for each of the controls
on the panel;
 The new-settings behavior uses the set-knobs behavior of
the Knobs* class to change the knobs settings whenever
the train number setting is changed.
 The Motor-interface defines an attribute for speed that can
be set by other classes.
Detailed Specification
 The Transmitter and Receiver classes are shown in
Figure.
 They provide the software interface to the physical
devices that send and receive bits along the track.
 The Transmitter provides a distinct behavior for each
type of message that can be sent; it internally takes
care of formatting the message.
 The Receiver class provides a read-cmd behavior to
read a message off the tracks.
 Another variable holds a flag showing when the
command has been processed.
 The Formatter class is shown
Detailed Specification in Figure 1.23.
 The formatter holds the
current control settings for all
of the trains.
 The send-command method is
a utility function that serves
as the interface to the
transmitter.
 The operate function
performs the basic actions for
the object.
 A simple specification, which
states that the formatter
repeatedly reads the panel,
determines whether any
settings have changed, and
sends out the appropriate
messages.
 The panel-active behavior
returns true whenever the
panel’s values do not
Detailed Specification
Detailed Specification
 The figure shows two changes to the knob settings:
 First to the throttle, inertia, or emergency stop; then to
the train number.
 The panel is called periodically by the formatter to
determine if any control settings have changed.
 If a setting has changed for the current train, the formatter
decides to send a command, issuing a send-command
behavior to cause the transmitter to send the bits.
 Because transmission is serial, it takes a noticeable
amount of time for the transmitter to finish a command; in
the meantime, the formatter continues to check the
panel’s control settings.
 If the train number has changed, the formatter must cause
the knob settings to be reset to the proper values for the
new train.
Detailed Specification

 The state diagram for a very simple version of the operate


behavior of the Formatter class is shown in Figure 1.25.
 This behavior watches the panel for activity:
 If the train number changes, it updates the panel display;
otherwise, it causes the required message to be sent.
Detailed Specification
Detailed Specification
 The definition of the
train’s Controller class
is shown in Figure 1.27.
 The operate behavior is
called by the receiver
when it gets a new
command; operate
looks at the contents of
the message and uses
the issue-command
behavior to change the
speed,direction, and
inertia settings as
necessary.
Detailed Specification
Detailed Specification
 The operation of the Controller class during the
reception of a set-speed command is illustrated in
Figure 1.29.
 The Controller’s operate behavior must execute
several behaviors to determine the nature of the
message.
 Once the speed command has been parsed, it must
send a sequence of commands to the motor to
smoothly change the train’s speed.
Detailed Specification

You might also like