Thanks to visit codestin.com
Credit goes to www.scribd.com

100% found this document useful (1 vote)
15 views76 pages

Matlab Stateflow Documentation PDF Download

The document provides information on downloading the MATLAB Stateflow Documentation and includes links to various related MATLAB and Simulink ebooks. It outlines the features of Stateflow, its integration with Simulink, and offers installation instructions and guidance on modeling with Stateflow. Additionally, it contains a detailed table of contents covering various aspects of using Stateflow for event-driven system modeling.

Uploaded by

kootzmayanq9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
15 views76 pages

Matlab Stateflow Documentation PDF Download

The document provides information on downloading the MATLAB Stateflow Documentation and includes links to various related MATLAB and Simulink ebooks. It outlines the features of Stateflow, its integration with Simulink, and offers installation instructions and guidance on modeling with Stateflow. Additionally, it contains a detailed table of contents covering various aspects of using Stateflow for event-driven system modeling.

Uploaded by

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

Matlab Stateflow Documentation download

https://ebookbell.com/product/matlab-stateflow-
documentation-6741912

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Matlab And Simulink Indepth Modelbased Design With Simulink And


Stateflow User Interface Scripting Simulation Priyanka Patankar

https://ebookbell.com/product/matlab-and-simulink-indepth-modelbased-
design-with-simulink-and-stateflow-user-interface-scripting-
simulation-priyanka-patankar-45320544

Basic Matlab Simulink And Stateflow Colgren Richard

https://ebookbell.com/product/basic-matlab-simulink-and-stateflow-
colgren-richard-4322470

Matlab A Practical Introduction To Programming And Problem Solving 6th


Edition Stormy Attaway

https://ebookbell.com/product/matlab-a-practical-introduction-to-
programming-and-problem-solving-6th-edition-stormy-attaway-46075418

Matlab For Engineering Applications 5e Ise 5thise William J Palm Iii

https://ebookbell.com/product/matlab-for-engineering-
applications-5e-ise-5thise-william-j-palm-iii-46562738
Matlab And Simulink Crash Course For Engineers 1st Ed 2022 Eklas
Hossain

https://ebookbell.com/product/matlab-and-simulink-crash-course-for-
engineers-1st-ed-2022-eklas-hossain-46608958

Matlab Medical Imaging Toolbox Users Guide The Mathworks

https://ebookbell.com/product/matlab-medical-imaging-toolbox-users-
guide-the-mathworks-46611260

Matlab For Engineering Applications 5th Edition William Palm

https://ebookbell.com/product/matlab-for-engineering-applications-5th-
edition-william-palm-46651690

Matlab For Engineering Berardino Dacunto

https://ebookbell.com/product/matlab-for-engineering-berardino-
dacunto-48710470

Matlab For Medical Physics Reallife Clinical Scenarios And Projects


Jidi Sun

https://ebookbell.com/product/matlab-for-medical-physics-reallife-
clinical-scenarios-and-projects-jidi-sun-49034592
Stateflow®
Getting Started Guide

R2016a
How to Contact MathWorks

Latest news: www.mathworks.com

Sales and services: www.mathworks.com/sales_and_services

User community: www.mathworks.com/matlabcentral

Technical support: www.mathworks.com/support/contact_us

Phone: 508-647-7000

The MathWorks, Inc.


3 Apple Hill Drive
Natick, MA 01760-2098

Stateflow® Getting Started Guide


© COPYRIGHT 2004–2016 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used
or copied only under the terms of the license agreement. No part of this manual may be photocopied or
reproduced in any form without prior written consent from The MathWorks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation
by, for, or through the federal government of the United States. By accepting delivery of the Program
or Documentation, the government hereby agrees that this software or documentation qualifies as
commercial computer software or commercial computer software documentation as such terms are used
or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and
conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and
govern the use, modification, reproduction, release, performance, display, and disclosure of the Program
and Documentation by the federal government (or other entity acquiring for or through the federal
government) and shall supersede any conflicting contractual terms or conditions. If this License fails
to meet the government's needs or is inconsistent in any respect with federal procurement law, the
government agrees to return the Program and Documentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
June 2004 First printing New for Version 6.0 (Release 14)
October 2004 Online only Revised for Version 6.1 (Release 14SP1)
March 2005 Online only Revised for Version 6.2 (Release 14SP2)
September 2005 Online only Revised for Version 6.3 (Release 14SP3)
October 2005 Reprint Version 6.0
March 2006 Second printing Revised for Version 6.4 (Release 2006a)
September 2006 Reprint Version 6.5 (Release 2006b)
March 2007 Online only Rereleased for Version 6.6 (Release 2007a)
September 2007 Third printing Rereleased for Version 7.0 (Release 2007b)
March 2008 Fourth printing Revised for Version 7.1 (Release 2008a)
October 2008 Fifth printing Revised for Version 7.2 (Release 2008b)
March 2009 Sixth printing Revised for Version 7.3 (Release 2009a)
September 2009 Online only Revised for Version 7.4 (Release 2009b)
March 2010 Online only Revised for Version 7.5 (Release 2010a)
September 2010 Online only Revised for Version 7.6 (Release 2010b)
April 2011 Seventh printing Revised for Version 7.7 (Release 2011a)
September 2011 Online only Revised for Version 7.8 (Release 2011b)
March 2012 Online only Revised for Version 7.9 (Release 2012a)
September 2012 Online only Revised for Version 8.0 (Release 2012b)
March 2013 Online only Revised for Version 8.1 (Release 2013a)
September 2013 Online only Revised for Version 8.2 (Release 2013b)
March 2014 Online only Revised for Version 8.3 (Release 2014a)
October 2014 Online only Revised for Version 8.4 (Release 2014b)
March 2015 Online only Revised for Version 8.5 (Release 2015a)
September 2015 Online only Revised for Version 8.6 (Release 2015b)
October 2015 Online only Rereleased for Version 8.5.1 (Release
2015aSP1)
March 2016 Online only Revised for Version 8.7 (Release 2016a)
Contents

Introduction to the Stateflow Product


1
Stateflow Product Description . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2

Anatomy of a Stateflow Chart . . . . . . . . . . . . . . . . . . . . . . . . . 1-3

How Stateflow Software Works with Simulink Software . . . 1-5

Use C Chart to Model Event-Driven System . . . . . . . . . . . . . 1-6

Installing Stateflow Software . . . . . . . . . . . . . . . . . . . . . . . . . 1-7


Installation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Prerequisite Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Product Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Set Up Your Own Target Compiler . . . . . . . . . . . . . . . . . . . . 1-8
Using Stateflow Software on a Laptop Computer . . . . . . . . . 1-8

Related Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9

The Stateflow Chart You Will Build


