Showing posts with label Embedded Development. Show all posts
Showing posts with label Embedded Development. Show all posts

Thursday, August 12, 2010

Agile for Embedded Part I

I have used a number of development techniques in my career and, most recently, have taken up Agile Development as a means of rapidly building systems. However, Agile's heritage is in the development of web sites and I am currently interested in the development of embedded systems. The differences between these two require some modifications to the basic Agile techniques. I plan to publish a series of posts that describe the changes I would use.
This post is concerned with User Stories.
A User Story is a simple way of capturing the requirements of a system. It has many similarities to the Use Case as defined in UML. Both define requirements based on a consistent outside-in perspective from a User to the System.



The User Story is a single sentence in the form
As a [user role] , I can [feature] ,so that [benefit] .
Instead of the generic "user", the user role tries to identify different classes of users with different requirements. User is too generic. But Tom, Sally, Harry are too specific. When we see that Tom and Sally are customers and Harry is the administrator then the roles of Customer and Administrator emerge with separate interfaces, transactions, and requirements.
The feature  is what I want to accomplish with the system as the User Role.
And benefit; is why I want to use that feature. What value do I get from the story.

Suppose we are building Amazon.com. Then we might see user stories like:

As a Customer, I can search for something, so that I find the item I am looking for.
As a Customer, I can select an item from a results list to get more details, so I can decide if I want to buy it.
As a Merchant, I can register my business as an Amazon storefront, so I can sell my products.

So the catch with an embedded system is that the rich interaction with Users is not always present. In a "headless" system with no user interface, the embedded system depends on sensors to modify its behavior and will often send outputs to actuators. Let us imagine a thermostat as the system. I may have a simple user interface so that the homeowner can:

As a homeowner, I can change the mode of the HVAC between Off, Heat, and Cool, so that the house is maintained at the temperature I want.
As a homeowner, I can change the temperature limits, so that the house is maintained at the temperature I want.

A simple context diagram for the thermostat is shown below





The "Commands" shown on the diagram are for mode control and temp control, and map cleanly to the two user stories. But what about the "Display"? Unlike a web site where the user takes an explicit action of clicking on a link to see a new page, the display on a thermostat is always there. Or is it? That is what the Battery is doing on a diagram. Remember what the display looks like without the battery inserted? Blank. Insert the battery and the display comes on (usually showing default information) and stays on until the battery runs out of power. One could imagine a user story like

As the homeowner, I can insert a battery, so my thermostat will turn on and maintain my house temperature.

But what about the Thermocouple that provides the "Current Temp"? We use that to compare to the Mode and Set Point so that the Thermostat can tell the HVAC to turn on or turn off.

There is no natural user story involving the homeowner and the thermocouple.

My idea is to add event modeling as defined by Paul Ward and Stephen Mellor. An event is something that occurs at some point in time in the environment of a system and, for which the system should have a response.
This could also apply to the users but I think the user story format is fine for that. Below is a table that captures some of the events for this system

Battery inserted
Battery runs low
HVAC begins heating
HVAC begins cooling
HVAC stops heating
HVAC stops cooling
Temperature fluctuates

When the battery is inserted and when the battery runs low can both be determined by measuring the voltage.
We are not interested in the current voltage at anytime just these two events.

The diagram below shows the modes of the HVAC



This is a basic state diagram. If the behavior of our system will be different depending on what mode (i.e. state) it is in then using such a diagram helps separate the behavior and to better understand what would trigger the system to change states. For example the event of HVAC begins heating could occur when the system is Off. It should not occur when the HVAC is already cooling. Many events are important because they help us organize these modalities.

Finally, the Current Temperature that fluctuates is a special kind of event. The temperature always exists and has a value that the system wants to measure to determine if it should be heating or cooling and it wants to display the current temperature to the homeowner.

Events (like user stories) are intentionally abstract. As the response to the event is being analyzed one must answer how we will determine that the event has occurred. We must focus on the system boundary and look at the interfaces. Sometimes these interfaces are constrained. For example, suppose the HVAC manufacturers have gotten together and decided on a specific interface standard for status/controls. They might dictate the HVAC Status would be conveyed by a twisted pair wire with +5 volts indicating Heating, -5 volts indicating Cooling, and 0 volts indicating Off. So our thermostat could monitor the voltage and detect when the four events occurred.



So lets put this together in a user story / event table as shown below.



