You are on page 1of 56

Project name: ZIPC & CATS-IF Board-Based

Remote Control Car


Trainee: Kanjanakarun Pichead
Trainer: Kazuhiro Yamanishi
Advisor: Kenji Ohtsu, Ueshima Daisuke

Present Subject: Understanding of ZIPC 1st


(Simulation, Code Generation & Emulation)
Released date: 2007.08.31
1st Revision date: 2007.09.03
2nd Revision date: 2007.09.04

1
Content Outline / アウトライン
1. Design Specification
* Remote Control Car Overview
* Detail design specification (Flow Chart? / STD? /STM?)
* What is EHSTM? (Extended Hierarchy STM)
2. ZIPC Simulation
* What is the benefits of ZIPC Simulation?
* Software Prototyping with Design Specification?
3. ZIPC Code Generation
* What is the benefits of ZIPC Code Generation?
* How ZIPC doing Code Generation from STM?
4. ZIPC Emulation
* What’s a relationship of STM & Binary?
* State Transition-Oriented Debugging
5. Conclusion
2
1.Design 1.1) Remote Control Car
Specification Overview
*** Let’s think together about embedded software
design in our Remote Control Car
System hardware block diagram

R C LED LCD
IR Steering
e o
module Motor
m n
M32C83
o t
MCU
t r Motor Drive
OAKS32 Board
e o Driver Motor
l Car
UART
USB PC
CATS IF Board

3
1.Design 1.1) Remote Control Car
Specification Overview
*** Remote Control Command Specification

電源 Buttons Functions
電源 SystemON/OFF
1 setForward
1 2 3
3 setSpeedUp
4 5 6 5 setStop
7 setBackward
7 8 9
9 setSpeedDown
10 11 12 10 turnLeft
11 setCenter
+ +
12 turnRight


4
1.Design 1.1) Remote Control Car
Specification Overview
*** Use Case Diagram of System Requirement

What should be
the next design
diagram for the
detail design?
• Flow Chart ?
• STD ?
• STM ?

5
1.Design 1.2) Steering Motor Control
Specification Specification
a.) Basic Design
Steering Motor Degree Level
Turn 
Turn  Left Degree Turn Right Degree
Left4 Left1 Center Right1 Right4
Left3 Left2 Right2 Right3
(Max) (Min) (Min) (Max)

Steering Motor Control Functions

Buttons Functions
10 turnLeft Flow Chart? / STD? / STM?
11 setCenter What would be the best design
specification for this
12 turnRight steering motor control ?
6
1.Design 1.2) Steering Motor Control
Specification Specification
b.) Design Limitation of Flow Chart
Turn 
Turn  Left Degree Turn Right Degree
Left4 Left1 Center Right1 Right4
Left3 Left2 Right2 Right3
(Max) (Min) (Min) (Max)

Buttons Functions To cover all cases, flag No. >=


10 turnLeft event No. x state No. = 3 x 9 >= 27
11 setCenter
12 turnRight
Button?
*** There will be a lot of
flag and it will be hard 10 12
11
to understand for the
programmer. Motor State?

7
1.Design 1.2) Steering Motor Control
Specification Specification
c.) Design Limitation of STD
(State Transition Diagram)
Turn 
Turn  Left Degree Turn Right Degree
Left4 Left1 Center Right1 Right4
Left3 Left2 Right2 Right3
(Max) (Min) (Min) (Max)
*** It is good for overall design view. But, the
Buttons Functions
10 turnLeft design coverage is so difficult to notice. It is
difficult to comparing among a lot of
11 setCenter
connecting lines. trnR trnR trnR
12 turnRight
R1 R2 R3 R4
trnR
trnL trnL trnL
setC setC setC trnL,
trnL Center setC setC setC setC
trnR trnR trnL
trnR,
L4 L3 L2 L1 setC
trnLR trnR trnR 8
1.Design 1.2) Steering Motor Control
Specification Specification
d.) Design Advantage of STM

*** It is also good for overall design view. And, the


design coverage is more easier to notice than STD.
Designer can just comparing belong to the
columns or rows.
***And, we can also check the percent coverage of
ignore actions to determine the design responses
Steering Motor STM