2
The Stateflow Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

How the Stateflow Chart Works with the Simulink Model . . 2-6

A Look at the Physical Plant . . . . . . . . . . . . . . . . . . . . . . . . . . 2-7

Running the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9

v
Defining the Interface to the Simulink Model
3
Implementing the Interface with Simulink . . . . . . . . . . . . . . 3-2
Build It Yourself or Use the Supplied Model . . . . . . . . . . . . . 3-2
Design Considerations for Defining the Interface . . . . . . . . . 3-2
Adding a Stateflow Block to a Simulink Model . . . . . . . . . . . 3-3
Defining the Inputs and Outputs . . . . . . . . . . . . . . . . . . . . . 3-7
Connecting the Stateflow Block to the Simulink Subsystem . 3-13

Defining the States for Modeling Each Mode of


Operation
4
Implementing the States to Represent Operating Modes . . . 4-2
Build It Yourself or Use the Supplied Model . . . . . . . . . . . . . 4-2
Design Considerations for Defining the States . . . . . . . . . . . 4-2
Adding the Power On and Power Off States . . . . . . . . . . . . . 4-6
Adding and Configuring Parallel States . . . . . . . . . . . . . . . . 4-8
Adding the On and Off States for the Fans . . . . . . . . . . . . . 4-14

Defining State Actions and Variables


5
Implementing State Actions . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Build It Yourself or Use the Supplied Model . . . . . . . . . . . . . 5-2
Design Considerations for Defining State Actions and
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
Writing an Entry Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
Writing a During Action . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-6

vi Contents
Defining Transitions Between States
6
Adding the Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Build It Yourself or Use the Supplied Model . . . . . . . . . . . . . 6-2
Design Considerations for Defining Transitions Between
States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
Drawing the Transitions Between States . . . . . . . . . . . . . . . 6-4
Adding Default Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . 6-7
Adding Conditions to Guard Transitions . . . . . . . . . . . . . . . 6-10
Adding Events to Guard Transitions . . . . . . . . . . . . . . . . . . 6-12

Triggering a Stateflow Chart


7
Implementing the Triggers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-2
Build It Yourself or Use the Supplied Model . . . . . . . . . . . . . 7-2
Design Considerations for Triggering Stateflow Charts . . . . . 7-2
Defining the CLOCK Event . . . . . . . . . . . . . . . . . . . . . . . . . 7-3
Connecting the Edge-Triggered Events to the Input Signals . 7-4

Simulating the Chart


8
Setting Simulation Parameters and Breakpoints . . . . . . . . . 8-2
Prepare the Chart Yourself or Use the Supplied Model . . . . . 8-2
Checking That Your Chart Conforms to Best Practices . . . . . 8-2
Setting the Length of the Simulation . . . . . . . . . . . . . . . . . . 8-3
Configuring Animation for the Chart . . . . . . . . . . . . . . . . . . 8-4
Setting Breakpoints to Observe Chart Behavior . . . . . . . . . . 8-5
Simulating the Air Controller Chart . . . . . . . . . . . . . . . . . . . 8-5

vii
Debugging the Chart
9
Debugging Common Modeling Errors . . . . . . . . . . . . . . . . . . . 9-2
Debugging State Inconsistencies . . . . . . . . . . . . . . . . . . . . . . 9-2
Debugging Data Range Violations . . . . . . . . . . . . . . . . . . . . . 9-4

viii Contents
1

Introduction to the Stateflow Product

This chapter describes Stateflow event-based modeling software and its components.

• “Stateflow Product Description” on page 1-2


• “Anatomy of a Stateflow Chart” on page 1-3
• “How Stateflow Software Works with Simulink Software” on page 1-5
• “Use C Chart to Model Event-Driven System” on page 1-6
• “Installing Stateflow Software” on page 1-7
• “Related Products” on page 1-9
1 Introduction to the Stateflow Product

Stateflow Product Description


Model and simulate decision logic using state machines and flow charts

Stateflow is an environment for modeling and simulating combinatorial and sequential


decision logic based on state machines and flow charts. Stateflow lets you combine
graphical and tabular representations, including state transition diagrams, flow charts,
state transition tables, and truth tables, to model how your system reacts to events, time-
based conditions, and external input signals.

With Stateflow you can design logic for supervisory control, task scheduling, and fault
management applications. Stateflow includes state machines animation and static and
run-time checks for testing design consistency and completeness before implementation.

Key Features
• Modeling environment, graphical components, and simulation engine for modeling
and simulating complex logic
• Deterministic execution semantics with hierarchy, parallelism, temporal operators,
and events
• State diagrams, state transition tables, and state transition matrices representing
finite state machines
• Flow charts, MATLAB® functions, and truth tables for representing algorithms
• State diagram animation, state activity logging, data logging, and integrated
debugging for analyzing the design and detecting runtime errors
• Static and run-time checks for cyclic problems, state inconsistencies, data-range
violations, and overflow conditions
• Mealy and Moore finite-state machines

1-2
Anatomy of a Stateflow Chart

Anatomy of a Stateflow Chart


Here is an example of a Stateflow chart, which models as a finite-state machine the logic
required to shift gears in an automatic transmission system of a car:

Notice the following details in this chart:

• Each gear and shift position is represented by a state.


• States having a dashed boundary, such as gear_state and selection_state, are
parallel (can be active concurrently).
• States with a solid boundary, such as first, second, third and fourth, are
exclusive (only one can be active at a time).
• Transitions can be triggered by events and conditions.
• Directed-event broadcasts, such as UP and DOWN, trigger selective execution of chart
logic.

1-3
1 Introduction to the Stateflow Product

This chart is part of an example model called sf_car that ships with the Stateflow
product. To explore the model further, open it by typing sf_car at the command prompt
in the MATLAB Command Window.

1-4
How Stateflow Software Works with Simulink Software

How Stateflow Software Works with Simulink Software

Stateflow charts run as blocks in a Simulink model. The Stateflow block interfaces with
other blocks in the model using input and output signals. Through these connections,
Stateflow and Simulink software share data and respond to events that broadcast
between model and chart. For example, the Stateflow shift_logic block is integrated
with the Simulink sf_car model as shown.

You can develop your Stateflow chart before or after the Simulink model in which it will
run. Stateflow software comes with its own editor, which helps you simulate and test the
chart logic before you integrate it with a Simulink model. You can test a Stateflow chart
independently of its parent model by attaching a Source block as an input and a Sink
block as an output. During simulation, you can animate the chart to get visual feedback
about its run-time behavior.

1-5
1 Introduction to the Stateflow Product

Use C Chart to Model Event-Driven System

Before you start building a chart, you identify system attributes by answering these
questions:

