nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g...

167
XCD2458000-00, Revision B August 14, 2016 Nanomotion Ltd. POB 623, Yokneam 20692, Israel Tel: 972-73-2498000 Fax: 972-73-2498099 Web Site: www.nanomotion.com E-mail: [email protected] User Manual XCD2 Firmware

Transcript of nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g...

Page 1: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B August 14, 2016

Nanomotion Ltd. POB 623, Yokneam 20692, IsraelTel: 972-73-2498000 Fax: 972-73-2498099

Web Site: www.nanomotion.comE-mail: [email protected]

User Manual

XCD2 Firmware

Page 2: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser
Page 3: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B iii

Copyright © 2015 by Nanomotion Ltd.

All rights reserved worldwide. No part of this publication may be reproduced, modified, transmitted, transcribed, stored in retrieval system, or translated into any human or computer language, in any form or by any means, electronic, mechanical, magnetic, chemical, manual, or otherwise, without the express written permission of Nanomotion Ltd., Mordot HaCarmel Industrial Park, Yokneam, 20692, Israel.

This document contains proprietary information and shall be respected as a proprietary document with permission for review and usage given only to the rightful owner of the equipment to which this document is associated.

Limited Warranty

Nanomotion Ltd. (hereinafter NM) warrants the product (other than software) manufactured by it to be free from defects in material and workmanship for a period of time of one year (except those parts normally considered as consumable/expendable components such as motor conditioning brushes). The warranty commences thirty (30) days from the date of shipment.

NM warrants those parts replaced under warranty for a period equal to the remaining warranty coverage of the original part.

NM's sole and exclusive obligation under this warranty provision shall be to repair, or at its sole option exchange defective products or the relevant part or component, but only if: (i) the Purchaser reports the defect to NM in writing and provides a description of the defective product and complete information about the manner of its discovery within ten (10) days of its discovery; (ii) NM has the opportunity to investigate the reported defect and to determine that the defect arises from faulty material, parts or workmanship; and (iii) the Purchaser returns the affected product to a location designated by NM. These provisions constitute the exclusive remedy of the Purchaser for product defects or any other claim of liability in connection with the purchase or use of NM products.

This warranty policy applies only to NM products purchased directly from NM or from an authorized NM distributor or representative.

This warranty shall not apply to (i) products repaired or altered by anyone other than those authorized by NM; (ii) products subjected to negligence, accidents or damage by circumstances beyond NM control; (iii) product subjected to improper operation or maintenance (i.e. operation not in accordance with NM Installation Manuals and/or instructions) or for use other than the original purpose for which the product was designed to be used.

NM shall not in any event have obligations or liabilities to the Purchaser or any other party for loss of profits, loss of use or incidental, increased cost of operation or delays in operation, special or consequential damages, whether based on contract, tort (including negligence), strict liability, or any other theory or form of action, even if NM has been advised of the possibility thereof, arising out of or in connection with the manufacture, sale, delivery, use, repair or

Page 4: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B iv

performance of the NM products. Without limiting the generality of the preceding sentence, NM shall not be liable to the Purchaser for personal injury or property damages.

Patents

Nanomotion products are covered under one or more of the following registered or applied for patents.

5,453,653; 5,616,980; 5,714,833; 111597; 5,640,063; 6,247,338; 6,244,076; 6,747,391; 6,661,153; 69838991.3; 6,384,515; 7,119,477; 7,075,211; 69932359.5;1186063; 7,211,929; 69941195.5; 1577961; 4813708; 6,879,085; 6,979,936; 7,439,652; 7061158;1800356; 1800356; 1800356; 2007-533057 (pending); 2011-093431 (pending); 7,876,509; 10-2007-7009928 (pending); 200780019448.6; 7713361.9 (pending); 12/294,926 (pending); GB2008000004178 (pending); GB2009000003796 (pending); 12/398,216 (pending); GB2446428; 12/517,261 (pending); 08702695.1 (pending); 10-2009-7017629 (pending); 12/524,164 (pending); 12/581,194 (pending)

Contact Information

Website: www.nanomotion.com

Customer Service

Contact your local distributor or email Nanomotion Ltd. Technical Support Department at [email protected], with detailed problem description, additions, corrections or suggestions.

Nanomotion Ltd. Worldwide HeadquartersMordot HaCarmel Industrial ParkHaYetsira Street, PO Box 623Yokneam 20692Tel: +972-73-249-8000Fax: +972-73-249-8099Email: [email protected]

Nanomotion Inc - US Headquarters1 Comac Loop, Suite 14B2RonkonkomaNY 11779Tel: +1-800-8216266 Fax: +1-631-5851947Email: [email protected]

Page 5: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B v

Revision History

The following table shows the last three revisions to this document.

ECODoc Rev

Date Description

-- A 09/2015 Initial release

-- B 08/2016 Added new features and revised text to correct errors and improve read-ability,

Page 6: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B vi

Table of Contents

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

1.1 Conventions used in this manual. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

2 Overview of the XCD2 Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

2.1 XCD2 Hardware configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Supported HW platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3 Overview of Servo Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

3.1 XCD2 Controller Flow. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.1.1 Position Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

3.1.1.1 Third Order Motion Profile (JERK) . . . . . . . . . . . . . . . . . . . . . . . . 183.1.2 Encoder Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.1.3 Gyroscope Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.1.4 OpMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.1.5 Control Algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.1.5.1 Kp (Position Loop Gain) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.1.5.2 BIQUAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203.1.5.3 Kv (Velocity Loop Gain) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.1.5.4 Ki (Integral Gain) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.1.5.5 LI (Integrator Limit). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.1.5.6 Offset Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

