Main
HARmonica Software Manual
June 2002
Important Notice
Table of Contents:
Page
Page
Page
Page
Page
Page
Page
Page
1 About This Manual
1.1 Scope
1.2 Relevant documentation
1.2.1 Glossary
2 The Harmonica
2.1 Introduction
2.2.3 The Personality
2.2 Software Organization
2.2.1 The Boot software
2.3 Related Software
2.4 Units
2.4.1 Position units
2.4.2 Speed and acceleration units
2.4.3 Current and torque
2.5.1 Current and torque:
2.5 Internal Units and Conversions
Page
2.7 A/D converter
2.8 Digital inputs
2.9 Digital output
3 Communication With the Host
3.1 General 3.2 RS232 Communications
3.2.1 RS232 Basics
3.2.2 The Echo
3.2.3 Background Transmission
3.2.4 Errors and exceptions in RS232
3.3 CANopen Communication
4 The Interpreter Language
4.1 The command line
4.2 Expressions And Operators
4.2.1 Numbers
4.2.2 Mathematical And Logical Operators
4.2.3 General rules for operators 4.2.3.1 Promotion to float and truncation to integer
4.2.4 Operator details
4.2.4.1 Addition
4.2.4.2 Subtraction
4.2.4.3 Multiplication
4.2.4.4 Division
4.2.4.5 Remainder
4.2.4.7 Bitwise NOT
4.2.4.8 Bitwise OR
4.2.4.12 Logical Greater than
4.2.4.9 Bitwise AND
4.2.4.10 Logical Equality
4.2.4.13 Logical Greater than or equal
4.2.4.14 Logical Less than
4.2.4.17 Logical OR
4.2.4.15 Logical Greater than or equal
4.2.4.16 Logical AND
4.2.4.18 Logical NOT
4.2.4.19 Unary Minus
4.2.4.20 Bitwise Left Shift and Right Shift operators
4.2.5 Mathematical functions
4.2.6 Expressions
4.2.6.1 Simple Expressions
4.2.6.2 Assignment Expressions
4.2.6.3 User variables
4.2.6.4 Built-in Function Calls
4.2.6.5 Time functions
4.2.6.6 User Function Calls
4.3 Comments
5 The Harmonica User Programming Language
5.1 User Program Organization
5.2 Common
5.2.1 Line and Expression Termination
5.2.2 Line Continuation
5.2.3 Limitations
5.3 Expressions And Operators 5.3.1 Numbers
5.3.2 Mathematical and Logical Operators
5.3.3 General rules for operators
5.3.4 Operator details
5.3.5 Mathematical functions
5.3.6 Expressions 5.3.6.1 Simple Expressions
5.3.6.2 Assignment Expressions
5.3.6.3 User variables
5.3.6.4 System Commands
5.3.6.5 Built-in Function Calls
5.3.6.6 User Function Calls
5.4 Comments
5.5 Program Flow Commands
5.5.1 Labels (Entry points)
5.5.2 For iteration
5.5.3 While iteration
5.5.4 Until iteration
5.5.5 Wait iteration
5.5.6 IF condition
5.5.7 Switch selection
5.5.8 Break
5.6 Functions 5.6.1 Function definition
Page
5.6.2 Dummy variables
5.6.3 Count of output variables
5.6.4 Automatic variables
5.6.5 Global variables
5.6.6 Jumps
5.6.7 Functions and The Call Stack
Page
5.6.8 Killing The Call Stack
5.6.9 Automatic subroutines
5.6.9.1 List Of Automatic Routines
Page
5.6.9.2 Automatic Routines Arbitration
5.6.9.3 The Automatic Subroutine Mask
Page
6 Program Development and Execution
6.1 Editing a Program
6.2 Compilation
6.2.1 Compilation Error List
Page
Page
Page
Page
Page
Page
Page
6.3 Downloading and Uploading a Program
6.3.1 Binary data
6.3.2 The Assisting Commands For Down/Upload 6.3.2.1 The LP[N] command
6.3.2.2 The CP command
6.3.2.3 The CC command
6.3.3.2 Program downloading process
6.3.3 Downloading a Program 6.3.3.1 The DL command
6.3.4 Uploading a Program 6.3.4.1 The LS command
6.4 The program execution
6.4.1 Initiating a Program
6.4.2 Halting and resuming a program
6.4.3 Automatic program running with power up
6.4.4 Save to Flash
6.4.4.1 Clear user program from Flash
6.5 Debugging
6.5.1 Running, breaking, and resuming
6.5.3 Machine status
6.5.4 Program status
6.5.5 Setting and clearing break points
6.5.6 Continuation of the program
6.5.7 Single step
6.5.7.1 Run to Cursor
6.5.7.2 Step Over
6.5.7.3 Step In
6.5.7.4 Step Out
6.5.8 Getting stack entries
6.5.9 Setting stack
6.5.10 Getting call stack
6.5.11 View of global variables
6.5.12 View of local variables
Page
7 The Virtual Machines
7.1.1 Introduction Alla please complete where necessary
7.2 Virtual Machine registers
7.3 Call Stack During Function Call
7.4 Data types
7.5 Op code structure and addressing modes
7.6 Short reference
Page
7.7 Alphabetic reference
7.7.1 ADD - ADDITION
7.7.2 AND Bitwise AND Operator
7.7.3 CMP Compare
7.7.4 DIV Divide
7.7.5 EOL End Of Line
7.7.6 FORITR FOR Loop Iteration
7.7.7 FREE_VAC - Free Virtual Machine
7.7.8 F_OR Bitwise OR Operator
7.7.9 GETINDEX
7.7.10 GET_COMM Get Command
7.7.11 JMP Jump
7.7.12 JMP_EOL Jump
7.7.13 JMP_LABEL Jump to the label
7.7.14 JNZ Jump Not Zero
7.7.15 JNZ_EOL Jump Not Zero
7.7.16 JZ Jump If Zero
7.7.17 JZ_EOL Jump If Zero
7.7.18 LINK
7.7.19 MLT Multiply
7.7.20 MOV Assignment Operator (=)
7.7.21 NOT Bitwise NOT Operator
7.7.22 REM Reminder
7.7.23 RSLTA Relational Operator (>)
7.7.24 RSLTAE Relational Operator (>=)
7.7.25 RSLTAND Logical AND Operator (&&)
7.7.26 RSLTB Relational Operator (<)
7.7.27 RSLTBE Relational Operator (<=)
7.7.28 RSLTE Relational Operator (==)
7.7.29 RSLTNE Relational Operator (!=)
7.7.30 RSLTOR Logical OR Operator ( || )
7.7.31 SET_COMM Set Command
7.7.32 SETINDEX
7.7.33 SHR Shift Right
7.7.34 SHL Shift Left
7.7.35 SPADD
7.7.36 SUB - SUBTRACT
7.7.37 SYSSUBJ Jump To System Subroutine
7.7.38 UNARY_NOT - Logical NOT Operator (!)
7.7.39 USRSUBJ jump To User Subroutine
7.7.40 USRSUBRT Return from user subroutine
7.7.41 XOR Bitwise XOR Operator
8 The Recorder
8.1 Recorder sequencing: Programming, launching, and uploading data.
8.2 Signal mapping
8.3 Defining the set of recorded signals
8.4 Programming the length and the resolution
Page
- Triggered by a digital signal: The Harmonica will support this only in the future, TBD.
Page
8.6 Launching the recorder
8.7 Uploading recorded data
Page
Page
9 Commutation
9.1 General
9.1.2 The Stepper Commutation Policy
)cos(IKT e=
K
9.1.3 The BLDC commutation policy
9.2 Mechanical and electrical motion Figures are missing
9.3 Commutation sensors
9.3.1 Rotor Magnetic field sensors
9.3.2 Shaft Angle Sensors
revolutionshaftpercounts
pairspoleofnumber 360 mod(p1, pairspoleofnumber
revolutionshaftpercounts )
9.3.3.2 Detecting commutation errors (loss of feedback)
9.3.4 Parameterization of the commutation and the commutation sensors 9.3.4.1 Winding order
9.3.4.2 Hall sensors parameterization
9.3.4.3 Encoder parameterization
9.4 Commutation search 9.4.1 General
)sin(IKT T= (1)
K
)tf2sin(IKT rT = (3)
))f(tf2sin(IK)f(A)t(P rT = , where
9.4.3 Method limitation
9.4.4 Protections
9.4.5 Parameters related to starting the motor with no digital Hall sensors
9.5 Continuous Vs. Six-Steps commutation
)sin(IKT rFT = (1)
()
90 = , Ideally .0=
)cos(IKT T= we see that for a miss of 5, we lose about 0.4% of the torque. With a
9.5.1 Six-step commutation
9.5.2 Continuous commutation
9.6 Winding shapes
))240(hI)120(hI)(hI(KT bba ++=
)240(hII),120(hII),(hII 0c0b0a === for some value 0
I
9.6.1 Loading the commutation table
10 The current controller
)240(hI)120(hI)(hIIQ cba ++++=
)330(hI)210(hI)90(hIID cba +++++=
)90(gV)(gVVA DQ ++= )210(gV)120(gVVB DQ +++= )330(gV)240(gVVC DQ +++=
V ]1[PL >, where
V
R
]1[
]1[ 1log PL
CL
32768
]6[XP log
TS
10
10.2.2 The PI current controller
32768
10 25
8
TS
]4[XP log
Page
11 Unit Modes
11.1 Torque control: Unit mode 1
11.2 Speed mode: Unit mode 2
11.2.1 The software speed command
Page
Page
11.2.3 Stop management
11.3 The stepper mode: Unit mode 3
11.4 The Dual feedback mode: UM=4
--
11.5 The single feedback mode: UM=5
--
12 The position reference generator
12.1 The software reference generator
12.1.1 Switching Between Motion Modes
12.1.2 Comparison of the PT and the PVT interpolated modes
12.1.3 The Idle Mode and Motion Status
12.1.4 Point-To-Point (PTP ) 12.1.4.1 Basic Point-To-Point
12.1.4.2 Example
12.1.4.3 More Complicated PTP Motions
Page
12.1.5 Jogging
12.1.5.1 Example Simple jogging
12.1.5.2 Example On the fly mode switching
12.1.6 PVT: Position-Velocity-Time interpolated motion 12.1.6.1 What is PVT?
t
d ) t t ( c ) t t ( b ) t t ( a ) t ( P
c ) t t ( b 2 ) t t ( a 3 ) t ( V
Page
Page
12.1.6.2 The PVT Table
12.1.6.3 Motion Management
Figure 26 PVT Decisions Flow Chart
12.1.6.4 Mode Termination
12.1.6.5 PVT Motion Using CAN
12.1.6.5.1 The PVT Motion Programming Message
Figure 27 PVT Auto Increment Mode Flow Chart
12.1.6.5.2 Programming Sequence for The Auto Increment PVT Mode
12.1.6.6 The Parameters of The PVT Motion Mode
Page
Page
12.1.7 PT Motion 12.1.7.1 What Is PT
T m T
2
T
m
12.1.7.3 PT Motion Programming The Basic Mode 12.1.7.3.1 The PT Table
12.1.7.4 Motion Management
Page
12.1.7.5 Mode Termination
12.1.7.6 PT Motion Using CAN
12.1.7.7 The PT Motion Programming Message
12.1.7.8 Programming Sequence for The Auto Increment PT Mode
Figure 29 PT Auto Increment Mode Flow Chart
12.1.7.9 The Parameters of The PT Motion Mode
12.2 The External Position Reference Generator
Page
)t(c)t2cos(10000)t(x +=
12.2.1 ECAM
Page
Page
12.2.2 Dividing ECAM table into several logical portions
12.2.3 On the fly ECAM programming using CAN
12.2.4 Initializing the external reference parameters.
12.2.4.1 Jump-Free Motor Starting Policy
12.2.4.2 Switching the parameters of the external reference on the fly
12.3 The Stop management 12.3.1 General description
12.3.2 Stop Manager Internals
Page
Figure 33: Position output of the stop manager
Figure 34: Speed output of the Stop Manager
13 Sensors, I/O, and Events
13.1 Modulo counting 13.1.1 Modulo Counting
13.2 Digital Inputs
13.3 Digital Outputs
13.4 Events, and response methods
13.4.1 Manual inquiry
13.4.2 Periodical Inquiry
13.4.3 Automatic routines
13.4.4 Real time Motion management, Homing, Capture, and Flag
13.5 Homing and Capture 13.5.1 What Is Homing?
()()
count44
1
00
0
13.5.4 On the fly position counter updates
13.5.5 A homing with home switch and index example
Page
13.5.5.1 Example: Double homing corrects backlash offsets
13.5.6 Capturing
14 Limits, Protections, Faults, and Diagnosis
Page
14.2 Speed Protection
Page
!
14.5 Limit switches
14.6 Connecting an external brake
14.7 When the motor fails to start
14.8 Motion faults
Page
14.9 Diagnosis 14.9.1 Monitoring motion faults
14.9.1.1 Polling the amplifier status
14.9.1.2 Observing AOK
14.9.2 Inconsistent setup data
14.9.3 Device failures, and the CPU dump
14.10 Sensor faults 14.10.1 The motor cannot move
14.11 Commutation is lost 14.11.1 General
)sin(IKe
3 T
14.11.2 Reasons and effect of incorrect commutation
14.11.3 Detection of Commutation Feedback Fault
15 The Controller
15.1 General
sx
xdt
T
15.2.2 The Parameters of the Speed Controller
The basic continuous time PI controller is
=
]2[
t p t e K d e K K t I
15.3 The Position Controller 15.3.1 Block Diagram
15.3.2 The Parameters of the Position Controller
)()()( tkPosFeedbactPosCommandtePOS = [counts]
))(()))((2)),((min( tesignteabsteabsKPO SPOSPOS
)()( teKtCommandPI POS
K
as a
b
+
-z
)-z(1 G)-(1 G
k
k )( 21 bb + Float, represented by
)k(-z
)k(bs
k
b Float, represented by
a
)k(as )k(a
) k ( b
15.4.2 User Interface
15.4.2.1 An Example
15.5 The Gain-Scheduling Algorithm
15.6 Automatic Controller Gain-Scheduling
XmYmY )1()()1(
+ = +
<
=)(,
Page
16 Appendix A: The Harmonica Flash Memory Organization
16.1 Main partitions
16.2 The firmware partition
16.2.1 Table of Contents (TOC)
Name Size Byte location in the firmware partition Comment
Page
16.2.5 Contents of Text4-Text7
16.2.6 Contents of Text8
16.2.7 Contents of Text9
Page
16.2.8 Contents of Text10
16.2.9 Contents of Binary1
16.2.10 Contents of Binary2
16.2.11 Contents of Binary3
16.3 Parameters Partition
16.5.1 The TOC
16.5.2 The Compilation Done Flag
16.5.3 The Virtual Machine Code Segment
16.5.4 The Text Backup & Compiler data segment
16.5.5 The Function Symbol Table
16.5.6 The Variable Symbol Table
16.5.7 The Automatic Routines Table
17 Appendix B: Harmonica Internals
17.1 Software Structure
17.1.1 The Initialization block
17.1.2 The periodic Interrupt
17.1.3 The Idle Loop
Figure 42: Idle loop
18 Appendix C: Converting Clarinet/Saxophone programs to the Harmonica language
18.1 The Converter
18.2 The Converter Call
18.3 The Algorithm
18.4 The Conversion Process
18.5 Examples