9
1.Design 1.3) Drive Motor Control
Specification Specification
a.) Basic Design
Drive Motor Speed Level
Backward Speed Forward Speed
B4 B1 Stop F1 F4
B3 B2 F2 F3
(Max) (Min) (Min) (Max)

Motor
Drive Motor Control Functions
Driver
Buttons Functions
1 setForward Drive
STD? / STM?
3 setSpeedUp Motor
What would be the best design
5 setStop specification for this
7 setBackward drive motor control ?
9 setSpeedDow
10
1.Design 1.3) Drive Motor Control
Specification Specification
b.) Design Limitation of STD
(State Transition Diagram)
Backward Speed Forward Speed
B4 B1 Stop F1 F4
B3 B2 F2 F3
(Max) (Min) (Min) (Max)

Buttons Functions *** Can not see unusual cases or exceptions, it


1 setForward depends on an experience of the designer. So, the
3 setSpeedUp design is so easy for mistakes or omissions
5 setStop
7 setBackward ? setB spUp spUp spUp
9 setSpeedDow F1 F2 F3 F4
setF
spDn spDn spDn
setS setS setS setS
setB Stop
setS setS setS
spUp spUp spUp
setS
B4 B3 B2 B1
spDn spDn spDn 11
1.Design Advantage of STM
Specification for embedded software?
*** Using STM can do the exhaustive specification of
events and states, preventing mistakes and omissions.

12
1.Design 1.3) Drive Motor Control
Specification Specification
c.) Design Advantage of STM
*** Doing STM design can help us doing requirement analysis.
Software debugging could be done since design phase.

= process cells which are not covering in STD


13
1.Design 1.3) Drive Motor Control
Specification Specification
d.) Clarify the Design Specification by STM
• To ignore Speed Control Cmd when the car is stopping
• To ignore Fwd and Bwd Cmd when the car is already running in that state
• If user set Fwd while the car is in Bwd state, then the car will go Fwd at lowest speed
• If user set Bwd while the car is in Fwd state, then the car will go Bwd at lowest speed

14
1.Design 1.4) Tool for the Design
Specification Analysis

*** By Using of STM.


Developer can easily find
mistake point or
something that we forgot
in the design by checking
on each action cell.
Convert

Forgot ? Fix mistake point

15
1.Design 1.4) Tool for the Design
Specification Analysis
*** Using STM Design is to clarify
the Design Specification
Drive Motor Control STM

What should be the next


design diagram for the
detail design?
• Flow Chart ?
• STD ?
• STM ?
Steering Motor Control STM

16
1. Design 1.5) Tool for the Design
Specification Specification
*** Using STM Design is suite for the Design Specification
of Embedded Software

STD is suite for Simple and neat.


Flow Chart is
abstract explanation Anyway, if state
not suite for design in
but design omissions and event are too
a lot of flag such as
will depends on much. STM will not
embedded system.
design experience easy to understand
17
1.Design 1.6) What is EHSTM?
Specification (Extended Hierarchy STM)
*** The problem of STM is that the matrices can be very
large when we add a lot of amount of events and states

Number of process cells = 126

18
1.Design 1.6) What is EHSTM?
Specification (Extended Hierarchy STM)
*** Using the Hierarchy STM prevents an increase in the
area of STM cells
ZEH_0 MainControl ZEH_0.2 DriveMotorControl

ZEH_0.3 SteeringMotorControl

Number of process cells = 78


19
1.Design 1.6) What is EHSTM?
Specification (Extended Hierarchy STM)
*** Using the Extended Hierarchy STM controls the
interfacing between the designed STMs

ZEH_0.2 DriveMotorControl ZEH_0.3 SteeringMotorControl

Extension : Event Analysis Condition Branching


20
Software What is ZIPC?
(CASE Tool for embedded system)
Design Tool
*** ZIPC is the CASE Tool using EHSTM which supports
the middle phase of embedded software development.

Tool functions being used


in Development process
of our Remote Control Car
• EHSTM Editor
• ZIPC Simulator
• ZIPC Code Generator
• ZIPC Emulator

21
2. ZIPC 2.1) What is the benefits of
Simulation ZIPC Simulation?
*** Usual practices in Software Development
(Traditional)