1 What are your interfaces?

a What are the event triggers to which your system reacts?


b What are the inputs to your system?
c What are the outputs from your system?
2 Does your system have any operating modes?

a If the answer is yes, what are the operating modes?


b Between which modes can you transition? Are there any operating modes that
can run in parallel?

If your system has no operating modes, the system is stateless. If your system has
operating modes, the system is modal.

After identifying your system attributes, you can follow a basic workflow for building
Stateflow charts to model event-driven systems:

1 Define the interface to Simulink.


2 Define the states for modeling each mode of operation.
3 Define state actions and variables.
4 Define the transitions between states.
5 Decide how to trigger the chart.
6 Simulate the chart.
7 Debug the chart.

1-6
Installing Stateflow Software

Installing Stateflow Software

In this section...
“Installation Instructions” on page 1-7
“Prerequisite Software” on page 1-7
“Product Dependencies” on page 1-8
“Set Up Your Own Target Compiler” on page 1-8
“Using Stateflow Software on a Laptop Computer” on page 1-8

Installation Instructions
Stateflow software runs on Windows® and UNIX® operating systems. Your MATLAB
installation documentation provides all the information you need to install Stateflow
software. Before installing the product, you must obtain and activate a license (see
instructions in your MATLAB installation documentation) and install prerequisite
software (see “Prerequisite Software” on page 1-7 for a complete list).

Prerequisite Software
Before installing Stateflow software, you need the following products:

• MATLAB
• Simulink
• C or C++ compiler supported by the MATLAB technical computing environment

The compiler is required for compiling code generated by Stateflow software for
simulation.

The 64–bit Windows version of the Stateflow product comes with a default C compiler,
LCC-win64. LCC-win64 is used for simulation and acceleration. LCC-win64 is only
used when another compiler has not been configured in MATLAB.

Note: The LCC-win64 compiler is not available as a general compiler for use with the
command line MEX in MATLAB. It is a C compiler only, and cannot be used for SIL/
PIL modes.

1-7
1 Introduction to the Stateflow Product

For platforms other than Microsoft® Windows or to install a different compiler, see
“Set Up Your Own Target Compiler” on page 1-8.

Product Dependencies

For information about product dependencies and requirements, see


www.mathworks.com/products/stateflow/requirements.html.

Set Up Your Own Target Compiler


If you have multiple compilers that MATLAB supports on your system, MATLAB selects
one as your default compiler. You can change the default compiler by calling the mex –
setup command, and following the instructions. For a list of supported compilers, see
www.mathworks.com/support/compilers/current_release/.

Note: If you are using Microsoft Visual C++® 2010 Professional (or earlier) or Windows
SDK 7.1, the generated C code cannot contain any C structure greater than 2 GB. In a
single chart, do not use data with an aggregate size greater than 2 GB or 400 MB with
debugging enabled.

Using Stateflow Software on a Laptop Computer


If you plan to run the Microsoft Windows version of the Stateflow product on a laptop
computer, you should configure the Windows color palette to use more than 256 colors.
Otherwise, you may experience unacceptably slow performance.

To set the Windows graphics palette:

1 Click the right mouse button on the Windows desktop to display the desktop menu.
2 Select Properties from the desktop menu to display the Windows Display
Properties dialog box.
3 Select the Settings panel on the Display Properties dialog box.
4 Choose a setting that is more than 256 colors and click OK.

1-8
Related Products

Related Products
Several MathWorks® products extend the capabilities of Stateflow software. For
information about these related products, see www.mathworks.com/products/
stateflow/related.htm.

1-9
2

The Stateflow Chart You Will Build

To get hands-on experience using Stateflow software, you will build a Stateflow chart
in incremental steps that follow the basic workflow described in “Use C Chart to Model
Event-Driven System” on page 1-6. To give you a context for your development efforts,
this chapter describes the purpose and function of the chart you will build and explains
how it interfaces with a Simulink model. You will also learn how to run a completed
version of the model from the MATLAB command line.

• “The Stateflow Chart” on page 2-2


• “How the Stateflow Chart Works with the Simulink Model” on page 2-6
• “A Look at the Physical Plant” on page 2-7
• “Running the Model” on page 2-9
2 The Stateflow Chart You Will Build

The Stateflow Chart


You will build a Stateflow chart that maintains air temperature at 120 degrees in a
physical plant. The Stateflow controller operates two fans. The first fan turns on if the
air temperature rises above 120 degrees and the second fan provides additional cooling
if the air temperature rises above 150 degrees. When completed, your Stateflow chart
should look something like this:

As you can see from the title bar, the chart is called Air Controller and is part of a
Simulink model called sf_aircontrol. When you build this chart, you will learn how to
work with the following elements of state-transition charts:

2-2
The Stateflow Chart

Exclusive (OR) states. States that represent mutually exclusive modes of operation.
No two exclusive (OR) states can ever be active or execute at the same time. Exclusive
(OR) states are represented graphically by a solid rectangle:

The Air Controller chart contains six exclusive (OR) states:

• PowerOn
• PowerOff
• FAN1.On
• FAN1.Off
• FAN2.On
• FAN2.Off

Parallel (AND) states. States that represent independent modes of operation. Two
or more parallel (AND) states at the same hierarchical level can be active concurrently,
although they execute in a serial fashion. Parallel (AND) states are represented
graphically by a dashed rectangle with a number indicating execution order:

The Air Controller chart contains three parallel (AND) states:

• FAN1
• FAN2
• SpeedValue

Transitions. Graphical objects that link one state to another and specify a direction of
flow. Transitions are represented by unidirectional arrows:

2-3
2 The Stateflow Chart You Will Build

The Air Controller chart contains six transitions, from

• PowerOn to PowerOff
• PowerOff to PowerOn
• FAN1.On to FAN1.Off
• FAN1.Off to FAN1.On
• FAN2.On to FAN2.Off
• FAN2.Off to FAN2.On

Default transitions. Graphical objects that specify which exclusive (OR) state is to
be active when there is ambiguity between two or more exclusive (OR) states at the same
level in the hierarchy. Default transitions are represented by arrows with a closed tail:

The Air Controller chart contains default transitions:

• At the chart level, the default transition indicates that the state PowerOff is
activated (wakes up) first when the chart is activated.
• In the FAN1 and FAN2 states, the default transitions specify that the fans be powered
off when the states are activated.

State actions. Actions executed based on the status of a state.

The Air Controller chart contains two types of state actions:

• entry (en) action in the PowerOff state. Entry actions are executed when the state
is entered (becomes active).
• during (du) action in the SpeedValue state. During actions are executed for a state
while it is active and no valid transition to another state is available.

2-4
The Stateflow Chart

Other types of state actions

