This guide is delivered subject to the following conditions and restrictions:
This guide contains proprietary information belonging to Elmo Motion Control Ltd. Such
information is supplied solely for the purpose of assisting users of the HARmonica servo
amplifier.
The text and graphics included in this manual are for the purpose of illustration and reference
only. The specifications on which they are based are subject to change without notice.
Information in this document is subject to change without notice. Corporate and individual
names and data used in examples herein are fictitious unless otherwise noted.
Doc. no.
Elmo Motion Control Ltd.
The Elmo Motion Control warranty for this product covers only the elimination of problems due to manufacturing defects that result in
impaired function. Specifically excluded from this warranty is the elimination of problems caused by abuse, damage, neglect, overloading,
wrongful operation and unauthorized manipulations of the product. This product warranty is for a period of 12 months from the time of operational startup but no longer than 18 months from shipment from the manufacturing plant. Damage claims that exceed the warranty
obligation – including consequential damages – will be rejected in all cases. If any term or condition in this warranty is at variance or
inconsistent with any provision or condition (whether general or special) contained in or referred to in the Terms of Conditions of Sale
outlined at the back of Elmo’s Standard Acknowledgement form, then the latter shall prevail and be effective.
HARSFEN0602
Copyright
2002
All rights reserved.
Elmo Motion Control Ltd.
64 Gisin St., P.O. Box 463
Petach Tikva
49103
Israel
Tel: +972 3 929-2300
Fax: +972 3 929-2322
Elmo Motion Control Inc.
900(H) River St.
Kennedy Industrial Park
Windsor, CT 06095
USA
2 THE HARMONICA .........................................................................................................................................11
2.3 Related Software...................................................................................................................................................... 12
1
2.4 Units .......................................................................................................................................................................... 12
2.4.2Speed and acceleration units ................................................................................................................................. 13
2.4.3Current and torque................................................................................................................................................. 13
2.5 Internal Units and Conversions.............................................................................................................................. 13
2.5.1Current and torque:................................................................................................................................................13
2.5.4Power DC voltage ................................................................................................................................................. 14
2.8 Digital inputs ............................................................................................................................................................15
2.9 Digital output............................................................................................................................................................ 15
3 COMMUNICATION WITH THE HOST...........................................................................................................16
3.2.4Errors and exceptions in RS232............................................................................................................................ 17
3.3 CANopen Communication ...................................................................................................................................... 17
4 THE INTERPRETER LANGUAGE ................................................................................................................18
4.1 The command line.................................................................................................................................................... 19
4.2 Expressions And Operators .................................................................................................................................... 19
4.2.2Mathematical And Logical Operators....................................................................................................................19
4.2.3General rules for operators....................................................................................................................................20
5 THE HARMONICA USER PROGRAMMING LANGUAGE ...........................................................................28
5.1 User Program Organization....................................................................................................................................28
5.2.1Line and Expression Termination..........................................................................................................................29
5.3 Expressions And Operators.....................................................................................................................................30
5.3.2Mathematical and Logical Operators.....................................................................................................................30
5.3.3General rules for operators....................................................................................................................................30
5.5 Program Flow Commands.......................................................................................................................................34
5.6.3Count of output variables....................................................................................................................................... 42
5.6.7Functions and The Call Stack................................................................................................................................45
5.6.8Killing The Call Stack...........................................................................................................................................47
6 PROGRAM DEVELOPMENT AND EXECUTION..........................................................................................51
6.1 Editing a Program....................................................................................................................................................51
6.3 Downloading and Uploading a Program................................................................................................................59
6.3.2The Assisting Commands For Down/Upload........................................................................................................60
6.3.3Downloading a Program........................................................................................................................................61
6.3.4Uploading a Program.............................................................................................................................................62
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
6.4 The program execution............................................................................................................................................ 62
6.4.1Initiating a Program............................................................................................................................................... 63
6.4.2Halting and resuming a program........................................................................................................................... 63
6.4.3Automatic program running with power up.......................................................................................................... 64
6.4.4Save to Flash......................................................................................................................................................... 64
6.5.1Running, breaking, and resuming..........................................................................................................................64
6.5.5Setting and clearing break points .......................................................................................................................... 66
6.5.6Continuation of the program................................................................................................................................. 66
6.5.11View of global variables................................................................................................................................... 69
6.5.12View of local variables..................................................................................................................................... 69
7 THE VIRTUAL MACHINES............................................................................................................................71
7.1.1Introduction Alla please complete where necessary.............................................................................................. 71
7.3 Call Stack During Function Call ............................................................................................................................ 71
7.4 Data types ................................................................................................................................................................. 72
7.5 Op code structure and addressing modes .............................................................................................................. 73
7.6 Short reference......................................................................................................................................................... 73
7.7.5EOL – End Of Line............................................................................................................................................... 77
7.7.6FORITR – FOR Loop Iteration............................................................................................................................. 77
7.7.13JMP_LABEL – Jump to the label..................................................................................................................... 80
7.7.14JNZ – Jump Not Zero....................................................................................................................................... 81
7.7.15JNZ_EOL – Jump Not Zero ............................................................................................................................. 81
7.7.16JZ – Jump If Zero............................................................................................................................................. 82
7.7.17JZ_EOL – Jump If Zero....................................................................................................................................82
7.7.30RSLTOR – Logical OR Operator ( || )..............................................................................................................88
7.7.31SET_COMM – Set Command..........................................................................................................................88
7.7.34SHL – Shift Left ...............................................................................................................................................89
8 THE RECORDER ...........................................................................................................................................94
8.1 Recorder sequencing: Programming, launching, and uploading data. ...............................................................94
8.2 Signal mapping .........................................................................................................................................................95
8.3 Defining the set of recorded signals........................................................................................................................96
4
8.4 Programming the length and the resolution ...................................................................................... ....................96
8.5 Trigger events and timing........................................................................................................................................97
8.6 Launching the recorder .........................................................................................................................................100
8.7 Uploading recorded data .......................................................................................................................................100
9.1.1Brush DC motors.................................................................................................................................................103
9.3.1Rotor Magnetic field sensors...............................................................................................................................105
9.4.2Selecting the parameters......................................................................................................................................109
9.4.5Parameters related to starting the motor with no digital Hall sensors..................................................................111
9.5 Continuous Vs. Six-Steps commutation................................................................................................................111
9.6.1Loading the commutation table...........................................................................................................................114
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
10 THE CURRENT CONTROLLER..................................................................................................................115
10.1.3The PI current controller.................................................................................................................................120
10.2 Current amplifier protections............................................................................................................................... 121
11 UNIT MODES ...............................................................................................................................................123
11.1 Torque control: Unit mode 1................................................................................................................................. 123
11.2 Speed mode: Unit mode 2...................................................................................................................................... 124
11.3 The stepper mode: Unit mode 3............................................................................................................................ 128
11.4 The Dual feedback mode: UM=4.......................................................................................................................... 129
11.5 The single feedback mode: UM=5 ........................................................................................................................ 131
5
12 THE POSITION REFERENCE GENERATOR.............................................................................................132
12.1 The software reference generator......................................................................................................................... 132
12.1.1Switching Between Motion Modes ................................................................................................................ 132
12.1.2Comparison of the PT and the PVT interpolated modes................................................................................ 133
12.1.3The Idle Mode and Motion Status.................................................................................................................. 133
12.2 The External Position Reference Generator........................................................................................................ 159
12.2.2Dividing ECAM table into several logical portions ....................................................................................... 165
12.2.3On the fly ECAM programming using CAN.................................................................................................. 166
12.2.4Initializing the external reference parameters................................................................................................. 167
12.3 The Stop management........................................................................................................................................... 168
13.2 Digital Inputs.......................................................................................................................................................... 173
13.3 Digital Outputs....................................................................................................................................................... 173
13.4 Events, and response methods ................................................................................................... ........................... 174
13.4.4Real time – Motion management, Homing, Capture, and Flag...................................................................... 175
13.5 Homing and Capture............................................................................................................................................. 175
13.5.1What Is Homing?............................................................................................................................................ 175
13.5.3Homing the auxiliary encoder.........................................................................................................................176
13.5.4On the fly position counter updates ................................................................................................................177
13.5.5A homing with home switch and index example............................................................................................177
14 LIMITS, PROTECTIONS, FAULTS, AND DIAGNOSIS...............................................................................181
14.1 Current limiting......................................................................................................................................................182
14.3 Position Protection .................................................................................................................................................184
14.6 Connecting an external brake ...............................................................................................................................186
14.7 When the motor fails to start.................................................................................................................................187
14.9.3Device failures, and the CPU dump................................................................................................................190
14.10.1The motor cannot move..................................................................................................................................190
14.11 Commutation is lost................................................................................................................................................191
14.11.2Reasons and effect of incorrect commutation .................................................................................................191
14.11.3Detection of Commutation Feedback Fault....................................................................................................192
15 THE CONTROLLER.....................................................................................................................................193
15.1 General ....................................................................................................................................................................193
15.2 Speed Control .........................................................................................................................................................194
15.2.2The Parameters of the Speed Controller.........................................................................................................195
15.3 The Position Controller..........................................................................................................................................196
15.3.2The Parameters of the Position Controller......................................................................................................197
15.4 The High Order Filter............................................................................................................................................198
15.5 The Gain-Sche duling Algorithm...........................................................................................................................201
16 APPENDIX A: THE HARMONICA FLASH MEMORY ORGANIZATION....................................................204
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
16.1 Main partitions....................................................................................................................................................... 204
16.2 The firmware partition..........................................................................................................................................204
16.2.1Table of Contents (TOC)................................................................................................................................ 204
16.2.2Contents of Text1........................................................................................................................................... 205
16.2.3Contents of Text2........................................................................................................................................... 205
16.2.4Contents of Text3........................................................................................................................................... 205
16.2.5Contents of Text4-Text7................................................................................................................................. 206
16.2.6Contents of Text8........................................................................................................................................... 207
16.2.7Contents of Text9........................................................................................................................................... 207
16.2.8Contents of Text10......................................................................................................................................... 209
16.2.9Contents of Binary1........................................................................................................................................ 209
16.2.10Contents of Binary2........................................................................................................................................ 209
16.2.11Contents of Binary3........................................................................................................................................ 209
16.5 User Code partition................................................................................................................................................ 209
16.5.4The Text Backup & Compiler data segment .................................................................................................. 211
16.5.5The Function Symbol Table........................................................................................................................... 211
16.5.6The Variable Symbol Table............................................................................................................................ 212
18.1 The Converter ........................................................................................................................................................ 216
18.2 The Converter Call ................................................................................................................................................ 216
18.3 The Algorithm ........................................................................................................................................................ 216
18.4 The Conversion Process......................................................................................................................................... 216
Table 2-1: Analog sampled signals.........................................................................................................................15
Table 4-1 – Mathematical and Logical Operators...................................................................................................20
Table 5-1 – Automatic subroutines and their priority.............................................................................................49
Table 7-1 – Harmonica op codes...........................................................................................................................75
Table 8-1: Commands relevant to the recorder.......................................................................................................94
Table 8-2: Default mapping of recorded signals.....................................................................................................95
Table 8-3: Some additional recorded signals...........................................................................................................96
Table 8-6: SR recorder status reports....................................................................................................................100
Table 8-7:Parameters for uploading recorded data................................................................................................100
Table 8-8: BH – record structure...........................................................................................................................102
Table 9-1: Hall sensor values................................................................................................................................105
Table 12-4: Motion status indications...................................................................................................................134
Table 12-5 – Parameter of PTP Motion.................................................................................................................135
Table 12-11 – PT Related Parameters...................................................................................................................159
Table 12-12 – PT CAN Emergency Messages......................................................................................................159
Table 12-13 – ECAM Related Command.............................................................................................................162
Table 13-1: Commands relevant to modulo counting...........................................................................................172
Table 14-1: Commands relevant to limits, protection, and diagnosis...................................................................182
Table 14-2: Cases where feedback limits do not apply.........................................................................................184
Table 14-3 - CD Reported Elements.....................................................................................................................190
Table 15-1 – Unit Mode Values and Definitions...................................................................................................193
Table 15-2 – List of all control parameters...........................................................................................................194
Table 15-3: Programming sets of controller parameters for gain schedulilng ......................................................202
Table 15-4 – Automatic Gain Scheduling Process................................................................................................203
Table 15-5 – Gain scheduling automatic indexing parameter...............................................................................203
8
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
List of Figures:
Figure 1 - Slope and window trigger types.............................................................................................................98
Figure 2 – Pre trigger delay.....................................................................................................................................99
Figure 3: Two phased linear motor.......................................................................................................................104
Figure 4: Three phased line ar motor.....................................................................................................................104
Figure 5: Three phase rotary motor.......................................................................................................................104
Figure 6: Digital Hall sens o rs readout...................................................................................................................106
Figure 7: Loss of torque due to commutation miss...............................................................................................112
Figure 8: Winding shape funct ion for a Trapeze motor.......................................................................................113
Figure 9: Winding shape function for sinusoidal motor........................................................................................114
Figure 10: Current controller structure..................................................................................................................115
Figure 11: Peak/Continuous current limit selection..............................................................................................117
Figure 12: Time constant selection (Small signal) for the torque inpu t filter.......................................................119
Figure 13: Rate limiting for the torque input filter................................................................................................120
Figure 14: Current PI controller............................................................................................................................120
Figure 15: Unit mode 1 (Torque) structure...........................................................................................................123
Figure 16: Unit mode 2 (Speed) structure.............................................................................................................124
Figure 17 – Speed Profiling using JV, AC and DC ..............................................................................................125
Figure 18 – Speed command for different smooth Factor.....................................................................................126
Figure 19: Auxiliary spe ed com m and generati on.................................................................................................127
This specification presents relevant data for understanding and using the Harmonica
software.
The Software Specification complements the Command Reference Manual. The Command
Reference Manual lists each single command with all its options. The Software
Specification Manual is designed to give wider view of the Harmonica system. The topics
are covered functionally, with reference to many commands.
1.2 Relevant documentation
Document Comments
The Harmonica Command Reference
Manual
The Harmonica CAN Manual A Complementary document. The CAN
The Harmonica User Manual A Complementary document. This document
The Composer Manual This manual explains the Composer IDE and
A complementary document. The Command
Reference Manual lists the system variables
and interpreter commands of the Harmonica.
Manual explains the CAN communication
objects of the Harmonica, and their usage.
describes how to select the right Harmonica
model, how to install it, and how to perform
initial setup
how to best use it with the Harmonica.
10
1.2.1 Glossary
The following abbreviations and terms are used in this document:
ALU Arithmetic Logic Unit, the part of the CPU that makes math and address
ICD Interface control document. A definition for the external world relations of a
CSCI Computer Software Configuration Item. A stand alone program that as long as it
CSU Computer Software Unit. A functional block in the software.
DSP Digital Signal Processor.
EDS The list of CAN object supported by a device, in a standard form suitable for
ID Direct current. The current component that generate magnetic field in parallel to the
IDE Integrated development environment
IQ Quadrature current. The current component that generate magnetic field
PDO Process Data Object. A CAN message type. A PDO avoids the need to allocate data
PPR Pulse Per Revolution
calculations.
product. For software, the ICD defines external I/O relations.
conforms its ICD, may be freely maintained.
standard configuration software.
fixed magnet of the rotor
perpendicular to the fixed magnet of the rotor
payload for object addressing by a pre-agreement (called PDO mapping) about the
message contents.
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
2 The Harmonica
2.1 Introduction
The Harmonica a sophisticated and capable network-oriented single-axis amplifier, with:
- State of the art control algorithms, including high order filters and gain
scheduling
- State of the art reference generation algorithm, including absolute timed
interpolated motion, auxiliary signal following, and ECAM.
- Synchronization capability for network operation
- Conformance to CANopen standards
- User friendly programming
- Advanced analyzing tool for setup behavior
- Built in auto-tuning facilities
- Built in database maintenance tools.
- Built in firmware maintenance tools.
All these are implemented in the extremely small environment of the DSP.
11
2.2 Software Organization
The DSP software is divided into three parts.
The first part is the boot software. The boot software is permanently burnt into the code
flash internal to the DSP, and cannot be upgraded during product life. The boot software
includes some data that helps the firmware identify the exact amplifier model it is operating.
The data includes the maximal motor phase current, the nominal bus voltage, the hardware
of the communication sensors and I/O interface, and the grade of the amplifier (basic or with
extended capabilities).The second part is the operational software (firmware). The firmware may be updated at
the user site if some upgrading or modifications are required.
The third part is a supportive database that must be loaded to the serial flash. This
supportive part provides a file system for personality description, storage of application
database, and factory or user provided programs.
2.2.1 The Boot software
The Boot software has the following functions:
- Initialize some of the registers of the DSP
- Test code validity automatically. If code validation fails, pass automatically to
the "Download Firmware" mode.
- Degenerated RS232 communication handling and interpreter, only in the level
required for firmware downloading functions.
- Support firmware downloads into the on-chip flash memory.
- Pass control to start of firmware.
2.2.2 The Firmw are
The firmware implements all the other software functions, as described in this manual and in
the Command Reference manual.
The firmware will pass control to the boot software when a DF command initiates a
firmware version upgrade. At the end of the firmware downloading process, the Harmonica
reboots.
2.2.3 The Personality
Elmo HARmonica Software Manual
For rotary motors, CA[18] is the number of sensor counts per one full
HARSFEN0602
P R E L I M I N A R Y D R A F T
The personality data is loaded to the serial flash memory. The personality data includes a
file allocation table and several files. The personality files include data about the Harmonica.
A partial list is:
List of supported command
List of error code
CAN EDS
All these data items enable an IDE to deal with the Harmonica. The File Allocation table
reserves place for storage of application parameters and of user programs. The personality
data is burnt into the serial flash using the firmware software.
The firmware can boot without personality data, but it will not become fully functional
before the personality data is programmed in place.
Full explanations of the personality data are given in the chapter “Appendix A: The
Harmonica Flash Memory Organization”.
2.3 Related Software
The Harmonica requires supporting software for setup, tuning, programming, and
performance assessment. The support software is called “Composer”. It runs on a PC
computer, under Windows.
The Composer includes the following functions (among many others):
•
Terminal for direct user interface by RS232 or by CAN
•
A recorder with advanced scope controls. You can observe up to 8 signals
simultaneously, triggered by a selection of events.
•
Setup and tuning tools:
•
Menus for entering basic application data and limits
•
Tools for associating functions to I/O connector pins
•
Automatic tuning of current controller
•
Automatic tuning for commutation
•
Manual and automatic Speed controller tuning
•
Manual and automatic Position controller tuning
•
Application database maintenance
•
Save and load application database
•
Edit application parameters, with help
•
Advanced IDE for user program development:
•
Editor
•
Compiler
•
Downloading and uploading of user programs
•
Debugger, with:
•
Various break point and stepping options
•
Watches for local and global variables
•
Call stack watch
The Composer software reads the personality data from the Harmonica, and can therefore
adapt to the specific amplifier model you bought.
12
2.4 Units
This section describes how the Harmonica measures time, position, speed, voltage, and
current.
2.4.1 Position units
The Harmonica refers to position by sensor counts. The sensor counts may be related to
physical units using the following commands:
Command Description
CA[18]
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
mechanical revolution.
CA[23] For linear motors, CA[23] stores the number of counts per user unit (Meter, or
any other unit the user may select). CA[23] is stored only for convenience – the
Harmonica software does not use this number for any internal calculation.
For rotary motors, set CA[23]=0.
YA[1],YA[3] YA[1] is the auxiliary feedback resolution, counts/physical unit. YA[3] sets
what a physical unit is: Revolution, Meter, or other.
YA[1] and YA[3] are stored only for convenience – the Harmonica software
does not use these numbers for any internal calculation.
2.4.2 Speed and acceleration units
The speed units are counts/sec, and the acceleration units are counts/sec2. The speed units
may be related to physical units by converting the counts to revolutions, Meters, etc, as
explained in the section "Position units" above.
2.4.3 Current and torque
Currents are measured in Amperes. That is not so simple as it sounds, since there is no
single accepted method to specify the current of three-phased motors.
For sinusoidal motors, RMS phase current normally specifies the motor current. The RMS is
taken over a mechanical revo lution; so that the phase currents are the "Motor current" only if
the motor revolves with constant speed.
For trapeze-wound motors, the conventional six-steps drive leaves one motor phase open
circuited, and only one current flows through the two driven motor phases. This driven
phases current specifies the "Motor current". For trapeze-wound motor running six-step
commutation continuously at 1Amp, the RMS current is 0.92Amp.
The Harmonica has one motor current definition, although it can run equally well sinusoidal,
Trapezoidal, or free form motor windings.
We defined the motor current as the maximum winding current in a mechanical revolution.
This definition is consistent with the traditional current definition for six-step motors and it
readily extend to other winding forms.
The user of sinusoidal motors must multiply the motor current reported by the Harmonica by
the factor of 0.71 to obtain the RMS phase current.
13
2.5 Internal Units and Conversions
In order to optimize the use of its CPU, the Harmonica works inside with local units for
time, for current, for DC bus voltage, and for electrical angle.
•
The user normally thinks of time in terms of seconds. Most of the control algorithms view time
by counting controller sampling-times.
•
The user thinks of currents in terms of Amperes. The Harmonica thinks internally in the terms of
A/D bits.
•
The user may think of electrical angles in terms of degrees or radians. The Harmonica divides
the electrical cycle to 1024.
Normally the internal representation of time and currents is transparent to the user. For
example, the user demands motor current in Amperes, and accepts motor current reports in
Amperes as well. The Harmonica does the translation. The following situations, however,
require the user to consider the internal data representation.
•
Uploading data from the real time recorder - Refer "The Recorder" Chapter.
•
Interpreting CAN mapped synchronous PDO's
•
Specifying motions in the micro stepping mode.
Some user interface commands retrieve the conversion factors for user convenience.
2.5.1 Current and torque:
Elmo HARmonica Software Manual
Hz
5000
HARSFEN0602
P R E L I M I N A R Y D R A F T
The internal representation of phase currents is by A/D bits.
Torque commands, and the active and the reactive parts of the current have another
representation, since the coordinate transformations from phase current to torque introduce
scaling.
The relation between internal phase currents, internal torque, and Amperes is given by the
following commands:
Command Description
MC The full current range of the amplifier.
The amplifier represents MC Amperes by 14000 bits internally.
(The maximum A/D reading is 16384 and some spare is left for overshoots and
over-current detection)
WS[22] Torque command multiplier.
Internal torque command = WS[22]×DV[1].
WS[5] Phase current multiplier
Internal phase current = WS[5]×Phase Current[Amp]
2.5.2 Speed:
Speeds are represented internally by the units of counts/(216 speed controller sampling
times).
For example, if the sampling time of the speed controller is 200usec (5000Hz sampling
16
21000
frequency), then 1000 counts/sec will be represented internally as
⋅
13107
=
.
14
The relation between speeds and internal commands is given by the following commands
Command Description
TS Sampling time of the current controller. The sampling time of the sped
WS[53] Conversion from internal units to counts/sec
2.5.3 Electrical angle:
The electrical angle is measured by 1024 counts per electrical revolution.
Think of a motor with 3 pole pairs. To rotate this motor a full mechanical revolution in the
stepper mode (UM=3) you have to specify the m ov em ent of (3×1024)=3072 position counts.
2.5.4 Power DC voltage
Power DC voltage is represented internally in A/D units.
The relation between the internal representation and the bus voltage is given by:
Command Description
WS[54] Conversion from internal units to Volts.
Power DC voltage = WS[54]×Power DC voltage (Internal representation)
This section summarizes the set of Harmonica peripherals.
2.6.1 Position decoders
There are two position decoders, termed main and auxiliary. The main and the auxiliary
decoders are similar. Both decoders are timed (through the timer sets A and B) for accurate
speed information.
A position decoder measures quadrature or Pulse/Direction. The maximum counting rate of
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
a decoder is 20mHz, without input filter.
If input filter is applied, the maximum pulse rate is reduced, as explained at the EF[N]
command in the Command Reference Manual.
The encoder input is not protected. There is no hardware to identify illegal transitions.
Exceeding the maximal pulse rate will cause loss of counts that cannot be detected.
2.7 A/D converter
The A/D samples the following:
Signal Description
Ia,Ib,Ic The three phase currents, sampled simultaneously
Ain,ref The analog input and the reference voltage are sampled simultaneously to
form a differential measurement
Bus voltage The bus voltage is sampled to correct the current loop gain.
Table 2-1: Analog sampled signals
The resolution of all the measurements is 12bit, and in practice the last bit is noisy.
The motor currents are measured offset-free, because of a special measurement mechanism.
The analog inputs cannot avoid an offset, due to electronic inaccuracies in the Harmonica
circuits. This offset can be corrected using the AS[1] parameter, to the resolution of about
5mv.
The ability to correct offsets by AS[1] is limited to the resolution of 5mv, and about 10mv in
practice. This means that, for example, if AG[2]=10000, the offset correction quality to
speed analog reference will be limited to about 100count/sec.
15
2.8 Digital inputs
The Harmonica has six digital input connector pins. All the input pins are routed to a digital
input port. In addition two pins (5 and 6) are routed to high speed capturing input for main
and auxiliary homing. You can associate special functions to digital input pins, like Enable,
Stop, RLS, and FLS – refer the IL command in the Command Reference Manual.
The digital input response time is limited by the speed of the optical couplers, and also by
the input filters.
The encoder index and home input are filtered similarly to the position decoders. The timing
of the position decoder filters is explained in the EF[N] documentation in the command
reference.
The other digital inputs are filtered in software only. The timing of software filtering is
explained in the IF[N] documentation in the command reference.
The use of the digital inputs is detailed in the chapter on Sensors, I/O, and Events.
2.9 Digital output
The Harmonica has two digital output connector pins.
These two pins can be used for non-committed digital outputs, or programmed by the OL
command for special functions, like activating external brakes.
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
3 Communication With the Host
3.1 General
3.2 RS232 Communications
The Harmonica can communicate by RS232 with baud rates up to 115200baud/sec.
The maximum baud rate depends in the sampling time. The baud rate of 115200baud/sec
works only when TS equals or is less than 70. The communication rate of 57600 baud/sec
works with all sampling time options.
Please refer to PP[] command in the Command Reference Manual.
3.2.1 RS232 Basics
The RS232 method can only serve to communicate a host to a single amplifier. The RS232 lines are full
duplex – they can carry bidirectional communications. This means that the host can transmit to the amplifier
whenever it finds it right, without considering the state of the amplifier.
The RS232 communication consists of ASCII printable characters only, with some exceptions:
•
The characters 0xD (carriage return).
•
Some non-printable characters that are used as error codes. Please refer to EC command in the
Command Reference.
The basic syntax for RS232 commands may be an assignment,
<Command mnemonic>{[<index>]}{<Equal sign><Value>}<Terminator>
Or a free evaluation:
<Value><Terminator>
Where
Item Description
Command mnemonic Two letters (case insensitive) assigned to a command. Please see the
Command Reference manual for a complete list of command
mnemonics.
Index The index, if the mnemonic refers to a vector parameter or command.
Equal sign The ‘=’ character (Optional, if the command assigns a value to a
parameter)
Value Parameter value (Optional, if the command assigns a value to a
parameter)
The parameter value may be any legitimate arithmetic or functional
expression, as explained later in this section.
Terminator
<CR>
1
or ‘;’.
16
Table 3-1 – RS232 Rx Item Description
An assignment evaluates an expression and stores the result in a variable.
A free evaluation evaluates an expression and sends the result to the terminal.
Typical examples are:
MO<CR>
Asks the amplifier to report the value of the variable MO.
MO=1<CR>
1
<CR> is a carriage return, which is the character 0xd (13 decimal).
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
Sets the value of 1 to the MO variable.
CA[2]=1;
Sets the value of the CA[2] variable. CA[N] denotes a vector of parameters that can be accessed by their
index.
The free evaluation
(5+sin(PX))*sqrt(abs(VX))
Returns a numerical value to the terminal.
More detail about text interpreting is given in the chapter "The Interpreter Language".
The amplifier responds to the host communicated commands. It never initiates an unasked-for message to
the host.
The syntax of the amplifier answers is
{<Value>}{<Error code>}<Terminator>
Where
Item Description
Value Parameter value (Optional, if the command asks to report parameter)
Error code A binary number that may be interpreted according to the error code tables –
please refer the EC Command in the Command Reference Manual.
Terminator ‘;’ if the host command has been successfully executed, else ‘;?’
17
Table 3-2 – RS232 Tx Item Description
3.2.2 The Echo
When using RS232 each character that is received by the amplifier is echoed back to the host. The echo is
immediate, per each received character.
3.2.3 Background Transmission
When the host enters the BH=n command to the amplifier, the amplifier uploads the recorder data to the
host. The uploading process may take few seconds. At the time the amplifier uploads records to its host, it is
still listening to the host for new commands.
Consider the command sequence
BH=1;MO=0<CR>
The amplifier will start to transmit the recorder data immediately. Few milliseconds later, while the recorder
data is still transmitting, the amplifier will execute the MO=0 command. The amplifier will store the
response message to the MO=0 command, in order to transmit it later, immediately after the records upload
terminates.
Note:
If the host does not know the communication parameters, it may transmit a series of terminators and try
several baud rates, until it can receive a matching sequence of echoes.
3.2.4 Errors and exceptions in RS232
If an error is intercepted (Overrun, noise, parity, framing), then the entire message including this
error is discarded, and answered by the “communication error” code response.
Although the communication is defined as 8 bits per character, only the byte values 0-127 are used.
The characters 127-255 are treated as UART errors.
Empty strings with terminators are echoed back, but otherwise ignored.
3.3 CANopen Communication
A detailed description of CANopen communications is out of the scope of this manual.
Please refer the CANopen Manual.
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
4 The Interpret er Language
The amplifier has a language that enables the user to communicate with the Amplifier. Using this language,
the user can
•
Setup the Amplifier
•
Command the Amplifier what to do
•
Inquire the Amplifier status
There are two methods for communicating with the Amplifier.
The first of them is to use the communication interfaces, either the RS232 or the CANopen
interface, to pass commands to the Amplifier, and accept the Amplifier immediate response.
This method requires on line communication and close cooperation between the Amplifier
and its host.
The other method is to write a program in the Amplifier language and to store it in the
Amplifier. The Amplifier can run the program with minimal or no host assistance.
The physics and the standards of the RS232, and CANopen communication methods imply
differences in the command syntax used by each method.
This section describes the Amplifier language in the basic “RS232” or CAN “OS” syntax.
The CANopen communication method can access simple numeric interpreter get and set
commands very efficiently. The CAN binary interpreter uses PDO objects to issue
interpreter commands and to collect the response.
This is the most economical way minimizes both the communication load and the Amplifier
CPU load.
The CAN OS (command prompt) method can be used to access the entire set of interpreter
services, including those inaccessible by the binary CAN interpreter, using a text format.
The CANopen communication method is a broad topic and is beyond the scope of this
manual. Please refer the CANopen Communication Manual.
Programs use the interpreter syntax, with extension that are necessary to support program
flow instructions and in line documentation.
The full set of the Amplifier commands is documented in the Amplifier Command
Reference Manual.
18
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
4.1 The command line
The Interpreter evaluates input strings, called “expressions”. An expression is a sequence of
characters, terminated by a semicolon ‘;’, a line feed, or a carriage return.
A command line may include the “Comment marker” – two consecutive asterisks. All the text from
the comment marker to the next line feed or carriage return is ignored.
The maximal expression length is 512 symbols.
The comment marker feature enables the preparation of documented batch files, to be later sent
directly to the amplifier.
Example:
a = 3 ; b = 2 ; c = a + b ** Ignore this text
This line consists of three expressions separated with semicolon. The comment “Ignore this text” is
ignored.
4.2 Expressions And Operators
19
The Amplifier language supports operators, which specify a mathematical, logical or
conditional operation/relation between two operands or more. Operands (actually
parameters) and operators may be combined in almost any way to create an expression. The
following paragraphs present the operators and the expression syntax rules.
4.2.1 Numbers
The Amplifier has two number types: 32 bit integers and 32 bit floating point numbers. As
text inputs, numbers that contain a decimal point or an exponent notation are interpreted as
floats. Other numbers are interpreted as integers.
The range for integers is [-2.1475e+009,+ 2.1475e+009].
Positive integers may be written as decimal or as hexadecimal.
The hexadecimal notation 0x10 is equivalent to the decimal number 16.
A 32-bit floating-point number has 24 significant mantissa bits and 8 bits of exponent.
The range for floating point numbers is [-1e20, 1e20].
A floating-point number may be written with or without an exponent.
2.5e4 is equivalent to 25000.0. It is not equivalent to 25000, since the latter number is
interpreted as integer.
If an integer number overflows integer range, it is interpreted as an error.
If a floating-point number overflows floating-point range, it is interpreted as an error.
Logical operators yield 0 or 1 as a result. The results of logical operators are integers.
4.2.2 Mathematical And Logical Operators
The following table lists the mathematical and logical operators of the language. The table
also specifies the operator precedence, which is discussed in the next paragraphs. The larger
number has the higher precedence.
Operator Description Precedence
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
+ Add two operands. 9
- Subtract the right operand from the left one. 9
* Multiply two operands. 10
/ Divide the left operand by the right one. 10
% Remainder after division two integers 10
^ XOR 1
~ Bitwise NOT of an operand. 11
& Bitwise AND between two operands. 5
| Bitwise OR between two operands. 4
<< Bitwise Shift left 8
>> Bitwise Shift right 8
== Logical equality 6
!= Logic not equal 6
< Logic smaller than 7
<= Logic smaller or equal 7
> Logic greater than 7
>= Logic greater or equal 7
&& Logical AND 3
|| Logical OR 2
! Logical negation 11
- Unary minus 11
= Assignment
() Parentheses, for expression nesting and function calls
[] Square parenthesis, for array indices and multiple value function
returns
20
Table 4-1 – Mathematical and Logical Operators
4.2.3 General rules for operators
4.2.3.1 Promotion to float and truncation to integer
Most the arithmetic operators work on both integers and floats. An arithmetic operation between integers
will yield integers, an operation between floating point numbers, or between an integer and a floating-point
number, will yield a floating-point result. For example, all the expressions below are legitimate:
1+2 (The result is 3, integer)
1+0x10 (The result is 17, integer) Note that 0x10 is treated as a standard integer.
1+2.0 (The result is 3.0, float)
2.1+3.4 (The result is 5.5, float)
The operation of division between two integers may yield a floating-point result in a case of division with
remainder. For example:
8/2 (The result is 4, integer)
9/2 (The result is 4.5, float)
If a result of multiplication between two integers overflows integer range
[-2.1475e+009,+2.1475e+009], this result will be converted into floating point, but won’t be truncated. For
example:
100000 * 100000 (The result is 10000000000, float)
Bit operators require an integer input. Floating-point inputs to bit operators are truncated to integers.
7.9 & 3.4 is equivalent to 7 & 3, since before applying the operator & (Bitwise AND) the floating point
number 7.9 is truncated to the integer 7, and 3.4 is truncated to the integer 3..
4.2.4 Operator details
The following paragraphs describe the operators in detail.
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
4.2.4.1 Addition
Notation +
Description Arithmetic addition
Number of
2
arguments
Output type According to the section Promotion to float and truncation to integer
Example 4+5=9
3.45+2.78=6.23
4.2.4.2 Subtraction
Notation Description Arithmetic subtraction
Number of
arguments
Output type According to the section Promotion to float and truncation to integer
Example 4-5=-1
2
3.45-2.78=0.67
21
4.2.4.3 Multiplication
Notation *
Description Arithmetic multiplication
Number of
2
arguments
Output type According to the section Promotion to float and truncation to integer
Example PA=PA*2 doubles PA
5*4=20
1.5*2=3.0
4.2.4.4 Division
Notation /
Description Arithmetic division
Number of
2
arguments
Output type According to the section Promotion to float and truncation to integer
Example 20/4=5
3/1.5=2.0
4.2.4.5 Remainder
Notation %
Description Remainder after division two integers
Number of
arguments
Output type According to the section Promotion to float and truncation to integer
Example 20%4=0
2
5%2=1
4.2.4.6 XOR
Notation ^
Description Exclusive or, bitwise.
Number of
arguments
2
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
Output type 32 bit long integer.
Example if x=1 as x^3=2
4.2.4.7 Bitwise NOT
Notation ~
Description Bitwise NOT
Number of
1
arguments
Output type 32 bit long integer.
Example ~3 is 0xfffffffc, which is actually –4
~3.2 is the same as !3
4.2.4.8 Bitwise OR
Notation |
Description Bitwise OR
Number of
arguments
Output type 32 bit long integer.
Example PA = 0x2 | 0x5 is equivalent to PA = 7
2
PA = 0x2 | 5.1 is the same
22
4.2.4.9 Bitwise AND
Notation &
Description Bitwise AND
Number of
2
arguments
Output type 32 bit long integer.
Example PA = 0x7 & 0x3 is equivalent to PA = 3
PA = 0x7 & 3.1 is the same
4.2.4.10 Logical Equality
Notation ==
Description Logical equality
Number of
2
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x==y yields 1
if x=3 and y=5 as x==y yields 0
4.2.4.11 Logical Inequality
Notation !=
Description Logical inequality
Number of
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x!=y yields 0
2
if x=3 and y=5 as x!=y yields 1
4.2.4.12 Logical Greater than
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
Notation >
Description Logical greater than
Number of
2
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x>y yields 0
if x=3 and y=2 as x>y yields 1
if x=1 and y=2 as x>y yields 0
4.2.4.13 Logical Greater than or equal
Notation >=
Description Logical greater than or equal
Number of
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x>=y yields 1
2
if x=3 and y=2 as x>=y yields 1
if x=1 and y=2 as x>=y yields 0
23
4.2.4.14 Logical Less than
Notation <
Description Logical less than
Number of
2
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x<y yields 0
if x=3 and y=2 as x<y yields 0
if x=1 and y=2 as x<y yields 1
4.2.4.15 Logical Greater than or equal
Notation <=
Description Logical greater than or equal
Number of
2
arguments
Output type 0 or 1 (0 equals to false, 1 equals to true)
Example if x=3 and y=3 as x<=y yields 1
if x=3 and y=2 as x<=y yields 0
if x=1 and y=2 as x<=y yields 1
4.2.4.16 Logical AND
Notation &&
Description Logical AND. The result is 1 if both arguments are nonzero, 0 if any is zero.
The arguments are not truncated to integers before evaluations
Number of
arguments
Output type 0 or 1
Example 1 && 5 yields 1
2
0.21 && 2 yields 1
0 && 2 yields 0
4.2.4.17 Logical OR
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
Notation ||
Description Logical OR. The result is 1 if any of the arguments is nonzero, 0 if both are zero.
The arguments are not truncated to integers before evaluations
Number of
2
arguments
Output type 0 or 1
Example 1 || 0 yield 1
0 || 0 is 0.
4.2.4.18 Logical NOT
Notation !
Description Logical NOT. The result is 1 if the argument is zero, and 0 else
The arguments are not truncated to integers before evaluations
Number of
arguments
Output type 0 or 1
Example !4 yields 0
1
!0 yields 1
!0.0004 yields 1
24
4.2.4.19 Unary Minus
Notation Description Unary MINUS. The result is negative if the argument is positive, and vise
versa.
The arguments are not truncated to integers before evaluations
Number of
1
arguments
Output type The same as argument
Example -4.5 yields –4.5
-4 yields –4
(-4) yields 4
-5+5 yields 0
4.2.4.20 Bitwise Left Shift and Right Shift operators
Notation << or >>
Description The bitwise shift operators shift their first operand left (<<) or right (>>) by the
number of positions the second operand specifies.
The arguments are truncated to integers before evaluations.
Number of
arguments
Output type 32 bit long integer.
Example 8>>2 yields 2
2
8<<2 yields 32
4.2.5 Mathematical functions
The following table presents the mathematical built-in functions of the language.
Function names are case sensitive.
Operator Description Returns
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
sin Sine Floating point
cos Cosine Floating point
abs Absolute value Same type as input argument
25
sqrt Square root, or zero if argument is
negative
fix Truncate to integer.
fix(3.8) is 3
fix(-3.8) is -3
rnd Truncate to nearest integer.
rnd(3.8) is 4
rnd(-3.8) is –4
tdif Time difference
x=TM
tdif(x ) returns the time in msec since
x=TM has been sampled.
4.2.6 Expressions
An expression is a combination of operands (parameters) and operators that is evaluated in a
single value. Expressions work with immediate numbers, Amplifier commands, Amplifier
and global user-program variables.
There are different types of expressions, as described below.
4.2.6.1 Simple Expressions
A simple expression is evaluated in a single value. Any parameter and mathematical/logical
operator may be used to create a simple expression. Normally, simple expressions may be
used as a part of other types of expressions.
Simple expressions are evaluated according to the priority of the operators, as specified in
4-1 – Mathematical and Logical Operators. In case of equal priority, the expression is
Table
evaluated from left to right.
The use of parentheses is allowed to 16 nesting levels.
Assignment expressions are used to assign a value to variable or command. The syntax of an assignment
expression is:
<Parameter or command name>=<simple expression>
Example:
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
sp=sp*2/5+ac
op=ip|5
If the variable or the command is a vector, the assignment is allowable only for its single member. The
syntax of the vector member assignment is:
<Parameter or command name>[index]=<simple expression>
The index is an index of the relevant member vector. Indices are enumerated from zero.
Example:
ca[1] = 1
4.2.6.3 User variables
User variables are defined within a user program. The description and syntax rules of the variable definition
see at User variables of User Programming Language
User program variables may be used within the command line only if a program was compiled successfully
and downloaded to the Amplifier.
Through the Interpreter a user may inquire user variable value or change it.
A user has to pay special attention to the scope of a variable. A variable may be defined at the global or local
scope. The local variables are available only within the function where they are defined, while the global
variables are available within any function and outside a function.
A user variable may be inquired or changed when the program is in the running or halt status.
For example, suppose that a compiled program includes the following lines at the global scope:
int ZEBRA,GIRAFA[3];
float GNU;
Then the expression
GNU=ZEBRA*GIRAFA[1]+2*sin(GIRAFA[2]);
is valid. User program variables are case sensitive.
26
4.2.6.4 Built-in Function Calls
The built-in function call may be used in a single expression. For a list of built-in-functions refer
Mathematical Functions
The built-in function call may be a part of a single expression.
Example:
sin(3.14/2)
AC=abs(DC)
SP=SP+sin(3.14/2)
4.2.6.5 Time functions
Use the TM command to read the system 32 bit microsecond counter.
The time difference from the present time to an older sampling of TM can be taken in two methods:
Example
QP[1] = TM ; ** QP[1] is used just as storage
…. ** Do something
QP[2] = QP[1]-TM ; ** QP[2] is time difference in microseconds.
Example
QP[1] = TM ; ** QP[1] is used just as storage
…. ** Do something
QP[2] = tdif( QP[1]) ; ** QP[2] is time difference in milliseconds.
Time differences cannot be taken longer then 31 minutes.
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
4.2.6.6 User Function Calls
The XQ command enables a user function call. See Running of a User Program
A user function cannot be called from the command line without the XQ command.
4.3 Comments
Comments are texts that are written into the code to enhance its readability.
A double asterisk marks comments. The comment starts in a double asterisk comment marker, and
terminates at the next end of line.
The Amplifier ignores the comments when evaluating an expression.
Example:
mo=1; **motor on
This example demonstrates that a comment may start anywhere in the program line. The MO=1 instruction
preceding the comment marker shall be executed.
Remark: Comments in the command line differ from comments in a user program. User Program Language
has three methods to write comments, while the Interpreter Language has the only one.
27
Elmo HARmonica Software Manual
HARSFEN0602
P R E L I M I N A R Y D R A F T
5 The Harmonica User Programming Language
This chapter describes the Harmonica user language in detail.
This chapter is somewhat out of place, since the user program language is not really a feature of the
Harmonica.
The Harmonica can only understand virtual assembly commands – see commands at the chapter The Virtual
Machines: Short reference.
The Compiler translates user language into virtual assembly commands. It reads user program and
transforms it to the sequence of simple virtual assembly commands. The compilation process runs off-line in
the PC, not inside the Harmonica. Before the Harmonica executes a user program, it must be preliminarily
compiled and the compiled code must be downloaded to the serial flash of the Harmonica. A little more
about the Compiler see at the section Compilation
An Amplifier program is a list of commands in certain order. A user program can be anything from a simple
list of commands to a very complicated machine management algorithm.
The section below describes how to write, maintain, and run user programs for the Amplifier.
5.1 User Program Organization
A user program is organized as follows:
•
Integer and floating point variable declarations
•
Program text, including expressions, commands, labels, and comments
•
An exit directive may be used to terminate the program.
Most of the interpreter commands can be used in the program text. In order to learn if a
given interpreter command can be used in a program, please refer the scope attribute of that
command in the Command Reference Manual.
The Interpreter commands that cannot be used in a program are:
•
Commands that upload or download data between the Amplifier and its host.
•
Commands that store data in the flash memory, or that retrieve data from the flash memory.
•
Commands concerning the execution of the user program.
In addition to the interpreter commands, a program may include program flow statements
that manage how the program runs.
•
Iterations.
•
Subroutine execution commands.
•
Conditions.
In the program text, semicolons, commas, line feeds or carriage returns separate the
commands.
A single program line is executed as a one unit, preventing intervention from the interpreter
or a CAN command.
For example in the sequence
UM=5;
MO=1;
It is possible that an interpreter command shall be executed between the execution of the
two program statements. If the interpreter statement was UM=2, then MO=1 is specified for
a wrong unit mode. The sequence
MO=0;UM=5;MO=1;BG
Guarantees that MO=1 is executed with the correct unit mode.
Example 1:
int x,k; Variable declarations
##Foo Label definition
28
Loading...
+ 190 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.