3.1.6 Zero Feed Forward (ZFF) Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.1.7 Open Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.1.8 Driver Limit (DOL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.1.9 Dead Zone Mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.1.10 PWM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

4 Host Communication Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.1 Communication Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.2 Communication Address. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264.3 Communication Protocol. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4.3.1 Packet Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274.3.2 Block Structure Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.3.3 Receiving data Block Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

4.4 Communication Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.4.1 SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

4.4.1.1 SPI Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 304.4.1.2 SPI Packet structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

4.4.2 IIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.4.2.1 IIC Configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324.4.2.2 IIC Packet structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

4.4.3 UART (RS232) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.4.3.1 UART HW Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.4.3.2 UART Packet structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Page 7: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B vii

Table of Contents

5 Commands and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.1 Numbers and Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.1.1 Floating Point Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.1.2 Literal Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.1.3 Units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

5.2 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355.2.1 Communication (Group 0). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

5.2.1.1 Set Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.2.1.2 Set Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.2.1.3 Get Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375.2.1.4 Ping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.2.1.5 Get channel index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395.2.1.6 Bridge Buffer write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395.2.1.7 Bridge Buffer read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

5.2.2 System (Group 1). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.2.2.1 Home . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.2.2.2 Motor Frequency Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.2.2.3 Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435.2.2.4 Save parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.2.2.5 Get version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.2.2.6 Execute XMS program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455.2.2.7 Stop XMS program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455.2.2.8 Resume XMS program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465.2.2.9 Get axis number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465.2.2.10 BiQuad configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 465.2.2.11 Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

5.2.3 Bootloader (Group 2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525.2.3.2 Boot into XCD2 Main Firmware . . . . . . . . . . . . . . . . . . . . . . . . . . 525.2.3.3 Boot packet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

5.2.4 Servo (Group 5) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545.2.4.1 Move . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 545.2.4.2 Velocity loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555.2.4.3 Open loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 565.2.4.4 Set position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575.2.4.5 Enable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575.2.4.6 Disable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585.2.4.7 Kill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595.2.4.8 Configure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

5.2.5 Variables API (Group 6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605.2.5.1 Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 605.2.5.2 Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615.2.5.3 Assign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625.2.5.4 Report with Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 625.2.5.5 Assign with Axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635.2.5.6 Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635.2.5.7 Pause. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645.2.5.8 Get Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 655.2.5.9 Log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

Page 8: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B viii

Table of Contents

5.2.6 Data packet examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 675.2.6.1 Multi-Block Move Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685.2.6.2 Multi-block of Assign and Report command . . . . . . . . . . . . . . . . . 695.2.6.3 Get version command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

5.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715.3.1 Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

5.3.1.1 Axis selection (XAXIS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715.3.1.2 Elapsed time (TIME) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.1.3 Motor frequency (MFREQ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.1.4 Servo tick length in msec (SPRD) . . . . . . . . . . . . . . . . . . . . . . . . 725.3.1.5 User Variables (V0 - V19) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

5.3.2 Motion Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.2.1 Velocity (VEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.2.2 Acceleration (ACC). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.2.3 Deceleration (DEC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725.3.2.4 Kill deceleration (KDEC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.3.2.5 3rd order motion profile (JERK) . . . . . . . . . . . . . . . . . . . . . . . . . 735.3.2.6 Target position (TPOS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

5.3.3 Motion Profiler Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.3.3.1 Reference position (RPOS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735.3.3.2 Reference velocity (RVEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

5.3.4 Motion Signals for Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.4.1 Feedback position (FPOS). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.4.2 Feedback velocity (FVEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.4.3 Position error (PE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.4.4 Position latched (POSI) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

5.3.5 Servo Loop and Drive Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.5.1 Position Loop Gain (KP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.5.2 Velocity loop gain (KV). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745.3.5.3 Velocity loop integrator gain (KI) . . . . . . . . . . . . . . . . . . . . . . . . 755.3.5.4 Velocity loop integrator limit (LI). . . . . . . . . . . . . . . . . . . . . . . . . 755.3.5.5 Position loop integrator gain (PKI). . . . . . . . . . . . . . . . . . . . . . . . 755.3.5.6 Position loop integrator limit (PLI). . . . . . . . . . . . . . . . . . . . . . . . 755.3.5.7 BiQuad filters parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755.3.5.8 Encoder resolution (ENR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.5.9 Dead zone min (DZMIN) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.5.10 Dead zone max (DZMAX) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.5.11 Zero feed forward (ZFF). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.5.12 Friction Compensation Variables . . . . . . . . . . . . . . . . . . . . . . . . . 765.3.5.13 Realtime drive output (DOUT) . . . . . . . . . . . . . . . . . . . . . . . . . . 775.3.5.14 Position Offset (POSOFFS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.3.5.15 Blackout Period (BLOUT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.3.5.16 Drive output offset (DOFFS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

5.3.6 Safety . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.3.6.1 Drive output limit (DOL). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 775.3.6.2 Software Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785.3.6.3 Position error limit (PEL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785.3.6.4 Motion Time limit (MTL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785.3.6.5 Motor temperature (MTTMP) . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Page 9: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B ix

Table of Contents

5.3.7 Analog Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795.3.7.1 Analog inputs 0 - 3 (AIN0 - AIN3) . . . . . . . . . . . . . . . . . . . . . . . . 795.3.7.2 Analog inputs 4 - 11 (AIN4 - AIN11) . . . . . . . . . . . . . . . . . . . . . . 79

5.3.8 Analog Outputs (DAC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795.3.8.1 Analog output 0 (AOUT0). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 795.3.8.2 Analog output 0 Scaled (AOUTSC0). . . . . . . . . . . . . . . . . . . . . . . 805.3.8.3 Analog output 1 (AOUT1). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.3.8.4 Analog output 1 - scaled (AOUTSC1) . . . . . . . . . . . . . . . . . . . . . . 80

5.3.9 Digital Inputs/Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.3.9.1 Digital inputs / outputs 0 - 15 (IO_0 - IO_15) . . . . . . . . . . . . . . . 80

5.3.10 Flags (accept values 0 or 1 only) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 805.3.10.1 Motion is in progress (S_MOVE) . . . . . . . . . . . . . . . . . . . . . . . . . 805.3.10.2 Servo loop is busy (S_BUSY) . . . . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.3 Index position latched (S_IND) . . . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.4 Homing Successful (S_HOME). . . . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.5 In-position flag (S_INPOS) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.6 Scope User Value (SSTAT) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.7 Motion Phase Variable (MTNPHS) . . . . . . . . . . . . . . . . . . . . . . . . 815.3.10.8 Servo tick synchronization variable (SERTICK) . . . . . . . . . . . . . . . 82

5.4 Pseudovariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 825.5 Error Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

6 XMS - Motion Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

6.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876.2 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

6.2.1 Floating Point Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 886.2.2 Literal Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

6.3 Units . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896.4 Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 906.5 Built-in Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916.6 XMS Script Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

6.6.1 Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926.6.2 XMS Script for a Linear Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

6.6.2.1 XMS Script for a Rotary Application . . . . . . . . . . . . . . . . . . . . . . . 956.6.3 XMS for Multi-axes Application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

7 Special Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

7.1 Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1087.2 Power Save. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1097.3 Motor Frequency Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

7.3.1 Frequency Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1107.3.1.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

7.3.2 Temperature Compensation Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . 1137.3.2.1 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1137.3.2.2 Temperature measurement configuration . . . . . . . . . . . . . . . . . 1137.3.2.3 Conversion from ADC values to degrees Celsius . . . . . . . . . . . . . 113

7.4 Communication Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

Page 10: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

7.4.1 Bridge Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1147.4.1.1 Bridge Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

7.4.2 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1157.4.3 Communication Channel Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

7.4.3.1 UART Configuration and Status variable . . . . . . . . . . . . . . . . . . . 1167.4.3.2 IIC Configuration and Status variable . . . . . . . . . . . . . . . . . . . . . 1177.4.3.3 SPI Configuration and Status variable . . . . . . . . . . . . . . . . . . . . . 117

7.4.4 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1197.5 Gyro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

7.5.1 Module overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1197.5.2 Drift Compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

7.5.2.1 BIAS cancelation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1207.5.2.2 Temperature Drift Compensation . . . . . . . . . . . . . . . . . . . . . . . . 120

7.5.3 Mechanical installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1217.5.4 Gyro Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237.5.5 Operation modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1237.5.6 XMS Variables for Gyroscope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1267.5.7 Configurable Gyro pseudovariables . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1287.5.8 Gyro Module Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

7.5.8.1 XMS Gyro Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1297.6 Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

7.6.1 Position Latch and Encoder Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1317.6.2 Homing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

7.6.2.1 Hard stop method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1337.6.2.2 Index method. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

7.6.3 TIME Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1347.6.3.1 Safe Time Measuring. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

8 XCD2 Commander. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136

8.1 Overview of XCD2 Commander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1368.2 Work Flow with XCD2 Commander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1378.3 Overview of the XCD2 Commander Panels . . . . . . . . . . . . . . . . . . . . . . . . . 137

8.3.1 Launching XCD2 Commander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1388.3.2 XCD2 Configuration and tuning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

8.3.2.1 Configuration of the servo controller. . . . . . . . . . . . . . . . . . . . . . 1408.4 Tuning of the XCD2 System Servo Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

8.4.1 Setup & Basic parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1418.4.2 Additional parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1438.4.3 Tune Servo Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1448.4.4 Scope. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1458.4.5 Watch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

8.5 Working with XMS Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1488.5.1 Editing a Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1488.5.2 Executing an XMS Script. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

8.6 Managing Flash Data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1508.7 Error Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

9 Firmware Upgrade. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .153

9.1 File structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1539.2 Upgrade through XCD2 Commander . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Page 11: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

9.3 Upgrade through Host computer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

Page 12: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 9

1 INTRODUCTION

This manual is relevant for FW version 1.10 and above.

provides information for developing and using Nanomotion's XCD2™ Software to control Nanomotion motors with the XCD2 Controller. The manual is divided into the following sections,

• Overview of the XCD2 Firmware, page 11• Overview of Servo Loops, page 15• Host Communication Protocol, page 26• Commands and Variables, page 34• XMS - Motion Scripts, page 87• Special Features, page 108• XCD2 Commander, page 136• Firmware Upgrade, page 153

1.1 CONVENTIONS USED IN THIS MANUAL Throughout this manual commands are shown in BOLD and parameter values are shown in italics

NOTE: Notes provide additional information that is not included in the normal text flow.

CAUTION: Caution provides information about actions that will adversely affect system performance.

Best Known Methods (BKM): Provides additional detailed information about operations and methods.

BKM

Page 13: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Conventions used in this manual

XCD2458000-00, Revision B 10

Danger: Indicates operations or activities that may cause damage to equipment or injury to personnel.

Page 14: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 11

2 OVERVIEW OF THE XCD2 FIRMWARE

2.1 XCD2 HARDWARE CONFIGURATIONNanomotion's Controller/Drivers with XCD2 firmware supply dynamic servo control to ensure accurate position changes. Figure 2-1 is a high level block diagram of the XCD2 firmware architecture.

XCD2 firmware is consist of 3 main components that allow customer design flexibility.

Figure 2-1: XCD2 Firmware architecture top view

• Firmware – SW package that contains general controller-driver functions

Page 15: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Supported HW platforms

XCD2458000-00, Revision B 12

• HW Configuration file – HW to XCD2 FW connection as motor type, encoder type, the number of active axis, communication channels definition, IOs, analog ports and etc.

• XCD2 motion applications can be executed in one of two channels:• XMS motion script allows to customer to develop their own

motion application. After writing and verifying the XMS, it can be downloaded into the XCD2 and automatically executed at power up. For additional information refer to XMS - Motion Scripts, page 87.

• HOST Communication – XCD2 FW supports up to 4 communication channels with set commands. For additional information refer to Host Communication Protocol, page 26.

The XCD2 FW has the flexibility to adapt to different hardware configurations without changing basic firmware. XCD2 firmware architecture includes a dedicated HW configuration file to ensure the match between firmware and hardware. The following functionality can be configured:

• Communication channels – UART, SPI or IIC channel working simultaneous.

• HW Safety signals – positive/negative limits, and emergency stops can be defined.

• User IO – user general purpose input/output signals. The signals can be defined as run-time direction changeable or as inputs only.

• Analog inputs – option to connect analog signals, voltage/current measurement or any analog sensor, to hardware running XCD2 FW. All sampled signals are translated into percentage scale [0 to 100].

• Analog Output (DAC) - XCD2 features two DAC channels that can represent any internal variables.

• Servo rate – XCD2 can run servo loops at up to 20 kHz. The servo rate is limited by feedback sensor communication speed and refresh rate. The SPRD variable provides relevant information about the defined servo rate.

2.2 SUPPORTED HW PLATFORMSThe XCD2 FW is available in one of three forms:

• programmed in the XCD2151003-XX Controller/Driver

The HW configuration is pre-compiled in the factory and cannot be modified by the user. Refer to your hardware product user manual to verify installed hardware config-uration.

Page 16: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Supported HW platforms

XCD2458000-00, Revision B 13

• programmed in a controller/driver for a Nanomotion solution• free standing with a reference schematic for customer built hardware

When supplied as part of a Nanomotion solution, or XCD2 Controller/Driver product the FW configuration is factory set and cannot be modified.

When using a reference schematic NM will provide configuration support.

Communication channels• RS232/RS485/UART - Asynchronous Serial Communication• IIC serial communication• SPI - Serial peripheral interface

Digital IOUp to 8 GPIOs

Analog IO• ADC - Analog-to-Digital converter. Up to 12 channels• DAC - Digital-to-Analog converter. Up to 2 channels

AxesUp to 2 independent axes with closed loop control.

Motor types• Edge• Edge4X

Feedback typesQuadrature encoder - Incremental encoder with two output channels (A, B) to sense position and one additional channel for index (home).

Absolute encoder with BiSS interfaces. The FW supports 18-32 bit BiSS configurations.

The maximum data rate is 21 Mhz.

Page 17: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Supported HW platforms

XCD2458000-00, Revision B 14

GyroGyro with configurable orientation, temperature drift compensation.

Page 18: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 15

3 OVERVIEW OF SERVO LOOPS

XCD2 appears as two independent XCD controllers running in one package, sharing the same communication channels and the same XMS program. Control over axis selection is through the communication channel, or using the variable XAXIS in an XMS script.

Nanomotion Controller/Drivers programmed with XCD2 firmware supply dynamic servo control to ensure accurate position changes. The motion platform consists of the following major building blocks.

• Linear or rotary stage mounted on a platform• Nanomotion motors: EDGE or EDGE4X• Encoder, Gyro• XCD2 Controller/Driver• Remote computer to host the XCD2 Commander

Figure 3-1: XCD2 motion application block diagram

The Controller provides a PWM signal to an AC converter. The output AC is applied to the motor driving the stage. As the stage moves, the encoder provides position information to the Controller. The Controller compares the current position against a calculated expected position and corrects the PWM drive signal to correct motor speed. This process occurs at the servo rate (nominally 20KHZ).

3.1 XCD2 CONTROLLER FLOWThe XCD2 Controllers are based on a standard PIV (position integral velocity) controller with a non-linear mechanism. The Controller uses several

Page 19: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 16

mechanisms to control movement of stages using Nanomotion piezoelectric motors.

• Offset mechanism• Zero Feed-Forward mechanism• Dead Zone mechanism

Figure 3-2: XCD2 Controller Block Diagram

3.1.1 POSITION PROFILER

When the Controller receives a MOVE command it calculates a position profile that defines the expected stage positions at intervals that are derivatives of the servo rate. The profile defines three phases:

• Acceleration - configured by ACC and VEL variables• Constant velocity - configured thought VEL variable• Deceleration phase - configured by DEC and VEL variables• Third Order Motion Profile (JERK), page 18

Figure 3-3, page 17 shows a typical position profile.

To determine the current state of the motion profiler refer to Motion Phase Variable (MTNPHS), page 81.

Page 20: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 17

Figure 3-3: Position and Velocity Profile changes over time

The ACC parameter is a value (<UserUnit>/sec2) used for acceleration. During acceleration (ACC) the Controller supplies a signal that increases motor speed. After the motor reaches the configured velocity (VEL) the Controller maintains velocity by changing the drive command. As the stage approaches the target position the Controller begins to reduce the drive command.

<UserUnit> defines the physical units that motion platform uses. For example in a linear stage the value of <UserUnit> is millimeter and for a rotary stage it is degree.

Due to the inaccuracy of floating point calculations, use a comparison operation with epsilon value. For example VEL is 50 and RVEL, when entering constant velocity phase, is 4.999999×101, then• RVEL <> VEL – this expression never has a false (zero) value. • (VEL – abs(RVEL)) > 0.00001 – this value will be true (one) during

acceleration phase and false (zero) at constant velocity phase.

Page 21: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 18

3.1.1.1 THIRD ORDER MOTION PROFILE (JERK)In order to reduce the working point of the motor during rapid acceleration transitions, or when shifting from acceleration to constant velocity, the FW can incorporate JERK in the Motion Profile. This smooths both velocity and acceleration at the transition point. For setting the parameter refer to 3rd order motion profile (JERK), page 73.

• JERK=0 - disables 3rd order profiler and uses only 2nd order profiler• JERK>0 - enables 3rd order profiler (Jerk units are <UserUnit>/sec3)

Figure 3-4: Position Profile of 2nd and 3rd Order Profile

3.1.2 ENCODER FEEDBACK

The encoder provides feedback of the stage (rotary or linear) position. After mounting on the stage, the parameter ENR (Encoder Resolution) provides a conversion of the encoder resolution to User Units (mm, degrees, radians, etc). For additional information about the ENR parameter refer to ENR on page 140.

Page 22: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 19

3.1.3 GYROSCOPE FEEDBACK

The gyroscope provides feedback of the system position in space. Refer to Gyro, page 119

3.1.4 OPMODE

The OpMode allows selection between 8 presets for the control parameters (for example Kv, Kp, Ki, Li)) and provides selection between feedback input from Encoder or Gyro. Refer to Figure 3-2, page 16.

• OpMode 0 - Encoder feedback (FPOS+FVEL from Encoder)• OpMode 1 - Gyro feedback (FPOS+FVEL from Gyro)• OpMode 2 - Encoder/Gyro (FPOS from Encoder FVEL from Gyro)

3.1.5 CONTROL ALGORITHM

XCD2 Controller uses a PIV algorithm to simplify adjustment of control parameters even if the motion system is not fully described.

The PIV control algorithm is based on the following mechanisms:

• Position Loop• Velocity Loop• Non-Linear Mechanisms

Position LoopPosition loop deals with PE alone, this the main factor that affects the bandwidth of the system. Inputs are

• RPOS• FPOS

The control element is Kp.

Velocity LoopVelocity Loop is the dominate factor in the control algorithm, is a key factor for the move and settle. Inputs are:

• RVEL (\ZFF)• FVEL• PE multiplied by Kp

The control elements are:

Page 23: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 20

• BiQuads• Kv

• Integral:• Ki• Li• FRP• FRN

Non-Linear MechanismsFriction (FRN/FRP) and ZFF mechanisms are used to overcome the nonliterary of the piezoelectric motor.

Figure 3-5: Control Algorithm

3.1.5.1 KP (POSITION LOOP GAIN)The proportional gain (Kp) determines the contribution of restoring force that is directly proportional to the position error. If Kp is set to 0, only the Velocity Loop is used in the algorithm. This restoring force functions in much the same way as a spring in a mechanical system.

During each sample period (Servo Tick), the PIV loop calculates the position error, the difference between the instantaneous trajectory position and the primary feedback position. The position error is multiplied by Kp to produce the proportional component.

An axis with a value of Kp that is too small will be unable to hold the axis in position and is very soft. Increasing Kp stiffens the axis and improves its ability to maintain position when exposed to outside forces. However, too large a value of Kp can result in instability.

3.1.5.2 BIQUAD

The BiQuad 1 and BiQuad 2 are second order filters used to filter noise and

Page 24: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 21

obtain better motion control. Each BiQuad can be enabled or disabled.

If enabled the BiQuad can be set to perform in one of the following modes:

• Low Pass Filter• Bandwidth (Hz)• Damping ratio (usually less than 1)

• Notch Filter• Resonance Frequency (Hz)• Frequency bandwidth (Hz)• Attenuation (Recommended values: [2,10])

• Full BiQuad filter• pole frequency (Hz)• pole damping (Any number)• zero frequency (Hz)• zero damping (Any number)

• Native - custom defined filter

3.1.5.3 Kv (VELOCITY LOOP GAIN)The Velocity Loop Gain (Kv) determines the contribution of restoring force (damping) proportional to the velocity of the motor/actuator, and is therefore the most important control gain. If Kv is set to zero, no control is applied to the profile. If Kv is set too high the system will produce a high pitch sound indicative of unwanted oscillations.

The velocity feedback derivative is calculated and updated during each Servo tick (Servo tick synchronization variable (SERTICK), page 82).

Velocity feedback is estimated through a combination of speed dependent algorithms. At high speeds, velocity is simply the change in position per sample. This method is used for smoother performance when estimating velocities less than one encoder count per sample period.

3.1.5.4 KI (INTEGRAL GAIN)The integral gain (Ki) is applied after Kv and determines the contribution of restoring force that increases with time, ensuring that the static position error

The Native BiQuad allows configuring a unique BiQuad that is not specifically Low pass, Notch, or full. Configuration is from the XCD2 Commander, Comm Protocol or XMS script. When configuring the Native BiQuad all five parameters must be included in the configuration.

Page 25: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 22

in the servo loop is forced to zero. This restoring force works against constant torque loads to help achieve zero position error when the axis is stopped.

3.1.5.5 LI (INTEGRATOR LIMIT)The Integrator Limit is expressed in percent and limits the contribution of the Integrator Gain to the motion profile. A valid input is in the range [0,100].

3.1.5.6 OFFSET MECHANISMThe offset mechanism provides an initial starting value to overcome the natural friction of the motor by initializing the integrator. The offset value is set using two parameters:

• Friction Positive (FRP) - compensates for friction in the positive direction.

• Friction Negative (FRN) - compensates for friction in the negative direction

These parameters are set at between 50-100% of the value required to cause the motor to move. This is determined during the initial tuning of the servo loop.

3.1.6 ZERO FEED FORWARD (ZFF) MECHANISM

The Zero feed forward mechanism improves the motors settling time. This is done by stopping the Velocity Feed Forward (VFF), and reducing the speed at which the motor approaches the Target Position. As shown in the block diagram, VFF provides a value derived from the position profile. The value of ZFF is dependent on the moving mass. and is typically set to a value of between 30 and 50 microns from the target position. For a larger mass ZFF should be increased.

Page 26: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 23

Figure 3-6: Motor braking on approach to Target Position

3.1.7 OPEN LOOP The open loop command allows direct control of the axis from the XCD Commander. The command moves the Driver Limit from the Closed Loop circuit and connects it to the Open Loop input.

3.1.8 DRIVER LIMIT (DOL)The Driver Limit determines the maximum output from the controller circuits. The value is expressed in percent with a valid range of [0,100].

The Open Loop command overrides some safety features. For this reason it should be used for testing system operation only.

Page 27: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 24

3.1.9 DEAD ZONE MECHANISM

The Dead Zone mechanism takes advantage of the motor’s intrinsic friction to prevent jitter and improve the settling time. The Dead Zone is defined by two areas on either side of the motor.

• Dead Zone Minimum (DZMIN) - a range around the Target Position that is the desired final position of the motor.

• Dead Zone Maximum (DZMAX) - defines the maximum allowable final position of the motor.

DZMIN is the distance from the TPOS - Target Position at which the Dead Zone mechanism drops the drive command to 0 (Figure 3-1, page 15). At this point the motor’s intrinsic friction applies mechanical braking to the motor. At this phase servo corrections are not working. If absolute value of Position error (PE) is greater than DZMAX the Controller applies a signal to return the motion platform toward the TPOS until DZMIN is reached.

Blackout Time (BLOUT) is the time window when the controller ignores the PE value. BLOUT is activated after entering DZMIN. After BLOUT expires PE is compared to DZMAX.

Figure 3-7 shows examples of the Dead Zone mechanism. The upper left graph shows motion platform behavior. The initial position of the motion platform is 0.0 <userUnits>. At time 0 the controller gets a move command with a target position of 10 <userUnits>. After the motion platform reaches the target position an external interference signal is applied to the platform. If the platform exits DZMAX the servo works to return the platform to TPOS.

The graph in the lower left of Figure 3-7 shows the XCD2 flag behavior. Notice that signal levels are 0 or 1. They are placed on the plot to make it easier to understand time behavior of the signals.

The right-hand graph in Figure 3-7 shows a zoom-in of the motion platform behavior during the external interference. Notice that signal levels of S_BUSY and S_INPOS are 0 or 1. Settling occurs after the motor enters DZMIN, and does not move outside DZMAX.

S_MOVE flag is high while the profiler is active and goes low when calculated motion is completed.

S_BUSY flag goes low immediately after DZMIN entry.

S_INPOS flag goes high immediately after BLOUT is expired.

Page 28: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2 Controller Flow

XCD2458000-00, Revision B 25

Figure 3-7: Dead Zone Mechanism

3.1.10 PWMPWM is the controller output supplied to the driver. The PWM generator receives a value that is the result of the all components of the servo loop mechanism.

Usually DZMIN is 1 or 2 counts, and DZMAX is 5 to 10 counts. In these plots much higher values are used to clarify the process.

Page 29: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 26

4 HOST COMMUNICATION PROTOCOL

4.1 COMMUNICATION CHANNELSCommunication with the Host is provided through physical channels such as UART (RS232), IIC and SPI. The communication channels are described in following paragraphs.

4.2 COMMUNICATION ADDRESSEach Controller stores its communication address based on the communication channel in use. The address is a number in the range of 0-254. The user can change the Controller’s address by using the command Set Address. A user defined address can be stored in the Controller's flash memory by using the Save command. The user defined address is retrieved at power up. The default addresses are:

• UART - 0x00• IIC - 0xA4• SPI - 0x00

Each Host command includes the destination address. A destination address of 0 defines broadcasting, where any connected Controller accepts and responds to the command. The Controller accepts the Host's command and responds only if the Controller's address matches the Host's command destination address.

4.3 COMMUNICATION PROTOCOLXCD2 Controller uses a Master/Slave communication model, where the XCD2 controller is the Slave (i.e. the passive role, only replies to messages sent from the master. It will never initiate a data transaction). The Master (e.g. MCU, PC, etc.) initiates the data transaction and the Slave replies.

Each communication session includes two events:

• The Host initiates the session by sending a command.

The address is in the range of 0-254 for UART and IIC. SPI does not include address.

Some communications commands request the address for safety, for example ERASE FLASH.

Page 30: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Protocol

XCD2458000-00, Revision B 27

• The Controller responds to the command. In some cases the reply is simply a prompt, accepting or rejecting the command.

4.3.1 PACKET STRUCTURE

The Command and Reply have the same structure. Figure 4-1 shows general packet structure.

• Interface - contents of the interface depend on the communications channel in use• UART - Synchronization Bytes (2); Address• IIC - Address• SPI - no contents

• Start Byte (0xD5) - defines packet beginning• Packet length including start and stop indexes. For example if packet

payload is 4 byte, then packet length is 7• Packet payload - one or more blocks• Footer - 0xDA is stop index and it indicates packet end

Figure 4-1: Packet structure

The packet payload can have a number of blocks (Figure 4-2). The blocks have the following structure:

• Command header has 3 bytes• 1st byte – Block length• 2nd byte – group ID• 3rd byte – command

• Command payload – Contains one or more Blocks. Each block has the following structure:• Block length• Command Group ID• Command Code• Parameters

Page 31: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Protocol

XCD2458000-00, Revision B 28

Figure 4-2: Block Structure

In most commands, the command code is followed by parameters. Each parameter is a numerical value occupying one or more bytes. The command determines the parameter format. Some parameters specify a Controller variable, referenced by its numerical ID.

The following table describes the parameter formats.

All formats are binary in little-endian format, Least Significant Byte first.

Table 1: Command Parameters' Formats

Format Number of bytes Range

Float 4 -3.4*1038 to +3.4*1038 approximately (compliant with IEEE 754)

UInt8 1 0 to 255

UInt16 2 0 to 65535

UInt32 4 0 to 4294967295

Page 32: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Protocol

XCD2458000-00, Revision B 29

4.3.2 BLOCK STRUCTURE DESCRIPTION

The following table describes the Block structure.

The commands are broken into groups. Each group is responsible for a different module in the XCD2 system. page 36

The following table shows the currently defined commands groups.

4.3.3 RECEIVING DATA BLOCK STRUCTURE

The Receive Block structure is the same as the Send structure. The Group and Command IDs are copied from the Send Command.

Commands that are require specific reply data will contain reply parameters in the command block payload (byte offset 3). See for example the commands Get version, page 44, Report, page 61.

Table 2: Block Structure

Byte offset Byte size Content

0 1 Block length including command header

1 1 Group ID

2 1 Command

3 Up to 58 Parameters

Table 3: Group ID

Group ID Group Name Description Commands

0 Communication

Controls and Status of communication channels. page 36

1 System System group holds controls system functions and features. page 41

2 Bootloader Bootloader group responsible for firmware upgrade process. page 52

5 Servo Servo group holds controls and statuses of servo module. page 54

6 Variable Variables group provides interface for variables. page 60

Page 33: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Channels

XCD2458000-00, Revision B 30

Commands that do not require specific reply data will contain only the Status of ACK (accepted) or NACK (rejected), in command block payload (byte offset 3).

Commands that are not recognized will be replied with a NACK Status.

4.4 COMMUNICATION CHANNELS

4.4.1 SPIThis paragraph describes the XCD2 interface over SPI channel, where the XCD2 is the Slave, and HOST is the Master.

4.4.1.1 SPI CONFIGURATIONFigure 4-3 shows the SPI communication configuration:

• Full-duplex synchronous transfers on three lines.• Data format: 8-bit transmission.• Frame format: Most-Significant-Bit comes first.• Clock Phase: The first clock transition is the first data capture edge.• Clock Polarity: clock is 0 when IDLE.• Clock speed: up to 21 MHz

Table 4: Status Response Codes

Code Name Description

0 NACK Command failed – invalid command code, incorrect parameters

1 ACK Command executed

Page 34: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Channels

XCD2458000-00, Revision B 31

Figure 4-3: SPI Timing Diagram

4.4.1.2 SPI PACKET STRUCTUREEach SPI packet is the same and has no specific prefix.

Figure 4-4: SPI Packet Structure

• Maximum packet length is 64 bytes• Several command blocks could be placed in the same packet as shown

at Figure 4-2• Communication task synchronizes every 50 µsec. It is crucial for the

user to wait at least 100µsec between each SPI iteration

Page 35: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Channels

XCD2458000-00, Revision B 32

• For read operation user must send at least the number of clocks that is equal to packet length to read the packet, otherwise packet will be lost after NSS goes high

4.4.2 IICThis paragraph describes XCD2 interface over IIC channel, while XCD2 is IIC – Slave and HOST processor is IIC – Master.

4.4.2.1 IIC CONFIGURATIONIIC communication configuration:

• 7-bit addressing• Fast speed (up to 400kbps)

4.4.2.2 IIC PACKET STRUCTUREIIC packet has the structure that is shown at Packet structure, page 27 while IIC address is command prefix (Figure 4-5). IIC packet contains:

• Maximum packet length is 64 bytes• Default IIC address is 0xA4, but the address can be changed and

stored at FLASH (page 85) memory• Several command blocks could be placed in the same packet as shown

in Figure 4-5, page 33• The Communication task synchronizes every 50 µsec. There must be

at least 100 µsec between each IIC iteration

BKM There are two ways to handle read operation:• Read packet length is calculated before actual read operation

according to the reply packet length. Refer to Commands and Variables, page 34.

• Current packet length is stored at byte 1, Communication Channels, page 30. Then the read operation continues as follows:• Read 1st two bytes• Read the rest of packet bytes, while the number of read bytes

equal to (Byte 1 – 2)• Verify that 1st byte is 0xD5 and the last byte (Byte 1 – 1) is equal

to 0xDA

Page 36: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Channels

XCD2458000-00, Revision B 33

Figure 4-5: IIC Packet Structure

4.4.3 UART (RS232)This paragraph describes XCD2 interface over UART channel.

Broadcast address = 0.

4.4.3.1 UART HW CONFIGURATIONUART communication configuration:

• Constant baud rate of 115200 bps.• 8-bit word length• No parity• 1 stop bit

4.4.3.2 UART PACKET STRUCTUREFigure 4-5 shows the UART packet structure. UART packet contains:

• Maximum packet length is 64 bytes• Several command blocks could be placed at the same packet

Figure 4-6: UART packet structure

Page 37: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 34

5 COMMANDS AND VARIABLES

This section describes XCD2 software interfaces through both the communication protocol and XMS scripts.

5.1 NUMBERS AND VALUESThe Host Protocol and XMS scripts use standard numbers and values as described below.

5.1.1 FLOATING POINT VALUES

All numbers are floating point values complying with the IEEE 754 definition of single precision arithmetic. The values range is [-3.4×1038, 3.4×1038] approximately. All calculations are performed using single-precision floating numbers.

5.1.2 LITERAL CONSTANTS

Literal constants can appear in different formats. The format of the literal constant has no effect on its internal presentation; the controller converts each constant to a floating point number before using it in calculations.

5.1.3 UNITS

The XCD2 controller uses discrete units of measure. Time is expressed in milliseconds (msec) and scaled values are a percent of the maximum possible. Units of position or distance are based on the user’s application. Throughout

Table 1: Literal Constants Formats in XMS

Format Examples

Integer 1, 20, -1078

Real 0.1, 20.35, 0.000009

Scientific 1e-5, 2.3e10

Hexadecimal 0x07FF, 0x1E23

Page 38: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 35

this document these are referred to as User Units. The User Units can be expressed in standard units of measure expressed as millimeter, degree, or radian. These units are typically based on an encoder mounted on the stage. To convert User Units to units for the XCD2 a scaling factor is used. The Encoder Resolution (ENR) provides this conversion. Physical values such as position, velocity, and acceleration are derived using the ENR (refer to Encoder Feedback, page 18).

The following table shows the variable unit’s relation when ENR provides a physical measurement in millimeters (i.e. linear application).

5.2 COMMANDSThe following paragraphs provide details on available XCD2 commands. The commands are shown as subheadings in their groups. The heading is followed by a brief description of the command including relevant parameters. Following the explanation there are two subheadings: Comm Protocol; XMS command.

• The Comm Protocol includes a table showing the command structure.

Table 2: Measuring Units for Physical Values

Value Example of variables example User Units

position/distance POS, RPOS, FPOS, TPOS <UserUnits> (e.g. mm)

velocity VEL, RVEL, FVEL <UserUnits> per second (e.g. mm/sec)

acceleration ACC<UserUnits> per seconds2

(e.g. mm/sec2)

Jerk JERK<UserUnits> per seconds3

(e.g. mm/sec3)

time TIME millisecond (msec)

scaled values AIN0, AOUT1, DOUT percent of maximum (%)

Direction Group Code Parameter Parameter Format

to MCUCommand Group in decimal value

Command code in decimal value

List of parameters sent to the XCD2 controller

Parameter type (parameter size in bytes)

from MCU

List of parameters received from the XCD2 controller

Parameter type (parameter size in bytes)

Page 39: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 36

Parameter formats are described in Command Parameters' Formats, page 22.

• The XMS command shows the structure of the XMS command and an example showing how the command is used in a script.

5.2.1 COMMUNICATION (GROUP 0)This paragraph describes the communication layer command set.

5.2.1.1 SET ADDRESS Sets the Controller address to the channel in which it was received. Address value can be any number between 0 to 255.

The default value is zero, for IIC it’s 0xA4.

If the Controller address is zero, the Controller accepts any destination address. If the destination address is zero (broadcasting), the Controller accepts the command regardless of the Controller’s address.

If both Controller and destination addresses are non-zero, the Controller answers only if the destination address matches the Controller’s address.

Comm Protocol

XMS Commandnone

Whenever a command contains a list of 2 or more parameters that are optional, the parameters are shown in order of importance. There must be data available for each optional parameter. Optional parameters can be omitted starting with the least impor-tant parameter only.

The XCD2 FW must complete executing a command/process before continuing with the next command/process. There a several commands, such as Home, that have a related command that allows the program to move to the next command/process before the first is completed. The “n” before the command name indicates a com-mand that does not have to complete before the script moves to the next command. For example, Home and nHome.

Direction Group Code Parameter Format

to MCU0 4

Address UInt8 (1)

from MCU Status UInt8 (1)

Page 40: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 37

5.2.1.2 SET AXISAll commands that are received without the optional axis parameter will use the value configured by this command. The number of axis per system is determined by the Hardware configuration file. Each communication channel (i.e UART (2x), IIC, SPI) and XMS has its own axis.

Comm Protocol

XMS CommandXAXIS =<value>

The command will set the XMS active axis. The values are either 0 or 1 depending on the number of axes installed.

Code ExampleThis example will move axis 0 to position 7 at velocity of 70 and move axis 1 to position 120 at velocity of 100

5.2.1.3 GET AXISRetrieves the currently configured axis for this communication channel.

Direction Group Code Parameter format

to MCU0 5

Axis UInt8 (1)

from MCU Status UInt8 (1)

XAXIS = 0

VEL = 70

nmove 7

XAXIS = 1

VEL = 100

nmove 120

The number of axes per system is determined by the Hardware configuration.

Page 41: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 38

Comm Protocol

XMS Command<variable>=XAXIS

Code Example

5.2.1.4 PINGThis is a basic communication test command. It will copy the payload sent, if exist, to the reply packet.

Comm Protocol

XMS Commandnone

Direction Group Code Parameter format

to MCU0 5

None

from MCU Axis UInt8 (1)

// This script set and get the xaxis:

XAXIS = 0

V0 = XAXIS

XAXIS = 1

V1 = XAXIS

// result:

// V0 = 0

// V1 = 1

Direction Group Code Parameter format

to MCU0 5

Data (opt) UInt8 (1) max 20 Bytes

from MCU Data (opt) UInt8 (1)

Page 42: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 39

5.2.1.5 GET CHANNEL INDEXGet communication channel index for which the command was received.

Comm Protocol

XMS Commandnone

5.2.1.6 BRIDGE BUFFER WRITEFill the Communication Bridge TX buffer (refer to Communication Bridge, page 114). Parameters supplied to the MCU are:

• Channel index• Buffer index• Data to store

Response from the MCU is one of the following:

• 0 – NACK, incorrect message length• 1 – ACK, command approved• 2 – ERR_01, Invalid channel index• 3 – ERR_02, Exceeds buffer size• 4 – ERR_03, Channel isn't configured as master

Comm Protocol

XMS CommandIn order to access the buffer, use the relevant TX buffer variables. Refer to Variables, page 115

Direction Group Code Parameter format

to MCU0 7

None

from MCU Index UINT8

Direction Group Code Parameter format

to MCU0 9

ChannelIndexData

UINT8UINT8UINT8 X N

from MCU Status UINT8

Page 43: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 40

Code ExampleThis example will populate the bridge buffers as follows:

• UART bridge buffer bytes 0 with 0x5A and Byte 1 with 0x3D • SPI byte 0 with 0x07• IIC byte 0 with 0x13.

5.2.1.7 BRIDGE BUFFER READRead from the Comm Bridge RX buffer (refer to Communication Bridge, page 114).Parameters supplied to the MCU are:

• Channel index• Buffer index• Number of bytes to obtain (limited to buffer size)

Response from the MCU is one of the following:

• 0 – NACK, incorrect message length• 1 – ACK, command approved• 2 – ERR_01, Invalid channel index• 3 – ERR_02, Exceeds buffer size• 4 – ERR_03, Channel isn't configured as master Data from buffer

Comm Protocol

XMS CommandIn order to access the buffer, use the relevant RX buffer variables. Refer to Variables, page 115

UARTTX00 = 0x5A

UARTTX01 = 0x3D

SPITX00 = 0x07

IICTX00 = 0x13

Direction Group Code Parameter format

to MCU0 10

ChannelIndexLength

UINT8UINT8UINT8

from MCUStatusData

UINT8UINT8 x length

Page 44: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 41

Code ExampleThis example will check if the second received Byte in the UART buffer equals 7 and if so move to target defined in the third byte.

5.2.2 SYSTEM (GROUP 1)This paragraph describes the XCD2 system level command set. The number of axis per system is determined by the Hardware configuration.

5.2.2.1 HOME The command returns the stage to its home position.

• Method selects one of the standard homing sequences. The parameters and methods are described in Homing, page 132

• Origin (Optional) - defines the position at the home point. If omitted, zero is assumed.

• velocity1 (Optional) - defines velocity of the first phase (hard stop). If omitted, VEL value is used.

• velocity2 (Optional) - defines second phase velocity (encoder index). If omitted, velocity1 value is used.

• Axis parameter (Optional) - specifies the axis of operation. If the Axis parameter is omitted, the command is applied to the last selected axis.

Will return status of NACK if Homing or Calibration is running, otherwise ACK.

if (UARTRX01 = 7)

move UARTRX02

end

BKM Use low velocity in velocity1 parameter when searching for the hard-stop. This will help overcome the gaging phenomena and prevent damage to the system.

Page 45: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 42

Comm Protocol

XMS CommandXMS execution is halted at this line. S_HOME flag reset to zero at start of motion and set to 1 after home procedure completed successfully.

HOME / NHOME <method> <origin> <velocity1> <velocity2>

Code Example

5.2.2.2 MOTOR FREQUENCY CALIBRATIONThis command initiates the motor frequency calibration procedure (Motor Frequency Calibration, page 110) to find the motor’s optimal working point.

Axis parameter (Optional) - specifies the axis of operation. If the Axis parameter is omitted, the command is applied to the last selected axis.

Will return status of NACK if Homing or Calibration is running, otherwise ACK.

Comm Protocol

Direction Group Code Parameter Format

to MCU1 2

Method Origin (opt) Velocity1 (opt)Velocity2 (opt)Axis (opt)

UInt8 (1) Real (4) Real (4) Real (4) UInt8 (1)

from MCU Status UInt8(1)

// each of the lines below will initiate homing

home 0 //initiate with negative direction

home 0, -1 //As above + set the origin to be -1

home 0, -1, 10 //As above + set first velocity to be 40

home 0, -1, 10, 5 //As above + set second velocity to be 5

Direction Group Code Parameter format

to MCU1 3

Axis (opt) UInt8 (1)

from MCU Status UInt8(1)

Page 46: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 43

XMS Command

MFCALIB

Code Example

5.2.2.3 RESETWill perform software reset. Used to reload parameters from flash without power up cycle.

Comm Protocol

XMS CommandNone

XMS execution will stall at this line and wait for servo synchronization.

// These line will perform motor-frequency calibration for the two Axes:

xaxis = 0

mfcalib

xaxis = 1

mfcalib

The RESET execution will be performed immediately, which means no reply is sent.

Direction Group Code Parameter format

to MCU1 6

from MCU None None

Page 47: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 44

5.2.2.4 SAVE PARAMETERSSaves parameter values to flash memory. At the next start-up, the Controller reads the parameters from the flash and starts with the stored parameters instead of default values.

The provided parameters are:

• Address - specifies address of the communication channel.• 90 (0x5A) - is constant. • Bit selection determines what to store or erase. If no option entered the

default is store variables and XMS to Flash.• Bit0 – store variables • Bit1 – store XMS • Bit3 – Erase variables section • Bit4 – Erase XMS section

Erasing a sector will restore factory defaults.

Will return NACK if parameters are invalid or data verification failed.

Comm Protocol

XMS Commandnone

5.2.2.5 GET VERSIONThe command requests information about Controller firmware.

• XCD2 version• Serial number

BKM Address and security code parameters are required to prevent unintentional use of the command.

BKM Reply message will be sent after full execution, the operation can take up to 5 sec-onds.

Direction Group Code Parameter Format

to MCU1 7

address 90 (0x5A) Options (opt)

UInt8 (1)UInt8 (1)UInt8 (1)

from MCU Status UInt8 (1)

Page 48: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 45

• Device type – XCD2 controller • Application version – all zeros in case of XCD2 controller

Comm Protocol

XMS Commandnone

5.2.2.6 EXECUTE XMS PROGRAMNACK means uploaded XMS program failed validation.

Comm Protocol

XMS Commandnone

5.2.2.7 STOP XMS PROGRAMStops the currently executing XMS program.

Comm Protocol

Direction Group Code Parameter format

to MCU

1 10

None None

from MCU

XCD2 versionSerial numberDevice type App version

Int32 (4)Int32 (4) UInt16 (2) Int32 (4)

Direction Group Code Parameter format

to MCU1 14

None None

from MCU Status UInt8 (1)

Direction Group Code Parameter format

to MCU1 15

None None

from MCU Status UInt8 (1)

Page 49: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 46

XMS Commandnone

5.2.2.8 RESUME XMS PROGRAMResumes the currently paused XMS program.

The parameter ExFlag = 0

Comm Protocol

XMS Commandnone

5.2.2.9 GET AXIS NUMBERThe command requests information about how many axes are configured in the controller. The number of axes is defined when configuring the XCD2 Main Board.

Comm Protocol

XMS Commandnone

5.2.2.10 BIQUAD CONFIGURATIONProvides ability to configure the BiQuad filters.

Direction Group Code Parameter format

to MCU1 17

ExFlags UInt8 (1)

from MCU Status UInt8 (1)

Direction Group Code Parameter format

to MCU1 23

None None

from MCU Axes count UInt8(1)

The Native BiQuad allows configuring a unique BiQuad that is not specifically a Low Pass, Notch, or full. Configuration is from the XCD2 Commander, XMS script, or Comm Protocol. Refer to BiQuad filters parameters, page 75

Page 50: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 47

The command requires the following information:

• Axis - 0 or 1• Biquad = 1 or 2• Type

• 0=Low Pass• 1=Notch• 2=Full BiQuad

• Variables • Low Pass – Bandwidth, Damping ratio• Notch - Resonance, Width, Attenuation• Full BiQuad - Pole Frequency, Pole Damping, Zero

Frequency, Zero Damping

Comm Protocol

XMSCONFIGBIQUADFILTER <module>,<type>,<var1>,<var2>,<var3>,<var4>

Table 5-1:

Directions Group Code Parameters

To MCU5 18

UINT8 – Axis

UINT8 – Module

UINT8 – Type

Float - up to 4 Variables

Reply from MCU Status (Ack/Nack)

Page 51: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 48

Code Example

Native/Custom BiQuadUsing this feature requires entering all five BiQuads. The following is an example of the Biquad configuration in XMS. For more information about the configuration refer to BiQuad filters parameters, page 75

BQA1=<value>

BQA2=<value>

BQB0=<value>

BQB1=<value>

BQB2=<value>

5.2.2.11 SCOPEThe scope module allows streaming of any internal variables data at full servo rate. The data can be streamed in any of the UART channels at a configurable baud-rate. In order to overcome the possible baud-rate / data-rate limitation it’s possible to reduce the data-rate by:

• Selecting 16bit float (*) instead of 32bit• Diluting the transitions to 1/k servo rate

XAXIS = 0

// BiQuad 1 - Low Pass - Bandwidth=280, Damping ratio=0.7

ConfigBiQuadFilter 1,0,280,0.7

pause

// BiQuad 2 - Low Pass - Bandwidth=280, Damping ratio=0.5

ConfigBiQuadFilter 2,0,280,0.5

// BiQuad 1 - Notch - Resonance=500, Width=50, Attenuation=5

ConfigBiQuadFilter 1,1,500,50,5

pause

// BiQuad 1 - Full BiQuad - Pole Freq=200,Pole Damping=0.5,Zero Freq=100,Zero Damping=1

ConfigBiQuadFilter 1,2,200,0.5,100,1

pause

(*) a standard floating point (single, 32bit) is not converted to half-precision but instead it’s shifted by 16 bits. The only thing affected is the LSB of the mantissa. The exponent part is still 8bits.

To interpret the value the data needs to be shifted back into 32bits.

Page 52: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 49

Scope usage steps:

• Enable the scope module and configure its communication channel• Configure scope sample channels• Activate streaming of data

Scope streams data packets. Each data packet contains 2 sync bytes and a status byte.

0xD7 <Status Byte> <Data> 0xA5

Data contains all of the channels, 16 or 32bit each (e.g 2 channels of 16bit + 1 channel of 32bit = 8bytes of data + 3 bytes of overhead)

Comm. Protocol

Scope Enable

Enable Parameters

• Channel Index• UART0 = 0• UART1 = 1

• Baud-rateAny value between 115200 to 10.5Mbps

All Scope actions can be initiated through Comm Protocol, XMS script, or from the XCD2 Commander.

Directions Group Code Parameters

to MCU6 32

UInt8 – Channel Index

UInt32 – Baud-rate

UInt16 – Dilution

from MCU Status (Ack/Nack)

Directions Group Code Parameters

to MCU

6 32

none

from MCU

UInt8 – Enabled

UInt8 – Channel Index

UInt16 – Dilution

UInt32 – Baud-rate

Page 53: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 50

• DilutionServo rate divider, can be any value bigger than 0

• Enabled:• False = 0 - the rest of the values are invalid• True = 1

Scope Disable

Scope Config - Add/Edit channel

Config Parameters

• Channel: 0-7• Axis: axis to sample• VardID: variable to sample (refer to Variables, page 71• Config bits:

bit 0 = 1 High res. (32bit) enabled

bits 1 to 15: reserved

Delete channel

Delete Parameters

• Channel: 0-7

Directions Group Code Parameters

To MCUVars (6) 33

none

from MCU Status (Ack/Nack)

Directions Group Code Parameters

To MCUVars (6) 33

UInt8 – Channel

UInt8 – Axis

UInt16 – VarID

UInt16 – Config

from MCU Status (Ack/Nack)

Directions Group Code Parameters

To MCUVars (6) 33

UInt8 – ChannelUInt8 – DNC

from MCU Status (Ack/Nack)

Page 54: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 51

• DNC: reserved = 0

Get channel

Parameters description

none

Scope Activate:

• Parameters description• Active:

• False = 0• True = 1

• Status (optional):This byte is included with each scope data stream packet

XMS command:Scope start command will start/activate data streaming. The optional parameter StatusByte (SSTAT) stores StatusByte value.

SCOPESTART

Scope stop command will stop data streaming

SCOPESTOP

Directions Group Code Parameters

To MCU

Vars (6) 33

UInt8 – Channel

Reply from MCU

UInt8 – Axis

UInt16 – VarID

UInt16 – Config

Directions Group Code Parameters

To MCUVars (6) 32

UInt8 – Active

UInt8 – Status (optional)

from MCU Status (Ack/Nack)

To MCUVars (6) 32

None

from MCU UInt8 – Active

Page 55: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 52

Code Example

5.2.3 BOOTLOADER (GROUP 2)This paragraph describes the Bootloader command set. For more information about the bootloader refer to Firmware Upgrade, page 153

5.2.3.1 BOOT INTO BOOTLOADER This command tells XCD2 firmware to boot into the Bootloader stage.

Comm Protocol

XMS Commandnone

5.2.3.2 BOOT INTO XCD2 MAIN FIRMWAREThis command tells Bootloader load XCD2 firmware.

for V0=0 to 10

ZFF= 0.1 * V0

move 0

delay 100

disable

scopestart V0 // Start scope streaming with SSTAT var set to V0

nmove 1

while S_MOVE

end

scopestop // Stop scope streaming

end

Direction Group Code Parameter format

to MCU2 7

None None

from MCU Status UINT8 (1)

Page 56: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 53

• ACK – upgrade process was successful and XCD2 firmware will be loaded

• NACK – upgrade process failed and XCD2 will stay in the Bootloader

Comm Protocol

XMS Commandnone

5.2.3.3 BOOT PACKETThe command transfers new FW to Flash. Refer to File structure, page 153.

Comm Protocol

StatusThis command is sent from XCD2 to HOST as a reply for Boot packet. The following operational codes (hexadecimal) may be returned:

• 0x00 – Pass• 0x01 – Unknown command. • 0x02 – XCD2 is write protected. XCD2 FW upgrade could not be done. • 0x03 – Erase failure • 0x04 – Data block write operation fail. • 0x05 – Data block is out of range• 0x07 – Previous operation in progress

XMS Commandnone

Direction Group Code Parameter format

to MCU2 4

None None

from MCU Status UINT8 (1)

Direction Group Code Parameter Format

to MCU2 3

Boot block < 58

from MCU Status UINT8 (1)

Page 57: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 54

5.2.4 SERVO (GROUP 5)This paragraph describes the servo module command set.

5.2.4.1 MOVE Move to absolute position. Position is an expression that defines a new target position. If the ENABLE was not executed before MOVE, the MOVE command enables the servo loop. After motion execution, the servo loop remains enabled, and the motor keeps final position.

The command provides smooth motion to the specified position using values VEL and ACC for building a velocity profile. Refer to Control Algorithm, page 19

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS CommandMOVE / NMOVE <position> <axis>

The number of axes per system is determined by the Hardware configuration file, refer to the hardware data sheet.

The units are defined by the Encoder/ENR variable relation. Refer to ENR on page 132 for more information.

Direction Group Code Parameter Format

to MCU5 2

Position Axis (opt)

Real (4) UInt8(1)

from MCU Status UInt8(1)

XMS execution will stall at this line and waiting for servo synchronization.

Page 58: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 55

Code Example

5.2.4.2 VELOCITY LOOPThe controller switches to velocity-loop operation, PE is ignored. Command is an expression that defines target velocity.

Execute velocity loop control. The parameter defines the required velocity in User units/sec.

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS CommandVELOCITYLOOP <velocity>

xaxis = 0

for V0 = 0 to 9

move 10

delay 200

move -10

delay 200

end

Direction Group Code Parameter format

to MCU5 3

VelocityAxis (opt)

Real (4) UInt8(1)

from MCU Status UInt8(1)

XMS execution will stall at this line and wait for servo synchronization.

Page 59: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 56

Code ExampleThis example moves axis 0 at velocity 10 for 1 sec:

5.2.4.3 OPEN LOOP The controller switches to open-loop operation. Command is an expression that defines drive output value.

• Command: -100 to +100• Axis: The axis to be moved is an optional parameter. If the Axis

parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS CommandOPENLOOP <command>

Code ExampleThis example moves axis 0 at a PWM level of 20% for 1 sec:

XAXIS = 0

velocityloop 10

delay 1000

disable

Direction Group Code Parameter format

to MCU5 4

CommandAxis (opt)

Real (4) UInt8(1)

from MCU Status UInt8(1)

XMS execution will stall at this line and waiting for servo synchronization.

XAXIS = 0

openloop 20

delay 1000

disable

Page 60: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 57

5.2.4.4 SET POSITION Assigns axis feedback position (FPOS).

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS CommandSET FPOS <position>

Code ExamplePerforms homing by setting the FPOS to -0.2 at the hardstop

5.2.4.5 ENABLEEnables the servo loop. While the servo loop is enabled, the motor is actively held in its current position to correct for deviations caused by an external force.

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

Direction Group Code Parameter format

to MCU5 5

Position Axis (opt)

Real (4) UInt8(1)

from MCU Status UInt8(1)

XAXIS = 0

nmove -100000

while (abs(PE) < 0.5)

end

disable

set FPOS = -0.2

Direction Group Code Parameter format

to MCU5 7

Axis (opt) UInt8(1)

from MCU Status UInt8(1)

Page 61: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 58

XMS Command

ENABLE <axis>

Code Example

5.2.4.6 DISABLE Disables the servo loop which stops active position error corrections. While the servo loop is disabled, the motor resists movement from external forces because of the motor’s high static holding force.

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

An axis parameter of 255 (0xFF) disables all axes.

Comm Protocol

XMS CommandDISABLE

XMS execution will stall at this line and waiting for servo synchronization.

// 2 seconds of movements:

MTL = 0

velocityloop 10

delay 2000

disable

// Keep the position:

enable

Direction Group Code Parameter format

to MCU5 8

Axis (opt) UInt8(1)

from MCU Status UInt8(1)

XMS execution will stall at this line and waiting for servo synchronization.

Page 62: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 59

Code Example

5.2.4.7 KILL The Kill command causes motion deceleration at the KDEC rate. The motor remains enabled.

The axis is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS Command

KILL

Code Example

// 2 seconds of movement and the stopping the motor

MTL = 0

velocityloop 10

delay 2000

disable //would not keep the position

BKM To disable instead of kill the motor use Disable, page 58

Direction Group Code Parameter format

to MCU5 10

Axis (opt) UInt8(1)

from MCU Status UInt8(1)

xaxis = 0 // Select axis 0

move 1 // move to target 1 (blocking)

nmove 10 // move to target 10 (non-blocking)

delay 50 // wait 50ms

kill // kill movement

XMS execution will stall at this line and wait for servo synchronization.

Page 63: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 60

5.2.4.8 CONFIGUREProvides configuration of the Controller. Available codes are defined under Pseudovariables, page 82.

Comm Protocol

XMS CommandCONFIG <axis> <variable ID> <parameter>

Code Example

5.2.5 VARIABLES API (GROUP 6)This group handles the defining and controlling of variables in the controller.

This paragraph describes variables interface command set. In the following table the number of axes per system is determined by the hardware configuration.

5.2.5.1 MONITOR Monitors a channel variable.

After command, and during each cycle, the Controller converts the variable using the scale and passes it to analog output. The parameters are:

Direction Group Code Parameter format

to MCU5 13

Axisvariable IDparameter (opt)

UInt8 (1) UInt16 (2) Real (4)

from MCU Status UInt8(1)

// Set IO(2:0) direction to be an output

config 905, 0x0007

// Read back pseudo var 905 and store it in V0

V0 = getvar(905)

// Set IO(2:0) direction to be an input

config 905, 0x0000

// Read back pseudo var 905 and store it in V1

V1 = getvar(905)

Page 64: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 61

• channel defines analog output to use: • 0 – AOUT0 • 1 – AOUT1

• variable specifies variable to monitor. • scale defines a conversion factor. • axis define what axis to use for monitor

Comm Protocol

XMS CommandNot supported

5.2.5.2 REPORTReport variable values. The command requests current variable values. Up to 10 variables can be requested in one command. In addition to XMS variables, the command accepts IDs of pseudovariables. Refer to XMS Variables, page 63 for a list of XMS and pseudovariables.

Comm Protocol

Direction Group Code Parameter format

to MCU6 2

channelvariablescaleaxis(1)

UInt8 (1)UInt16 (2)Real (4)UInt8(1)

from MCU Status UInt8(1)

Direction Group Code Parameter format

to MCU

6 4

var1var2 (opt)…var10 (opt)

UInt16 (2)UInt16 (2)…UInt16 (2)

from MCU

var1var1…var10

Float(4)Float(4)…Float(4)

Page 65: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 62

XMS CommandAccess variable by name.

Code ExampleStore FPOS in V0.

5.2.5.3 ASSIGNEach specified variable is assigned with the corresponding value. Up to 7 variables can be assigned in one command. Refer to XMS Variables, page 63 for a list of XMS and pseudovariables.

Comm Protocol

XMS CommandAccess variable by name.

Code ExampleSet velocity to V0

5.2.5.4 REPORT WITH AXISThis command has same purpose like command REPORT, but after each var ID there is an identification of what axis is referred to.

The axis to be moved is an optional parameter. If the Axis parameter is omitted, the command is applied to the last selected axis.

V0=FPOS

Direction Group Code Parameter format

to MCU6 6

variable1value1variable2 value2...

UInt16 (2)Real (4)UInt16 (2)Real (4)...

from MCU Status UInt8(1)

VEL=V0

Page 66: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 63

Comm Protocol

XMS Commandnone

5.2.5.5 ASSIGN WITH AXISThis command has same purpose like command ASSIGN, but after each variable ID there is an identification of what axis is referred to. If the Axis parameter is omitted, the command is applied to the last selected axis.

Comm Protocol

XMS Commandnone

5.2.5.6 DELAYProvides a time delay in milliseconds between actions.

Direction Group Code Parameter format

to MCU 6 132

var1axis(1)var2 (opt)axis (opt)…var10 (opt)axis (opt)

UInt16 (2)UInt8(1)UInt16 (2)UInt8(1)…UInt16 (2)UInt8(1)

Direction Group Code Parameter format

to MCU6 134

Variablevalue1axis(1)variable2 (opt)value2 (opt)axis (opt)…

UInt16 (2)Real (4)UInt8(1)UInt16 (2)Real (4) UInt8(1)…

from MCU Status UInt8(1)

Page 67: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 64

Comm Protocolnone

XMSDELAY <time>

Code Example

5.2.5.7 PAUSEThe command effectively provides breakpoint functionality. When the command is encountered, the program stops execution and waits for host commands. This command is used for program debugging with the XCD2 Commander.

Comm Protocolnone

XMSPAUSE

// Initiate one second of movement in velocity of 10 user-units per second

XAXIS = 0

velocityloop 10

delay 1000 // one second of delay

disable

BKM Another good use of pause is when an unknown delay is needed for operation of the system.

Page 68: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 65

Code Example

5.2.5.8 GET VARIABLEReturns value of a variable or a bit from a variable. The function accepts one or two arguments. The first argument specifies ID of a variable. The second argument specifies bit in the variable. If the second argument is omitted, the function returns current value of the variable. If the second argument is in range from 0 to 31, the function returns 0 or 1 according to the corresponding bit in the variable.

For available pseudovariables refer to Pseudovariables, page 82.

Comm Protocolnone

XMS<variable>=GETVAR <varName>

Code ExampleReads the Status pseudovariable.

5.2.5.9 LOGLogging function writes string line to specified file with formatting options. If format includes format specifiers (subsequences with {}), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.

// This script will stop the stage manually by the user:

XAXIS = 0

velocityloop 5

pause //hit the resume button to resume the program

disable

V0 = getvar(900)

Page 69: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 66

Log is a special function that requires synchronization between the Controller and Host. It stores the arguments following the <text expression> in the buffer and waits for the host to pull them before resuming the XMS script.

Comm Protocolnone

XMSLOG <text expression>,Arg0, Arg1 … Arg9

Code Example

Dialog WindowsWhen the Commander is running, on the first log instruction the following dialog will open and will wait for user input. During that time the XMS is halted

Figure 5-1: XMS Log Files Selection

The content of the text expression follows MSDN String.Format Method (.NET).

Log “Hello world”,0

Log “Constant = {0}, Time = {1}”,3.1415, TIME

Page 70: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 67

5.2.6 DATA PACKET EXAMPLES

The following example will send one packet that contains to two command blocks with a Move command (one for each axis).

Packet bytes breakdown:

• 0 and 1 – used in UART protocol only• 2 – used in UART and IIC• 3, 4 and 23 – Packet header and footer• 6 to 13 – First move block command• 14 to 21 – Second move block command

Page 71: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 68

5.2.6.1 MULTI-BLOCK MOVE COMMAND Table 6: Multi-block Move Command

Request format (Host > XCD2) Response format (XCD2 > Host)

Byte # Raw Data Description Byte

#Raw Data Description

0 0xE4 SyncByte1 0 0xE4 SyncByte1

1 0xA5 SyncByte2 1 0xA5 SyncByte2

2 0x00 Address 2 0x00 Address

3 0xD5 Start index 3 0xD5 Start index

4 0x13 Packet length with header (3 to 22) 4 0x0B Packet length with header

(3 to 13)

5 0x08 Block length (5 to 12) 5 0x04 Block length (5 to 8)

6 0x05 Group ID 6 0x05 Group ID

7 0x02 Move command ID 7 0x02 Move command ID

8 0x00 0x00 Target parametersingle value in IEEE-754 format. Note that byte order is in Little-Endian format. Left column has value 10 Right column has value -10

8 Status - ACK

9 0x00 0x00 9 0x04 Block length (9 to 12)

10 0x20 0x20 10 0x05 Group ID

11 0x41 0xC1 11 0x02 Move command ID

12 0x00 Axis 12 0x01 Status - Ack

13 0x08 Block length (13 to 20) 13 0xDA Stop index

14 0x05 Group ID

15 0x02 Move command ID

16 0x00 0x00 Target parameter

17 0x00 0x00 Single value of IEEE-754 format. Note that byte order is little-endian.Left column has value 10Right column has value -10

18 0x20 0x20

19 0x41 0xC1

20 0x01 Axis

21 0xDA Stop index

Page 72: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 69

5.2.6.2 MULTI-BLOCK OF ASSIGN AND REPORT COMMAND

Table 7: Multi-Block of Assign and Report Command

Request format (Host > XCD2) Response format (XCD2 > Host

Byte #

Raw Data Description Byte

#Raw Data Description

0 0xE4 SyncByte1 0 0xE4 SyncByte1

1 0xA5 SyncByte2 1 0xA5 SyncByte2

2 0x00 Address 2 0x00 Address

3 0xD5 Start index 3 0xD5 Start index

4 0x13 Packet length with header (3 to 21) 4 0x12 Packet length with header (3 to

20)

5 0x09 Block length (5 to 13) 5 0x04 Block length (5 to 8)

6 0x06 Group ID 6 0x06 Group ID

7 0x06 Assign command ID

7 0x06 Assign command ID8 0x84pseudovariable 900

9 0x03

10 0x00 Target parameter (Refer to pseudovariable 900 Pseudo-Variables, page 68) • BiQaud1 – enable • BiQaud2 – disable • AB1 drive mode Feedback direction is reversed Drive direction is reversed

8 0x01 Status - Ack

11 0x10 9 0x0B Block length (9 to 19)

12 0x0D 10 0x06 Group ID

13 0x00 11 0x04 Report command ID

14 0x07 Block length (14 to 20) 12 0x5C FPOS(0) = – 150.56°

15 0x06 Group ID 13 0x8F

16 0x04 Report command ID 14 0x16

17 0x09 ID of FPOS (Little-Endian format) 15 0xC3

18 0x00 16 0x14 FVEL(0) = 25.96°/s

19 0x0A ID of FVEL (Little-Endian format) 17 0xAE

20 0x00 18 0xCF

21 0xDA Stop index 19 0x41

20 0xDA Stop index

Page 73: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Commands

XCD2458000-00, Revision B 70

5.2.6.3 GET VERSION COMMAND

Table 8: Get Version Command Structure

Request format (Host > XCD2) Response format (XCD2 > Host)

Byte #

Raw Data Description Byte

#Raw Data Description

0 0xE4 SyncByte1 0 0xE4 SyncByte1

1 0xA5 SyncByte2 1 0xA5 SyncByte2

2 0x00 Address 2 0x00 Address

3 0xD5 Start index 3 0xD5 Start index

4 0x06 Packet length with header (3 to 8) 4 0x14 Packet length with header

(3 to 22)

5 0x03 Block length (5 to 7) 5 0x11 Block length (5 to 21)

6 0x01 System group ID 6 0x01 System group ID

7 0x0A Get version command ID7 0x0A Get version command ID

8 0xDA Stop index

8 0x01 XCD2 version – XX.XX.XXX

9 0x09

10 0x0C

11 0x01

12 0x5C Serial number – 0xC3168F5C

13 0x8F

14 0x16

15 0xC3

16 0x80 Device type – XCD2

17 0x01

18 0x00 App version – XX.XX.XXXX

19 0x03

20 0x53

21 0x03

22 0xDA Stop index

Page 74: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 71

5.3 VARIABLESVariables can be used either in the XMS program or in Host communication. When used in the XMS program, variables are referenced by name. All variable names are predefined; i.e. the user can use only these predefined variable names.

In Host communication, the Commands Assign, Report, and Monitor refer to the variable by 16-bit ID.

The XMS variables are subdivided into two classes:

• System variables; each system variable has a predefined meaning, for example:• VEL – required motion velocity• FPOS – feedback position

• User variables with predefined names: V0, V1, V2 … V19. A user variable has no predefined meaning, and can store any number required in a program.

Variables, page 71 summarizes the variables. For each variable, the paragraph specifies the following parameters:

• ID for use in read/assign variable command (Variables API (Group 6), page 60).

• Name for use in XMS program• Tags - Variable tags

• NT – no specific tags.• FL – Variable saved to flash memory at SAVE PARAMETERS

command and loaded at power up.• AX – Axis variable• RO – read only variable.• ST – SET function is used for variable assignment (refer to

Table 3, page 90.

5.3.1 GLOBAL VARIABLES

5.3.1.1 AXIS SELECTION (XAXIS)The variable affects execution of XMS program, but does not affect the Host commands received through communication channels. All subsequent commands refer to the specified axis.

• ID: 72• Tag: NT

Page 75: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 72

5.3.1.2 ELAPSED TIME (TIME)Elapsed time in milliseconds. It can be set to any value using the XMS or Comm Protocol (refer to TIME Variable, page 134)

• 38• RO, ST

5.3.1.3 MOTOR FREQUENCY (MFREQ)PWM frequency. Refer to Motor Frequency Calibration, page 110.

• 23• FL, AX, RO

5.3.1.4 SERVO TICK LENGTH IN MSEC (SPRD)• 24• RO

5.3.1.5 USER VARIABLES (V0 - V19)• 1000 - 1019• NT

5.3.2 MOTION PARAMETERS

5.3.2.1 VELOCITY (VEL)Target velocity in motion profile during constant velocity phase

• ID: 1• Tag: FL, AX

5.3.2.2 ACCELERATION (ACC)Acceleration in motion profile during acceleration phase

• 2• FL, AX

5.3.2.3 DECELERATION (DEC)Deceleration in motion profile during acceleration phase, if equal zero then ACC is used.

Page 76: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 73

• 3• FL, AX

5.3.2.4 KILL DECELERATION (KDEC)This parameter is in use while the Kill command is executing.

• 4• FL, AX

5.3.2.5 3RD ORDER MOTION PROFILE (JERK)Refer to Third Order Motion Profile (JERK), page 18JERK = 0 - 2nd order motionJERK > 0 - 3rd order motion

• 113• FL, AX

5.3.2.6 TARGET POSITION (TPOS)• 5• AX, RO

5.3.3 MOTION PROFILER SIGNALS

The motion profiler is tracked during each servo tick by variables that hold the reference signal for position (RVEL) and velocity (RVEL).

5.3.3.1 REFERENCE POSITION (RPOS)This signal follows the position trajectory calculated each servo tick.

• 6• AX, RO

5.3.3.2 REFERENCE VELOCITY (RVEL)This signal follows the velocity trajectory calculated each servo tick.

• 7• AX, RO

Page 77: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 74

5.3.4 MOTION SIGNALS FOR SENSORS

Feedback read from feedback sensors (or calculated) is represented in position (FPOS) and velocity (FVEL) variables.

5.3.4.1 FEEDBACK POSITION (FPOS)Encoder read or integral over gyro read.

• 9• AX, RO, ST

5.3.4.2 FEEDBACK VELOCITY (FVEL)Encoder derivative or gyro read.

• 10• AX, RO

5.3.4.3 POSITION ERROR (PE)PE is calculated as RPOS-FPOS.

• 12• AX, RO

5.3.4.4 POSITION LATCHED (POSI)Position latched on encoder index pulse.

• 52• AX, RO

5.3.5 SERVO LOOP AND DRIVE CONFIGURATION

5.3.5.1 POSITION LOOP GAIN (KP)Refer to Kp (Position Loop Gain), page 20

• x13• FL, AX

5.3.5.2 VELOCITY LOOP GAIN (KV)Refer to Kv (Velocity Loop Gain), page 21

Page 78: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 75

• 14• FL, AX

5.3.5.3 VELOCITY LOOP INTEGRATOR GAIN (KI)Refer to Ki (Integral Gain), page 21

• 15• FL, AX

5.3.5.4 VELOCITY LOOP INTEGRATOR LIMIT (LI)Refer to LI (Integrator Limit), page 22

• 16• FL, AX

5.3.5.5 POSITION LOOP INTEGRATOR GAIN (PKI)• 64• FL, AX

5.3.5.6 POSITION LOOP INTEGRATOR LIMIT (PLI)• 65• FL, AX

5.3.5.7 BIQUAD FILTERS PARAMETERSAll the parameters of the BiQuad, in each mode, are given in Laplace domain; those parameters are transformed by bilinear transform (Tustin) to the following discrete transfer function. Bilinear transform:

The numerator and denominator coefficients (B0,B1,B2,A1,A2) are the Native parameters in the XCD commander. Also can be used in XMS in the following manner:

ID TAG

BQA1 17 FL, AX

s 2 T z 1– z 1+ =

H s Hd z B0 B1z1–

B2z2–

+ +

1 A1z1–

A2z1–

+ +-------------------------------------------------= =

Page 79: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 76

5.3.5.8 ENCODER RESOLUTION (ENR) User Units per one encoder count.

• 22• FL, AX

5.3.5.9 DEAD ZONE MIN (DZMIN)• 40• FL, AX

5.3.5.10 DEAD ZONE MAX (DZMAX)• 41• FL, AX

5.3.5.11 ZERO FEED FORWARD (ZFF)• 42• FL, AX

5.3.5.12 FRICTION COMPENSATION VARIABLESRefer to Offset Mechanism, page 22.

Friction in positive direction (FRP)Refer to

• 43

BQA2 18 FL, AXBQB0 19 FL, AXBQB1 20 FL, AXBQB2 21 FL, AXBQ2A1 67 FL, AXBQ2A2 68 FL, AXBQ2B0 69 FL, AXBQ2B1 70 FL, AXBQ2B2 71 FL, AX

ID TAG

Page 80: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 77

• FL, AX

Friction in negative direction (FRN)• 44• FL, AX

5.3.5.13 REALTIME DRIVE OUTPUT (DOUT)Percent of maximal output

• 45• AX, RO

5.3.5.14 POSITION OFFSET (POSOFFS)Used with absolute encoders. The value is updated when SET FPOS command used.

• 95• FL, AX, RO

5.3.5.15 BLACKOUT PERIOD (BLOUT)Configures Blackout time in milliseconds (refer to Dead Zone Mechanism, page 24).

• 112• FL, AX

5.3.5.16 DRIVE OUTPUT OFFSET (DOFFS)Percent of shifted drive output between positive and negative direction, used to calibrate symmetry. For example, move at the same Vel for the same command at pos/neg directions

• 53• FL, AX

5.3.6 SAFETY

5.3.6.1 DRIVE OUTPUT LIMIT (DOL)Limits the drive output to DOL value (percent of maximum output). The function is disabled if DOL = 0.

• 39• FL, AX

Page 81: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 78

5.3.6.2 SOFTWARE LIMITSThe software limit will disallow moves outside of the bounds set in user units. Disables the motor if 0 and throws and error. Refer to Error Codes, page 85.

Positive Limit (SLP)• 47• FL, AX

Negative Limit (SLN)• 48• FL, AX

5.3.6.3 POSITION ERROR LIMIT (PEL)Absolute value of allowed position error. if = 0 - PEL disabled

• 49• FL, AX

5.3.6.4 MOTION TIME LIMIT (MTL)Maximum time (msec) from motion start until target position is reached. the motor is disabled if MTL is exceeded, and throws and error. Refer to Error Codes, page 85.

if = 0 - MTL disabled

• 51• FL, AX

5.3.6.5 MOTOR TEMPERATURE (MTTMP)Variable is valid only in systems with thermal sensor. Uses an internal lookup table of values. Default units are Celcius.

• 107• AX, RO

BKM Set away from hard stop after homing procedure is done.

Page 82: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 79

5.3.7 ANALOG INPUTS

XCD2 features 16 analog inputs for user general purposes that are defined during HW design and configuration. These variables are used in the commands of Variables API (Group 6), page 60.

There is an option in the HW configuration file to define a different scaling factor. The Analog sampler can be configured to produce an error when the analog value is outside of a min/max level and dwell time.

5.3.7.1 ANALOG INPUTS 0 - 3 (AIN0 - AIN3)Value represented as percentage of reference voltage and varies between 0 and 100.

• 30 - 33• RO

5.3.7.2 ANALOG INPUTS 4 - 11 (AIN4 - AIN11)Value represented as percentage of reference voltage and varies between 0 and 100.

• 55 - 62• RO

5.3.8 ANALOG OUTPUTS (DAC)The voltage produced is calculated by the formula:

Refer to Variables API (Group 6), page 60 for configuring the variable outputs.

5.3.8.1 ANALOG OUTPUT 0 (AOUT0)Value has range from 0 to 4095.

• 34• RO

AIN0 and AIN1 are also used for motor NTC temperature feedback in Edge4X.

voltage variable 100+ 200 3.3=

Page 83: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 80

5.3.8.2 ANALOG OUTPUT 0 SCALED (AOUTSC0)Percent of max

• 35• NT

5.3.8.3 ANALOG OUTPUT 1 (AOUT1)Value has range from 0 to 4095.

• 36• RO

5.3.8.4 ANALOG OUTPUT 1 - SCALED (AOUTSC1)Percent of max

• 37• NT

5.3.9 DIGITAL INPUTS/OUTPUTS XCD2 supports up to 16 GPIOs depending on the hardware configuration. Some pins allows re-configuration of their direction (Input/Output) in runtime using IO-direction (905) pseudovariable (refer to IO direction, page 84).

• As input, driving the pin to low/high (GND or VCC) will change the value of the corresponding variable to 0 or 1.

• As output, setting the variable value from 0 or 1 will affect the pin state GND or VCC.

5.3.9.1 DIGITAL INPUTS / OUTPUTS 0 - 15 (IO_0 - IO_15)Values can be 1 or 0

• 73 - 88• NT

5.3.10 FLAGS (ACCEPT VALUES 0 OR 1 ONLY)

5.3.10.1 MOTION IS IN PROGRESS (S_MOVE)Refer Dead Zone Mechanism, page 24

Page 84: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Variables

XCD2458000-00, Revision B 81

• 90• AX, RO

5.3.10.2 SERVO LOOP IS BUSY (S_BUSY)Refer Dead Zone Mechanism, page 24

• 91• AX, RO

5.3.10.3 INDEX POSITION LATCHED (S_IND)Refer to Position Latch and Encoder Index, page 131

• 92• AX, RO, ST

5.3.10.4 HOMING SUCCESSFUL (S_HOME)Refer to Home, page 41

• 93• AX, RO

5.3.10.5 IN-POSITION FLAG (S_INPOS)Refer Dead Zone Mechanism, page 24

• 94• AX, RO

5.3.10.6 SCOPE USER VALUE (SSTAT)Refer to Scope, page 108

• 114• NT

5.3.10.7 MOTION PHASE VARIABLE (MTNPHS)Refer to Position Profiler, page 16

• 115• AX

The following position profiler states are available:

Value State

Page 85: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Pseudovariables

XCD2458000-00, Revision B 82

5.3.10.8 SERVO TICK SYNCHRONIZATION VARIABLE (SERTICK)High on completion of each servo tick. see also Synchronization, page 92

• 117• ST

5.4 PSEUDOVARIABLESA pseudovariable has an ID but does not have a name. Pseudovariables can be accessed using the ASSIGN/REPORT command in the Comm Protocol or CONFIG/GETVAR in XMS.

The 4 bytes in the psuedovariable are filled with special content, not necessarily in Real format (for example binary bit structure).

0 ACCEL_BUILT_UP

1 ACCEL_CONST

2 ACCEL_RAMP_DOWN

3 VELOCITY_CONST

4 DECEL_BUILT_UP

5 DECEL_CONST

6 DECEL_RAMP_DOWN

7 IDLE

BKM when using XMS assign the pseudovariables using Hex code.

Page 86: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Pseudovariables

XCD2458000-00, Revision B 83

Table 9: Pseudovariables

ID Name Tag Comments

900 Status FL, AX

Corresponding 4 bytes in Controller's reply contain a bit mask with the following bits:

0 – Script Run flag (1 – script is running, 0 – not running)

1 – S_QUEUE flag

2 – S_MOVE flag

3 – S_BUSY flag

4-7 – Reserved

8 - Open Loop flag (1 – motor PWM is enabled, 0 – disabled)

9 – Reserved

10 – Motor enabled

11 – Velocity loop flag (1 – velocity is enabled, 0 – velocity loop disabled)

12 – First BiQuad filter enabled

13 - Second BiQuad filter enabled

14 - Reserved

15 – Reserved

16 - PWM Mode (0 – Linear (AB5) Mode, 1 – Normal (AB1A) Mode

17 - Motor flag (0 - EDGE/EDGE4X motor; 1 - HR Motor)

18 - Inverse Feedback

19 - Inverse Drive Output

20-31 (Reserved)

901 Program Status NT

Corresponding 4 bytes in Controller's reply are interpreted as follows

Bits 0-15: Currently executed program line

Bits 16-31: Status value:

0 - program was not executed

1 - execution is in progress

2 - program finished successfully

3 - program was terminated by a user

100 and above – program was terminated due to error. Value is the error (refer to Error Codes, page 85)

Page 87: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Pseudovariables

XCD2458000-00, Revision B 84

902 Safety Disable FL, AX

Corresponding 4 bytes in the Controller reply contain a bit mask with the following bits:

Bit 0 – Negative Limit

Bit 1 – Positive Limit

Bit 2 – Emergency Stop

Bit 3 – Motor Not Connected

• 0 = indicates enabled safety signal• 1 = indicates disabled safety signal

By default, all faults are enabled.

903 Safety Inverse FL, AX

Corresponding 4 bytes in Controller's reply contain a bit mask with the following bits:

Bit 0 – Negative Limit

Bit 1 – Positive Limit

Bit 2 – Emergency Stop

• 0 = active-high polarity (fault occurs if the signal has high level)

• 1 = active-low polarity.By default, all signals are active-low.

904 Safety state FL, AX

Corresponding 4 bytes in Controller's reply contain a bit mask with the following bits:

Bit 0 – Negative Limit

Bit 1 – Positive Limit

Bit 2 – Emergency Stop

Bit 3 – Motor Not Connected The result shows a raw state of the safety inputs.

• 0 = low voltage level• 1 = high voltage level.

905 IO direction FL

Corresponding 4 bytes in Controller's reply contain a bit mask. In the mask:

Bit 0 - behavior of IO_0

Bit 1 - behavior of IO_1

Bit 15 - behavior of IO_15

• 0 = IO is input• 1 = IO is output.

950 XMS checksum RO

Returns the checksum (32-bit integer) of XMS program in the Controller memory as calculated according to Adler-32 algorithm.

Table 9: Pseudovariables

ID Name Tag Comments

Page 88: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Error Codes

XCD2458000-00, Revision B 85

5.5 ERROR CODESWhen the XCD2 detects an error, the following actions take place:

• The error variable (Last error, page 85) is updated• The currently running XMS program is aborted, and motor action is

stopped• An error code appears as an XCD2 Commander popup

951 XMS length ROReturns the length (in bytes) of the XMS program (32-bit integer) in the Controller memory.

960 Last error AX

Returns a real value of the last error in the Controller. Refer to Error codes in Table 10, page 85. The XMS program reads the value using the GETVAR function. The XMS program running in non-stop mode can use the value to check if a motion has terminated successfully.

981 Axes number RO Number of supported axes in the system.

990 UART 0 address FL

Access to communication channel address. 991 UART 1

address FL

992 IIC address FL

993 SPI address FL

994Power Save Enable

FL1=enable0=disable

Table 9: Pseudovariables

ID Name Tag Comments

Table 10: Error Code

Code Comments

101Position Error - Absolute value of position error (PE) exceeds the value specified in the PEL parameter. The condition is checked only if PEL is enabled (PEL>0).

102 Software Limit - Feedback position FPOS is out of the range from SLN to SLP. The condition is checked only if SLN<SLP.

115 Motion Timeout - Motion continued for MTL milliseconds.

Page 89: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Error Codes

XCD2458000-00, Revision B 86

116 Wrong axis number – the requested axis is not valid.

120 Operation Failure - Special operation (homing or calibration) failed.

201 Illegal XMS instruction

204 Mathematical Error - The error occurs in an expression calculation. For example the function argument is out of range.

301 Unsupported Method - Unsupported method in special operation (homing or calibration) is requested.

Table 10: Error Code

Code Comments

Page 90: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 87

6 XMS - MOTION SCRIPTS

XCD Motion Script (XMS) is a script language that is designed to execute motion commands at XCD2 controller. XMS can be used to create programs to control XCD2 or to express motion algorithms.

6.1 OVERVIEWXMS has a unique set of commands and its own special syntax for organizing script commands. XMS is first compiled in the XCD2 Commander (refer to XCD2 Commander, page 136) to ensure that the script’s syntax is correct, then a binary image of the script is constructed and sent to the XCD2 Controller. The XCD2 Controller executes the script. This allows the user to save the XMS to Controller and run the script without HOST interruption.

Variable XAXIS defines the axis affected by XMS commands. The Controller starts with XAXIS value of 0, and all subsequent commands apply to axis 0. As soon as the XMS program assigns 1 to XAXIS, all subsequent commands refer to axis 1.

XMS scripts are executed when XCD2 operating system is not performing real-time tasks such as servo and signal processing tasks. That means that a number of XMS lines can be executed in the same time slot, providing the XMS functions do not require servo task synchronization. Refer to Synchronization, page 92 for information about the synchronization commands.

The following figure shows XMS execution order over the time.

Figure 6-1: XMS execution time scheme

Page 91: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Numbers

XCD2458000-00, Revision B 88

The XMS script for the above scheme has 4 lines:

Servo tasks run at a predefined rate and are executed in precise time slots (refer to Servo tick length in msec (SPRD), page 72). After completion of a servo task the XCD2 OS switches to the XMS task. The sequence shown in Figure 6-1.

6.2 NUMBERS

6.2.1 FLOATING POINT VALUES

All numbers in XMS program are floating point values complying with the IEEE 754 definition of single precision arithmetic. The values range is [-3.4×1038, 3.4×1038] approximately. All calculations are performed using single-precision floating numbers.

nmove FPOS+10 // move for 10 user unit (mm for linear applications or degrees or radians for rotary applications) from current position. There are two action performed in this line: Addition of 10 to feedback position; Sending move command to servo module.

while S_BUSY // polling of S_BUSY flag. S_BUSY flag goes high, equal 1, after a new motion command enters motion queue at servo module. S_BUSY flag goes low, equal zero, after motion platform enters dead-zone minimum.

end

disable // disable servo and motor

Time Description

1The sum of current position and 10 is calculated. The MOVE command with the sum is placed in the servo command queue. XMS is halted till next servo tick is done.

2S_BUSY is checked one time. XMS stays at line 2 & 3 because S_BUSY equals 1. The servo task took longer than average because it needed to calculate the motion profile request.

3 S_BUSY is checked multiple times. XMS stays at line 2 & 3 because S_BUSY is equal 1.

N-1S_BUSY is checked one time. XMS goes at line 4 because S_BUSY is equal 0. Disable command is placed in the servo command queue. XMS is halted until the next servo tick is done.

N XMS finished execution.

Page 92: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Units

XCD2458000-00, Revision B 89

6.2.2 LITERAL CONSTANTS

In the XMS program, literal constant can appear in different formats. The format of the literal constant has no effect on its internal presentation; the controller converts each constant to a floating point number before using it in calculations.

6.3 UNITSThe XCD2 controller uses discrete units of measure. Time is expressed in milliseconds (msec) and scaled values are a percent of the maximum possible. Units of position or distance are based on the user’s application. Throughout this document these are referred to as User Units. The User Units can be expressed in standard units of measure expressed as millimeter, degree, or radian. These units are typically based on an encoder mounted on the stage. To convert User Units to units for the XCD2 a scaling factor is used. The Encoder Resolution (ENR) provides this conversion. Physical values such as position, velocity, and acceleration are derived using the ENR.

The following table shows the variables unit’s relation when ENR provides a physical measurement in millimeters for a linear application. For example, with a 1 micron encoder the ENR should be set to 0.001 so that the User Units are in millimeters.

Table 1: Literal Constants Formats in XMS

Format Examples

Integer 1, 20, -1078

Real 0.1, 20.35, 0.000009

Scientific 1e-5, 2.3e10

Hexadecimal 0x07FF, 0x1E23

Table 2: Measuring Units for Physical Values

Value Example of variables example User Units

position/distance POS, RPOS, FPOS, TPOS millimeter (mm)

velocity VEL, RVEL, FVEL millimeter per second (mm/sec)

acceleration ACCmillimeter per second per second (mm/sec2)

time TIME millisecond (msec)

scaled values AIN0, AOUT1, DOUT percent of maximum (%)

Page 93: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Syntax

XCD2458000-00, Revision B 90

6.4 SYNTAXThe Syntax is equivalent to the spelling and grammar of a programming language. XCD2 understands only the exact form that the XCD2 expects. That expected form is called the syntax. The following table summarizes XCD2 - XMS syntax.

Table 3: Syntax

Element Type Description and Examples

Variables XMS variable Variables, page 71

Set

Sets a special variable. The command resembles assignment, but unlike regular assignment causes special actions. The command applies to limited set of variables that are read-only and cannot be addressed in regular assignment.

Literal constants 10, -0.0001, 0x0FFF, 3.256E2

Arithmetic operators

Arithmetic operations result in a real number.+ adds two operands- subtracts second operand from the first* multiplies both operands/ divides numerator by denominator = assignment to variable

Compare operators

Operation results in an integer. These operators that are used in decision control statements.= equal<> not-equal < less than <= less than or equal to > greater than >= greater than or equal to

Logical operators

Operation results in an integer& logical AND operator| logical OR operator^ logical XOR operator

Decision control statements

if - statement will execute if the expression is true. else - statement will execute if the expression of if statement is false. Note:end syntax is needed at the end of the statement

Page 94: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Built-in Functions

XCD2458000-00, Revision B 91

6.5 BUILT-IN FUNCTIONSThe following table shows built-in functions that the XMS language provides that can be used in expressions along with variables and constants.

6.6 XMS SCRIPT EXAMPLESThis section provides example XMS scripts for both linear and rotary applications.

Count-controlled loops

For V0 = 0 to 10 – repeat the statement 11 times while every statement V0 variable increments by 1. For V0 = 0 to 2 step 0.5 – repeat the statement 5 times while every statement V0 variable increases by 0.5.Note:• Only user variables (Variables, page 71) can

be used for statement control• end syntax is needed at the end of the

statement

Condition-controlled loops

while (statement) – repeating loop until condition is true or non-equal to zero.Note:end syntax is needed at the end of the statement

Table 3: Syntax

Element Type Description and Examples

Table 4: Built-in Functions

Function Purpose Comment

abs Calculates absolute value of an argument.

The argument can be any number.

sin Calculates sine of an argument.

cos Calculates cosine of an argument.

tan Calculates tangent of an argument

sqrt Calculates square root of an argument.

The argument can be any zero or positive number.

rand Calculates real number for uniform distribution.

Function does not take any argument.

Page 95: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 92

6.6.1 SYNCHRONIZATION

The servo synchronization variable will go high (one) on each servo tick completion. Related variable Servo tick length in msec (SPRD), page 72.

XMS ExampleIn the following example, if servo rate is 20k, a 1 second movement will result in:

V1 = 20000

V2 = unknown value (may vary depending on SPRD and controller utilization)

V3 = 1000

6.6.2 XMS SCRIPT FOR A LINEAR APPLICATION

The following linear motion program example executes a set of motions. Each motion is positioned to a point in the range of 0 to 20 mm.

set TIME = 0

nmove 25

while (S_BUSY = 1)

if (SERVOTICK = 1)

V1 = V1 + 1

set SERVOTICK = 0else

V2 = V2 + 1end

end

V3 = TIME

// Seed of random number generator

// assigned to variable V10.

V10=999

// Homing, method 0 to the left hard-stop

home 0

// while loop executes forever, as

// condition expression is always non-zero.

while 1

Page 96: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 93

// for loop executes 6 times,

// loop variable V1 changes from 0 to 5.

for V1=0 to 5

// Force-back move - Inner for loop executes 6 times,

// loop variable V0 changes from 0 to 5.

for V0=0 to 5

// Set a required motion velocity.

// Velocity starts from 10 mm/sec,

// then rises to 45, 80, 115, 150

// and finally reaches 185 mm/sec.

VEL=10+V0*35

// move to absolute position 5 mm.

move 5

// move to absolute position 15 mm.

move 15

end //end of "for V0=0 to 5 ".

//move to absolute position 0 mm.

move 0

// Incremental move forward -Inner for loop executes

// 4 times, loop variable V0 changes from 0 to 5.

for V0=0 to 3

//move to relative position, increment 4 mm.

move RPOS+4

//delay for 100 milliseconds.

delay 100

end //end of "for V0=0 to 3".

// Incremental move backward - Inner for loop executes

// 4 times, loop variable V0 changes from 0 to 5.

for V0=0 to 3

//move to relative position, increment -4 mm.

move RPOS-4

//delay for 100 milliseconds.

Page 97: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 94

delay 100

end //end of inner for loop.

// Variable step forward - Inner for loop executes 8 times,

// loop variable V0 changes from 1 to 8.

for V0=0.5 to 4 step 0.5

// move to relative position, increments 0.5, 1, 1.5, etc.

move RPOS+V0

//delay for 100 milliseconds.

delay 100

end //end of "for V0=0.5 to 4 step 0.5".

// Variable step forward - Inner for loop executes 8 times,

// loop variable V0 changes from 1 to 8.

for V0=0.5 to 4 step 0.5

//move to relative position, increments -0.5, -1, -1.5, etc.

move RPOS-V0

//delay for 100 milliseconds.

delay 100

end //end of "for V0=0.5 to 4 step 0.5".

end //end of "for V1=0 to 5"

// Positioning to random points - for loop executes 201 times,

// loop variable V1 changes from 0 to 200

for V1=0 to 200 //.

// Random number generator (11 bits)

// At each cycle generate a random number between 0 and

// 2048. Symbol "&" designates logical AND. Literal 0x07FF is

// hexadecimal constant, equal to decimal 2047.

// V10 is random number in the range of 0 to 2048.

V10=V10*993+1

V10=V10&0x07FF

Page 98: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 95

6.6.2.1 XMS SCRIPT FOR A ROTARY APPLICATIONThe following example motion program performs a series of tests on a rotary stage with hard-stops to determine the stage ability to operate correctly. The program locates the stage’s hard stops, identifies the index, and then runs a four hour conditioning program. The following is an example of an XMS script for rotary motion program.

// move to random absolute position in the range from 0 to 18 mm.

move 18*V10/2048

// delay for 100 milliseconds

delay 100

end // end of "for V1=0 to 200"end // end of "while 1"

ENR = 360/1184000 // Define user units in degrees

DZMIN = ENR // DZMIN is set equal to Encoder resolution

DZMAX = 15*ENR // DZMAX is set to 15 times the Encoder resolution

PEL = 5 // Sets maximum position error to 5 degrees

ZFF = 0.003 // Zero Feed Forward is set to 0.003 degrees

FRN = 10 // Negative Friction is set to 10%

FRP = 10 // Positive Friction is set to 10%

MTL = 60000 // Maximum TIME Limit is set to 60 seconds

KP = 300 // Position error gain

KV = 0.5 // Velocity and position error gain

KI = 300 // Integrator gain

LI = 60 // Integrator limiter

VEL = 40 // Velocity is set to 40 deg/sec

ACC = 500 // Acceleration is set to 500 deg/second2

KDEC = 1000 // Kill deceleration at 1000 deg/sec2

V0 = 0 // user variable for home offset

Page 99: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 96

// Find the negative hard-stop - move in a negative direction

// to a position that is larger than the hard-stop. In this case

nmove -500

// The loop continues as long as the absolute position error (PE) is

// smaller than -0.5 degree.

while abs(PE) < 0.5

end

// When the PE is greater than 0.5 degree stop the loop because

// the hard-stop has been found, and disable motor.

disable

// Reset index flag

set S_IND = 0

//Find the Position Index and set the Index Position to Home offset (V0)

nmove 360

// Wait until index not found

while S_IND=0

end

// kill motion

kill

delay 100

//for V0=0 set the index position to 0 position

set FPOS=FPOS-POSI-V0

//Find Home offset

nmove -360

while abs(PE) < 0.5

end

// disable the motor

disable

// This value is the distance of the Index from the middle of the stage

Page 100: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 97

V0=FPOS+185

// Set the negative hard-stop position to -5 degrees

set FPOS=-5

// set the velocity to 120 deg/sec

VEL = 120

// is the maximum positive position error when the

// reference velocity is in the constant velocity range.

V2 = 0

// is the minimum position error when the reference

// velocity is in the constant velocity range.

V3 = 0

// is the maximum positive PWM (DOUT)

V4 = 0

// is the minimum negative PWM (DOUT)

V5 = 0

// Reset current TIME

set TIME = 0

// Finds maximum and minimum position error, maximum and minimum DOUT

// over the total stage travel during a four hour period

while TIME < (4*3600000)

// move to 360 degree

nmove 360

delay 2

// Skip acceleration phase, reference velocity no equal

// to target velocity.

while RVEL <> VEL

end

// while in the acceleration is zero (constant velocity phase)

Page 101: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 98

// the loop will continue

while RVEL = VEL

// Measures the maximum of position error

if PE > V2

V2 = PE

end

// Measures the minimum of position error

if PE < V3

V3 = PE

end

// Measure maximum PWM of positive command

if DOUT > V4

V4 = DOUT

end

end // end of "while RVEL = VEL".

// wait till platform reach target zone of 360 degree

while S_BUSY

end

// wait a second

delay 1000

// move to 0 degree

nmove 0

delay 2

// Skip acceleration phase, reference velocity not equal

// to target velocity.

while RVEL <> -VEL

end

// while in the acceleration is zero (constant velocity phase)

// the loop will continue

while RVEL = -VEL

// Measures the maximum of position error

if PE > V2

Page 102: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 99

6.6.3 XMS FOR MULTI-AXES APPLICATION

This section provides an example script for dual axes application. XMS assumptions are:

• XCD2 has 2 circular axes• Axis 0 – has range of [-30°,110°]• Axis 1 – has range of ±175

XMS written in a state-machine manner, while user can control the XMS by assigning a value in the V0 variable. The State machine has the following states:

• V0 is equal to 0 – IDLE state.• V0 is equal to 1 – enable servo loop (keep current position) at both

axes.• V0 is equal to 2 – disable motors at both axes.• V0 is equal to 3 – scan whole range of both axes with continuous

movements.

V2 = PE

end

// Measures the minimum of position error

if PE < V3

V3 = PE

end

// Measure minimum PWM of negative command

if DOUT < V5

V5 = DOUT

end

end

// wait till platform reach target zone of 0 degree

while S_BUSY

end

// wait a second

delay 1000

end

Page 103: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 100

• V0 is equal to 4 – homing procedure for both axes.• V0 is equal to 5 – go to user specific location {x, y}, while x get its

value from V1 variable and y get its value from V2 variable• V0 is equal to 6 – scan whole range at both axes with steps

movements.

// time for system start up sequence

delay 2000

// Set state machine to IDLE

V0=0

// Start infinite loop

while 1

// Enable two axes

if V0 = 1

// Set state machine to IDLE

V0 = 0

// Set working axis to 1

XAXIS = 1

// enable servo loop

enable

// Set working axis to 0

XAXIS=0

// enable servo loop

enable

end // end of "if V0 = 1".

// Disable two axes

if V0 = 2

// Set state machine to IDLE

V0 = 0

// Set working axis to 1

XAXIS=1

// disable servo loop and motor

disable

// Set working axis to 0

Page 104: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 101

XAXIS=0

// disable servo loop and motor

disable

end // end of "if V0 = 2".

// scan over whole range

if V0 = 3

// move to start position

// Set working axis to 0

XAXIS = 0

move 110

// Set working axis to 1

XAXIS = 1

move 175

delay 1000

// start point-to-point infinite movement loop

// until V0=0 (set by user)

while V0

// Set working axis to 0

XAXIS = 0

// non-conditional movement

nmove -30

// Set working axis to 1

XAXIS = 1

// conditional movement - script will stack on this

// line until deceleration phase finished.

move -175

delay 1000

// Set working axis to 0

XAXIS = 0

// non-conditional movement

nmove 110

// Set working axis to 1

Page 105: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 102

XAXIS = 1

// conditional movement - script will stack on this

// line until deceleration phase finished.

move 175

delay 1000

end

// Set working axis to 0

XAXIS=0

// disable servo loop and motor

disable

// Set working axis to 1

XAXIS=1

// disable servo loop and motor

disable

end //of scan V0=5

// homing

if V0=4

// Set state machine to IDLE

V0 = 0

// Go over both axes

for V1 = 0 to 1

// Set working axis

XAXIS = V1

// sample current position

V3 = FPOS

// move with constant velocity till hard-stop found

velocityloop 100

// Keep searching for hard-stop

V2=1

while V2

// wait 10 msec

delay 10

Page 106: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 103

// check if position difference is zero

if abs(FPOS-V3) < 20*ENR

// stop searching for hard-stop

V2 = 0

// disable servo loop and motor

disable

end

// sample current position

V3=FPOS

end // end of "while V2".

// Assign new position

if V1 = 0

// Axis 0 has hard stop at 110 degree

set FPOS = 110

else

// Axis 0 has hard stop at 175 degree

set FPOS = 175

end // end of "if V1 = 0".

end // end of "for V1 = 0 to 1".

end // end of homing V0 = 4

// go to user specific position

if V0=5

// Set state machine to IDLE

V0 = 0

// Set working axis to 0

XAXIS=0

// calculate distance to travel for axis 0

V4=abs(FPOS-V1)

// store current position of axis 1

XAXIS=1

// calculate distance to travel for axis 0

V5=abs(FPOS-V2)

Page 107: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 104

// make decision what axis has a longer movement

if V5 < V4

// Set working axis to 1

XAXIS = 1

// non-conditional movement

nmove V2

// Set working axis to 0

XAXIS = 0

// conditional movement - script will stack on this

// line until deceleration phase finished.

move V1

else

// Set working axis to 0

XAXIS = 0

// non-conditional movement

nmove V1

// Set working axis to 1

XAXIS = 1

// conditional movement - script will stack on this

// line until deceleration phase finished.

move V2

end // end of "if V5 < V4".

// disable axis if V3 not equal zero

if V3 <> 0

// Set working axis to 1

XAXIS = 1

// disable servo loop and motor

disable

// Set working axis to 0

XAXIS = 0

Page 108: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 105

// disable servo loop and motor

disable

end // end of "if V3".

end // end of "if V0=7"

// step and steer movement over whole motion range

// at both axes

if V0=6

// axis 0 step

V3 = 10

// axis 0 start position

V5 = 0

// axis 1 step

V4 = 10

// axis 1 start position

V6 = 0

// Default delay between movements

V10 = 1000

// continue executing inner loop till user won't reset V0

while V0

// Set working axis to 1

XAXIS = 1

// non-conditional movement

nmove V5

// Set working axis to 0

XAXIS = 0

// non-conditional movement

nmove V6

// Set working axis to 1

XAXIS = 1

// sample motion profile

V7 = S_MOVE

Page 109: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 106

// Set working axis to 0

XAXIS=0

// sample motion profile

V8 = S_MOVE

// Wait for the end of motion of both axis

while V7 | V8

// Set working axis to 1

XAXIS = 1

// sample motion profile

V7 = S_MOVE

// Set working axis to 0

XAXIS=0

// sample motion profile

V8 = S_MOVE

end // end of "while V7 | V8".

// Wait time between motions

delay V10

// update next point for axis 0

V5 = V5 + V3

// check axis 0 limits

if V5 > 110 | V5 < -30

// swap direction

V3 = -V3

// update next point

V5 = V5 + V3

end // end of "if V5 > 110 | V5 < -30".

// update next point for axis 1

V6 = V6 + V4

// check axis 0 limits

if V6 > 175 | V6 < -175

// swap direction

Page 110: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XMS Script Examples

XCD2458000-00, Revision B 107

V4 = -V4

// update next point for axis 1

V6 = V6 + V4

end // end of "if V6 > 175 | V6 < -175".

end

// Set working axis to 1

XAXIS = 1

// disable servo loop and motor

disable

// Set working axis to 0

XAXIS = 0

// disable servo loop and motor

disable

end // of V0=8

end // end of "while 1".

Page 111: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 108

7 SPECIAL FEATURES

The document is organized in following way

• Scope, page 108• Power Save, page 109• Motor Frequency Calibration, page 110• Communication Bridge, page 114• Gyro Module, page 123

7.1 SCOPEThe scope module allows streaming of any internal variables data at full servo rate. The data can be streamed in any of the UART channels at a configurable baud-rate. In order to overcome the possible baud-rate/data-rate limitation it’s possible to reduce the data-rate by:

• Selecting 16bit float (*) instead of 32bit• Diluting the transitions to 1/k servo rate

Scope usage steps:

• Enable the scope module and configures its communication channel (UART 0 or 1)

• Configure scope sample channels• Activate streaming of data

Scope streams data packets. Each data packet contains 2 sync bytes and a status byte.

0xD7 <Status Byte> <Data> 0xA5

(*) a standard floating point (single, 32bit) is not converted to half-precision but instead it’s shifted by 16 bits. The only thing affected is the LSB of the mantissa. The exponent part is still 8bits.

To interpret the value the data needs to be shifted back into 32bits.

Page 112: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Power Save

XCD2458000-00, Revision B 109

Data contains all of the channels, 16 or 32bit each (e.g 2 channels of 16bit + 1 channel of 32bit = 8bytes of data + 3 bytes of overhead)

7.2 POWER SAVEWhen Power-Save-Mode is enabled, the controller will wake up every 100ms to parse communication messages and check its position. If movement has occurred, it will perform position correction and resume Power Save mode. The use the Power Save module and related pins must be considered during HW design.

During Power Save:

• all peripheral components (ADC, Timers, etc) are turned off• a Power-Save bit is added to each pin changing it to analog input

Power Save is enabled/disabled using pseudovariable Power Save Enable, page 85.

Figure 7-1: Power Save Enable Window in XCD2 Commander

All Scope actions can be initiated through Comm Protocol or from the XCD2 Com-mander. XMS scripts provide starting and stopping Scope. Refer to Scope, page 48

For use of the XCD2 Commander to configure the Scope refer to Scope, page 145

In power save mode communication is parsed every 100ms. This will cause the XCD2 Commander GUI to be unresponsive.

Page 113: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Motor Frequency Calibration

XCD2458000-00, Revision B 110

7.3 MOTOR FREQUENCY CALIBRATIONThe ideal frequency needed to drive a piezo motor shifts in correlation with the temperature. The first step in calibration is determining the correct operating frequency. Because temperature affects the ideal operating frequency of the motor, the system determines the current temperature and shifts the operating frequency to adjust for the temperature.

7.3.1 FREQUENCY CALIBRATION

The system finds the frequency at which the motor has maximum speed in steady-state (discounting acceleration, dead zone and other movement initiation issues). The calibration process covers a range of frequencies, moving the motor in Open Loop (fixed PWM) for a fixed amount of time (ms) in the same region (forward and backward movement). It looks for the best delta-movement. If the best frequency is between the two maximum measured points the weighted average is calculated:

Figure 7-3 and Figure 7-4 show the expected Frequency vs Move distance behavior. This is the basis of the calibration.

Figure 7-2: Frequency vs Move distance

Only one axis at a time can be calibrated.

Page 114: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Motor Frequency Calibration

XCD2458000-00, Revision B 111

Figure 7-3: Optimal frequency calculation

If the best movement distance found during the calibration is smaller than the minimum travel distance (MCF_TD, page 112), the frequency will return to its previous value and an error flag is displayed.

The resulting calibration frequency is saved as variable MFREQOFFS. This the offset between the calibration value and the calculated temperature/frequency look up table (Temperature Compensation Algorithm, page 113).

7.3.1.1 VARIABLESThe parameters will be saved as global variables (same for all axes) and accessible to the user and XMS. The following table shows the calibration variables:

MFREQOFFS TempCompensationFreq CalibrationFrequency –=

Table 1: Calibration variables

VAR ID Name Description Initial value

63 MCF_SF Start frequency 153000 Hz

66 MCF_FF Finish frequency 190000 Hz

102 MCF_TS Total steps 12

103 MCF_AT Acceleration time 0 millisecond

104 MCF_TT Travel time 5 msec

105 MCF_PL PWM level 60 %

Page 115: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Motor Frequency Calibration

XCD2458000-00, Revision B 112

The following parameters are saved to the flash and configured upon power-up:

• MFREQ• MFREQ1• MFREQOFFS

Figure 7-4 shows the maximum distance traveled at each temperature.

Figure 7-4: Temperature vs Frequency vs Distance, Axis 1

106 MCF_TD Minimum travel distance 0.2 mm

108 MCF_DB Deceleration time 2 msec

109 MCF_DT Debug output – maximum distance traveled [output]

110MFREQOFFS

Calibration result – offset from frequency lookup table value to match the desired calibration frequency.

[output]

Table 1: Calibration variables

VAR ID Name Description Initial value

Page 116: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Motor Frequency Calibration

XCD2458000-00, Revision B 113

7.3.2 TEMPERATURE COMPENSATION ALGORITHM

Temperature Compensation matches the optimal motor frequency to the current motor temperature using a predefined lookup table.

The system samples the temperature and preforms a low pass filter (e.g. 1sec average) on the readings. When the temperature passes the hysteresis value, MFREQHYST, page 113, a new frequency is calculated and applied

Note that there is an inverse relation between the temperatures and frequencies, the lower the temperature the higher the optimal operating frequency.

7.3.2.1 VARIABLES

7.3.2.2 TEMPERATURE MEASUREMENT CONFIGURATIONEach axis is coupled with Analog input index and two configuration bits:

7.3.2.3 CONVERSION FROM ADC VALUES TO DEGREES CELSIUSTemperature measurement is based on a Thermistor connected in parallel to a fixed value resistor, the ratio changes the voltage sampled by the ADC. The ADC sampler is configured to provide a value that ranges from 0% to 100%,

Table 2: Temperature Compensation variables

VAR ID Name Description Initial value

107 MTTMP Motor temperature after LPS, axis depended. [Output]

110 MFREQOFFS Frequency offset, calculated by Frequency Calibration Algorithm. 0

111 MFREQHYST Temperature hysteresis 5 degrees

Table 3: Temperature and drift bit configuration

Bits Name Description

[0..4]Analog input index

Corresponding AIN index; possible values 0 … 19

[5]Process temperature

Read and process ADC data1 = Enabled

[6] Process frequency correction

Calculate and update motor frequency1 = Enabled.

Page 117: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Bridge

XCD2458000-00, Revision B 114

where 0% = 0V and 100% = 3.3V, for each axis (AI0, AI1). A lookup table is used to convert these values to temperature in Celsius.

7.4 COMMUNICATION BRIDGEXCD2 serves as a communication bridge, transferring data from the HOST to peripheral devices with serial communications (UART, IIC and SPI). The Bridge channels are defined during HW design and configuration.

Figure 7-5: Functional Block Diagram

7.4.1 BRIDGE CONFIGURATION

The following section describes the steps required in order to configure a communications channel as an Active bridging channel.

7.4.1.1 BRIDGE CONFIGURATIONThe following steps define the configuration process.

1. Enable the selected channel Bridge module.

2. Configure the HOST channels characteristics (e.g Clock, Phase, etc)

3. The HOST performs read/write operations to devices through XCD2 HW

Host is responsible for connecting and constructing the device messages accordingly to device specification. This is accomplished by populating XCD2 control registers and buffers. Refer to Bridge Buffer write, page 39, and Bridge Buffer read, page 40.

Page 118: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Bridge

XCD2458000-00, Revision B 115

Figure 7-6: Device Message

7.4.2 VARIABLES

In the following Variable names the xxxx can be UART (Base=5376), IIC (Base=5120) or SPI (Base=4864) string.

Table 4: Communication Bridge XMS Variables

ID Name Flag Variable Description

Base+0000 xxxxCNTR NT control variable

Base+002 xxxxRXLEN NT number of bytes to receive

Base+003 xxxxRXCNT RO number of received bytes

Base+004 xxxxTXLEN NT number of bytes to transmit

Base+005 xxxxTXCNT RO number of bytes transmitted

Base+008 ...Base+071

xxxxRX00...XXXXRX63

RO data of received bytes

Base+072...Base+135

xxxxTX00...XXXXTX63

NT data of bytes to transmit

SPI will perform a read on every clock (write or read)

Page 119: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Bridge

XCD2458000-00, Revision B 116

7.4.3 COMMUNICATION CHANNEL REGISTERS

7.4.3.1 UART CONFIGURATION AND STATUS VARIABLE

Bit description• EN: Channel enable

• 0: channel disabled• 1: channel enabled

• BR: Baud rate• 0 – 9.6 kbps, 1 – 19.2 kbps, • 2 – 38.4 kbps, 3 – 57.6 kbps• 4 – 115.2 kbps, 5 – 230.4 kbps, • 6 – 460.8 kbps, 7 – 921.6 kbps, • 8 – 2 Mbps, 9 - 3 Mbps

• DW9: 9 bit Data width• 0: 8 bit data width• 1: 9 bit data width

• SBS: Stop bit size• 0: 1 stop bit• 1: 2 stop bit

• PT: Parity type• 0: None• 1: Even• 2: Odd

• ST: Start Transaction• Write 1 to start transmit/receive sessions. This bit is reset

by the FM or if UL is 1.• UL: Unlock

• Write 1 to enable configuration changes and mid transaction termination.

Table 5: UARTCRRT

31-10 15 14 13-5 8 7 6 5 4 3 2 1 0

Reserved UL ST Reserved PT SBS DW9

BR EN

r w/r w/r r r/w r/w r/w r/w r/w

Page 120: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Bridge

XCD2458000-00, Revision B 117

7.4.3.2 IIC CONFIGURATION AND STATUS VARIABLE

Bit description• EN: Channel enable

• 0: channel disabled• 1: channel enabled

• AAM: Acknowledged Address mode• 0: 7 bit address• 1: 10 bit address

• CLK: Clock speed• 0 - 50 kHz, 1 - 100 kHz,• 2 - 150 kHz, 3 - 200 kHz,• 4 - 250 kHz, 5 - 300 kHz,• 6 - 350 kHz, 7 - 400 kHz

• ST: Start Transaction• Write 1 to start transmit/receive sessions. This bit is reset

by the FM or if UL is 1.• UL: Unlock

• Write 1 to enable configuration changes and mid transaction termination.

7.4.3.3 SPI CONFIGURATION AND STATUS VARIABLE

Bit description• EN: Channel enable

• 0: channel disabled

Table 6: IICCNTR

31-7 15 14 13-5 4 3 2 1 0

Reserved UL ST Reserved CLK AAM ENr w/r w/r r r/w r/w r/w

Table 7: SPICNRT

31-16 15 14 13-6 5 4 3 2 1 0

Reserved UL ST Reserved CLK PHA POL ENr w/r w/r r r/w r/w r/w r/w

Page 121: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Communication Bridge

XCD2458000-00, Revision B 118

• 1: channel enabled• POL: Clock Polarity

• 0: Clock is 0 when idle• 1: Clock is 1 when idle

• PHA: Clock phase• 0: The first clock transition is the first data capture edge• 1: The second clock transition is the first data capture

edge• CLK: Clock speed

• 0 - 21.00 MHz, 1 - 10.50 MHz,• 2 - 5.25 MHz, 3 - 2.62 MHz,• 4 - 1.31 MHz, 5 - 0.66 MHz,• 6 - 0.33 MHz, 7 - 0.16 MHz

• ST: Start Transaction• Write 1 to start transmit/receive sessions. This bit is reset

by the FM or if UL is 1.• UL: Unlock

• Write 1 to enable configuration changes and mid transaction termination. SPI Configuration and Status Variable

Page 122: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 119

7.4.4 EXAMPLE

Figure 7-7: Example of Bridge transaction execution

7.5 GYRO

7.5.1 MODULE OVERVIEW

This paragraph provides detailed overview of gyroscope SW module and its usage that is integrated in the XCD2 FW. The XCD2 works with the MCU MEMS gyroscope.

The XCD2 FW is designed to support a 6-axis device that combines a 3-axis gyroscope, 3-axis accelerometer.

Page 123: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 120

7.5.2 DRIFT COMPENSATION

One of the challenges to work with MEMS gyroscopes is drift. Drift occurs due to thermal variations that cause the mechanical properties of the vibrating thermal mass to fluctuate over time, leading to a systematic error. The following subsections explain the method of minimizing drift.

7.5.2.1 BIAS CANCELATIONThe local solution to cancel a drift from a gyroscope is to subtract the average bias. The following equation shows the new angular velocity after subtracting the average bias.

Equation 7-1

To activate the mechanism assign the Gyro XMS variable GAVEREN, page 131 to 1. However, new is updated after the averaging window, XMS variable GAVERTIME, page 131, is passed. The number of samples is calculated by the FW based on the following equation.

Equation 7-2

• GAVERTIME specifies averaging time in milliseconds.• SPRD specifies servo loop sampling period in milliseconds

7.5.2.2 TEMPERATURE DRIFT COMPENSATIONGyroscope temperature drift compensation is done by polynomial approximation. The temperature (T) is measured by MPU-6000. A 2nd order polynomial function matches the approximation error criteria. Equation 7-3 shows the drift approximation model for a single axis. The drift of each axis is calculated with this equation.

Equation 7-3

new1N---- i

i 0=

N

=

NGAVERTIME

SPRD-----------------------------------=

b2T2

b1T b0+ +=

Page 124: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 121

Drift coefficients are available using the Gyro Module Interface, page 129. There are nine XMS Gyro variables, 3 coefficients for each of the axes (refer to Table 11, page 129). In the variable structure (ex: GTDFTxCi) x can be X, Y and Z and i can be 0, 1 and 2.

Figure 7-8 shows experiment measurements of the gyroscope behavior over the temperature range and its approximation curve.

Figure 7-8: Gyro temperature drift approximation

7.5.3 MECHANICAL INSTALLATION

To be independent of the gyroscope’s mechanical installation an orientation matrix is used. The stage axes are transformed into 3 XCD2 axes. Refer to

Page 125: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 122

Figure 7-9 and Equation 7-5 while Aorientation is a 3x3 matrix, refer to Equation 7-4.

Figure 7-9: MCU Installation at XCD2

Equation 7-4

Equation 7-5

The orientation matrix can be accessed by variables GORxx, refer to Table 11, page 129.

Equation 7-6

Aorientation

axx axy axz

ayx ayy ayz

azx azy azz

=

raw Aorientation mpu6000=

XCD2 gyroscope axes, xy, and z are fixed

Page 126: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 123

7.5.4 GYRO MODULE

The transformation from 3 axes gyroscope to 2 axes is done by equation Equation 7-7, while xy, and z are calculated by Equation 7-8.

Equation 7-7

Equation 7-8

Velocity feedback switching between encoder derivative and gyroscope is performed with the OPMODE variable, refer to paragraph 7.5.5 for a description of OPMODE behavior and Table 10, page 129.

Servo presets are an additional feature that provides a flexible option to support different servo tuning parameters.

7.5.5 OPERATION MODES

XCD2 has an embedded function that switches feedback types and provides a load/store operation for servo presets. The operation mode is controlled by the variable OPMODE, page 127.

Figure 7-10: Gyro Modes in Stabilization

axis0 x=

axis1 y axis0cos z axis0sin+=

raw aver– drift–=

Page 127: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 124

Table 8: Operation Mode Description

OPMODE Value

Mode Name Mode Description

0 Encoder

This is the standard motion mode. An encoder is used to provide position and velocity feedback. When OPMODE is assign 0: • Both axes are disabled• Axis 0 servo loop parameters are stored to

preset number (OPMODE*2)• Axis 1 servo loop parameters are stored to

preset number (OPMODE*2+1)• Encoder is used as position feedback• PRPFT is equal to 0• Encoder derivative is used as velocity

feedback• PRVFT is equal to 0• Preset 0 is loaded to servo loop for axis 0• Preset 1 is loaded to servo loop for axis 1

1 Gyro

The gyroscope used for velocity feedback (refer to Figure 7-11). The encoder is used for position feedback, but position error gain KP is set to zero.

When OPMODE is assign to 1, then:• Both axes are disabled • Axis 0 servo loop parameters are stored to

preset number (OPMODE*2)• Axis 1 servo loop parameters are stored to

preset number (OPMODE*2+1)• Encoder is used as position feedback• PRPFT is equal to 0• Gyroscope is used as velocity feedback• PRVFT is equal to 1• Preset 2 is loaded to servo loop for axis 0• Preset 3 is loaded to servo loop for axis 1

Page 128: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 125

Figure 7-11: Line of sight stabilization

2 Encoder – Gyro

In Encoder/Gyro mode the body where XCD2 is mounted (refer to Figure 7-12) is the reference. The encoder is used for position feedback and the gyroscope for velocity feedback. High frequency noise is suppressed, but XCD2 will follow the main body movements. When OPMODE assign to 2• Both axes disabled • Axis 0 servo loop parameters are stored to

preset number (OPMODE*2)• Axis 1 servo loop parameters are stored to

preset number (OPMODE*2+1)• Encoder is used as position feedback PRPFT

is equal to 0. • Gyroscope is used as velocity feedback.

PRVFT is equal to 1• Preset 4 is loaded to servo loop for axis 0• Preset 5 is loaded to servo loop for axis 1

Table 8: Operation Mode Description

OPMODE Value

Mode Name Mode Description

To ensure stabilization working properly, set OPMODE to 1 or 2, and disable the dead-zone mechanism by setting DZMIN to a negative value.

Page 129: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 126

Figure 7-12: Body stabilization

7.5.6 XMS VARIABLES FOR GYROSCOPE

XMS variables can be used either in an XMS program or in Host communication. When used in the XMS program, variables are referenced by name. All variable names are predefined. the user cannot create variable names.

In Host communication, the commands ASSIGN, REPORT, and MONITOR refer to the variable by a 16-bit ID.

Table 10 summarizes the XMS variables. For each variable, the table specifies next parameters:

• ID for use in report/assign variable command• Name for use in XMS program• Variable tags:

• FL – Variable is saved to flash memory at SAVE PARAMETERS command and loaded at power up

• RO – read only variable

In the following table the name of many variables has an x syntax (ex. PRxKP). The x refers to preset number that can vary from 0 to 7. I

First ID is x=0second ID is x=1…last ID is x=7

Page 130: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 127

Table 9: Servo Preset XMS variables

ID Name Tag Comments

1025 PRPFT ROPosition feedback type:0 – encoder1 - gyroscope

1026 PRVFT ROVelocity feedback type: 0 – encoder 1 - gyroscope

1251 OPMODE FL Operation mode control.

1027, 1055, 1083, 1111, 1139, 1167, 1195, 1223 PRxKP FL Position loop gain

1028, 1056, 1084, 1112, 1140, 1168, 1196, 1224 PRxPKI FL Position loop integrator gain

1029, 1057, 1085, 1113, 1141, 1169, 1197, 1225 PRxPLI FL Position loop integrator limit

1030, 1058, 1086, 1114, 1142, 1170, 1198, 1226 PRxKV FL Velocity loop gain

1031, 1059, 1087, 1115, 1143, 1171, 1199, 1227 PRxKI FL Velocity loop integrator gain

1032, 1060, 1088, 1116, 1144, 1172, 1200, 1228 PRxLI FL Velocity loop integrator limit

1033, 1061, 1089, 1117, 1145, 1173, 1201, 1229 PRxFNP FL Friction in positive direction

1034, 1062, 1090, 1118, 1146, 1174, 1202, 1230 PRxFRN FL Friction in negative direction

1035, 1063, 1091, 1119, 1147, 1175, 1203, 1231 PRxENR FL Encoder resolution

1036, 1064, 1092, 1120, 1148, 1176, 1204, 1232 PRxDZMIN FL Dead zone minimum

1037, 1065, 1093, 1121, 1149, 1177, 1205, 1233 PRxDZMAX FL Dead zone maximum

1038, 1066, 1094, 1122, 1150, 1178, 1206, 1234 PRxBQ1A1 FL

First BiQuad filter parameters

1039, 1067, 1095, 1123, 1151, 1179, 1207, 1235 PRxBQ1A2 FL

1040, 1068, 1096, 1124, 1152, 1180, 1208, 1236 PRxBQ1B0 FL

1041, 1069, 1097, 1125, 1153, 1181, 1209, 1237 PRxBQ1B1 FL

1042, 1070, 1098, 1126, 1154, 1182, 1210, 1238 PRxBQ1B2 FL

Page 131: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 128

7.5.7 CONFIGURABLE GYRO PSEUDOVARIABLES

Configurable pseudovariables can be used either in the XMS program or in Host communication. When used in the XMS program, variables are referenced by ID number.

The access to pseudovariable is done by:

• config command at XMS to write pseudovariable.• getvar command at XMS to read pseudovariable.• configure command at communication level to write pseudovariable.

Refer to Assign, page 62 and Report, page 61.

The following table summarizes the servo preset pseudovariables. For each variable, the table specifies next parameters:

1043, 1071, 1099, 1127, 1155, 1183, 1211, 1239 PRxBQ2A1 FL

Second BiQuad filter parameters

1044, 1072, 1100, 1128, 1156, 1184, 1212, 1240 PRxBQ2A2 FL

1045, 1073, 1101, 1129, 1157, 1185, 1213, 1241 PRxBQ2B0 FL

1046, 1074, 1102, 1130, 1158, 1186, 1214, 1242 PRxBQ2B1 FL

1047, 1075, 1103, 1131, 1159, 1187, 1215, 1243 PRxBQ2B2 FL

1048, 1076, 1104, 1132, 1160, 1188, 1216, 1244 PRxDCG FL Damping gain

1049, 1077, 1105, 1133, 1161, 1189, 1217, 1245 PRxDCFA1 FL

Damping BiQuad filter parameters

1050, 1078, 1106, 1134, 1162, 1190, 1218, 1246 PRxDCFA2 FL

1051, 1079, 1107, 1135, 1163, 1191, 1219, 1247 PRxDCFB0 FL

1052, 1080, 1108, 1136, 1164, 1192, 1220, 1248 PRxDCFB1 FL

1053, 1081, 1109, 1137, 1165, 1193, 1221, 1249 PRxDCFB2 FL

1054, 1082, 1110, 1138, 1166, 1194, 1222, 1250 PRxCFG FL

Servo configuration. Refer to 900, page 83.

Table 9: Servo Preset XMS variables

ID Name Tag Comments

Page 132: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 129

• ID for use in report/assign variable command• Variable tags:

• WO – write only variable

7.5.8 GYRO MODULE INTERFACE

This paragraph explains how to interface with the gyroscope module.

7.5.8.1 XMS GYRO VARIABLESXMS variables can be used either in the XMS program or in Host communication. When used in the XMS program, variables are referenced by name. All variable names are predefined; i.e. the user can use only these predefined variable names.

In Host communication, the Commands Assign, Report, and Monitor refer to the variable by 16-bit ID; see XCD2 User Manual for command description.

The following table summarizes the XMS variables. For each variable, the table specifies next parameters:

• ID for use in report/assign variable command• Name for use in XMS program• Variable tags:

• AX – Axis variable• RO – read only variable.• WO – write only variable.• ST – SET function is used for variable assignment.

Table 10: Servo preset pseudovariables

ID Tag Parameters Format Comments

768 WO Axis Preset index

Real (4) Real (4) Load preset parameters to servo loop.

769 WO Axis Preset index

Real (4) Real (4)

Store servo parameters to servo preset.

Table 11: Gyroscope XMS variables

ID Name Tag Comments

4352 GTMP RO MCU temperature in °C

4353 GRAWX ROAngular velocity at axis X after orientation matrix transformation.

Refer to Equation 7-5

Page 133: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Gyro

XCD2458000-00, Revision B 130

4354 GRAWY ROAngular velocity at axis Y after orientation matrix transformation.

Refer to Equation 7-5

4355 GRAWZ ROAngular velocity at axis Z after orientation matrix transformation.

Refer to Equation 7-5

4356 GTDFTX RODrift compensation value at axis X.

Refer to Equation 7-8

4357 GTDFTY RODrift compensation value at axis Y.

Refer to Equation 7-8

4358 GTDFTZ RODrift compensation value at axis Z.

Refer to Equation 7-8

4359 GAVERX ROCalculated average bias value at axis X.

Refer to Equation 7-8S

4360 GAVERY ROCalculated average bias value at axis Y.

Refer to Equation 7-8

4361 GAVERZ ROCalculated average bias value at axis Z.

Refer to Equation 7-8

4362 GVELX ROAngular velocity at axis X after drift compensation and average subtraction.

Refer to Equation 7-8

4363 GVELY ROAngular velocity at axis Y after drift compensation and average subtraction.

Refer to Equation 7-8

4364 GVELZ ROAngular velocity at axis Z after drift compensation and average subtraction.

Refer to Equation 7-8

4365 GVEL AX,ROAngular velocity.

Refer to Equation 7-7

4366 GPOS AX,ST Angle calculated by gyroscope

4367 GTDFTEN FL Enable drift compensation. This variable can get values 0 or 1.

4368 GTDFTXC0 FLb_(x,0) coefficient of drift estimation of axis X.

Refer to Equation 7-3

4369 GTDFTXC1 FLb_(x,1) coefficient of drift estimation of axis X.

Refer to Equation 7-3

Table 11: Gyroscope XMS variables

ID Name Tag Comments

Page 134: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Special Functions

XCD2458000-00, Revision B 131

7.6 SPECIAL FUNCTIONSThis section contains XMS special functions and examples of XMS operations.

7.6.1 POSITION LATCH AND ENCODER INDEX

The XCD2 encoder’s HW interface provides special input for position latch. This input should be connected to encoder index output, sometime called reference mark by some manufactures. The function is used internally in Homing (Figure 7.6.2) based on encoder index. Positive pulse on the input causes immediate latching of the current encoder position in variable POSI.

4370 GTDFTXC2 FLb_(x,2) coefficient of drift estimation of axis X.

Refer to Equation 7-3

4371 GTDFTYC0 FLb_(y,0) coefficient of drift estimation of axis Y.

Refer to Equation 7-3

4372 GTDFTYC1 FLb_(y,1) coefficient of drift estimation of axis Y.

Refer to Equation 7-3

4373 GTDFTYC2 FLb_(y,2) coefficient of drift estimation of axis Y.

Refer to Equation 7-34374 GTDFTZC0 FL b_(z,0) coefficient of drift estimation of axis Z.

4375 GTDFTZC1 FL b_(z,1) coefficient of drift estimation of axis Z.

4376 GTDFTZC2 FL b_(z,2) coefficient of drift estimation of axis Z.

4377 GAVEREN FL Enable average bias subtraction. This variable can get values 0 or 1.

4378 GAVERTIME FL Averaging time in milliseconds.

4379 GORXX FL

Coefficients of orientation matrix.

Refer to Equation

4380 GORXY FL

4381 GORXZ FL

4382 GORYX FL

4383 GORYY FL

4384 GORYZ FL

4385 GORZX FL

4386 GORZY FL

4387 GORZZ FL

Table 11: Gyroscope XMS variables

ID Name Tag Comments

Page 135: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Special Functions

XCD2458000-00, Revision B 132

The related delay is at nanosecond level and provides one-encoder-count resolution of the latched position.

Figure 7-13: Home and Position Latch

Position latch function operates with two XMS variables:

• POSI - real variable• S_IND - flag

S_IND flag equal zero after XCD2 start up. Positive pulse on the latch input toggles S_IND to become one and current encoder position is latched by variable POSI. The value one in S_IND indicates that the latch input was activated and the value of POSI is valid. To repeat a position latch function, reset S_IND to zero (set S_IND = 0).

7.6.2 HOMING

XCD2 supports two different feedback types: incremental encoder with quadrature pulses and absolute encoder with BiSS interface. Incremental encoders provide a specific number of equally spaced pulses per revolution for rotary motion or millimeter for linear motion. After XCD2 power up cycle the number of counted pulses is zero for incremental encoder or to some absolute position for absolute encoder. This circumstance forces a scale calibration, that

As long as S_IND=1, the next activation of the latch input will not be acted on.

Page 136: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Special Functions

XCD2458000-00, Revision B 133

defines the position of physical zero in real world coordinates. Homing procedure solves this problem.

XCD2 has two methods to preform homing procedure, by hard-stop or by encoder Index signal. Each one of those methods can be initiated with a negative or positive movement.

7.6.2.1 HARD STOP METHODThe controller will generate motion at the given optional parameter Velocity1 (by default it is set to VEL) with a negative direction if Method is set to 0 or 2, or positive if the method is set to 1 or 3.

When hard stop is reached the given optional parameter Origin will be set as the current FPOS. The Origin is set to 0.0 by default.

7.6.2.2 INDEX METHODThe Index method builds upon the hard-stop method. When the hard stop is reached it switches to 2nd Index-looking phase.

Systems that are using incremental encoders need to run the homing procedure on every power up cycle.

Absolute encoders need to perform homing procedure only one time. After physical zero definition is done, position offset is saved as POSOFFS variable. On every power up cycle POSOFFS is loaded from FLASH memory.

Table 12: Homing Methods

Method ID Description

0 Set origin at hard-stop – initiate with negative direction

1 Set origin at hard-stop – initiate with positive direction

2 Set origin at Index – initiate with negative direction

3 Set origin at Index – initiate with positive direction

BKM Set origins at a distance from the hard stop to avoid mechanical contact. For example, set the origin to 0.1mm. This will allow movement to 0 and still remain 0.1mm from the hardstop.

Page 137: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Special Functions

XCD2458000-00, Revision B 134

Figure 7-14: Homing procedure by Index flow diagram

After hard stop is reached, it will commence movement at the given optional parameter Velocity2 (by default it is set to Velocity1) with a negative direction if Method is set to 3, or positive if the method is set to 2.

When index is found (S_IND = 1) the index position will receive the given optional parameter Origin (by default it is set to 0.0).

7.6.3 TIME VARIABLE

The Controller provides high resolution time service through the variable TIME (page 72). This variable provides time in milliseconds elapsed since the Controller start-up, or since the last executed command SET TIME=0. The resolution of time counting is depends on a servo rate. Therefore the variable may read fractional values, such as 2345.05. Time counting has the limitations that are listed below.

Command SET TIME=0 resets the Time value to zero and restarts counting. To use full resolution, the command should be executed in the application periodically, so that using of TIME occurs not later than 12 minutes past the last SET TIME=0.

After about 12 minutes of uninterrupted counting the resolution of TIME begins to gradually deteriorate.After about two days of uninterrupted counting TIME variable rolls down to zero and starts new counting cycle.

Page 138: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Special Functions

XCD2458000-00, Revision B 135

7.6.3.1 SAFE TIME MEASURINGThe following script example shows at how to safely use TIME variable for measuring motion time. The XMS program repeats motion 100 times, measures full motion time (up to the motor physically enters DZMIN interval) and stores minimum motion time in V3 and maximum motion time in V4.

XMS example of Measuring Motion Time

V3=10000 // Initialize V3 with big value.

V4=0 // Initialize V4 with small value.

for V19=0 to 99 // Repeat 100 times.

move 5 // Move to initial point.

while S_BUSY // Wait for physical motion end.

end

set TIME=0 // Reset TIME.

move 15 // Move

while S_BUSY // Wait for physical motion end.

end

V0=TIME // Latch elapsed TIME.

if V0<V3

V3=V0

end

if V0>V4 // Update maximum TIME.

V4=V0

end

end //End of "for V19=0 to 99"

Page 139: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 136

8 XCD2 COMMANDER

The XCD2 Commander™ is an application that resides on an external Host computer. XCD2 Commander gives the user the ability to:

• Configure and tune the XCD2 Controller Motion system• Edit and save XMS scripts• Evaluate and troubleshoot motion control program operation• Edit program parameters• Save the final motion control program on the XCD2 Controller• Save the final program to file on the Host and save from the Host to

other Controllers

8.1 OVERVIEW OF XCD2 COMMANDERThe XCD2 Commander is a user interface that provides access to all operations involved in developing, testing, and using XMS scripts, as well as monitoring Controller and motor states.

The interface provides the following:

• Communication between XCD2 Commander and the XCD2 Controller. the protocol is based on a Host/Client relationship. XCD2 Commander resides on the Host (remote computer) and the XCD2 Controller is the Client. Communication is performed on any one of the defined channels (refer to Host Communication Protocol, page 26).

• XCD2 Motion Program™ - The XCD2 Motion Program (XMS script) is a scripting language that gives the user the ability to customize and control Nanomotion motors. XMS uses both standard commands and variables to control motor position, stops, speed and loading.

• User interface - Provides a number of actions:• downloading and executing a motion program from the

Host to the Controller.• access the Controller's flash memory to tune the servo

loop parameters• editing of motion control programs written in XMS• Saving programs from the Controller's flash memory to

the Host for reuse on other Controllers.

Page 140: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Work Flow with XCD2 Commander

XCD2458000-00, Revision B 137

8.2 WORK FLOW WITH XCD2 COMMANDERThe XCD2 Commander is typically used to tune the motion control system. The Commander is supplied with example XMS scripts that can serve as a starting point for program development. If a script is developed from scratch it must be saved with the extension (<fileName>.xms). After development open the file in the XCD2 Commander to verify the script. The file is opened with the parts of the script color coded. The next step is to check the operation of the script on the system by clicking Download and Execute. This downloads the script to the Controller's RAM and simulates a power on to start the program.

Figure 8-1: Basic Work Flow

If discrepancies are found in motor operation or there is a need to fine tune parts of the program specific commands can be applied and their response monitored. The parameters that require modification can be edited and the program rerun. All modifications of the program are implemented in the Controller's RAM. These changes are not saved unless they are saved to the Controller's Flash memory.

After development and testing are complete the final program is saved to the Controller's Flash. From here the program can be moved to a file (<fileName>.S19) on the Host computer. This file can be copied to other Controllers.

8.3 OVERVIEW OF THE XCD2 COMMANDER PANELSThe XCD2 Commander has three main panels:

Page 141: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Overview of the XCD2 Commander Panels

XCD2458000-00, Revision B 138

• Communication - provides connection between the Commander and the XCD2 device.• Port• Address• Info

• Motion Program - provides access to XMS scripts• BROWSE for scripts• EDIT opens an edit window for viewing and editing XMS

scripts• DOWNLOAD & EXECUTE The selected script

• Setup - • CONFIGURE SERVO LOOP

• TUNE SERVO LOOP

• MANAGE FLASH DATA

• MANAGE OTP• The bottom section provides three additional tools

• SCOPE

• WATCH

• XCD2 CONTROL

• ENABLE

8.3.1 LAUNCHING XCD2 COMMANDER The XCD2 Commander does not require installation. The application’s executable and its DLLs should reside in the same local folder.

1. Double-click XCD2_Commander.exe.

The XCD2 Commander main window opens. The Port and Address fields, and the Info pane are empty until selections are made.

Windows XP users should install Microsoft .Net framework from http://www.micro-soft.com/en-us/download/details.aspx?id=17851

Page 142: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Overview of the XCD2 Commander Panels

XCD2458000-00, Revision B 139

Figure 8-2: XCD2 Commander Main Window

2. Select the port that the Controller/Driver is connected to. The port can be UART(VCP), SPI or IIC.

3. Select the Address of the Controller/Driver.

4. Click OPEN/CLOSE PORT.

The Info pane is filled with information from the connected XCD2 device.

8.3.2 XCD2 CONFIGURATION AND TUNING

System setup comprises of four stages:

• Configuration of the servo controller• Tuning of the servo loop

The Port appears as green, black, or orange:

• Green – XCD2 device detected• Black – Available port (XCD2 device not connected)• Orange – Unable to open port (in use)

Page 143: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Overview of the XCD2 Commander Panels

XCD2458000-00, Revision B 140

• Verification using an XMS• Saving parameters and XMS to the flash

8.3.2.1 CONFIGURATION OF THE SERVO CONTROLLERThis stage goal is to determine that all of the polarities are correct and that the encoder is configured correctly.

Encoder resolution - ENRMake sure that the value entered represents the system Unit.

Safety polaritiesIf there are GPIO pins allocated as safety and switches are connected to them select the correct polarity, otherwise select Disable.

Ensure that the Status indicators at the bottom of the window are all green. If not reset the related logic selections in the drop-down menus in the top portion of the window. For example, if the Positive Limit indicator is red select Active High in the Positive Limit Switch drop-down.

Drive and Feedback polaritiesIn the Open Loop Command pane move the slider slowly right (positive PWM signal). When the motor begins to move, stop and record the value shown in the Open Loop Command field. If the motor movement is in the opposite direction (as shown by a negative number in the Current Position field), select or deselect Inverse Drive Output and recheck motor action.

The slide displacement is proportional to the PWM duty cycle. In the Info pane, check that the Controller is in Normal mode. In this mode the motor shows a sensible Dead Zone and normally starts moving at 15-30% of PWM duty cycle. If the motor hasn't moved at 50% of PWM, do not continue. The motor apparently has a problem that must be corrected.

The maximum encoder frequency is 21M counts Motion platform should follow next inequality:

where FVEL is feedback velocity of the motion platform and ENR is encoder resolution.

FVELENR

--------------- 21 106

Page 144: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 141

8.4 TUNING OF THE XCD2 SYSTEM SERVO LOOP After installing XCD2 Commander it is necessary to tune the connected servo loop. This operation sets the drive and feedback loop gain to ensure smooth motor operation.

8.4.1 SETUP & BASIC PARAMETERS

1. Click CONFIGURE SERVO LOOP.

Figure 8-3: Configure Servo Loop Window

This procedure provides tuning instructions for a linear stage. Procedures for tuning a rotary stage will be added in a later revision of this document.

BKM Normal mode is recommended for most applications.Linear mode may be useful for some applications with extreme requirements. However, Linear mode increases power consumption and motor wear

Page 145: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 142

Slowly move the PWM in the positive direction, record the values of PWM level in which the stage started to move and the value shown in the Current Position where the motor stops.

2. Move the slider slowly to the negative PWM direction and record the same values as the previous step.

3. Click TUNE SERVO LOOP button in the Commander main window.

4. In the lower pane of the Tune Servo Loop window, enter values for Position 1 and Position 2 obtained in steps 2 and 3.

5. In BACK-FORCE WITH DELAY enter 500 milliseconds.

6. Click POSITION 1 and ensure that the motor moves to that position.

7. Click POSITION 2 and ensure that the motor moves to that position.

8. If movement in both directions is ok, click Back-Force with Delay. The motor will begin moving between Position 1 and Position 2. Any of the following indicate a need to tune the servo loop:

• Noisy motion• unstable movement intolerable overshoot• position error• other undesirable motor action

9. While the motor is moving increase KV until an audible sound appears. Each increase should be twice the previous increment. The noise will typically be heard at the extremes of the stage movement.

10. Return the KV value to the last value before the noise began.

11. Raise the KV value very gradually with small increments.

12. Divide the value where the noise starts again by 2 and enter as KV. The stage runs smoothly with no audible noise.

while i and j are the number of iterations from Step 9 and 11 respectively.

The values should be at least 1 mm off the hard stops noted in the above steps.

KVi 2i

KV0=

KVj 2i 1–

KV0 j 2i

10------+=

KVfinal 0.5 2i 1–

KV0 j 2i

10------+

=

Page 146: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 143

13. Reset Kp to 200. If the stage physically oscillates (low frequency movement), reduce Kp to 100.

14. Stop the motor movement.

15. In order to save the tuning settings select Manage Flash Data in the Commander's main window and click RAM>FLASH. Refer to Managing Flash Data, page 150

8.4.2 ADDITIONAL PARAMETERS

1. Select the Others tab.

2. Set the parameters as follows: Press ENTER after entering data in fields.

• ENR (Encoder Resolution) - units appropriate for For example:• Linear applications - If the encoder resolution is listed as

1000 counts per mm, enter 0.001 in the ENR field. • Rotary applications - If the encoder resolution is listed as

4096 counts per revolution, enter 360/4096=0.08789 (degrees per count) in the ENR field.

• DZMIN = Normal mode=2*ENR (0.02 micron)• DZMAX = 10*ENR (0.1 micron)

• ZFF = 0.03 - 0.05 (30-50 micron)• FRP = 60% of value recorded in Setup & Basic parameters,

page 141 step 2 (default value is 10)• FRN = 60% of value recorded in Setup & Basic parameters,

page 141 step 3 (default value is -10)• SLN = 0 (disables negative software limit)• SLP = 0 (disables positive software limit) • PEL = 0 - (disables critical position error)

Display of position-related variables in the XCD2 Commander is formatted according to the ENR value.

If the required Drive Mode is Linear (AB5), set:

• DZMIN to 0• DZMAX to 1*ENR • FRP and FRN to zero

Page 147: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 144

• TEL = 0 - (disables Temperature Error Limit)• MTL = 20000 (Sets Motion Time Limit to 20 sec). A value of 0 disables

the Motion Time Limit parameter.

3. Select the Basic Parameters tab and set the following parameters:

• KP = 20• KV = 0.1• KI = 300• LI = 90

4. Select the Biquad 1 tab and set the following parameters:

• Enabled = select• Type = Low Pass• Bandwidth (Hz) = 700• Damping Ratio = 0.7

5. In the lower section of the window select the Motion Parameter tab and set the parameters:

• VEL to 50 (mm/sec)• ACC to 1000 (mm/sec2).

8.4.3 TUNE SERVO LOOP

1. Click Tune Servo Loop

The tuning values entered in step 3 below are for the purpose of tuning the stage only. After tuning is completed the user should adjust these values according the application's requirements.

Page 148: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 145

Figure 8-4: Tune Servo Loop Window

8.4.4 SCOPE

1. Click Scope.

2. In the upper left corner, in the communication panel, choose the appropriate port com (available port should be in green)

3. Change the required servo rate if needed

4. Choose your variables to be monitored. check the "high resolution" checkbox to sample in 32-bit floating point instead of 16-bit.

5. Configure trigger if needed

6. Click on browse and give (new) file name.

7. Click Configure scope

8. Click Enable stream

Page 149: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 146

9. Click Start/Stop streaming as needed.

10. Note: for changing the configuration (rate, variables, etc.) need to stop streaming, disable streaming, and back to step 3.

Do the following to convert the sample data to CSV

1. Click 'convert to CSV'

2. Choose the XSD file to convert, then click export

Figure 8-5: Scope Configuration Window

Page 150: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Tuning of the XCD2 System Servo Loop

XCD2458000-00, Revision B 147

Figure 8-6: Convert Data to CSV Format

8.4.5 WATCH

The Watch window provides two functions:

• sending two variables to be monitored by the DACs (refer to section XX and 'monitor' command in comm protocol)

• watching up to 4 variables values in "soft real-time"

Note, updating the value of watched variable depends on communication speed and other servo tasks. There is no guarantee that the value will be update in real-time, so it can be delayed.

In the other hand, the updating frequencies can also be too much fast that an human eye can pay attention

Page 151: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Working with XMS Scripts

XCD2458000-00, Revision B 148

Figure 8-7:

8.5 WORKING WITH XMS SCRIPTS The user can develop a motion control program from scratch, or run a Nanomotion sample script that provides a starting point for program development. The sample scripts are in the evaluation kit software package folder titled Scripts. The folder contains two XMS scripts.

• <productName>_DEMO_KIT_Cond.xms - sets general defaults• <productName>_DEMO_KIT_Steps.xms - sets defaults for step

operation.

8.5.1 EDITING A SCRIPT The edit function can be used for editing existing XMS scripts. By using one of the supplied sample scripts the user can experiment with the system, develop a unique script.

1. In the Motion Program pane click BROWSE.

2. Browse to the folder containing XMS scripts and select a script and click OPEN.

3. The path to the script appears in the Motion Program field.

Page 152: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Working with XMS Scripts

XCD2458000-00, Revision B 149

4. Click EDIT.

5. The Script edit panel opens. Commands and parameters are color coded.

Figure 8-8: XMS edit window

6. Click VERIFY to check script syntax. If there are errors in the script syntax, an error message appears and the line with the error is highlighted.

7. Edit the script as required. The editor verifies the script syntax. An error message is displayed with the line number of the error and marks the error in the script. If no error is found no message is displayed.

8. To test the script click DOWNLOAD & EXECUTE button to execute the script. The script is loaded to the Controller's RAM and a power on condition is simulated to start the motor. The button name changes to STOP. The Line field indicates the currently running script line.

9. To save the program select Program > Save or Save As.

8.5.2 EXECUTING AN XMS SCRIPT To execute an XMS script follow next steps:

1. Close any open XMS editing window.

2. In the Motion Program pane click BROWSE.

3. Browse to the folder containing XMS scripts and select a script.

4. The selected script's full path is displayed in the Motion Program field.

Page 153: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Managing Flash Data

XCD2458000-00, Revision B 150

5. Click DOWNLOAD & EXECUTE.

6. To stop the script click STOP. The Stop & Disable button stops the script execution and disables the motor.

8.6 MANAGING FLASH DATA The XMS program and parameters reside in the Controller’s RAM. Changes that were made during editing will be lost on power down. They must be saved either to the Controller’s Flash memory, an XMS file or as an S19 file. the S19 file can be loaded directly to the memory of multiple controllers.

After executing the program, the program's parameters are displayed in the Configure Servo Loop and Tune Servo Loop dialogs. These parameters can be edited to improve and fine tune the motor's operation. After editing these parameters the program can be rerun to test the changes. Editing of the program cannot be done while the motor is operating. Parameter edits are copied to the Controller's RAM and affect the motor's current operation.

1. In the Commander's Setup pane click MANAGE FLASH DATA. The dialog has three tabs that display the contents of the Flash memory. Each tab displays the contents of both the Controller's Flash and RAM.

• Configuration• Flash Variables• Program - shows Program size and checksum in the Flash

drive and RAM• The Encoder Compensation tab provides the ability to

import or export an encoder compensation value.

2. Save and upload data as follows: RAM > FLASH saves the Controller's RAM to its Flash memory. The process overwrites the contents of the Flash memory.

Page 154: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Error Messages

XCD2458000-00, Revision B 151

Figure 8-9: Manage Flash Data dialog - Configuration tab

Figure 8-10: Manage Flash Data dialog - Variable tab (two axes)

8.7 ERROR MESSAGESWhen the Controller driver detects an error, the following actions take place:

Page 155: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Error Messages

XCD2458000-00, Revision B 152

• An error code appears on the screen. Refer to Error Codes, page 85• The currently running XMS program is aborted, and motor action is

stopped

Page 156: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 153

9 FIRMWARE UPGRADE

This section discusses the procedure for upgrading XCD2 FW upgrade, in order to bring the XCD2 up to date or to improve its characteristics. XCD2 FW can be upgraded through any of active communication channel (Communication Channels, page 26). The process can be done through XCD2 Commander, or by HOST processor when XCD2 is part of in the embedded system.

XCD2 has a bootloader that is responsible for rewriting the main XCD2 application firmware. A number of security checks are responsible for ensuring the integrity of the upgrade process.

9.1 FILE STRUCTUREXCD2 uses encrypted files for upgrade process. The file is divided into a sequence of data blocks as shown below. Sequential blocks are marked with different colors to make it easier to understand.

Each block has a header that contains:

• Block name – 2 bytes• Block size in bytes including itself and block name – 1 byte• Block payload – N bytes. Block size can vary

In case of process failure XCD2 will remain in the boot stage till correct XCD2 firm-ware is written.

The FW can be rolled back after upgrade.

Nanomotion does not guarantee backward compatibility of all functions.The customer is responsible for ensuring that all relevant functions still work after upgrade.

Page 157: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Upgrade through XCD2 Commander

XCD2458000-00, Revision B 154

Figure 9-1: NMUF File Structure Example

9.2 UPGRADE THROUGH XCD2 COMMANDERXCD2 upgrade procedure through XCD2 Commander is:

1. Run XCD2_Commander.exe.

Table 1: NMUF File Block Types

Block name Description

0x5310

Initiation block with structure:

B[0-3] – file size in bytes in little-endian format. In Figure 9-1 the file size is 83785 bytes. B[4-7] – total block number in file in little-endian format. In Figure 9-1 there are 3494 blocks in the file. Next bytes are for internal usage.

0x5300 - 0x5311 All those blocks are for internal usage.

Page 158: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Upgrade through XCD2 Commander

XCD2458000-00, Revision B 155

Figure 9-2: XCD2 Commander Main Window

In the Communication pane selection the Port and Address.

Click OPEN PORT.

The XCD2 controller information is displaced in the Info field.

Ensure that all motors are turned off.

Ensure that there are no XMS scripts running.

click XCD2 CONTROL.

Choose SW UPGRADE tab.

Page 159: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Upgrade through Host computer

XCD2458000-00, Revision B 156

Figure 9-3: XCD2 Utilities Window

Click LOAD FILE button and choose the valid *.nmuf file for the upgrade.

Click START UPGRADE.

Follow the instructions that shown in pop-on windows.

Wait until the upgrade process completes. The process Status is shown in the progress bar.

Click INFO and verify that the new firmware version is appears in the fields.

9.3 UPGRADE THROUGH HOST COMPUTERXCD2 supports FM upgrade through customer HOST platform. To perform XCD2 firmware upgrade customer HOST platform need to integrate the whole upgrade procedure. For proper XCD2 firmware upgrade procedure next assumptions should be taken into account:

• Communication is working without errors.• XCD2 Status is:

• XMS is not running. All motion operation should be stopped.• HOST platform should know how to divide the binary file into upgrade

blocks (File structure, page 153).• Due to a nature of different memory operations that are done during

the XCD2 firmware upgrade process; the timing for receiving acknowledgment could be variate. HOST platform should poll the

Page 160: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Upgrade through Host computer

XCD2458000-00, Revision B 157

current operation Status and only when current operation is done send the next packet/block.

XCD2 firmware upgrade procedure through HOST platform is:

1. Send CALL BOOTLOADER command and wait for acknowledgment.

Set packet index to zero.

Send (i)th packet.

• Send (i+1)th packet.• If acknowledgment received go step 5

If “Operation in progress” received, repeat step 4.

Increment packet index (i).

Packet index is greater than total packets number (Table 1, page 154), go to step, otherwise go to step 4.

Call main application.

• If acknowledgment received that main XCD2 FW will be loaded after start up time.

• In case of non-acknowledgment start whole procedure again.

To prevent uncontrolled operation it is necessary that:• XMS is not running. • All motion operation should be stopped Refer to File structure, page 153.

Page 161: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

Upgrade through Host computer

XCD2458000-00, Revision B 158

Figure 9-4: XCD2 firmware upgrade flow by HOST

Page 162: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 159

INDEX

INDEX

AACC

variable ................................................35ACK ............................................................30address

communication ....................................26default .................................................36IIC ........................................................85set command .......................................36SPI .......................................................85UART ...................................................85

AIN0variable ................................................35

AOUT1variable ................................................35

assign ........................................................82

Bbiquad ........................................................20

configuration .......................................46disable .................................................21enable ..................................................21flag enable ...........................................83full ........................................................47

variables ........................................47low pass ...............................................47

variables ........................................47mode

full biquad ......................................21low pass filter ................................21native .............................................21notch filter .....................................21

nativeparameters ....................................75XMS variables ................................48

notch ...................................................47variables ........................................47

parameters ..........................................21blackout time

BLOUT .................................................24bootloader .................................................29

boot into ..............................................52FW upgrade .......................................153

broadcast ...................................................36

Ccommand

assign ............................62, 71, 126, 129multi-block example ......................69with axis ........................................63

biquad configuration ...........................46block

header ...........................................27parameters ....................................27structure ........................................27

boot into XCD2 main firmware ............52boot packet .........................................53buffer read ..........................................40buffer write ..........................................39calibration ............................................42config ...........................................82, 128configure .....................................60, 128disable .................................................58enable ..................................................57execute xms program .........................45get axis ................................................37get axis number ..................................46get channel index ................................39get version .....................................44, 70getvar ....................................82, 85, 128home ...........................................41, 132kill ........................................................59monitor ..........................60, 71, 126, 129move ..............................................16, 54

example .........................................67open loop ......................................23, 56packet ..................................................27payload ................................................27ping ......................................................38report .............................................61, 71

multi-block example ......................69report with axis ...................................62reset ....................................................43

reply ..............................................43save .....................................................26save parameters ..........................44, 126scope ...........................................48, 108

activate ..........................................51configure .......................................50delete .............................................50disable ...........................................50enable ..............................48, 49, 108get channel ....................................51initiation .........................................49

Page 163: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 160

INDEX

set ..................................41, 71, 132, 134bootloader .....................................52

set address ....................................26, 36set axis ................................................37set position ..........................................57stop xms program ...............................45structure ..............................................27velocity loop ........................................55

command interface ...................................27communication

address ................................................26channel ................................................26

IIC ..................................................32SPI .................................................30UART .............................................33

commands ...........................................29speed ...................................................12variables ..............................................71

communication bridgeRX buffer .............................................40SPI config ..........................................117TX buffer .............................................39UART config .......................................116variable

Bytes received .............................115Bytes to receive ...........................115Bytes to transmit .........................115Bytes transmitted ........................115control .........................................115

communication channel ............................12IIC ........................................................13RS232 ..................................................13RS485 ..................................................13SPI .......................................................13UART ...................................................13

communication protocol ............................26control algorithm

biquad ..................................................20Ki .........................................................21Kp ........................................................20Li ..........................................................22offset mechanism ................................22

Ddata

packet ..................................................29format ............................................29

streamed .............................................48

data packetexample ...............................................67

dead zoneDZMIN .................................................24mechanism ..........................................16

dead zone mechanism ..............................24DZMAX .................................................24

disablesafety ...................................................84state machine ......................................99

DOL ............................................................23DOUT

variable ................................................35drive mode

AB1 ......................................................69AB5 ....................................................143

driver limit .................................................23DOL ......................................................23

DZMAX .......................................................24DZMIN

gyro ...................................................125

Eenable

state machine ......................................99encoder

absolute ...............................................13quadrature ...........................................13

encoder resolutionENR ..............................................18, 143linear application ...............................143rotary application ..............................143user units .................................18, 35, 89

executevelocity loop ........................................55xms script ..........................................149

Ffilter

biquad ..................................................21enabled ..........................................83

configuration .......................................46low pass ...............................................21

temperature compensation .........113native ...................................................21notch .............................................21, 46

Page 164: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 161

INDEX

XCD2 commander .............................144flag

biquad enable ......................................83HR motor .............................................83inverse drive ........................................83inverse feedback .................................83motor active ........................................83open Loop ............................................83PWM mode ..........................................83s_busy ...........................................24, 83script run .............................................83s_inpos ................................................24s_move ................................................83s_queue ...............................................83velocity loop ........................................83

formatdata packet ..........................................29

FPOSvariable ................................................35

FRN - friction negative ..............................22FRP - friction positive ................................22FVEL

variable ................................................35

Ggyro

drift ....................................................120bias cancellation ..........................120bias compensation .......................120temperature compensation .........120

drift compensation ....................120, 130OPMODE

encoder ........................................124gyro .............................................124

opmode .............................................124orientation matrix ..............................121variable

average bias subtraction .............131GAVEREN .....................................120GAVERTIME .................................120GORxx ..........................................122OPMODE ......................................123SPRD ............................................120

IIIC ..............................................................32

addressdefault ...........................................36

communication bridge .......................114configuration

bit description ..............................117configuration variable ........................117data packet ..........................................67variable ID .........................................115

integrator limitLi ..........................................................22

JJERK ..........................................................73jerk

variable ................................................35

KKDEC ....................................................59, 73Ki .............................................................144

integral gain ........................................21tune servo loop .................................144

Kp ..............................................................20gyro ...................................................124position loop ........................................74

kptune servo loop .................................144

Kvtune servo loop .................................144velocity loop ........................................74

LLi

tune servo loop .................................144loader ........................................................52

MMTL ............................................................85

NNACK .........................................................30

Page 165: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 162

INDEX

Ooffset mechanism ................................16, 22open loop

XCD2 Commander .............................140opmode .............................................19, 124

Ppacket ........................................................27

IIC structure ........................................32SPI structure .......................................31structure ..............................................27UART structure ....................................33

POSvariable ................................................35

position loopgain ......................................................74

power save ..............................................109pseudovariable

addressUART 0 ..........................................85UART 1 ..........................................85

IO direction .........................................84last error ..............................................85number of axes ...................................85program IIC .........................................83safety disable ......................................84safety inverse ......................................84safety state ..........................................84XMS checksum ....................................84XMS length ..........................................85

Rreport .........................................................82RPOS

variable ................................................35RVEL

variable ................................................35

Ss_busy .......................................................24scope

initiation ...............................................49send

data packet ..........................................29servo loop

configure ...........................................141Servo Tick ..................................................20S_INPOS

flag ................................................24, 81S_MOVE .....................................................24SPI .............................................................30

configurationbit description ..............................117

SPRD ..........................................................12Status

pseudovariable ....................................83status

ACK ......................................................30NACK ...................................................30

Ttarget position ...........................................24

TPOS ....................................................24TIME

variable ................................................35TPOS

variable ................................................35

UUART .........................................................33

configurationbit description ..............................116

user unitsENR ................................................35, 89

Vvariable

ACC ................................................17, 72AIN0-AIN3 ...........................................79AIN4 - AIN11 .......................................79AOUT0 .................................................79AOUT1 .................................................80AOUTSC0 .............................................80AOUTSC1 .............................................80BLOUT .................................................77BQ2A1 .................................................76BQ2A2 .................................................76BQ2B0 ..................................................76BQ2B1 ..................................................76BQ2B2 ..................................................76

Page 166: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

XCD2458000-00, Revision B 163

INDEX

BQA1 ....................................................75BQA2 ....................................................76BQB0 ....................................................76BQB1 ....................................................76BQB2 ....................................................76calibration

acceleration time .........................111calibration result ..........................112debug output ...............................112decel time ....................................112finish frequency ...........................111frequency offset ..........................113min travel ....................................112motor temp .................................113PWM level ....................................111start frequency ............................111temp hysteresis ...........................113total steps ....................................111travel time ...................................111

DEC ................................................16, 72DOFFS ..................................................77DOL ......................................................77DZMAX .................................................76DZMIN .................................................76FPOS ....................................................74FRN ......................................................77FRP ......................................................76FVEL .....................................................74IO_0 - IO_15 .......................................80jerk ......................................................73Ki .........................................................75Kp ........................................................74Kv .........................................................74Li ..........................................................75MFREQ1 ...............................................76MTL ......................................................78MTNPHS ...............................................81MTTMP .................................................78PE ........................................................74PEL .......................................................78PKi .......................................................75PLi ........................................................75POSI ....................................................74POSOFFS .............................................77RPOS ....................................................73RVEL ....................................................73S_BUSY ................................................81SERTICK ..............................................82S_HOME ..............................................81

S_IND ..................................................81S_INPOS ..............................................81SLN ......................................................78SLP .......................................................78S_MOVE ...............................................80SSTAT ..................................................81status

IIC configuration .........................117SPI configuration .........................117UART configuration .....................116

TIME ....................................................72TPOS ....................................................73V0 - V19 ..............................................72VEL ................................................17, 72XAXIS .............................................71, 87ZFF .......................................................76

VELvariable ................................................35

velocity feed forward ................................22VFF ............................................................22

XXMS

built in functionsabs .................................................91cos .................................................91rand ...............................................91sin ..................................................91sqrt ................................................91tan .................................................91

commands ...........................................35communication bridge .......................115flash data ...........................................150floating point values ............................34gyro

pseudovariables ...........................128variables ..............................120, 126

literal constants ...................................34script ....................................................12scripts

editing ..........................................148execution .....................................149working with ................................148

special functions ................................131syntax

arithmetic operator .......................90compare operator ..........................90count-controlled loop ....................91

Page 167: nanomotion.com · XCD2458000-00, Revision B iv performance of the NM products. Without limitin g the generality of the preceding sentence, NM shall not be liable to the Purchaser

decision control statement ............90literal constant ...............................90logical operator .............................90

units of measure .................................34variables ..............................................71

ZZFF .......................................................16, 22