There are other types of state actions besides entry and during, but they involve
concepts that go beyond the scope of this guide. For more information, see “Syntax for
States and Transitions”.

Conditions. Boolean expressions that allow a transition to occur when the expression
is true. Conditions appear as labels for the transition, enclosed in square brackets ([ ]).

The Air Controller chart provides conditions on the transitions between FAN1.On and
FAN1.Off, and between FAN2.On and FAN2.Off, based on the air temperature of the
physical plant at each time step.

Events. Objects that can trigger a variety of activities, including:

• Waking up a Stateflow chart


• Causing transitions to occur from one state to another (optionally in conjunction with
a condition)
• Executing actions

The Air Controller chart contains two edge-triggered events:

• CLOCK wakes up the Stateflow chart at each rising or falling edge of a square wave
signal.
• SWITCH allows transitions to occur between PowerOff and PowerOn at each rising or
falling edge of a pulse signal.

2-5
2 The Stateflow Chart You Will Build

How the Stateflow Chart Works with the Simulink Model


The Stateflow chart you will build appears as a block named Air Controller that is
connected to the model of a physical plant in the Simulink sf_aircontrol model. Here
is the top-level view of the model:

The Simulink model passes the temperature of the plant as an input temp to the
Stateflow Air Controller block. Based on the temperature of the plant, the controller
activates zero, one, or two fans, and passes back to the model an output value airflow
that indicates how fast the air is flowing. The amount of cooling activity depends on the
speed of the fans. As air flows faster, cooling activity increases. The model uses the value
of airflow to simulate the effect of cooling when it computes the air temperature in
the plant over time. You will learn more about these design elements in “Interface with
Simulink”.

The Signal Builder block in the Simulink model sends a square wave signal (CLOCK) to
wake up the Stateflow chart at regular intervals and a pulse signal (SWITCH) to cycle the
power on and off for the control system modeled by the Stateflow chart. You will learn
more about these design elements in “Implementing the Triggers” on page 7-2.

2-6
A Look at the Physical Plant

A Look at the Physical Plant


Simulink software models the plant using a subsystem called Physical Plant, which
contains its own group of Simulink blocks. The subsystem provides a graphical hierarchy
for the blocks that define the behavior of the Simulink model. The inputs, airflow
speed and ambient temperature, model the effects of the controller activity on plant
temperature. Here is a look inside the Physical Plant subsystem:

In this model, the internal temperature of the plant attempts to rise to achieve steady
state with the ambient air temperature, set at a constant 160 degrees (as shown in “How
the Stateflow Chart Works with the Simulink Model” on page 2-6). The rate at which the
internal temperature rises depends in part on the degree of thermal isolation in the plant
and the amount of cooling activity.

Thermal isolation measures how much heat flows into a closed structure, based
on whether the structure is constructed of materials with insulation or conduction
properties. Here, thermal isolation is represented by a Gain block, labeled Thermal
Isolation. The Gain block provides a constant multiplier that is used in calculating the
temperature in the plant over time.

Cooling activity is modeled using a constant multiplier, derived from the value of
airflow, an output from the Stateflow chart. The chart assigns airflow one of three
cooling factors, each a value that serves as an index into a multiport switch. Using

2-7
2 The Stateflow Chart You Will Build

this index, the multiport switch selects a cooling activity multiplier that is directly
proportional to the cooling factor, as follows:

Cooling Factor What It Means Cooling Activity


(Value of Airflow)
0 No fans are running. The value of temp 0
is not lowered.
1 One fan is running. The value of temp -0.05
is lowered by the cooling activity
multiplier.
2 Two fans are running. The value of -0.1
temp is lowered by the cooling activity
multiplier.

Over time, the subsystem calculates the cooling effect inside the plant, taking into
account thermal isolation and cooling activity. The cooling effect is the time-derivative of
the temperature and is the input to the Integrator block in the Physical Plant subsystem.
Let the variable temp_change represent the time derivative of temperature. Note that
temp_change can be a warming or cooling effect, depending on whether it is positive or
negative, based on this equation:

temp_change = ((ambient - temp) * ( thermal isolation multiplier) ) + ((ambient - temp) * ( cooling factor))

The Integrator block computes its output temp from the input temp_change, as follows:

t
temp(t) = Ú temp _ change(t) dt + 70
t0

Note In this model, the initial condition of the Integrator block is 70 degrees.

temp is passed back to the Stateflow Air Controller chart to determine how much cooling
is required to maintain the ideal plant temperature.

2-8
Running the Model

Running the Model


To see how the sf_aircontrol model works, you can run a completed, tested version,
which includes the Stateflow chart you will build. Here's how to do it:

1 Start MATLAB software.

If you need instructions, consult your MATLAB documentation.


2 Type sf_aircontrol at the command line.

This command starts Simulink software and opens the sf_aircontrol model:

3 Double-click the Air Controller block to open the Stateflow chart.


4 Double-click the Scope block to display the changes in temperature over time as the
model runs.

Tip Position the Air Controller chart and the Scope window so they are both visible
on your desktop.

2-9
2 The Stateflow Chart You Will Build

5 Start simulation in the Air Controller chart by selecting Simulation > Run.

As the simulation runs, the chart becomes active (wakes up) in the PowerOff
state. Notice in the Scope that until PowerOn becomes active, the temperature rises
unchecked. After approximately 350 seconds into the simulation, a rising edge signal
switches power on and the fans become active.

Note Simulation time can be faster than elapsed time.

When the temperature rises above 120 degrees, FAN1 cycles on. When the
temperature exceeds 150 degrees, FAN2 cycles on to provide additional cooling.
Ultimately, FAN1 succeeds in maintaining the temperature at 120 degrees until a
falling edge signal switches power off again at 500 seconds. Then, the temperature
begins to rise again.

The Scope captures the temperature fluctuations:

2-10
Running the Model

Stopping or pausing simulation

You can stop or pause simulation at any time.

• To stop simulation, select Simulation > Stop.


• To pause simulation, select Simulation > Pause.

2-11
2 The Stateflow Chart You Will Build

6 Close the model.

Where to go next. Now you are ready to start building the Air Controller chart. Begin
at phase 1 of the workflow: “Implementing the Interface with Simulink” on page 3-2.

2-12
3

Defining the Interface to the Simulink


Model

2
Define the states 6
for modeling each Simulate
mode of operation the chart

1 3 5 7
Define the Define Decide how to Debug
interface state actions trigger the chart the chart
to Simulink and variables

4
Define the
transitions
between states

In phase 1 of this workflow, you define the interface to the Simulink model.
3 Defining the Interface to the Simulink Model

Implementing the Interface with Simulink