(Design omissions)

Revised Design
(Design omissions)
更改設計)
更改設計)
(更改設計

(Design omissions)

So, we can not


see design omissions
from Design Phase
before Coding Phase

22
Image source: http://en.wikipedia.org/wiki/Image:V-model.JPG
1. ZIPC 2.1) What is the benefits of
Simulation ZIPC Simulation?
*** Actively verifies the design specification before coding
(Using ZIPC) • Verification can start from
the moment the design
(Design omissions) specification is created
EH imu

• Reduces code-level
&S
ST

debugging man-hours
Re

M lation

(Design omissions)
vis

• Reduces logical bugs at the


(更

De
ed

design stage
改設

sig
D esi

n
計)
gn

(Design omissions)

Software Prototyping by
Design Spec.(EHSTM)

23
Image source: http://en.wikipedia.org/wiki/Image:V-model.JPG
2. ZIPC 2.2) How to do
Simulation Software Prototyping?
*** Software Module Design of Remote Control Car
(Sub-functions of Main Control)

Main Control
System
Initialization

System
Steering Motor Drive Motor Display API
functions

IR Command
setting
Steering Motor Drive Motor
API functions API functions
IR API
functions

 The parts that is designed by EHSTM in ZIPC


24
2. ZIPC 2.2) How to do
Simulation Software Prototyping?
*** Using ZIPC, we can do debugging before Coding.
So, the developers can see any design
DriveMotor Control STM omissions since design phase.

IR_Cmd
Setting STM
Main Control STM

Design Specification (EHSTM)


Simulation
SteeringMotor
Control STM

25
3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** Human errors of Coding Phase
(Traditional)

UM
LD
es
ign
(Re
-Pr

Manual Code Generation


og

(Design Interpretation errors)


ram
m
i ng

26
)

Image source: http://en.wikipedia.org/wiki/Image:V-model.JPG


3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** Preventing Human errors of Coding Phase
(Using ZIPC) • The design documentation
UM & S and code always match
L imu
EH lat • Uniform format
• Reduces manual coding
ST ion

man-hours
M
De
sig
n

Design Spec.(EHSTM)

Automated
Code Generation

27
Image source: http://en.wikipedia.org/wiki/Image:V-model.JPG
3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** ZIPC doing Code Generation from
Design Specificaion (EHSTM)
(Hardware Independence)
(Human Language)
Hardware
Abstraction EHSTM
Design
by ZIPC +
Automated
Others
ZIPC Sheet
Code Generation

(Hardware Dependence)
ANSI C
(*.c, *.h) (C Language)
API Func,
Device Driver
(*.c, *.h)
+ Implementation
on target platform
28
3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** Design Porting wizard for any 8-bit or larger target
platform even various makers
(Hardware Independence)
(Human Language)
Hardware
Abstraction EHSTM
Design
by ZIPC +
Automated
Replacement
Others
Design
DesignSheet
Sheet
Code Generation
for A

(Hardware Dependence) Gen.Code


for A
(Platform A)

(C Language)
(*.c, *.h)
API Func,
for A
(*.c, *.h)
+ Implementation Hardware of
on target platform Platform A

29
3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** Design Porting wizard for any 8-bit or larger target
platform even various makers
(Hardware Independence)
We can use same
(Human Language)
Hardware STM design in any
Abstraction different platform
EHSTM
Design
by ZIPC +
Automated
Others
Replacement
DesignSheet
Sheet
Code Generation
Design
for B
(Hardware Dependence) Gen.Code
for B
(Platform B)

(C Language)
(*.c, *.h)
API Func,
for B
(*.c, *.h)
+ Implementation Hardware of
on target platform Platform B

30
3. ZIPC Code 3.1) What is the benefits of
Generation ZIPC Code Generation?
*** Software Module Design of Remote Control Car
(Sub-functions of Main Control)
Main Control
System
Initialization

System
Steering Motor Drive Motor Display API
functions

IR Command
setting
Steering Motor Drive Motor
API functions API functions
IR API
functions

The parts that is being STM in ZIPC.