Conclusions
By adding events to user stories, I have introduced a means to capture requirements for embedded systems that do not have significant behavior at the human interface. This is consistent with the general approach of agile development because:

  • The event/response/benefit complexity is similar to the user story and can be treated in a similar fashion in SCRUM
  • The events have an outside-in perspective similar to the user story. This avoids "the system shall" type of requirement.


Stay tuned for Part II (Can Hardware be designed from User Stories / Events?)

Tuesday, April 28, 2009

Johnny goes to Harvard



Last weekend I attended the Deep Agile 2009 conference at Harvard University. This two day conference was put on by Agile Bazzaar, an ACM Chapter dedicated to the improvement of all things agile. Approximately 90 attendees participated in the conference and I thought that this was a very well run production. Kudos to the Agile Bazzaar volunteers and especially Nancy Van Schooenderwoert who chaired the program. 
The links above give the highlights from the events and I only want to add my own observations:

Jack Ganssle represented the non-agile development community and gave several presentations on his approach to embedded systems development. He favors object oriented development and follows Bertrand Meyer's Design by Contract process.

James Grenning was one of the original signers of the Agile Manefesto  He says he attended that event for the skiing but I suspect he had more involvement... He is a strong advocate of Test Driven Development, Pair Programming, and SCRUM. He showed all these elements to the audience but in some cases they were the regular versions without a significant embedded twist.

Russell Hill is a development manager at Key Technologies. He is an advocate of Test Driven Development for embedded and thoughout his presentations talked about his experiences at Key building a reusable set of boards for the various products Key manufactures. This system includes hard real-time behavior developed for an FPGA connected to a Motorolla micro processor handeling the UI and control logic. He brought a valuable perspective to the conference on what is achievable for embedded development using agile.

Here are my notes from a panel session:


In practice how can a HW based system be delivered incrementaly?
James - I don't do a lot of HW dev BUT "is it working?" is a good test.
Russel - Our HW is based on FPGA and has some flexibility. But boards would be developed incrementaly.
Jack - There is a lot of religion in agile.... HW tends to be late and broken.... and we don't anticipate that for SW

Do you expect to modify an embedded system on a 2-3 week sprint cycle?
James - would like visable progress without neccessarily being deliverable
Russel  - Key Technology can turn around a HW change very rapidly (2 days!)

When an embedded system is used for a consumer product who is the product owner?
Russel -  We have thousands of customers, Marketing dept, Field Serices represents the interests of the customer. Nancy - any problems with that. Russel - Sometimes. Only in last couple years has marketing been strong participant.
James - this is an organizational problem (of getting participation)

How to reconcile "HW requires long lead times" vs "Agile is incremental" ?
Russel - Board was not available for a couple years. SW was written to spec and was able to deliver 2 weeks after HW release.
Jack - Up front commitment to HW features and to the schedule is different for embedded.
James - At the beginning of an agile project one needs a vision of both HW and SW.

How do you handle scheule constraint.
James - in agile nothing is negotiable until it is late.
Russel - when we are late our internal customers now about it real soon. Visibility to decision makers is important.
Jack - This is not unique to agile. Quality, Schedule, Features pick any two. Jack thinks features should be unconstrained while keeping Quality and Schedule fixed.

Any experience including HW engineers in the SCRUM.
Russel - intersted but not active daily 
James - integrate early and often. Some teams use HW engineers as customer. One client in Finland does overnight board turns.

For an embedded system can a product backlog include User Stories that target either HW or SW? If so, what does a HW User Story look like.
Russel - We have not done that.
James - if you try it write a paper.
Jack - I think it would be very difficult.

I am concerned about the lack of upfront design. What if a User Story requires a big change?
Russel - we just experienced this with a project that required a substantial redesign. The requirement was given a year ago on an eight year project.

In classic agile the key to development is decomposition of the epic story into slices. How do you decompose in embedded?
Russel - Frankly we struggle getting our HW engineers to think agile but it is getting better. We had one example where a story to eliminate a spurious image required both sensor, hw platform, and sw.

What role if any does architecture have in agile?
James - we work on it every day. Every time a sprint is completed there is an architecture that supports SW completed to that date.
Russel - Some of our architecture is harder to change. 
Jack - Architecture and Design in embedded world is a lot less maliable. Up front design is very important.
Nancy - Some companies have a culture of detail which is driven by politics.

My question was the one about HW User Stories.... I am still looking for a way to weave the EE participation into a high tempo devlivery using agile approaches. I will take James up on his suggestion to write a paper when I have it all figured out.