In this section...
“Build It Yourself or Use the Supplied Model” on page 3-2
“Design Considerations for Defining the Interface” on page 3-2
“Adding a Stateflow Block to a Simulink Model” on page 3-3
“Defining the Inputs and Outputs” on page 3-7
“Connecting the Stateflow Block to the Simulink Subsystem” on page 3-13

Build It Yourself or Use the Supplied Model


To implement the interface yourself, work through the exercises in this section.
Otherwise, open the supplied model by entering this command at the MATLAB prompt:
addpath(fullfile(docroot, 'toolbox', 'stateflow', 'gs', 'examples'))
Stage1Interface

Design Considerations for Defining the Interface


The following sections describe the rationale for the input and output of the Stateflow
chart.

Inputs Required from Simulink Model

Type of Input. Temperature of the physical plant

Rationale. The purpose of the chart is to control the air temperature in a physical
plant. The goal is to maintain an ideal temperature of 120 degrees by activating one or
two cooling fans if necessary. The chart must check the plant temperature over time to
determine the amount of cooling required.

Properties of Input. The properties of the temperature input are as follows:

Property Value
Name temp

3-2
Implementing the Interface with Simulink

Property Value
Scope Input
Size Inherit from Simulink input signal for compatibility
Data type Inherit from Simulink input signal for compatibility
Port 1

Outputs Required from Stateflow Chart

Type of Output. Speed of airflow, based on how many fans are operating

Rationale. When the Simulink subsystem determines the temperature of the physical
plant over time, it needs to account for the speed of the airflow. Airflow speed is directly
related to the amount of cooling activity generated by the fans. As more fans are
activated, cooling activity increases and air flows faster. To convey this information, the
Stateflow chart outputs a value that indicates whether 0, 1, or 2 fans are running. The
Simulink subsystem uses this value as an index into a multiport switch, which outputs a
cooling activity value, as described in “A Look at the Physical Plant” on page 2-7.

Properties of Output. The properties of the airflow output are as follows:

Property Value
Name airflow
Scope Output
Data type 8-bit unsigned integer (uint8)

(The values can be only 0, 1, or 2.)


Port 1

Adding a Stateflow Block to a Simulink Model


To begin building your Stateflow chart, you will add a Stateflow block to a partially built
Simulink model called sf_aircontrol_exercise, which contains the Physical Plant
subsystem, described in “A Look at the Physical Plant” on page 2-7.

To add a Stateflow block to an existing Simulink model:

3-3
3 Defining the Interface to the Simulink Model

1 Open the Simulink model by typing sf_aircontrol_exercise at the MATLAB


command prompt.

The model opens on your desktop:

The model is incomplete because it does not include the Stateflow chart that you will
build as you work through the exercises in this guide. Instead, the model contains
several nonfunctional blocks: the Terminator, Inport, and Annotation blocks.
2 Delete the nonfunctional blocks and their connectors.

Tip Hold down the Shift key to select multiple objects, and then press Delete.

Your model should now look like this:

3-4
Implementing the Interface with Simulink

3 Save the model as Stage1Interface:

a Create a new local folder for storing your working model.


b In the Simulink model window, select File > Save As.
c Navigate to the new folder.
d Enter Stage1Interface as the file name.
e Leave the default type as Simulink Models.
f Click Save.
4 On the toolbar of the Simulink model, click the Library Browser icon:

The Simulink Library Browser opens on your desktop:

3-5
3 Defining the Interface to the Simulink Model

5 Add the Stateflow Chart block to the Simulink model:

a In the left scroll pane of the Library Browser, select Stateflow.


b Drag the first block, called Chart, into your model.

6 Click the label Chart under the Stateflow block and rename it Air Controller.
7 Change the action language of the chart to C:

a Double-click the block to open the chart.


b Right click in an empty area of the chart and select Properties.
c From the Action Language box, select C.
d Select OK.

3-6
Implementing the Interface with Simulink

Shortcut for adding a Stateflow block to a new Simulink model

At the MATLAB command prompt, enter this command:

sfnew

A new, untitled Simulink model opens on your desktop, automatically configured with a
Stateflow chart. For more information, see sfnew.

Defining the Inputs and Outputs


Inputs and outputs are data elements in a Stateflow chart that interact with the parent
Simulink model. To define inputs and outputs for your chart, follow these steps:

1 Double-click the Air Controller block in the Simulink model Stage1Interface to


open the Stateflow chart.

3-7
3 Defining the Interface to the Simulink Model

The Stateflow Editor opens on your desktop:

2 Add a data element to hold the value of the temperature input from the Simulink
model:

a In the editor menu, select Chart > Add Inputs & Outputs > Data Input
From Simulink.

The Data properties dialog box opens on your desktop with the General tab
selected:

3-8
Implementing the Interface with Simulink

The default values in the dialog box depend on the scope — in this case, a data
input.
b In the Name field, change the name of the data element to temp.
c Leave the following fields at their default values in the General tab because
they meet the design requirements:

3-9
3 Defining the Interface to the Simulink Model

Field Default Value What It Means


Scope Input Input from Simulink model. The data
element gets its value from the Simulink
signal on the same input port.
Size -1 The data element inherits its size from
the Simulink signal on the same port.
Complexity Off The data element does not contain any
complex values.
Type Inherit: Same as The data element inherits its data type
Simulink from the Simulink signal on the same
output port.

Note Ports are assigned to inputs and outputs in the order they are created.
Because temp is the first input you created, it is assigned to input port 1.
d In the General tab, select Add to watch window.

The Stateflow Breakpoints and Watch window lets you examine the value of
temp during breakpoints in simulation. You will try this in “Setting Simulation
Parameters and Breakpoints” on page 8-2.
e Click OK to apply the changes and close the dialog box.
3 Add a data element to hold the value of the airflow output from the Air Controller
chart:

a In the editor menu, select Chart > Add Inputs & Outputs > Data Output To
Simulink.

The Data properties dialog box opens on your desktop, this time with different
default values, associated with the scope Output:

3-10
Implementing the Interface with Simulink

Note: Because airflow is the first output you created, it is assigned to output
port 1.
b In the Name field of the Data properties dialog box, change the name of the data
element to airflow.
c In the Type field, select uint8 (8-bit unsigned integer) from the submenu.

3-11
3 Defining the Interface to the Simulink Model

d Look at the Initial value field.

The initial value is a blank expression, which indicates a default value of zero,
based on the data type. This value is consistent with the model design, which
specifies that no fans are running when the chart wakes up for the first time.
e Make the following changes for other properties in the General tab:

Property What to Specify