So, they are being Hardware Independence and
can be reused with other platforms 31
3. ZIPC Code 3.2) How to do coding for
Generation Implementation with ZIPC?
*** Text Replacement Design Sheet is as a Linker for API
Functions and as a Translator of Human Lang. to C Lang.
(Hardware Independence) Main Control Drive Motor
(Human Language) STM STM
Hardware
Abstraction Others IR Command Steering Motor
Replacement
Design DesignSheet
Design Sheet setting STM
by ZIPC for M32C83
+ STM
Automated
Code Generation
(Hardware Dependence)
Renesas
Gen.Code
(M32C83)
Drive, Steering from ZIPC (C Language)
(M32C83)
Renesas

API Func, (*.c, *.h)


for M32C83 Implementation
(*.c, *.h)
+ on Remote Control Car
32
3. ZIPC Code 3.3) What is the Text
Generation Replacement Design Sheet?

Generated C code (C Lang.)


STM (Human Lang.)
if ((UINT8)PressBtnBuff == 1)
E S S1 S2 {
Button電源_is_pressed Human Lang.
to }
C Lang.

Text Replacement Design Sheet (Translator)

#CHG Button電源_is_pressed (UINT8)PressBtnBuff == 1


33
3. ZIPC Code 3.3) What is the Text
Replacement Design Sheet?
Generation
*** Translate Human Lang. to C conditions
STM (Human Lang.) Generated C code (C Lang.)
if (PressBtnBuff == DENGEN_BUTT)
{

}
else if (PressBtnBuff == STOP_BUTT)
{

Text Replacement Design Sheet (Translator)

34
3. ZIPC Code 3.3) What is the Text
Replacement Design Sheet?
Generation
*** Translate Human Lang. & Link to Hardware API functions
STM (Human Lang.) Generated C code (C Lang.)
/*****************************************
MainTask MainControl( level : 0 )
State : 1 Event : 0 Action function
*****************************************/
static void ZMainTask_m0e0s1( void )
{
{
AppDispMsg.DispName=LCD_SystemOff;
AppDispMsg.Option=0;
AppDispSpeed.DispName=SPEED_STOP;
AppDispSpeed.Option=0;
Display_Message(AppDispMsg.DispName,
Display_Speed(AppDispSpeed.DispName,
};

Text Replacement Design Sheet (Translator)

35
3. ZIPC Code 3.4) How ZIPC doing Code
Generation Generation from STM?

*** Concept: There are three main parts ***

1. Initialization Function

2. Call Function
(event analysis function)

3. Action Function

* Please find more details in ZIPC Bible : Chapter14 The Generator 36


3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** STM is also good for the programming design of Devices APIs
(Sub-functions of Main Control)
Main Control
System
Initialization

System
Steering Motor Drive Motor Display API
functions

IR Command
setting
Steering Motor Drive Motor
API functions API functions
IR API
functions

The parts that is also designed and coding using


STM in ZIPC.
37
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Example in Programming of IR API functions

Victor‘s IR Signal Data pattern

Signal
Sync Signal (1 , 0 )
Data 16 bit( Overflow Reset
Type
38
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** STD of IR API functions

Wait state : Waiting for IR signal


Sync state : Sync IR signal is already received and waiting for 1 or 0 data
Reading state : Reading 16 bit of data and then go to wait state 39
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** STM of IR API functions

Convert

By using ZIPC converter. Developer can convert STD to STM.


40
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** STM of IR API functions

? ?


Some Action that we can not considered when it was STD will be show up when
It’s converted into STM.
41
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** STM of IR API functions

After considered, We fill the right action into the empty cell
42
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Code Optimization by STM

Adjust
Can be Merge

And actions on Sync and Reading state are giving the same result.
So, We can merge Sync and Reading state in to just one state.
43
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Code Optimization by STM

Optimize

For Complete Read Event, This one always activate on the 16th bit of data.
So, We turn this event to the condition in the action fields of data reading.
44
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Code Optimization by STM

Priority High

Priority Low

After that. Just arranged events by it’s priority and push coding into STM.
45
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Code generation of IR API functions
Increase_Reset_Counter Clear_Overflow_Flag Keep_Timer_Value Clear_Reset_Counter

Replace Replace

By using ZIPC, Designer can insert the program activities and processes by human
language into a structural area of STMs then the program will be generated with
a structural coding. Moreover, the designed STM is also good to show the overall
view of a program to get an easy understanding for another designers. 46
3. ZIPC Code 3.5) Tool for the Program
Generation Coding
*** Manual Coding using Flow chart is not easy to understand and
implement because there are a lot of branch conditions.
Flow chart of Manual Coding STM in ZIPC

47
3. ZIPC Code 3.5) Tool for the Program
Generation Coding

Manual Coding is using more time to develop because of omission and


complex of code .A lot of bug will found later. By using ZIPC, Developer
can checking design with simulate and then coding is a piece of cake. 48
4. ZIPC 4.1) How ZIPC doing
Emulation Emulation on Target Device?

