National Instruments NI-Motion User Manual - Pid Loop Descriptions

Manual is about: Motion Control

Summary of NI-Motion

  • Page 1

    Motion control ni-motion tm user manual ni-motion user manual november 2005 371242b-01.

  • Page 2

    Support worldwide technical support and product information ni.Com national instruments corporate headquarters 11500 north mopac expressway austin, texas 78759-3504 usa tel: 512 683 0100 worldwide offices australia 1800 300 800, austria 43 0 662 45 79 90 0, belgium 32 0 2 757 00 20, brazil 55 11 326...

  • Page 3: Important Information

    Important information warranty the media on which you receive national instruments software are warranted not to fail to execute programming instructions, due to defects in materials and workmanship, for a period of 90 days from date of shipment, as evidenced by receipts or other documentation. Nati...

  • Page 4: Contents

    © national instruments corporation v ni-motion user manual contents about this manual conventions ...................................................................................................................Xiii documentation and examples ..........................................................

  • Page 5: III

    Contents ni-motion user manual vi ni.Com p art iii programming with ni-motion chapter 4 what you need to know about moves move profiles ................................................................................................................ 4-1 trapezoidal.......................................

  • Page 6: Chapter 6

    Contents © national instruments corporation vii ni-motion user manual chapter 6 arc moves circular arcs..................................................................................................................6-1 arc move algorithm ...............................................................

  • Page 7: Chapter 10

    Contents ni-motion user manual viii ni.Com chapter 10 electronic gearing and camming gearing .......................................................................................................................... 10-1 algorithm ........................................................................

  • Page 8: Chapter 13

    Contents © national instruments corporation ix ni-motion user manual modulo breakpoints (ni 7330, ni 7340 and ni 7390 only) .........................................12-21 modulo breakpoints algorithm ......................................................................12-23 labview code ..............

  • Page 9: Chapter 15

    Contents ni-motion user manual x ni.Com c/c++ code .................................................................................................... 14-6 running, stopping, and pausing onboard programs .................................................... 14-8 running an onboard program .............

  • Page 10: Chapter 16

    Contents © national instruments corporation xi ni-motion user manual blending straight-line move segments........................................................................15-7 raster scanning using blended straight lines algorithm.............................15-8 labview code ....................

  • Page 11: About This Manual

    © national instruments corporation xiii ni-motion user manual about this manual this manual provides information about the ni-motion driver software, including background, configuration, and programming information. The purpose of this manual is to provide a basic understanding of the ni-motion driv...

  • Page 12: Documentation and Examples

    About this manual ni-motion user manual xiv ni.Com italic italic text denotes variables, emphasis, a cross reference, or an introduction to a key concept. Italic text also denotes text that is a placeholder for a word or value that you must supply. Monospace text in this font denotes text or charact...

  • Page 13

    About this manual © national instruments corporation xv ni-motion user manual • ni developer zone (nidz)—visit the ni developer zone, at ni.Com/zone , for example programs, tutorials, technical presentations, the instrument driver network, a measurement glossary, an online magazine, a product adviso...

  • Page 14: Part I

    © national instruments corporation i-1 ni-motion user manual part i introduction this user manual provides information about the ni-motion driver software, motion control setup, and specific task-based instructions for creating motion control applications using the labview and c/c++ application deve...

  • Page 15: Introduction to Ni-Motion

    © national instruments corporation 1-1 ni-motion user manual 1 introduction to ni-motion about ni-motion ni-motion is the driver software for national instruments 73xx motion controllers and the ni softmotion controller. You can use ni-motion to create motion control applications using the included ...

  • Page 16: Ni 73Xx Architecture

    Chapter 1 introduction to ni-motion ni-motion user manual 1-2 ni.Com software and hardware interaction figure 1-1. Ni motion control hardware and software interaction note the last block in figure 1-1 is not applicable to the ni softmotion controller. Ni motion controller architecture this section i...

  • Page 17

    Chapter 1 introduction to ni-motion © national instruments corporation 1-3 ni-motion user manual the controller cpu is a 32-bit micro-controller running an embedded real time, multitasking operating system. This cpu offers the performance and determinism needed to solve most complex motion applicati...

  • Page 18

    Chapter 1 introduction to ni-motion ni-motion user manual 1-4 ni.Com figure 1-2 illustrates the physical architecture of the ni motion controller hardware. Figure 1-2. Physical ni motion controller architecture tip because the ni softmotion controller is not a hardware device, information about its ...

  • Page 19

    Chapter 1 introduction to ni-motion © national instruments corporation 1-5 ni-motion user manual figure 1-3 shows the components of the ni 73xx motion controllers. Figure 1-3. Typical ni 73xx motion controller functional architecture figure 1-4 shows the components of the ni softmotion controller. F...

  • Page 20

    Chapter 1 introduction to ni-motion ni-motion user manual 1-6 ni.Com figure 1-5 illustrates the functional architecture of ni motion controllers. Figure 1-5. Ni motion controller functional architecture the following list describes how each component of the 73xx controllers and the ni softmotion con...

  • Page 21

    Chapter 1 introduction to ni-motion © national instruments corporation 1-7 ni-motion user manual the control loop handles closing the position/velocity loop based on feedback, and it defines the response and stability of the system. For stepper systems, the control loop is replaced with a step gener...

  • Page 22

    Chapter 1 introduction to ni-motion ni-motion user manual 1-8 ni.Com figure 1-6. Ni softmotion controller functional architecture for ormec ni softmotion controller for canopen when you use the ni softmotion controller with a canopen device, you can daisy chain up to 15 drives together and connect t...

  • Page 23

    Chapter 1 introduction to ni-motion © national instruments corporation 1-9 ni-motion user manual figure 1-7. Ni softmotion controller functional architecture for canopen in this configuration, the i/o and the control loop execute on the canopen drive. The ni softmotion controller uses an ni-can devi...

  • Page 24

    © national instruments corporation 2-1 ni-motion user manual 2 creating ni-motion applications this chapter describes the basic form of an ni-motion application and its interaction with other i/o, such as a national instruments data and/or image acquisition device. Creating a generic ni-motion appli...

  • Page 25

    Chapter 2 creating ni-motion applications ni-motion user manual 2-2 ni.Com figure 2-1. Generic steps for designing a motion application adding measurements to an ni-motion application figure 2-2 illustrates an expanded view of the topics covered in part iii, programming with ni-motion , of this manu...

  • Page 26

    Chapter 2 creating ni-motion applications © national instruments corporation 2-3 ni-motion user manual figure 2-2. Input/output with data and image acquisition * breakpoints cause a digital output to change state when a specified position is reached by an encoder. Breakpoints are not supported by th...

  • Page 27

    Chapter 2 creating ni-motion applications ni-motion user manual 2-4 ni.Com note if you are using rtsi to connect your motion controller to a national instruments data or image acquisition device, be aware that the ni softmotion controller does not support rtsi..

  • Page 28: Part II

    © national instruments corporation ii-1 ni-motion user manual part ii configuring motion control motion control is divided into two parts: configuration and execution. Part ii of this manual discusses configuring the hardware and software components of a motion control system using ni-motion. Part i...

  • Page 29: Tuning Servo Systems

    © national instruments corporation 3-1 ni-motion user manual 3 tuning servo systems when your motion control system includes a servo motor, you must tune and calibrate the system to ensure proper performance. This chapter covers general information about tuning and calibrating your servo system usin...

  • Page 30: Control Loop

    Chapter 3 tuning servo systems ni-motion user manual 3-2 ni.Com a properly tuned servo system exhibits overshoot as shown in figure 3-1. Figure 3-1. Properly tuned servo motor behavior the amount of time required for the motors to settle on the commanded position is called the settling time. By tuni...

  • Page 31

    Chapter 3 tuning servo systems © national instruments corporation 3-3 ni-motion user manual figure 3-2. Ni-motion ser vo pid loop.

  • Page 32: Pid Loop Descriptions

    Chapter 3 tuning servo systems ni-motion user manual 3-4 ni.Com pid loop descriptions the following are common variables relating to the pid control loop. Kp (proportional gain) the proportional gain (kp) determines the contribution of restoring force that is directly proportional to the position er...

  • Page 33: Kd (Derivative Gain)

    Chapter 3 tuning servo systems © national instruments corporation 3-5 ni-motion user manual kd (derivative gain) the derivative gain (kd) determines the contribution of restoring force proportional to the rate of change (derivative) of position error. This force acts much like viscous damping in a d...

  • Page 34: Kdac

    Chapter 3 tuning servo systems ni-motion user manual 3-6 ni.Com velocity feedforward is an open-loop compensation technique and cannot affect the stability of the system. However, if you use too large a value for vff, following error can reverse during the constant velocity portion, thus degrading p...

  • Page 35: 1/j

    Chapter 3 tuning servo systems © national instruments corporation 3-7 ni-motion user manual ga ga is the amplifier gain. Kt kt is the torque constant of the motor. Kt is represented in newton meters per amp. 1/j 1/j represents the motor plus load inertia of the motion system. Ke ke represents the co...

  • Page 36

    Chapter 3 tuning servo systems ni-motion user manual 3-8 ni.Com figure 3-3. Dual loop feedback tip you can enable dual-loop feedback on the ni motion controller by mapping an encoder as the secondary feedback for the axis, and then using the velocity feedback gain instead of the derivative gain to d...

  • Page 37: Velocity Feedback

    Chapter 3 tuning servo systems © national instruments corporation 3-9 ni-motion user manual velocity feedback you can configure the ni motion controller for velocity feedback using the kv (velocity feedback) gain. Using kv creates a minor velocity feedback loop. This is very similar to the tradition...

  • Page 38

    Chapter 3 tuning servo systems ni-motion user manual 3-10 ni.Com figure 3-6. Alternate dual-loop feedback algorithm ni motion controllers with velocity amplifiers velocity amplifiers close the velocity loop using a tachometer on the amplifier itself, as shown in figure 3-7. In this case, the control...

  • Page 39

    Chapter 3 tuning servo systems © national instruments corporation 3-11 ni-motion user manual figure 3-8 describes how to use ni motion controllers with velocity amplifiers. Figure 3-8. Ni motion controllers with velocity amplifiers algorithm you typically use velocity feedforward when using controll...

  • Page 40: Part III

    © national instruments corporation iii-1 ni-motion user manual part iii programming with ni-motion you can use the c/c++ functions and labview vis, included with ni-motion, to configure and execute motion control applications. Part iii of this manual covers the ni-motion algorithms you need to use a...

  • Page 41

    Part iii programming with ni-motion ni-motion user manual iii-2 ni.Com • synchronization • torque control • onboard programs.

  • Page 42: What You Need to Know About

    © national instruments corporation 4-1 ni-motion user manual 4 what you need to know about moves this chapter discusses the concepts necessary for programming motion control. Move profiles the basic function of a motion controller is to make moves. The trajectory generator takes in the type of move ...

  • Page 43: S-Curve

    Chapter 4 what you need to know about moves ni-motion user manual 4-2 ni.Com figure 4-1. Trapezoidal move profile s-curve the acceleration and deceleration portions of an s-curve motion profile are smooth, resulting in less abrupt transitions, as shown in figure 4-2. This limits the jerk in the moti...

  • Page 44: Coordinate Space

    Chapter 4 what you need to know about moves © national instruments corporation 4-3 ni-motion user manual • contoured move—is a user-defined move; you generate the trajectory, and the points loaded into the motion controller are splined to create a smooth profile the motion controller uses the specif...

  • Page 45: Trajectory Parameters

    Chapter 4 what you need to know about moves ni-motion user manual 4-4 ni.Com grouping axes into coordinate spaces. Using a multi-start automatically starts all axes virtually simultaneously. To simultaneously end the moves, you must calculate the move constraints to end travel at the same time. In c...

  • Page 46: Ni 73Xx Time Base

    Chapter 4 what you need to know about moves © national instruments corporation 4-5 ni-motion user manual ni 73xx time base velocity and acceleration values are loaded in counts/s, rpm, rps/s, steps/s, and so on, which are all functions of seconds or minutes. However, the trajectory generator updates...

  • Page 47

    Chapter 4 what you need to know about moves ni-motion user manual 4-6 ni.Com you can calculate this minimum velocity increment in rpm with the following formula: where vmin = 1/65,536 counts/sample or steps/sample ts = sample period in seconds per sample 60 = number of seconds in a minute r = counts...

  • Page 48: Ni 73Xx

    Chapter 4 what you need to know about moves © national instruments corporation 4-7 ni-motion user manual and is constrained by acceleration/deceleration according to the following equation: velocity ≤ (65,536 × deceleration) – acceleration where velocity is in counts/sample and acceleration and dece...

  • Page 49: Ni 73Xx

    Chapter 4 what you need to know about moves ni-motion user manual 4-8 ni.Com you can calculate the maximum velocity with the following equation: where vmax = 20 mhz for servos 8 mhz for steppers on a ni 7350 controller 4 mhz for steppers on a ni 7330, ni 7340, or ni 7390 motion controller and is con...

  • Page 50: Ni 73Xx

    Chapter 4 what you need to know about moves © national instruments corporation 4-9 ni-motion user manual you can calculate the minimum acceleration increment with the following formula: where amin = 1/65,536 counts/sample 2 or steps/sample 2 ts = sample period in seconds per sample for a typical ser...

  • Page 51

    Chapter 4 what you need to know about moves ni-motion user manual 4-10 ni.Com you can calculate the minimum acceleration increment in rps/s with the following formula: where amin = 1/65,536 counts/sample 2 or steps/sample 2 ts = sample period in seconds per sample r = counts or steps per revolution ...

  • Page 52: Ni 73Xx

    Chapter 4 what you need to know about moves © national instruments corporation 4-11 ni-motion user manual you can calculate the maximum rps/s using the following equation: where amax = 32 counts/sample 2 ts = sample period in seconds per sample r = counts or steps per revolution and is constrained a...

  • Page 53: Ni 73Xx

    Chapter 4 what you need to know about moves ni-motion user manual 4-12 ni.Com note if the distance of the move is too small, it may not be possible to reach the commanded maximum move constraints. In such instances, ni-motion adjusts the move constraints lower to reach the commanded position. Ni 73x...

  • Page 54

    Chapter 4 what you need to know about moves © national instruments corporation 4-13 ni-motion user manual ni 73xx arc move limitations the following are limitations to the velocity and acceleration of arc moves. Arc moves must use the following equations or an nimc_invalidvelocityerror is generated:...

  • Page 55: Timing Loops

    Chapter 4 what you need to know about moves ni-motion user manual 4-14 ni.Com timing loops national instruments recommends that you use the loop timings discussed in the following sections. Status display when you are displaying status information to the user, such as position, move status, or veloc...

  • Page 56: Straight-Line Moves

    © national instruments corporation 5-1 ni-motion user manual 5 straight-line moves a straight-line move executes the shortest move between two points. Position-based straight-line moves position-based straight-line moves use the specified target position to generate the move trajectory. For example,...

  • Page 57

    Chapter 5 straight-line moves ni-motion user manual 5-2 ni.Com the start position is always the current position of the axis or axes. You can load the end position as either an absolute position to move to or as a position relative to the starting position. Although you can update any parameter whil...

  • Page 58

    Chapter 5 straight-line moves © national instruments corporation 5-3 ni-motion user manual figure 5-2. 1d straight-line move in labview 1 load velocity 2 load acceleration/deceleration 3 load acceleration/deceleration 4 load s-curve time 5 set operation mode 6 load target position 7 start motion 8 r...

  • Page 59

    Chapter 5 straight-line moves ni-motion user manual 5-4 ni.Com figure 5-3. 2d straight-line move in labview 1 configure vector space 2 load velocity 3 load acceleration/deceleration 4 load acceleration/deceleration 5 load s-curve time 6 set operation mode 7 load target position 8 start motion 9 chec...

  • Page 60: C/c++ Code

    Chapter 5 straight-line moves © national instruments corporation 5-5 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. 1d stra...

  • Page 61

    Chapter 5 straight-line moves ni-motion user manual 5-6 ni.Com err = flex_load_scurve_time(boardid, axis, 1000, 0xff); checkerror; // set the operation mode err = flex_set_op_mode (boardid, axis, nimc_absolute_position); checkerror; // load position err = flex_load_target_pos (boardid, axis, 5000, 0...

  • Page 62: 2D Straight-Line Move Code

    Chapter 5 straight-line moves © national instruments corporation 5-7 ni-motion user manual // error handling nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id, and the error code of the //modal err...

  • Page 63

    Chapter 5 straight-line moves ni-motion user manual 5-8 ni.Com // configure a 2d vector space comprised of axes 1 and 2 err = flex_config_vect_spc(boardid, vectorspace, 1, 2, 0); checkerror; // set the velocity for the move (in counts/sec) err = flex_load_velocity(boardid, vectorspace, 10000, 0xff);...

  • Page 65

    Chapter 5 straight-line moves ni-motion user manual 5-10 ni.Com flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_modal_error_msg); } else // display regular error nimcdisplayerror(err,0,0); return ;// exit the application } velocity-based straight-line moves some motion applications require moves...

  • Page 66: Algorithm

    Chapter 5 straight-line moves © national instruments corporation 5-11 ni-motion user manual algorithm figure 5-4 is a generic algorithm applicable to both c/c++ and vi code. Figure 5-4. Velocity-based straight-line move algorithm.

  • Page 67

    Chapter 5 straight-line moves ni-motion user manual 5-12 ni.Com loading a second velocity and executing start motion causes the motion controller to accelerate or decelerate to the newly loaded velocity using the acceleration or deceleration parameters last loaded. The axis decelerates to a stop usi...

  • Page 68: Labview Code

    Chapter 5 straight-line moves © national instruments corporation 5-13 ni-motion user manual labview code figure 5-6. Velocity-based straight-line move in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on ...

  • Page 69

    Chapter 5 straight-line moves ni-motion user manual 5-14 ni.Com i32 errorcode;// error code // set the board id boardid = 3; // set the axis number axis = nimc_axis1; // move time for the first segment movetime1 = 5000; //milliseconds // move time for the second segment movetime2 = 10000; //millisec...

  • Page 70

    Chapter 5 straight-line moves © national instruments corporation 5-15 ni-motion user manual do { // check the following error/axis off status err = flex_read_axis_status_rtn(boardid, axis, &axisstatus); checkerror; // read the communication status register and check the modal //errors err = flex_rea...

  • Page 71

    Chapter 5 straight-line moves ni-motion user manual 5-16 ni.Com checkerror; // read the communication status register and check the modal // errors err = flex_read_csr_rtn(boardid, &csr); checkerror; // check the modal errors if (csr & nimc_modal_error_msg) { err = csr & nimc_modal_error_msg; checke...

  • Page 72

    Chapter 5 straight-line moves © national instruments corporation 5-17 ni-motion user manual flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_modal_error_msg); } else // display regular error nimcdisplayerror(err,0,0); return ;// exit the application } velocity profiling using velocity override yo...

  • Page 73: Algorithm

    Chapter 5 straight-line moves ni-motion user manual 5-18 ni.Com algorithm figure 5-7 is a generic algorithm applicable to both c/c++ and vi code. Figure 5-7. Velocity override algorithm waits the duration of time you specified for the originally loaded velocity waits the duration of time you specifi...

  • Page 74: Labview Code

    Chapter 5 straight-line moves © national instruments corporation 5-19 ni-motion user manual labview code figure 5-8. Velocity-based move using velocity override in labview 1 load velocity 2 load acceleration/deceleration 3 load acceleration/deceleration 4 load s-curve time 5 set operation mode 6 sta...

  • Page 75: C/c++ Code

    Chapter 5 straight-line moves ni-motion user manual 5-20 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) {...

  • Page 76

    Chapter 5 straight-line moves © national instruments corporation 5-21 ni-motion user manual // set the deceleration for the move (in counts/sec^2) err = flex_load_acceleration(boardid, axis, nimc_deceleration, 100000, 0xff); checkerror; // set the jerk (s-curve value) for the move (in sample periods...

  • Page 77

    Chapter 5 straight-line moves ni-motion user manual 5-22 ni.Com }while (!(axisstatus) && !(axisstatus & nimc_following_error_bit) && !(axisstatus & nimc_axis_off_bit)); //exit on move //complete/following error/axis off //------------------------------------------------- // second segment //--------...

  • Page 78

    Chapter 5 straight-line moves © national instruments corporation 5-23 ni-motion user manual err = flex_stop_motion(boardid, axis, nimc_decel_stop, 0); checkerror; // reset velocity override back to 100% err = flex_load_velocity_override(boardid, axis, 100, 0xff); checkerror; return ;// exit the appl...

  • Page 79: Arc Moves

    © national instruments corporation 6-1 ni-motion user manual 6 arc moves an arc move causes a coordinate space of axes to move on a circular, spherical, or helical path. You can move two-dimensional vector spaces in a circle only on a 2d plane. You can move a 3d vector space on a spherical or helica...

  • Page 80

    Chapter 6 arc moves ni-motion user manual 6-2 ni.Com to move axes in a circular arc, the motion controller needs the following information: • radius—specifies the distance from the center of the arc to its edge • start angle—orients the arc on its plane using the starting point as an axis to spin ar...

  • Page 81: Arc Move Algorithm

    Chapter 6 arc moves © national instruments corporation 6-3 ni-motion user manual figure 6-3. Positive and negative travel angles arc move algorithm figure 6-4. Circular arc move algorithm 1 positive travel angle 2 negative travel angle 1 2 load velocity start motion load acceleration/ deceleration p...

  • Page 82: Labview Code

    Chapter 6 arc moves ni-motion user manual 6-4 ni.Com labview code figure 6-5. Circular arc move in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compil...

  • Page 83

    Chapter 6 arc moves © national instruments corporation 6-5 ni-motion user manual u16 commandid;// the commandid of the function u16 resourceid;// the resource id i32 errorcode;// error code /////////////////////////////// // set the board id boardid = 1; // set the vector space number vectorspace = ...

  • Page 85: Spherical Arcs

    Chapter 6 arc moves © national instruments corporation 6-7 ni-motion user manual flex_read_error_msg_rtn (boardid,&commandi d,&resourceid, &errorcode); nimcdisplayerror(errorcode,commandid,res ourceid); //read the communication status register flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_moda...

  • Page 86

    Chapter 6 arc moves ni-motion user manual 6-8 ni.Com figure 6-7. Changing yaw by rotating the z axis in the transformed x'y'z' space, the 3d arc is reduced to a simpler 2d arc. The 3d arc is defined as a 2d circular arc in the x'y' plane of a transformed vector space x'y'z'. This transformed vector ...

  • Page 87: Algorithm

    Chapter 6 arc moves © national instruments corporation 6-9 ni-motion user manual algorithm figure 6-8. Spherical arc algorithm load velocity start motion load acceleration/ deceleration perform measurements (optional) load spherical arc radius, start angle, travel angle, yaw, and pitch move constrai...

  • Page 88: Labview Code

    Chapter 6 arc moves ni-motion user manual 6-10 ni.Com labview code figure 6-9. Spherical arc move in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and comp...

  • Page 89

    Chapter 6 arc moves © national instruments corporation 6-11 ni-motion user manual /////////////////////////////// // set the board id boardid = 1; // set the vector space number vectorspace = nimc_vector_space1; //////////////////////////////// // configure a 3d vector space comprising of axes 1, 2 ...

  • Page 91: Helical Arcs

    Chapter 6 arc moves © national instruments corporation 6-13 ni-motion user manual //get the command id, resource id, and the error code of the //modal error from the error stack on the device flex_read_error_msg_rtn (boardid,&commandi d,&resourceid, &errorcode); nimcdisplayerror(errorcode,commandid,...

  • Page 92: Algorithm

    Chapter 6 arc moves ni-motion user manual 6-14 ni.Com algorithm figure 6-11. Helical arc algorithm load velocity start motion load acceleration/ deceleration perform measurements (optional) load helical arc radius, start angle, travel angle, linear travel move constraints loop waiting for move compl...

  • Page 93: Labview Code

    Chapter 6 arc moves © national instruments corporation 6-15 ni-motion user manual labview code figure 6-12. Helical arc move in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files...

  • Page 94

    Chapter 6 arc moves ni-motion user manual 6-16 ni.Com // set the board id boardid = 1; // set the vector space number vectorspace = nimc_vector_space1; //////////////////////////////// // configure a 3d vector space comprising of axes 1, 2 and 3 err = flex_config_vect_spc(boardid, vectorspace, nimc_...

  • Page 96

    Chapter 6 arc moves ni-motion user manual 6-18 ni.Com flex_read_error_msg_rtn (boardid,&commandi d,&resourceid, &errorcode); nimcdisplayerror(errorcode,commandid,res ourceid); //read the communication status register flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_modal_error_msg); } else // dis...

  • Page 97: Contoured Moves

    © national instruments corporation 7-1 ni-motion user manual 7 contoured moves a contoured move moves an axis or a coordinate space of axes in a pattern that you define. The trajectory generator on the motion controller is not used during a contoured move. The controller takes position data in the f...

  • Page 98: Arbitrary Contoured Moves

    Chapter 7 contoured moves ni-motion user manual 7-2 ni.Com the difference between absolute contouring and relative contouring is how the points in the buffer are treated. The previous example was of an absolute contour move. A relative contour move treats the points as deltas according to the follow...

  • Page 99: Contoured Move Algorithm

    Chapter 7 contoured moves © national instruments corporation 7-3 ni-motion user manual contoured move algorithm figure 7-2. Contoured move algorithm clear the buffer that stores contoured move points start motion configure the buffer on the device perform measurements (optional) set operation mode s...

  • Page 100

    Chapter 7 contoured moves ni-motion user manual 7-4 ni.Com all contoured moves are relative, meaning motion starts from the position of the axis or axes at the time the contouring move starts. This behavior is similar to the way arc moves work. Depending on the operation mode you use, you can load a...

  • Page 101: Labview Code

    Chapter 7 contoured moves © national instruments corporation 7-5 ni-motion user manual labview code figur e 7-5 . Contoured move in labview 1 c onfigure v e ctor space 2 s et oper a tion mo de 3 c onfigure buff er 4 w ri te buff er 5 s tar t motion 6 r ead per a x is status 7 r ead per a x is status...

  • Page 102: C/c++ Code

    Chapter 7 contoured moves ni-motion user manual 7-6 ni.Com figure 7-6. Contoured move true case in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compil...

  • Page 103

    Chapter 7 contoured moves © national instruments corporation 7-7 ni-motion user manual i32 * downloaddata = null;// the temporary array that is created to // download the points to the motion controller u32 currentdatapoint = 0;// indicates the next point in the points // array to download i32 backl...

  • Page 104

    Chapter 7 contoured moves ni-motion user manual 7-8 ni.Com for (i=0;i downloaddata[i] = points[currentdatapoint++]; } err = flex_write_buffer(boardid, 1/*buffer number*/, buffersize, nimc_regeneration_no_change, downloaddata, 0xff); free(downloaddata); downloaddata = null; checkerror; // start motio...

  • Page 105

    Chapter 7 contoured moves © national instruments corporation 7-9 ni-motion user manual checkerror; } } // check the move complete status err = flex_check_move_complete_status(boardid, vectorspace, 0, &movecomplete); checkerror; if (movecomplete) break; // check for axis off status/following error or...

  • Page 106

    Chapter 7 contoured moves ni-motion user manual 7-10 ni.Com // free the buffer allocated on the motion controller memory err = flex_clear_buffer(boardid, 1/*buffer number*/); checkerror; return ;// exit the application ////////////////////// // error handling // nimchandleerror; //nimccatchthis: // ...

  • Page 107: Reference Moves

    © national instruments corporation 8-1 ni-motion user manual 8 reference moves use reference moves to move the axes to a known starting location and orientation. Reference functions include find reference, check reference, wait reference, read reference status, load reference parameters, and get ref...

  • Page 108: Reference Move Algorithm

    Chapter 8 reference moves ni-motion user manual 8-2 ni.Com reference move algorithm figure 8-1. Find reference move algorithm load velocity load jerk load acceleration/ deceleration find reference typically a find home find reference typically a find index move constraints loop waiting for find comp...

  • Page 109: Labview Code

    Chapter 8 reference moves © national instruments corporation 8-3 ni-motion user manual labview code figure 8-2. Find reference move in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd fo...

  • Page 110

    Chapter 8 reference moves ni-motion user manual 8-4 ni.Com //variables for modal error handling u16 commandid;// the commandid of the function u16 resourceid;// the resource id i32 errorcode;// error code //get the board id printf("enter the board id: "); scanf("%d", &scanvar); boardid=(u8)scanvar; ...

  • Page 111

    Chapter 8 reference moves © national instruments corporation 8-5 ni-motion user manual //wait for find reference to complete on the axis and also check //for modal errors at the same time do { //read the current position of axis err = flex_read_pos_rtn(boardid, axis, &position); checkerror; //displa...

  • Page 112

    Chapter 8 reference moves ni-motion user manual 8-6 ni.Com /////////////////////////////////////////////////////// ///////////// // error handling // nimchandleerror; // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do{ //get the command id, resource id, and the error ...

  • Page 113: Blending Moves

    © national instruments corporation 9-1 ni-motion user manual 9 blending moves use blending moves to create continuous motion between two or more move segments. Blending blending, also called velocity blending, superimposes the velocity profiles of two moves to maintain continuous motion. Blending is...

  • Page 114: Superimpose Two Moves

    Chapter 9 blending moves ni-motion user manual 9-2 ni.Com there are three ways you can start the second move in a blend: • superimpose the two moves by starting the second move as the first move starts to decelerate • start the second move after the first profile is complete • start the second move ...

  • Page 115

    Chapter 9 blending moves © national instruments corporation 9-3 ni-motion user manual blend after first move is complete blending moves after the first move is complete causes the first move segment to come to a complete stop before starting the profile of the second segment, as shown in figure 9-3....

  • Page 116: Blend After Delay

    Chapter 9 blending moves ni-motion user manual 9-4 ni.Com blend after delay you can blend two moves after a delay at the end of the first move, as shown in figure 9-4. Figure 9-4. Blending after a delay blending in this manner is useful if you want to start two move segments after a deterministic de...

  • Page 117: Blending Algorithm

    Chapter 9 blending moves © national instruments corporation 9-5 ni-motion user manual blending algorithm figure 9-5 illustrates a generic algorithm for blending moves. Figure 9-5. Blending algorithm start motion load move segment 2 blend motion perform measurements (optional) load move segment 1 coo...

  • Page 118: Labview Code

    Chapter 9 blending moves ni-motion user manual 9-6 ni.Com labview code f igure 9-6. B lend ed st raight -line mov e and a rc mo ve in l abv iew 1 c onfigure v e ctor space 2 l oad v e locity 3 l oad acceler a tion/decele ra tion 4 l oad acceler a tion/decele ra tion 5 l oad s-cu rv e t ime 6 s et op...

  • Page 119: C/c++ Code

    Chapter 9 blending moves © national instruments corporation 9-7 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main func...

  • Page 120

    Chapter 9 blending moves ni-motion user manual 9-8 ni.Com err = flex_set_op_mode(boardid, vectorspace, nimc_absolute_position); checkerror; // load the first straight-line segments to position 5000, 5000 err = flex_load_vs_pos(boardid, vectorspace, 5000, 5000, 0, 0xff); checkerror; // start the move...

  • Page 121

    Chapter 9 blending moves © national instruments corporation 9-9 ni-motion user manual { err = csr & nimc_modal_error_msg; checkerror; } sleep(50); //check every 50 ms }while (!Complete && !(axisstatus & nimc_following_error_bit) && !(axisstatus & nimc_axis_off_bit)); //exit on move //complete/follow...

  • Page 122

    Chapter 9 blending moves ni-motion user manual 9-10 ni.Com nimc_axis_off_bit)); //exit on move complete/following error/axis off return ;// exit the application /////////////////////////////////////////////////// // error handling // nimchandleerror; //nimccatchthis: // check to see if there were an...

  • Page 123: Electronic Gearing and

    © national instruments corporation 10-1 ni-motion user manual 10 electronic gearing and camming use electronic gearing or camming to synchronize the movement of one or more slave axes to the movement of a master device, which can be an encoder, adc, or the trajectory of another axis. The movement of...

  • Page 124: Algorithm

    Chapter 10 electronic gearing and camming ni-motion user manual 10-2 ni.Com algorithm figure 10-1. Electronic gearing algorithm the gear ratio is used to determine how far the slave axis must move in proportion to the master when gearing is enabled. The gear ratio can be absolute or relative. Slave ...

  • Page 125

    Chapter 10 electronic gearing and camming © national instruments corporation 10-3 ni-motion user manual for example, if you have a gearing ratio of 2:1 (slave:master), the slave moves 20 counts when the master device moves 10 counts. Figure 10-2. Relative gearing at enable absolute gearing behaves s...

  • Page 126: Gear Master

    Chapter 10 electronic gearing and camming ni-motion user manual 10-4 ni.Com changing a gear ratio on-the-fly during absolute gearing allows you to quickly synchronize the slave axis with the master axis. Note when the gear ratio is changed on-the-fly, the slave axis moves at full torque to the new p...

  • Page 127: Labview Code

    Chapter 10 electronic gearing and camming © national instruments corporation 10-5 ni-motion user manual labview code figure 10-4. Tracking an encoder using electronic gearing with superimposed move c/c++ code the following example code is not necessarily complete, and may not compile if copied exact...

  • Page 128

    Chapter 10 electronic gearing and camming ni-motion user manual 10-6 ni.Com // set the board id boardid = 1; // set the axis number slaveaxis = nimc_axis1; // master is encoder 4 master = nimc_encoder4; //////////////////////////////// // set up the gearing configuration for the slave axis err = fle...

  • Page 129

    Chapter 10 electronic gearing and camming © national instruments corporation 10-7 ni-motion user manual // load the target position for the registration (superimposed) //move err = flex_load_target_pos(boardid, slaveaxis, 5000, 0xff); checkerror; // start registration move on the slave err = flex_st...

  • Page 130: Camming

    Chapter 10 electronic gearing and camming ni-motion user manual 10-8 ni.Com camming electronic camming operates similarly to electronic gearing in that the move distance of an axis is proportional to the move distance of its master device. Camming differs from gearing in how the master/slave ratio i...

  • Page 131

    Chapter 10 electronic gearing and camming © national instruments corporation 10-9 ni-motion user manual figure 10-6. Multiple camming gear ratios an example of a motion control system that can benefit from the flexibility of electronic camming is welding parts as they travel on a conveyor belt. Figu...

  • Page 132

    Chapter 10 electronic gearing and camming ni-motion user manual 10-10 ni.Com figure 10-7. Welding application in this application, the master device is the position encoder attached to the conveyor belt, and the slave axis is the actuator that moves the welding point. The slave axis repeatedly perfo...

  • Page 133: Algorithm

    Chapter 10 electronic gearing and camming © national instruments corporation 10-11 ni-motion user manual algorithm similar to gearing, in a camming application, a slave axis can perform any move when camming is enabled. The move profile is superimposed over the camming profile. Figure 10-8. Camming ...

  • Page 134: Camming Table

    Chapter 10 electronic gearing and camming ni-motion user manual 10-12 ni.Com camming table when a camming operation is active, the slave axis follows a profile that is established using a list of master and slave positions pairs, called the camming table. Refer to table 10-1 for an example of a camm...

  • Page 135

    Chapter 10 electronic gearing and camming © national instruments corporation 10-13 ni-motion user manual 2,000 counts in the opposite direction of the conveyor belt at half the speed that the conveyor belt is traveling at. Figure 10-10 shows the move profile of the first and second move segments. Fi...

  • Page 136

    Chapter 10 electronic gearing and camming ni-motion user manual 10-14 ni.Com each row of data defines a gear ratio. The camming profile is repeated after a camming cycle is completed. The master position is always interpreted inside the modulus defined by the camming cycle. For example, initially, t...

  • Page 137: Slave Offset

    Chapter 10 electronic gearing and camming © national instruments corporation 10-15 ni-motion user manual figure 10-13. Gear ratio change figure 10-14 shows that when the master reaches position 6000, the slave axis moves back the original position, and the camming cycle begins again. Figure 10-14. C...

  • Page 138

    Chapter 10 electronic gearing and camming ni-motion user manual 10-16 ni.Com figure 10-15 shows that, after three camming cycles, the slave axis end position is 500 counts away from the starting position (0) with the slave offset, and that without the slave offset, the slave axis end position is 150...

  • Page 139: Master Offset

    Chapter 10 electronic gearing and camming © national instruments corporation 10-17 ni-motion user manual master offset if the material and welding point are not initially aligned, as shown in figure 10-16, the master offset must be applied to consider the position difference. Figure 10-16. Misaligne...

  • Page 140

    Chapter 10 electronic gearing and camming ni-motion user manual 10-18 ni.Com figure 10-17. Camming profile starts when first material passes figure 10-18 shows the camming profile used for the application portrayed in figure 10-16 and figure 10-17. Figure 10-18. Camming profiles with and without mas...

  • Page 141: Labview Code

    Chapter 10 electronic gearing and camming © national instruments corporation 10-19 ni-motion user manual labview code figure 10-19. Axis to axis camming c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-mo...

  • Page 142

    Chapter 10 electronic gearing and camming ni-motion user manual 10-20 ni.Com u8 slaveaxis = 1; // slave axis id u8 buffer = 1; // buffer to contain the cam table i32 positionarr[] = {0, 10000, 40000, 45000, 45000, 40000, 10000, 0}; // position array u32 positionsize = sizeof(positionarr) / sizeof(i3...

  • Page 143

    Chapter 10 electronic gearing and camming © national instruments corporation 10-21 ni-motion user manual // configure the superimposed move (optional) // set to absolute mode err = flex_set_op_mode(boardid, slaveaxis, nimc_absolute_position); checkerror; // set the maximum velocity data.Doubledata =...

  • Page 144

    Chapter 10 electronic gearing and camming ni-motion user manual 10-22 ni.Com flex_read_error_msg_rtn (boardid, &commandid, &resourceid, &errorcode); nimcdisplayerror(errorcode, commandid, resourceid); //read the communication status register flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_modal_...

  • Page 145: Acquiring Time-Sampled

    © national instruments corporation 11-1 ni-motion user manual 11 acquiring time-sampled position and velocity data ni motion controllers can acquire a buffer of position and velocity data that is firmware-timed. After you command the motion controller to acquire position and velocity data, a separat...

  • Page 146: Algorithm

    Chapter 11 acquiring time-sampled position and velocity data ni-motion user manual 11-2 ni.Com the fifo buffer is of a fixed size that can accommodate 4,096 samples for one axis. One sample consists of position data, in counts or steps, and velocity data, in counts/s or steps/s. As you increase the ...

  • Page 147

    Chapter 11 acquiring time-sampled position and velocity data © national instruments corporation 11-3 ni-motion user manual the data must be read one sample at a time. A four-axis sample uses the following pattern for returning the data. If you request 1,024 samples, you must read each of the 1,024 s...

  • Page 148: Labview Code

    Chapter 11 acquiring time-sampled position and velocity data ni-motion user manual 11-4 ni.Com labview code figure 11-3 acquires data for two axes, 200 samples, and three milliseconds apart. Figure 11-3. Acquire data using labview c/c++ code the following example code is not necessarily complete, an...

  • Page 149

    Chapter 11 acquiring time-sampled position and velocity data © national instruments corporation 11-5 ni-motion user manual i32 axis1positions[200];// array to store the positions (1) i32 axis1velocities[200];// array to store velocities(1) i32 axis2positions[200];// array to store the positions (2) ...

  • Page 150

    Chapter 11 acquiring time-sampled position and velocity data ni-motion user manual 11-6 ni.Com // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id, and the error code of the //modal error from the error stack on the device flex_read_...

  • Page 151: Synchronization

    © national instruments corporation 12-1 ni-motion user manual 12 synchronization you can synchronize ni motion controllers with ni data and image acquisition devices using breakpoints and high-speed captures. Timing and triggering with ni-motion is always related to either position or velocity. Sync...

  • Page 152: Absolute Breakpoints

    Chapter 12 synchronization ni-motion user manual 12-2 ni.Com table 12-1 shows the availability of breakpoint modes on each ni motion controller. Note if you are using a data or image acquisition device with your motion control system, be aware that the ni softmotion controller does not support the r...

  • Page 153

    Chapter 12 synchronization © national instruments corporation 12-3 ni-motion user manual note all breakpoints can be affected by jitter in the motion control system. For example, if you have a very small breakpoint window, the jitter in the motion control system could cause the position to change en...

  • Page 154

    Chapter 12 synchronization ni-motion user manual 12-4 ni.Com buffered breakpoint algorithm figure 12-1 shows the basic algorithm for implementing buffered breakpoints. Figure 12-1. Buffered breakpoint algorithm configure the onboard buffer enable the breakpoint write buffer write the array of breakp...

  • Page 155: Labview Code

    Chapter 12 synchronization © national instruments corporation 12-5 ni-motion user manual labview code figure 12-2. Buffered position breakpoint in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-...

  • Page 156

    Chapter 12 synchronization ni-motion user manual 12-6 ni.Com // buffer resources i32 breakpointpositions[] = {1000, 1100, 1200, 1300, 1400, 1500, 1600}; u16 numberofpoints = 7;// number of breakpoints f64 actualinterval;// required in the function call but not being //used f64 requestedinterval = 10...

  • Page 157

    (bufferstate != nimc_buffer_done)); // clear the buffer err = flex_clear_buffer(boardid, buffer); checkerror; return ; /////////////////////////////////////////////////...

  • Page 158: Single Position Breakpoints

    Chapter 12 synchronization ni-motion user manual 12-8 ni.Com single position breakpoints single position breakpoints execute one breakpoint per enabling. Single position breakpoint algorithm figure 12-3 shows the basic algorithm for implementing single position breakpoints. Figure 12-3. Single posit...

  • Page 159: Labview Code

    Chapter 12 synchronization © national instruments corporation 12-9 ni-motion user manual labview code figure 12-4. Single position breakpoint in labview 1 configure breakpoint 2 load breakpoint position 3 enable breakpoint output 4 read per axis status 5 motion error handler 4 3 2 1 5.

  • Page 160: C/c++ Code

    Chapter 12 synchronization ni-motion user manual 12-10 ni.Com refer to figure 12-5 for an example of how to route this breakpoint using rtsi. Figure 12-5. Single position breakpoint with rtsi using labview after the breakpoint is routed through rtsi, the trigger appears on both the rtsi line and the...

  • Page 161

    Chapter 12 synchronization © national instruments corporation 12-11 ni-motion user manual /////////////////////////////// // set the board id boardid = 1; // set the axis number axis = nimc_axis1; //////////////////////////////// // route breakpoint 1 to rtsi line 1 err = flex_select_signal (boardid...

  • Page 162

    Chapter 12 synchronization ni-motion user manual 12-12 ni.Com } sleep (10); //check every 10 ms }while (!(axisstatus & nimc_pos_breakpoint_bit)); // wait for breakpoint to be triggered } return ;// exit the application ////////////////////// // error handling nimchandleerror; //nimccatchthis: // che...

  • Page 163

    Chapter 12 synchronization © national instruments corporation 12-13 ni-motion user manual breakpoint is useful in this example because the current position is not important. The application must move the axis a specific number of counts from wherever it is, and then generate a breakpoint. Note all b...

  • Page 164: Labview Code

    Chapter 12 synchronization ni-motion user manual 12-14 ni.Com labview code in this example, a breakpoint generates and then is re-enabled 5,000 counts from where the move starts. The following code examples are designed to illustrate the relative breakpoint algorithm only. These examples are not com...

  • Page 165

    Chapter 12 synchronization © national instruments corporation 12-15 ni-motion user manual // set the axis number axis = nimc_axis1; /////////////////////////////// // route breakpoint 1 to rtsi line 1 err = flex_select_signal (boardid, nimc_rtsi1 /*destination*/, nimc_breakpoint1/*source*/); checker...

  • Page 166

    Chapter 12 synchronization ni-motion user manual 12-16 ni.Com return ;// exit the application /////////////////////////////////////////////////// // error handling // nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the comm...

  • Page 167

    Chapter 12 synchronization © national instruments corporation 12-17 ni-motion user manual periodic breakpoints (ni 7350 only) periodic breakpoints require that you specify an initial breakpoint and an ongoing repeat period. When enabled, the periodic breakpoints begin when the initial breakpoint occ...

  • Page 168: Labview Code

    Chapter 12 synchronization ni-motion user manual 12-18 ni.Com labview code figure 12-10. Periodic breakpoint output c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete a...

  • Page 169

    Chapter 12 synchronization © national instruments corporation 12-19 ni-motion user manual //variables for modal error handling u16 commandid; // the commandid of the function u16 resourceid; // the resource id i32 errorcode; //get the board id printf("enter the board id: "); scanf("%u", &boardid); /...

  • Page 170

    Chapter 12 synchronization ni-motion user manual 12-20 ni.Com checkerror; printf(""); do { //read the axis status err = flex_read_axis_status_rtn (boardid,axis,&axisstat us); checkerror; err = flex_read_pos_rtn (boardid,axis,¤tpos); checkerror; //check the breakpoint bit bpstatus = !((axisst...

  • Page 171

    Chapter 12 synchronization © national instruments corporation 12-21 ni-motion user manual nimchandleerror; // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource and the error code of the modal //error from the error stack on the board fle...

  • Page 172

    Chapter 12 synchronization ni-motion user manual 12-22 ni.Com figure 12-11. Breakpoint modulus of 500 as another example, if you set the breakpoint repeat period to be 2000 counts and the offset to be –500, breakpoints occur at –4500, –2500, –500, 1500, 3500. If the breakpoint is enabled when the ax...

  • Page 173: Modulo Breakpoints Algorithm

    Chapter 12 synchronization © national instruments corporation 12-23 ni-motion user manual modulo breakpoints algorithm figure 12-13 shows the basic algorithm for modulo breakpoints. Figure 12-13. Modulo breakpoints algorithm enable breakpoint wait for breakpoint to cause a trigger configure breakpoi...

  • Page 174: Labview Code

    Chapter 12 synchronization ni-motion user manual 12-24 ni.Com labview code figure 12-14. Modulo breakpoint using labview figure 12-15. Modulo breakpoint with rtsi using labview 1 configure breakpoint 2 load breakpoint modulus 3 load breakpoint position 4 enable breakpoint output 5 read per axis stat...

  • Page 175: C/c++ Code

    Chapter 12 synchronization © national instruments corporation 12-25 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main ...

  • Page 176

    Chapter 12 synchronization ni-motion user manual 12-26 ni.Com err = flex_enable_breakpoint(boardid, axis, nimc_true); checkerror; do { // check the move complete status/following error/axis off //status err = flex_read_axis_status_rtn(boardid, axis, &axisstatus); checkerror; // read the communicatio...

  • Page 177: High-Speed Capture

    Chapter 12 synchronization © national instruments corporation 12-27 ni-motion user manual nimcdisplayerror(err,0,0); return ;// exit the application } high-speed capture some motion control applications require that you execute a move and record the locations where external triggers happen. To accom...

  • Page 178

    Chapter 12 synchronization ni-motion user manual 12-28 ni.Com buffered high-speed capture algorithm figure 12-16. Buffered high-speed capture algorithm configure a buffer on the controller configure high-speed capture enable high-speed capture read buffer (optional) read captured positions to free t...

  • Page 179: Labview Code

    Chapter 12 synchronization © national instruments corporation 12-29 ni-motion user manual labview code figure 12-17. Buffered high-speed capture in labview c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni...

  • Page 180

    Chapter 12 synchronization ni-motion user manual 12-30 ni.Com u32 pointsdone;// indicates the number of points that have been //consumed u16 bufferstate;// indicates the state of the onboard buffer u32 currentdatapoint = 0;// indicates the next points to be read //from the buffer i32 * readbuffer = ...

  • Page 181

    Chapter 12 synchronization © national instruments corporation 12-31 ni-motion user manual if (backlog > 0) { readbuffer = (i32*)malloc(sizeof(i32)*backlog); // if captured position available in the buffer, read the //captured position from the buffer err = flex_read_buffer_rtn(boardid, 1/*buffer num...

  • Page 182

    Chapter 12 synchronization ni-motion user manual 12-32 ni.Com checkerror; return ;// exit the application /////////////////////////////////////////////////// ////////////// // error handling // nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_erro...

  • Page 183: High-Speed Capture Algorithm

    Chapter 12 synchronization © national instruments corporation 12-33 ni-motion user manual high-speed capture algorithm figure 12-18. High-speed capture algorithm configure high-speed capture read the captured position (optional) enable high-speed capture do the required task on trigger this could be...

  • Page 184: Labview Code

    Chapter 12 synchronization ni-motion user manual 12-34 ni.Com labview code figure 12-19. High-speed capture using labview to trigger the high-speed capture from a rtsi line, set the destination parameter in select signal to high speed capture 1, as shown in figure 12-20. 1 configure high-speed captu...

  • Page 185: C/c++ Code

    Chapter 12 synchronization © national instruments corporation 12-35 ni-motion user manual figure 12-20. High-speed capture with rtsi using labview c/c++ code the following section includes c/c++ code for executing a high-speed capture, as well as using rtsi to execute a high-speed capture. The follo...

  • Page 186

    Chapter 12 synchronization ni-motion user manual 12-36 ni.Com axis = nimc_axis1; //////////////////////////////// // route hsc 1 to rtsi line 1 err = flex_select_signal (boardid, nimc_hs_capture1 /*destination*/, nimc_rtsi1/*source*/); checkerror; //configure high-speed capture err = flex_configure_...

  • Page 187

    Chapter 12 synchronization © national instruments corporation 12-37 ni-motion user manual // nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id, and the error code of the //modal error from the erro...

  • Page 188

    Chapter 12 synchronization ni-motion user manual 12-38 ni.Com you also can create a software trigger by writing to the rtsi lines directly from software. You can route position breakpoints and encoder pulses using the rtsi bus to trigger other devices. You also can configure data and image acquisiti...

  • Page 189: Encoder Pulses Using Rtsi

    Chapter 12 synchronization © national instruments corporation 12-39 ni-motion user manual position breakpoints using rtsi you can use the select signal function to route position breakpoints using one of the rtsi lines. In this case, the motion controller triggers the external device at a given posi...

  • Page 190

    Chapter 12 synchronization ni-motion user manual 12-40 ni.Com high-speed capture input using rtsi when the rtsi line receives the trigger from a data or image acquisition device, the corresponding high-speed capture occurs, as shown in figure 12-25. Figure 12-25. High-speed capture input using rtsi ...

  • Page 191: Torque Control

    © national instruments corporation 13-1 ni-motion user manual 13 torque control to maintain constant torque or force, the sensor that returns the feedback to the motion controller must return a value proportional to the torque or force. The motion controller operates torque-control and position-cont...

  • Page 192

    Chapter 13 torque control ni-motion user manual 13-2 ni.Com tuning the control loop with a force sensor, which is an analog feedback sensor, produces the same results as with a position feedback sensor. Depending upon the resolution you are using, the system may require higher gains to ensure a fast...

  • Page 193

    Chapter 13 torque control © national instruments corporation 13-3 ni-motion user manual torque control using analog feedback algorithm figure 13-2. Torque control using analog feedback algorithm start motion start motion (optional) update target position (optional) set operation mode loop waiting fo...

  • Page 194: Labview Code

    Chapter 13 torque control ni-motion user manual 13-4 ni.Com labview code figure 13-3. Torque control using analog feedback using labview 1 load velocity 2 load acceleration/deceleration 3 load acceleration/deceleration 4 set operation mode 5 load target position 6 start motion 7 read per axis status...

  • Page 195: C/c++ Code

    Chapter 13 torque control © national instruments corporation 13-5 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main fu...

  • Page 196

    Chapter 13 torque control ni-motion user manual 13-6 ni.Com err = flex_load_acceleration(boardid, axis, nimc_deceleration, 100000, 0xff); checkerror; // set the jerk - s-curve time (in sample periods) err = flex_load_scurve_time(boardid, axis, 1000, 0xff); checkerror; // set the operation mode err =...

  • Page 197

    Chapter 13 torque control © national instruments corporation 13-7 ni-motion user manual } }while (!Movecomplete && !(axisstatus & nimc_following_error_bit) && !(axisstatus & nimc_axis_off_bit)); //exit on move complete/following error/axis off return ;// exit the application ////////////////////////...

  • Page 198: Monitoring Force

    Chapter 13 torque control ni-motion user manual 13-8 ni.Com monitoring force you can use this second force-feedback mode if you have a position sensor on the motor, in addition to the torque sensor. The control loop on the motion controller closes the position and velocity loops as usual. Use max to...

  • Page 199

    Chapter 13 torque control © national instruments corporation 13-9 ni-motion user manual torque control using monitoring force algorithm figure 13-5. Torque control using monitoring force algorithm read analog sensor check against required value start motion (optional) update target position (optiona...

  • Page 200: Labview Code

    Chapter 13 torque control ni-motion user manual 13-10 ni.Com labview code figure 13-6. Torque control using monitoring force in labview 1 load velocity 2 load acceleration/deceleration 3 load acceleration/deceleration 4 set operation mode 5 read adc 6 load target position 7 start motion 8 read per a...

  • Page 201: C/c++ Code

    Chapter 13 torque control © national instruments corporation 13-11 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main f...

  • Page 202

    Chapter 13 torque control ni-motion user manual 13-12 ni.Com err = flex_load_acceleration(boardid, axis, nimc_deceleration, 100000, 0xff); checkerror; // set the jerk (s-curve value) for the move (in sample periods) err = flex_load_scurve_time(boardid, axis, 100, 0xff); checkerror; // set the operat...

  • Page 203

    Chapter 13 torque control © national instruments corporation 13-13 ni-motion user manual } sleep (50); //check every 50 ms }while (!(axisstatus & nimc_axis_off_bit)); //exit on axis off return ;// exit the application /////////////////////////////////////////////////// // error handling // nimchandl...

  • Page 204

    Chapter 13 torque control ni-motion user manual 13-14 ni.Com speed control based on analog value in a system where a feed roll must run at speeds based on an input voltage, the algorithm to maintain the speed consists of reading the analog voltage connected to one of the analog channels on the motio...

  • Page 205: Labview Code

    Chapter 13 torque control © national instruments corporation 13-15 ni-motion user manual labview code figure 13-8. Speed control based on analog feedback using labview 1 load velocity 2 load acceleration/deceleration 3 load acceleration/deceleration 4 set operation mode 5 start motion 6 read adc 7 l...

  • Page 206: C/c++ Code

    Chapter 13 torque control ni-motion user manual 13-16 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) { u8...

  • Page 207

    Chapter 13 torque control © national instruments corporation 13-17 ni-motion user manual // set the jerk (s-curve value) for the move (in sample periods) err = flex_load_scurve_time(boardid, axis, 100, 0xff); checkerror; // set the operation mode to velocity err = flex_set_op_mode(boardid, axis, nim...

  • Page 208

    Chapter 13 torque control ni-motion user manual 13-18 ni.Com sleep (50); //check every 50 ms }while (!(axisstatus & nimc_axis_off_bit)); //exit on axis off return ;// exit the application /////////////////////////////////////////////////// // error handling // nimchandleerror; //nimccatchthis: // ch...

  • Page 209: Onboard Programs

    © national instruments corporation 14-1 ni-motion user manual 14 onboard programs this chapter provides information about how onboard programs work for the ni softmotion controller and for ni 73xx motion controllers. Using onboard programs with the ni softmotion controller to use onboard programs wi...

  • Page 210: Motion Controllers

    Chapter 14 onboard programs ni-motion user manual 14-2 ni.Com using onboard programs with ni 73xx motion controllers you can use the real-time operating system on the ni 73xx motion controller to run custom programs. This functionality allows you to offload some motion-specific tasks from the host p...

  • Page 211: Writing Onboard Programs

    Chapter 14 onboard programs © national instruments corporation 14-3 ni-motion user manual figure 14-1. Onboard program priority note if you continuously poll data from the host, the onboard program gets preempted and has less time to run. To keep this from happening, insert a small delay in the poll...

  • Page 212: Algorithm

    Chapter 14 onboard programs ni-motion user manual 14-4 ni.Com figure 14-2. Writing onboard programs algorithm figure 14-3. Basic onboard program algorithm 1 write the program you want to load onto onboard memory. You can use any ni-motion functions between begin and end store. 2 transfer the program...

  • Page 213: Labview Code

    Chapter 14 onboard programs © national instruments corporation 14-5 ni-motion user manual labview code figure 14-4. Onboard program in labview 1 begin program storage 2 load target position 3 load velocity in rpm 4 load accel/decel in rps/s 5 load accel/decel in rps/s 6 start motion 7 end program st...

  • Page 214: C/c++ Code

    Chapter 14 onboard programs ni-motion user manual 14-6 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) { u...

  • Page 215

    Chapter 14 onboard programs © national instruments corporation 14-7 ni-motion user manual err = flex_load_rpsps(boardid, axis, nimc_both, 50.00, 0xff); checkerror; // start the move err = flex_start(boardid, axis, 0); checkerror; // end program storage err = flex_end_store(boardid, 1); checkerror; r...

  • Page 216: Running An Onboard Program

    Chapter 14 onboard programs ni-motion user manual 14-8 ni.Com running, stopping, and pausing onboard programs use the run program, stop program, and pause/resume program functions to run, stop, and pause an onboard program that resides in the onboard memory of a motion controller. Running an onboard...

  • Page 217: Automatic Pausing

    Chapter 14 onboard programs © national instruments corporation 14-9 ni-motion user manual you can resume an onboard program with a function call from the host or from another running onboard program. Note it is not possible for an onboard program to resume itself. Tip similarly to the stop program f...

  • Page 218

    Chapter 14 onboard programs ni-motion user manual 14-10 ni.Com figure 14-5. Executing onboard programs generator reaction task communication task run program onboard programs.

  • Page 219

    Chapter 14 onboard programs © national instruments corporation 14-11 ni-motion user manual onboard program conditional execution algorithm figure 14-6. Onboard program conditional execution algorithm start move wait for move event signal begin store put motion controller in store mode end store end ...

  • Page 220: Labview Code

    Chapter 14 onboard programs ni-motion user manual 14-12 ni.Com labview code figure 14-7. Onboard program waiting for an i/o line to go active c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for...

  • Page 221

    Chapter 14 onboard programs © national instruments corporation 14-13 ni-motion user manual // set the board id boardid = 1; // set the axis number axis = nimc_axis1; //////////////////////////////// // begin onboard program storage - program number 1 err = flex_begin_store(boardid, 1); checkerror; /...

  • Page 222

    Chapter 14 onboard programs ni-motion user manual 14-14 ni.Com checkerror; return ;// exit the application ////////////////////// // error handling nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id...

  • Page 223: Algorithm

    Chapter 14 onboard programs © national instruments corporation 14-15 ni-motion user manual algorithm figure 14-8. Updating velocity based on adc channel algorithm before you execute this program, set the operation mode of the axis to velocity mode. Set a label start move jump to label begin store pu...

  • Page 224: Labview Code

    Chapter 14 onboard programs ni-motion user manual 14-16 ni.Com labview code figure 14-9. Updating velocity based on adc channel in labview 1 load constant to variable 2 load constant to variable 3 begin program storage 4 set operation mode 5 insert program label 6 read adc 7 multiply variables 8 sub...

  • Page 225: C/c++ Code

    Chapter 14 onboard programs © national instruments corporation 14-17 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main...

  • Page 226

    Chapter 14 onboard programs ni-motion user manual 14-18 ni.Com err = flex_read_adc16(boardid, nimc_adc1, 2); checkerror; //multiply variable 2 (adc value) with variable 1 (constant) // save the result in variable 3 err = flex_mult_vars(boardid, 1, 2, 3); checkerror; //subtract value in variable 3 fr...

  • Page 227: Branching Onboard Programs

    Chapter 14 onboard programs © national instruments corporation 14-19 ni-motion user manual ////////////////////// // error handling // nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id, and the err...

  • Page 228: Onboard Program Algorithm

    Chapter 14 onboard programs ni-motion user manual 14-20 ni.Com onboard program algorithm figure 14-10 shows an onboard program waiting for an i/o line to go active before starting a move. Figure 14-10. Using labels with onboard programs start move set a label wait for move event signal jump to label...

  • Page 229: Labview Code

    Chapter 14 onboard programs © national instruments corporation 14-21 ni-motion user manual labview code figure 14-11. Continuously executing onboard program in labview 1 begin program storage 2 set operation mode 3 load velocity in rpm 4 insert program label 5 load target position 6 select momo 7 wa...

  • Page 230: C/c++ Code

    Chapter 14 onboard programs ni-motion user manual 14-22 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) { ...

  • Page 231

    Chapter 14 onboard programs © national instruments corporation 14-23 ni-motion user manual err = flex_load_target_pos(boardid, axis, 5000, 0xff); checkerror; // wait for line 1 on port 1 to go active to finish executing err = flex_wait_on_event(boardid, nimc_io_port1, nimc_wait, nimc_condition_io_po...

  • Page 232: Math Operations

    Chapter 14 onboard programs ni-motion user manual 14-24 ni.Com //read the communication status register flex_read_csr_rtn (boardid,&csr); }while(csr & nimc_modal_error_msg); } else // display regular error nimcdisplayerror(err,0,0); return ;// exit the application } math operations ni-motion always ...

  • Page 233: Onboard Buffers

    Chapter 14 onboard programs © national instruments corporation 14-25 ni-motion user manual figure 14-12. Reading an indirect variable using indirect variables can be very useful in looping in onboard programs, as well as dynamically changing the input values to functions. Onboard buffers you can use...

  • Page 234: Algorithm

    Chapter 14 onboard programs ni-motion user manual 14-26 ni.Com buffers are created from a dynamic pool of memory, so you must free the memory when the buffer is not required. This same pool of memory is used to store onboard programs in ram. As the number or size of buffers increases, the available ...

  • Page 235

    Chapter 14 onboard programs © national instruments corporation 14-27 ni-motion user manual figure 14-15. Synchronizing host applications with onboard programs for example, consider a host application that reads an onboard variable that has been updated by an onboard program. Use the algorithm in fig...

  • Page 236: Labview Code

    Chapter 14 onboard programs ni-motion user manual 14-28 ni.Com labview code this example moves axis 1 between target positions of 5000 and –5000. The host reads the target position only after the move has completed, and the new target position has been calculated. Figure 14-17 shows the code that ru...

  • Page 237

    Chapter 14 onboard programs © national instruments corporation 14-29 ni-motion user manual figure 14-18 shows the code that runs on the host. Figure 14-18. Synchronization host code in labview note as the host is polling a register on the motion controller, it is not invoking the host communication ...

  • Page 238: C/c++ Code

    Chapter 14 onboard programs ni-motion user manual 14-30 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) { ...

  • Page 239

    Chapter 14 onboard programs © national instruments corporation 14-31 ni-motion user manual err = flex_load_var(boardid, targetposition, 1); checkerror; // begin onboard program storage - program number 1 err = flex_begin_store(boardid, 1); // set the operation mode to absolute position err = flex_se...

  • Page 240

    Chapter 14 onboard programs ni-motion user manual 14-32 ni.Com err = flex_jump_on_event (boardid, 0, nimc_condition_true, 0, 0, nimc_match_all, 1/*label number*/); checkerror; // end program storage err = flex_end_store(boardid, 1); checkerror; //------------------------------------------------ // h...

  • Page 241

    Chapter 14 onboard programs © national instruments corporation 14-33 ni-motion user manual err = flex_read_var_rtn(boardid, 1, ¤ttargetposition); checkerror; } sleep (50); //check every 50 ms }while (!(axisstatus & nimc_following_error_bit) && !(axisstatus & nimc_axis_off_bit)); //exit on move...

  • Page 242: Onboard Subroutines

    Chapter 14 onboard programs ni-motion user manual 14-34 ni.Com onboard subroutines you can create subroutines to run as onboard programs and execute them from within an onboard program. Algorithm figure 14-19 shows an onboard program algorithm that checks the i/o line state to determine which onboar...

  • Page 243: Labview Code

    Chapter 14 onboard programs © national instruments corporation 14-35 ni-motion user manual labview code figure 14-20 shows the main onboard program used to determine the subroutine call. Figure 14-20. Onboard subroutine call using labview 1 begin program storage 2 insert program label 3 select momo ...

  • Page 244

    Chapter 14 onboard programs ni-motion user manual 14-36 ni.Com figure 14-21 shows the subroutine that causes the motor to rotate clockwise. Figure 14-21. Clockwise subroutine using labview 1 begin program storage 2 set operation mode 3 load target position 4 load velocity in rpm 5 load accel/decel i...

  • Page 245

    Chapter 14 onboard programs © national instruments corporation 14-37 ni-motion user manual figure 14-22 shows the subroutine that causes the motor to rotate counter clockwise. Figure 14-22. Counter clockwise subroutine using labview 1 begin program storage 2 set operation mode 3 load target position...

  • Page 246: C/c++ Code

    Chapter 14 onboard programs ni-motion user manual 14-38 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main function void main(void) { ...

  • Page 247

    Chapter 14 onboard programs © national instruments corporation 14-39 ni-motion user manual err = flex_load_rpsps(boardid, axis, nimc_both, 50.00, 0xff); checkerror; // start the move err = flex_start(boardid, axis, 0); checkerror; // wait for move to complete err = flex_wait_on_event(boardid, 0, nim...

  • Page 248

    Chapter 14 onboard programs ni-motion user manual 14-40 ni.Com checkerror; // wait for move to complete err = flex_wait_on_event(boardid, 0, nimc_wait, nimc_condition_move_complete, 2/*indicates axis 1*/, 0, nimc_match_all, 1000 /*time out*/, 0); checkerror; // end program storage err = flex_end_sto...

  • Page 249

    Chapter 14 onboard programs © national instruments corporation 14-41 ni-motion user manual // insert label number 2 err = flex_insert_program_label(boardid, 2); checkerror; // execute program 2 err = flex_run_prog(boardid, 2); checkerror; // wait for program 2 to finish executing err = flex_wait_on_...

  • Page 250: Changing A Time Slice

    Chapter 14 onboard programs ni-motion user manual 14-42 ni.Com automatically starting onboard programs you can configure the onboard program to start automatically without calling the run program function. The onboard program runs as soon as the motion controller exits the reset state. To use this f...

  • Page 251: Part IV

    © national instruments corporation iv-1 ni-motion user manual part iv creating applications using ni-motion you can combine the moves, input/output, and other functionality discussed in part iii, programming with ni-motion , to create complete motion control applications. The following chapters show...

  • Page 252: Scanning

    © national instruments corporation 15-1 ni-motion user manual 15 scanning the goal of the scanning application is to inspect a wafer under a fixed laser. Multiple detectors collect the scattered laser light and feed the data to an analysis system that maps any defects. The wafer rests on an xy stage...

  • Page 253

    Chapter 15 scanning ni-motion user manual 15-2 ni.Com raster scanning using straight lines algorithm figure 15-2. Raster scanning using straight lines algorithm the raster scanning algorithm for straight-line moves stops the motors after every segment of the move, so the cycle time is longer than ot...

  • Page 254: Labview Code

    Chapter 15 scanning © national instruments corporation 15-3 ni-motion user manual labview code f igure 15-3. Scanning using labview 1 c onfigure v e ctor space 2 l oad v e locity 3 l oad acceler a tion/decele ra tion 4 l oad acceler a tion/decele ra tion 5 load s-c u rv e t ime 6 s et ope ration mod...

  • Page 255: C/c++ Code

    Chapter 15 scanning ni-motion user manual 15-4 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. # define d_numberofsegments // main function...

  • Page 256

    Chapter 15 scanning © national instruments corporation 15-5 ni-motion user manual // set the deceleration for the move (in counts/sec^2) err = flex_load_acceleration(boardid, vectorspace, nimc_deceleration, 100000, 0xff); checkerror; // set the jerk or s-curve in sample periods err = flex_load_scurv...

  • Page 257

    Chapter 15 scanning ni-motion user manual 15-6 ni.Com //read the communication status register and check the modal //errors err = flex_read_csr_rtn(boardid, &csr); checkerror; //check the modal errors if (csr & nimc_modal_error_msg) { err = csr & nimc_modal_error_msg; checkerror; } sleep(10); //chec...

  • Page 258

    Chapter 15 scanning © national instruments corporation 15-7 ni-motion user manual blending straight-line move segments blending the straight-line move segments enables continuous motion, which decreases the cycle time of the scan. The cycle time is much faster because the motors are not forced to st...

  • Page 259

    Chapter 15 scanning ni-motion user manual 15-8 ni.Com raster scanning using blended straight lines algorithm figure 15-5. Raster scanning using blended straight lines algorithm configure the coordinate space load move constraints set blend factor set operation mode create the move segments load move...

  • Page 260: Labview Code

    Chapter 15 scanning © national instruments corporation 15-9 ni-motion user manual labview code fig u re 15 -6. Scanning using blending 1 c onfigure v e ctor space 2 l oad v e locity 3 l oad acceler a tion/decele ra tion 4 l oad acceler a tion/decele ra tion 5 l oad s-cu rv e t ime 6 load blend f a c...

  • Page 261: C/c++ Code

    Chapter 15 scanning ni-motion user manual 15-10 ni.Com c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. #define d_numberofsegments // main function...

  • Page 262

    Chapter 15 scanning © national instruments corporation 15-11 ni-motion user manual // set the deceleration for the move (in counts/sec^2) err = flex_load_acceleration(boardid, vectorspace, nimc_deceleration, 100000, 0xff); checkerror; // set the jerk or s-curve in sample periods err = flex_load_scur...

  • Page 263

    Chapter 15 scanning ni-motion user manual 15-12 ni.Com checkerror; }else{ // check the blend complete status err = flex_check_blend_complete_status (b oardid, vectorspace, 0, &complete); checkerror; } // check the following error/axis off status for axis 1 err = flex_read_axis_status_rtn(boardid, ni...

  • Page 264: User-Defined Scanning Path

    Chapter 15 scanning © national instruments corporation 15-13 ni-motion user manual return ;// exit the application // error handling nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if (csr & nimc_modal_error_msg){ do { //get the command id, resource id, and the error...

  • Page 265

    Chapter 15 scanning ni-motion user manual 15-14 ni.Com figure 15-7. User-defined scanning path using the contoured move gives you the greatest amount of flexibility regarding the scan area and speed. However you lose the benefit of the trajectory generator of the ni motion controller. Refer to chapt...

  • Page 266

    Chapter 15 scanning © national instruments corporation 15-15 ni-motion user manual user-defined scanning path algorithm figure 15-8. User-defined scanning path algorithm configure onboard buffer write buffer start motion clear the onboard buffer used to store the points set operation mode loop waiti...

  • Page 267: Labview Code

    Chapter 15 scanning ni-motion user manual 15-16 ni.Com labview code figur e 15-9 . Scan nin g using con touring 1 c onfigure v e ctor space 2 s et oper a tion mo de 3 c onfigure buff er 4 w ri te buff er 5 s tar t mo tion 6 c hec k buff er 7 w ri te b u ff er 8 c lear buff er 9 s et op er atio n mod...

  • Page 268: C/c++ Code

    Chapter 15 scanning © national instruments corporation 15-17 ni-motion user manual c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files that are complete and compile as is. // main functio...

  • Page 269

    Chapter 15 scanning ni-motion user manual 15-18 ni.Com vectorspace = nimc_vector_space1; // configure a 2d vector space comprised of axes 1 and 2 err = flex_config_vect_spc(boardid, vectorspace, nimc_axis1, nimc_axis2, nimc_axis3); checkerror; // set the operation mode to absolute position err = fle...

  • Page 270

    Chapter 15 scanning © national instruments corporation 15-19 ni-motion user manual if (backlog >= 300){ downloaddata = malloc(sizeof(i32)*backlog); datacopied = 0; for (i=0;i if (currentdatapoint > numpoints) break; downloaddata[i] = points[currentdatapoint]; currentdatapoint++; datacopied++; } err ...

  • Page 271

    (axisstatus & nimc_axis_off_bit) ){ break;//break out of the for loop because an axis was killed } }...

  • Page 272: Rotating Knife

    © national instruments corporation 16-1 ni-motion user manual 16 rotating knife the purpose of this application is to cut a web with a rotating knife. The blade must cut precisely between labels on the web. Because the web material can stretch under certain conditions, it is not enough to cut the we...

  • Page 273

    Chapter 16 rotating knife ni-motion user manual 16-2 ni.Com figure 16-1. Rotating knife a synchronization point b correction point a b.

  • Page 274: Algorithm

    Chapter 16 rotating knife © national instruments corporation 16-3 ni-motion user manual algorithm figure 16-2. Rotating knife application algorithm initialize a = 0; b = 500 load appropriate move constraints for the slave set gear master = encoder 4; slave = axis 1 enable high-speed capture set gear...

  • Page 275: Labview Code

    Chapter 16 rotating knife ni-motion user manual 16-4 ni.Com labview code figure 16-3. Rotating knife application using labview figures 16-4 and 16-5 show the remaining cases for the block diagram in figure 16-3. Figure 16-4. Figure 16-3 sequence structure 1 1 configure gear master 2 load gear ratio ...

  • Page 276: C/c++ Code

    Chapter 16 rotating knife © national instruments corporation 16-5 ni-motion user manual figure 16-5. Figure 16-3 sequence structure 2 c/c++ code the following example code is not necessarily complete, and may not compile if copied exactly. Refer to the examples folder on the ni-motion cd for files t...

  • Page 277

    Chapter 16 rotating knife ni-motion user manual 16-6 ni.Com // set the axis number slaveaxis = nimc_axis1; // master is encoder 4 master = nimc_encoder4; //////////////////////////////// //------------------------------------------------- // set up the gearing configuration for the slave axis //----...

  • Page 278

    Chapter 16 rotating knife © national instruments corporation 16-7 ni-motion user manual { // check the high-speed capture status/following error/axis //off status err = flex_read_axis_status_rtn(boardid, slaveaxis, &axisstatus); checkerror; // read the communication status register and check the mod...

  • Page 279

    Chapter 16 rotating knife ni-motion user manual 16-8 ni.Com err = flex_start(boardid, slaveaxis, 0); checkerror; }// for loop return ;// exit the application /////////////////// // error handling /////////////////// nimchandleerror; //nimccatchthis: // check to see if there were any modal errors if ...

  • Page 280: Sinusoidal Commutation For

    © national instruments corporation a-1 ni-motion user manual a sinusoidal commutation for brushless servo motion control sinusoidal commutation allows you to use less expensive servo motor drives with ni motion controllers that support this feature. Phase initialization when the system is first powe...

  • Page 281: Direct Set

    Appendix a sinusoidal commutation for brushless servo motion control ni-motion user manual a-2 ni.Com direct set direct set is an initialization method where the controller sets the current position as the specified phase angle. This initialization method is recommended only for a custom system with...

  • Page 282

    Appendix a sinusoidal commutation for brushless servo motion control © national instruments corporation a-3 ni-motion user manual troubleshooting hall effect sensor connections complete the following steps if you have problems with hall effect sensor connections. 1. Check the manuals that shipped wi...

  • Page 283: Initializing The Controller

    © national instruments corporation b-1 ni-motion user manual b initializing the controller programmatically you can initialize the motion controller from within a labview, visual basic, or c/c++ program, in addition to initializing controllers in measurement & automation explorer (max). Refer to tab...

  • Page 284

    Appendix b initializing the controller programmatically ni-motion user manual b-2 ni.Com 10. Call halt on all axes to activate them. Use the stop motion vi with stop type (decel) set to halt stop. 11. Configure capture and compare settings. Use the vis on the motion i/o palette to configure the capt...

  • Page 285: The Labview Real-Time Module

    © national instruments corporation c-1 ni-motion user manual c using the motion controller with the labview real-time module using ni-motion on a real-time (rt) system is designed to be almost transparent for anyone familiar with ni-motion. Using ni-motion with rt requires the following hardware and...

  • Page 286

    Appendix c using the motion controller with the labview real-time module ni-motion user manual c-2 ni.Com 6. If ni-motion is not already installed, right-click within the dialog box and select install software. A dialog appears that lets you select what to download. Make sure the checkbox next to ni...

  • Page 287

    Appendix c using the motion controller with the labview real-time module © national instruments corporation c-3 ni-motion user manual to remove the mapped motion controller, browse to my system under device and interfaces. Right-click the mapped controller and select unmap remote device. You should ...

  • Page 288: Technical Support and

    © national instruments corporation d-1 ni-motion user manual d technical support and professional services visit the following sections of the national instruments web site at ni.Com for technical support and professional services: • support—online technical support resources at ni.Com/support inclu...

  • Page 289: Glossary

    © national instruments corporation g-1 ni-motion user manual glossary a a/d analog-to-digital absolute mode treat the target position loaded as position relative to zero (0) while making a move. Absolute position position relative to zero. Acceleration/ deceleration measurement of the change in velo...

  • Page 290

    Glossary ni-motion user manual g-2 ni.Com binary number system with a base of 2. Buffer temporary storage for acquired or generated data. Bus group of conductors that interconnect individual circuitry in a computer. Typically, a bus is the expansion vehicle to which i/o or other devices are connecte...

  • Page 291

    Glossary © national instruments corporation g-3 ni-motion user manual e encoder device that translates mechanical motion into electrical signals; used for monitoring position or velocity in a closed-loop system. Encoder resolution number of encoder lines between consecutive encoder marker or z-bit i...

  • Page 292

    Glossary ni-motion user manual g-4 ni.Com home switch (input) physical position determined by the mechanical system or designer as the reference location for system initialization. Frequently, the home position is also regarded as the zero position in an absolute position frame of reference. Host co...

  • Page 293

    Glossary © national instruments corporation g-5 ni-motion user manual m m meters mcs move complete status microstep proportional control of energy in the coils of a stepper motor that allow the motor to move to or stop at locations other than the fixed magnetic/mechanical pole positions determined b...

  • Page 294

    Glossary ni-motion user manual g-6 ni.Com p pci peripheral component interconnect—a high-performance expansion bus architecture originally developed by intel to replace isa and eisa. Pci is achieving widespread acceptance as a standard for pcs and workstations; it offers a theoretical maximum transf...

  • Page 295

    Glossary © national instruments corporation g-7 ni-motion user manual rpm revolutions per minute—units for velocity. Rpsps or rps/s revolutions per second squared—units for acceleration and deceleration. Rtr ready to receive s s seconds servo specifies an axis that controls a servo motor. Sinusoidal...

  • Page 296

    Glossary ni-motion user manual g-8 ni.Com v v volts velocity mode move the axis continuously at a specified velocity. W watchdog timer task that shuts down, or resets, the motion control device if any serious error occurs. Word standard number of bits that a processor or memory manipulates at one ti...

  • Page 297: Index

    © national instruments corporation i-1 ni-motion user manual index a absolute contouring, 7-4 acceleration feedforward, 3-6 acceleration in counts/s 2 , 4-8 acceleration in rps/s, 4-9 acquiring data algorithm, 11-2 c/c++ code, 11-4 data path, 11-1 labview code, 11-4 adding, measurements to an ni-mot...

  • Page 298

    Index ni-motion user manual i-2 ni.Com blending moves, 9-1 branching onboard programs algorithm, 14-20 c/c++ code, 14-22 labview code, 14-21 breakpoints using rtsi, 12-39 breakpoints. See synchronization buffers onboard algorithm, 14-26 data flow, 14-25 c c/c++ code position-based straight-line move...

  • Page 299

    Index © national instruments corporation i-3 ni-motion user manual direct set, a-2 documentation, xiv conventions used in manual, xiii ni resources, d-1 related documentation, xiv drivers (ni resources), d-1 dual loop feedback, 3-7 algorithm, 3-8 e electrical cycle, counts per, a-2 electronic cammin...

  • Page 300

    Index ni-motion user manual i-4 ni.Com control loop, 3-2 acceleration feedforward, 3-6 derivative gain, 3-5 dual loop feedback, 3-7 algorithm, 3-8 ga, 3-7 integral gain, 3-4 kdac, 3-6 kt, 3-7 proportional gain, 3-4 velocity feedback, 3-5, 3-9 algorithm, 3-10 velocity amplifiers, 3-10 velocity feedfo...

  • Page 301

    Index © national instruments corporation i-5 ni-motion user manual spherical, 6-7 algorithm, 6-9 c/c++ code, 6-10 labview code, 6-10 arc moves, 6-1 blending, 9-1 after delay, 9-4 after first move, 9-3 algorithm, 9-5 c/c++ code, 9-7 labview code, 9-6 superimposing, 9-2 camming, 10-1 contoured move ab...

  • Page 302

    Index ni-motion user manual i-6 ni.Com onboard programs, 14-2 algorithm, 14-4 automatically starting, 14-42 branching algorithm, 14-20 c/c++ code, 14-22 labview code, 14-21 buffers algorithm, 14-26 data flow, 14-25 changing a time slice, 14-42 conditional execution, 14-9 algorithm, 14-11 c/c++ code,...

  • Page 303

    Index © national instruments corporation i-7 ni-motion user manual labview code, 16-4 solution, 16-1 rtsi encoder pulses, 12-39 hardware implementation, 12-38 high-speed capture input, 12-40 software trigger, 12-39 using breakpoints with, 12-39 run sequence, 8-1 running onboard programs, 14-8 s scan...

  • Page 304

    Index ni-motion user manual i-8 ni.Com labview code, 5-13 straight-line moves, 4-1, 5-1 subroutines, onboard algorithm, 14-34 c/c++ code, 14-38 labview code, 14-35 supervisory control, 1-6 support, technical, d-1 synchronization, 12-1 breakpoint modes, 12-2 breakpoints absolute, 12-2 buffered, 12-3 ...

  • Page 305

    Index © national instruments corporation i-9 ni-motion user manual trajectory parameters acceleration in counts/s 2 , 4-8 acceleration in rps/s, 4-9 arc angles in degrees, 4-12 velocity in steps/counts per second, 4-7 velocity override in percent, 4-11 travel angle, 6-2 troubleshooting (ni resources...