Limit range Enter 0 for Minimum and 2 for Maximum.
Add to watch Select this to add airflow to the Watch tab of the
window Stateflow Breakpoints and Watch window.
f Click OK to apply the changes and close the dialog box.
4 Go back to the Simulink model by clicking the up-arrow button in the Stateflow
Editor toolbar.

Notice that the input temp and output airflow have been added to the Stateflow
block:

3-12
Implementing the Interface with Simulink

Tip You might need to enlarge the Air Controller block to see the input and output
clearly. To change the size of the block:

a Select the block and move your pointer over one of the corners until it changes to
this shape:

b Hold down the left mouse button and drag the block to the desired size.

5 Save Stage1Interface.

Tip There are several ways to add data objects to Stateflow charts. You used the
Stateflow Editor, which lets you add data elements to the Stateflow chart that is open
and has focus. However, to add data objects not just to a chart, but anywhere in the
Stateflow design hierarchy, you can use a tool called the Model Explorer. This tool also
lets you view and modify the data objects you have already added to a chart. For more
information, see “Stateflow Hierarchy of Objects” and “How to Add Data Using the Model
Explorer” in the Stateflow User's Guide. You can also add data objects programmatically
using the Stateflow API, as described in “Create Stateflow Objects” in the Stateflow API
Guide.

Connecting the Stateflow Block to the Simulink Subsystem


Now that you have defined the inputs and outputs for the Stateflow Air Controller block,
you need to connect them to the corresponding signals of the Simulink Physical Plant
subsystem. Follow these steps:

1 In the model Stage1Interface, connect the output airflow from Air Controller to
the corresponding input in Physical Plant:

a Place your pointer over the output port for airflow on the right side of the Air
Controller block.

The pointer changes in shape to crosshairs.


b Hold down the left mouse button and move the pointer to the input port for
airflow on the left side of the Physical Plant block.

3-13
3 Defining the Interface to the Simulink Model

c Release the mouse.

The connection should look something like this:

Tip You can use a shortcut for automatically connecting blocks. Select the source
block, and then hold down the Ctrl key and left-click the destination block.
2 Connect the output temp from the Physical Plant to the corresponding input in Air
Controller by drawing a branch line from the line that connects temp to the Scope:

a Place your pointer on the line where you want the branch line to start.
b While holding down the Ctrl key, press and hold down the left mouse button.
c Drag your pointer to the input port for temp on the left side of the Air Controller
block.
d Release the mouse button and the Ctrl key.
e Reposition the connection so that it looks like this:

3-14
Implementing the Interface with Simulink

Tip To reposition connections, move your cursor over the end of the line. When
the cursor changes to a circle, select the end of the line with the left mouse
button and drag the line to a new location.
3 Save Stage1Interface.

Where to go next. Now you are ready to model the operating modes with states. See
“Implementing the States to Represent Operating Modes” on page 4-2.

3-15
4

Defining the States for Modeling Each


Mode of Operation

2
Define the states 6
for modeling each Simulate
mode of operation the chart

1 3 5 7
Define the Define Decide how to Debug
interface state actions trigger the chart the chart
to Simulink and variables
4
Define the
transitions
between states

In phase 2 of this workflow, you define the states for modeling each mode of operation.
4 Defining the States for Modeling Each Mode of Operation

Implementing the States to Represent Operating Modes


In this section...
“Build It Yourself or Use the Supplied Model” on page 4-2
“Design Considerations for Defining the States” on page 4-2
“Adding the Power On and Power Off States” on page 4-6
“Adding and Configuring Parallel States” on page 4-8
“Adding the On and Off States for the Fans” on page 4-14

Build It Yourself or Use the Supplied Model


To implement the states yourself, work through the exercises in this section. Otherwise,
open the supplied model by entering this command at the MATLAB prompt:
addpath(fullfile(docroot, 'toolbox', 'stateflow', 'gs', 'examples'))
Stage2States

Design Considerations for Defining the States


The following sections describe the rationale for the hierarchy and decomposition of
states in the chart.

When to Use States

Whether or not to use states depends on the control logic you want to implement. You can
model two types of control logic: finite state machines and stateless flow charts. Each type
is optimized for different applications, as follows:

Control Logic Optimized for Modeling


Finite state machines Physical systems that transition between a finite number of
operating modes. In Stateflow charts, you represent each mode
as a state.
Stateless flow charts Abstract logic patterns — such as if, if-else, and case
statements — and iterative loops — such as for, while, and
do loops. You represent these logic constructs with connective
junctions and transitions in Stateflow charts. No states are
required. See “Decision Logic”.

4-2
Implementing the States to Represent Operating Modes

The Air Controller chart is a system that cools a physical plant by transitioning between
several modes of operation and, therefore, can be modeled as a finite state machine. In
the following sections, you will design the states that model each mode of operation.

Determining the States to Define

States model modes of operation in a physical system. To determine the number and type
of states required for your Air Controller chart, you must identify each mode in which
the system can operate. Often, a table or grid is helpful for analyzing each mode and
determining dependencies between modes.
Analysis of Operating Modes

For Air Controller, the modes of operation are

Operating Mode Description Dependencies


Power Off Turns off all power in the No fan can operate when power is off.
control system
Power On Turns on all power in the Zero, one, or two fans can operate
control system when power is on.
Fan 1 Activates Fan 1 Fan 1 can be active at the same time
as Fan 2. When activated, Fan 1 can
turn on or off.
Fan 1 On Cycles on Fan 1 Fan 1 On can be active if Fan 1 is
active and power is on.
Fan 1 Off Cycles off Fan 1 Fan 1 Off can be active if Fan 1 is
active, and power is on.
Fan 2 Activates Fan 2 Fan 2 can be active at the same time
as Fan 1. When activated, Fan 2 can
turn on or off.
Fan 2 On Cycles on Fan 2 Fan 2 On can be active if Fan 2 is
active and power is on.
Fan 2 Off Cycles off Fan 2 Fan 2 Off can be active if Fan 2 is
active and power is on.
Calculate airflow Calculates a constant value Calculates the constant value, based
of 0, 1, or 2 to indicate how on how many fans have cycled on at
fast air is flowing. Outputs each time step.
this value to the Simulink

4-3
4 Defining the States for Modeling Each Mode of Operation

Operating Mode Description Dependencies


subsystem for selecting a
cooling factor.

Number of States to Define

The number of states depends on the number of operating modes to be represented. In


“Analysis of Operating Modes” on page 4-3, you learned that the Air Controller chart
has nine operating modes. Therefore, you need to define nine states to model each mode.
Here are the names you will assign to the states that represent each operating mode in
“Implementing the States to Represent Operating Modes” on page 4-2:

State Name Operating Mode