ZIPC
Emulator

CPU
Debugger
Target
CPU

*** By communicating (inter-process communication) with any


company’s debugging applications, which control the target
49
program, ZIPC is able to indirectly control the program.
4. ZIPC 4.2) Support Debuggers
Emulation
The debuggers that can be linked with ZIPC

Our project
using this one 50
4. ZIPC 4.3) What’s a relationship of
Emulation STM & Binary?
*** When compiling the ZIPC generated code to Binary.
1. Generating an 2. Generating a 3. Download to
emulation load module Target CPU
source code (Binary) (M32C83)

#ifndef __ZIPC_NOTEMU__
unsigned short zemu_eventno[4]; zemu_eventno[4]
unsigned short zemu_actionno[4]; zemu_actionno[4]
unsigned short zemu_stateno[4];
zemu_stateno[4]
#endif
(*.c, *.h) (*.x30)

Those variables will


ZIPC will add the be compiled to be a Those variables
variables for Binary code will be addressed
emulation purpose into a RAM of
CPU Compiler CPU
ZIPC Code Generator (HEW: NC308) 51
4. ZIPC 4.3) What’s a relationship of
Emulation STM & Binary?
*** When running the program on Target CPU.
1. Program execution 2. Debugger is 3. Emulation
Target CPU getting debug load module
(M32C83) data from CPU via STM

zemu_eventno[0]=0;
zemu_actionno[0]=0;
zemu_stateno[0]=1;

;zemu_eventno[0] = 0;
MOV.W:Z #0,043CH
;zemu_actionno[0] = 0;
MOV.W:Z #0,0444H Event No.0
;zemu_stateno[0] = 1; Action No.0
MOV.W:Z #0001H,044CH State No.1

CPU Debugger ZIPC Emulator


52
(HEW)
4. ZIPC 4.4) What is the benefits of
Emulation ZIPC Emulation?
*** Using the Design Spec. (EHSTM) to do State Transition-
Oriented Debugging which is better than code oriented
Test Spec. debugging
Test Case #XX
User Action: Button電源_is_pressed
Sys Action: System Start
- MainConrolState = SystemON
- DrvMotorState = Stop
- StrMotorState = Center
- LCD msg “XXX”
- LED all off

Make it Easy
to Identify
bugs

53
Image source: http://en.wikipedia.org/wiki/Image:V-model.JPG
5. Conclusion 5.1) Development Flow
of our Remote Con. Car

ZIPC
ZIPC Emulator
Generator
EHSTM EHSTM
(Emulation)
Editor
ZIPC EHSTM
Simulator (Design Spec.)

54
5. Conclusion 5.2) What is the benefits for
using ZIPC?
1. Benefits at Design Phase
• Using EHSTM can do the exhaustive design specification
rather than the Flow Chart or STD, preventing mistakes
and omissions
2. Benefits at Simulation Phase
• Verification can start from the moment at the design
specification is being created and before coding.
• Reduces design omissions at the design stage
3. Benefits at Generation Phase
• Uniform format of the code. The documentation and code
always be matching
• Design Porting wizard for any target CPUs & various makers
4. Benefits at Emulation Phase
• Using the Design Spec. (EHSTM) to do state transition-
oriented which is better than code oriented debugging 55
Please be enjoying with
our emulation demonstration …

以上、
以上、よろしくお願
よろしくお願いします

56

You might also like