PowerOff Power Off
PowerOn Power On
FAN1 Fan 1
FAN2 Fan 2
SpeedValue Calculate airflow
FAN1.On Fan 1 On
FAN1.Off Fan 1 Off
FAN2.On Fan 2 On
FAN2.Off Fan 2 Off

Note: Notice the use of dot notation to refer to the On and Off states for FAN1 and FAN2.
You use namespace dot notation to give objects unique identifiers when they have the
same name in different parts of the chart hierarchy.

Determining the Hierarchy of States

Stateflow objects can exist in a hierarchy. For example, states can contain other states
— referred to as substates — and, in turn, can be contained by other states — referred to
as superstates. You need to determine the hierarchical structure of states you will define
for the Air Controller chart. Often, dependencies among states imply a hierarchical
relationship — such as parent to child — between the states.

4-4
Exploring the Variety of Random
Documents with Different Content
air of triumphant malignity masked under a silken courtesy. It was
the first time he and I had met in London.
"He asked me where I lodged, how long I had been in town, and
whether I was still pursuing my scientific investigations. I told him I
had other investigations on my hands, even more absorbing than
those of the laboratory; I had my granddaughter's evil fortunes to
guard from further decline.
"'Do you call it evil fortune to be mistress of such a house as this?'
he asked, looking round him at the hall in which we were standing.
"'I call it infamy to be the mistress of your master, most of all, his
slighted mistress,' I answered.
"'O, fie, sir! we all call the lady his wife. She is known here only as
Mrs. Topsparkle.'
"'An empty honour, sir, which the more strongly indicates her
dishonour. Did you ever know Mr. Topsparkle introduce his lady to
any decent woman, to any persons of standing or repute? No, his
only generosity is to surround her with a sybarite luxury, to leave her
in a gilded desolation. You all know she is not your master's wife,
and that no wife would consent to have her child carried off from
her by a stranger to a place of which she knows not the name.'
"'My master is a man accustomed to rule,' answered Fétis. 'We none
of us ever presume to thwart him.'
"I passed out of the house without another word, and waited day
after day for some sign from Margharita, to whom I had given the
address of my lodging; but none came. My illness had weakened me
considerably, and I was no longer able to loiter about within sight of
Mr. Topsparkle's door for an hour at a time; yet I dragged myself
there every evening, and generally contrived to got a word with my
ally in the servants' hall.
"One evening at dusk I saw a young man of remarkably handsome
appearance leave Mr. Topsparkle's house, as I thought with a
stealthy air, hurrying away with anxious glances to right and left, and
with the collar of his cloak pulled up about his ears.
"Two days afterwards I saw in the Flying Post that there had been a
passage of incivilities between the rich Mr. Topsparkle and young Mr.
Churchill, a brother of the famous Mrs. Arabella Churchill, the
favourite of the late King, a dispute which had nearly resulted in a
duel. I went at once to Soho Square, but was refused admittance.
Mrs. Topsparkle was dangerously ill, and her husband was in
constant attendance upon her.
"I asked to see Fétis, and, after waiting nearly an hour in the hall, he
came to me.
"In reply to my anxious questions he affected to make light of my
granddaughter's illness. 'A fit of the spleen,' he said, 'which Mr.
Topsparkle's tenderness has exaggerated into a serious malady. One
of the Court physicians is now with her.'
"I charged him with deceiving me. 'There has been a quarrel
between your master and that unhappy girl,' I said, 'and she is
reduced to a state of misery in which you will not allow me to see
her.'
"'Quarrel! What should they quarrel about?' he asked, with his
unblushing air.
"The physician came down-stairs attended by a couple of lacqueys
at this moment, and I went to him at once and questioned him
about his patient. He looked astonished at my effrontery, and turned
to Fétis for an explanation.
"'I am a near relative of the patient, sir,' I said, 'and this old heart
will break if any ill befalls her.'
"'My good man, the lady is not seriously indisposed. She is but
suffering from a languor which is natural to a woman of quality after
the ordeal of maternity; and she is somewhat vapourish from the
seclusion of convalescence. If she follows my prescriptions implicitly
she will soon be restored to good spirits and full beauty.'
"'Then she is not in danger?' I asked.
"'I can perceive none at present. I have attended her Grace of
Cleveland for the same malady; and when the Duchess of
Portsmouth returned to France she insisted on carrying my
prescriptions with her.'
"I had no confidence in an old twaddler of this order, whose gold-
headed cane and embroidered velvet suit were apparently his
strongest qualifications. I looked from him to Fétis, who, in spite of
his silken smoothness, had, I thought, a more anxious air than
usual. He was very pale, and his hollow eyes indicated a night of
watching.
"'I will not leave this house until I have seen my granddaughter,' I
said, resuming my seat in the hall; whereupon Fétis whispered to
the physician, who presently approached me and informed me with
a solemn air that although Mrs. Topsparkle's bodily health was in no
danger, her spirits were much affected, and that the agitation of an
interview with a relative might throw her into a fever.
"Alas, I knew that my presence could not bring calmness to that
wounded spirit. Unless she had been well enough to get up and
follow me out of that accursed house a meeting between us could
be of no avail. I had the physician's word that she was in no danger;
and though I put him down as a pompous pretender I yet gave him
credit for enough skill and enough honesty to answer such a plain
question as I had asked him. So I left the house soon after the
doctor, Fétis promising that if his lady were in calmer spirits next day
I should be allowed to see her.
"When I went to the house at noon next day she was a corpse. She
had gone off suddenly in a fit of hysterics soon after midnight, Mr.
Topsparkle and her waiting-woman being present. Mr. Topsparkle
was shut up in his room in an agony of grief, and would see no one.
"Had there been any medical man called in at the time of her death?
I asked. No, there had been no one. It was too sudden; but the
physician had been there this morning, and had endeavoured to
explain the cause of the death, which had taken him by surprise.
"I asked to see the dead; but this privilege was refused to me. I
inquired for Fétis, and was told he had gone out on business, and
was not expected back for some hours. The key of the room in
which Margharita was lying was in his possession. There were lights
burning in the room, but there was no one watching there. There
had been no religious ministrations. My granddaughter had perished
as the companion of an infidel, surrounded by infidels.
"I sat in the hall for some hours, despite the sneers and incivilities of
the servants, waiting for the return of Fétis; but he did not reappear
until I was worn out by agitation and fasting and the misery of my
position as the mark of insolence from overfed lackeys. I left the
house broken-hearted, and returned there next morning only in time
to see the coffin carried to the pompous hearse with its tall plumes
and velvet trappings and six Flanders horses. I followed on foot to a
graveyard in the neighbourhood, where my granddaughter was
buried in a soil crowded with the dead. Topsparkle was not present.
He was too ill to attend, I was told; and there were hootings and
hissings from the crowd as the funeral procession, with Fétis at its
head, went back to Soho Square.
"I followed him to the threshold of his master's house.
"'Do you know why the rabble hooted you?' I asked him, as we
stood side by side within the doors, which the porter shut quickly to
keep out the crowd.
"'Only because they are rabble, and hate their betters,' he answered.
"'They hooted you because a good many people in this
neighbourhood suspect that which I know for a certainty. They
suspect you and your master of having murdered that unhappy girl.'
"He called me an idiot and a liar; but I saw how his face, which had
been white to the lips as he passed through the crowd, now
changed to a still more ghastly hue.
"'O, you forget that it was I who armed your arsenal of murder. It
was in my laboratory you learnt all the arts of the old Italian
toxicologists—the poison, and the antidote, and the drug that
neutralises the antidote. You were laborious and persevering; you
wanted to master the whole science of secret murder. You had no
definite views of mischief then, only the thirst for evil, as Satan has,
revelling in sin for its own sake, courting iniquity; but you soon
found a use for your wicked power. First you snared your victim, and
then you killed her—you, the passionless hireling of a profligate
master, the venal slave and tool.'
"He made a sign to his underlings—the stalwart porter and three tall
footmen—and they came round me and thrust me out of the house,
flung me on to the pavement, helpless and exhausted. There was no
constable within call; the crowd had dispersed. I had nothing to do
but crawl back to my lodging, an impotent worm.
"Next day I was visited by a constable, who told me that I had
narrowly escaped being sent to gaol for an assault upon the
confidential servant of a gentleman of high position. He warned me
of the danger of staying any longer in the town, where I had already
made myself an object of suspicion as a foreign spy and a
dangerous person.
"I knew something about the interior of London gaols, and had
heard so many melancholy stories of the tyranny exercised even
upon poor debtors, and how much more upon common felons, that I
shuddered at the idea of being clapped into prison and kept there
indefinitely by the influence of Mr. Topsparkle. I knew that there was
no cell in our dungeons of Venice worse than some of the dens
where humanity was lodged in the Fleet, and I knew what the power
of wealth can do even in a country which boasts of freedom and
equal rights between man and man; so I did not make light of the
constable's counsel, but at all hazard to myself I obtained an
interview with the Italian consul, who was civil, but could give me no
help, and who smiled at suspicions for which I could allege no
reasonable ground. The fact that Fétis had made the art of secret
poison his especial study, to this gentleman's mind implied nothing
beyond a morbid taste.
"'You are yourself a toxicologist, sir,' he said, yet I take it you have
never poisoned anybody. Pray, what motive could Mr. Topsparkle or
his servant have had for making away with a lady who, as she was
not a wife, could have been easily provided for?'
"'Revenge. Mr. Topsparkle may have believed that she had been false
to him. It is known that he was jealous of her.'
"'And you would suspect a gentleman in Mr. Topsparkle's position, a
patron of art, a highly-accomplished person, and a man of society;
you would credit such a man with the murderous violence of an
Othello.'
"I tried to convince this gentleman that my granddaughter had been
poisoned, and that it was his duty to help me to bring the crime to
light. I entreated him to use his influence with the magistrate and to
get an order for the exhumation of the body; but he thought me, or
pretended to think me, a lunatic, and he warned me that I had
better leave England without delay, as I had no obvious business or
means of subsistence in this country, where there was a strong
prejudice against our countrymen, who were usually taken for
Jesuits and spies, a prejudice which had been heightened by the
popular dislike of the Queen and her confessor.
"In spite of this advice, I remained in London some time longer, in
the hope of obtaining some proof against the wretch I suspected,
although the thought of my laboratory drew me to Venice. I
questioned my friend in Mr. Topsparkle's household, and bribed him
to get what information he could from his fellow-servants; but all I
could hear from this source was that Mrs. Topsparkle had been
seized with a sudden indisposition late one evening, that an
apothecary, whom her waiting-woman called in hurriedly from the
neighbourhood, had been able to do nothing to relieve her
sufferings, and had been dismissed with contumely by Mr.
Topsparkle, who was angry with his lady's woman for having sent for
such a person. The sufferer took to her bed, never left it but for her
coffin, and Mr. Topsparkle remained in close attendance upon her
until the hour of her death.
"I found the apothecary in a shabby street near St. Giles's, and
discovered that he had a shrewd suspicion of poison, but was very
fearful of committing himself, especially in opposition to the Court
physician, who had given a certificate of death. And after many
useless efforts I went back to Venice, where I found my son a
broken man. He survived his daughter little more than a year.
"This is a truthful account of my granddaughter's elopement and
death, which I hope may some day assist in bringing her murderers
to shame, if it do not lead to their actual punishment. That she was
poisoned by Fétis, with the knowledge and consent of his master, I
have never doubted; but such a crime is difficult of proof where the
criminal is at once bold and crafty."

Lavendale laid down the manuscript with the conviction that


Vincenti's suspicions were but too well founded. There was that in
Topsparkle himself which had ever inspired him with an instinctive
aversion, while in Fétis he recognised a still subtler scoundrel. He
had heard enough of Mr. Topsparkle's early history to know that he
had been notorious for his vices even among the openly vicious, and
that such a man should progress from vices to crimes seemed within
the limits of probability.
And Judith, the woman Lavendale adored, was in the power of this
man, and by her insolent defiance, her attitude of open scorn, might
at any hour of her life provoke that evil nature beyond endurance.
Hitherto she had made the tyrant her slave; but his jealousy had
been aroused, the tiger had shown his claws, and who should say
when jealousy might culminate in murder?
"Poor giddy soul, she treats him lightly enough, and has hitherto
been mistress of the situation," thought Lavendale; "but she does
not know upon what a precipice she is treading. She does not know
the man or his true history. And in that house in Soho, where she
queens it so gaily, his victim died. There is the atmosphere of crime
in the midst of all that splendour. Would to God I could guard her
from harm! I might have saved her—might have carried her off to
love and freedom—if I had had a life to give her. But to lure her
away on false pretences, to unite her with a vanishing existence, to
leave her desolate and dishonoured in a foreign land! That were
indeed cruel. And I know that the vision could not deceive. I have
accepted my doom."
He wrote to Durnford again, urging him to closer watchfulness.
"You have often told me that you love me, Herrick," he wrote; "you
have said that the sympathy between us, engendered of a curious
likeness in tastes and disposition, is almost as strong as that
mysterious link which unites twin brothers. Think of me now as your
brother, and give me all a brother's devotion. Be the guardian angel
of her I dare not guard."

END OF VOL. II.


*** END OF THE PROJECT GUTENBERG EBOOK MOHAWKS: A
NOVEL. VOLUME 2 OF 3 ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like