flex_load_program_time_slice

NI-Motion Functions

flex_load_program_time_slice

Device Compatibility

Device Compatibility
7330
N
7340
Y
7344
Y
7350
Y
7390
N
NI SoftMotion Controller for CANopen—Xenus
N
NI SoftMotion Controller for CANopen—Accelnet
N

Load Program Time Slice

Usage

status = flex_load_program_time_slice(u8 boardID, u8 program, u16 timeSlice, u8 inputVector);

Purpose

Specifies the minimum time an onboard program has to run per watchdog period.

Parameters

Name Type Description
boardID u8 assigned by Measurement & Automation Explorer (MAX)
program u8 program number
timeSlice u16 execution time per watchdog period
inputVector u8 source of the data for this function

Parameter Discussion

program is the program number. Valid program numbers are 0x01 through 0xFF.

timeSlice is the execution time for the onboard program per watchdog period. Default is 2 ms.

inputVector indicates the source of the data for this function. Available input vectors include immediate (0xFF), variable (0x01 through 0x78), or indirect variable (0x81 through 0xF8). Refer to Input and Return Vectors for more detailed information.

Using This Function

Load Program Time Slice specifies the minimum time an onboard program has to be run per watchdog period.

Note  This function can only be run as a part of onboard program; the host cannot change the time slice of a program directly.

Some things to remember when changing the time slice of an onboard program:

  • A total of 20 ms is allowed for all running onboard programs.
  • Every onboard program loads with a default 2 ms time slice unless Load Program Time Slice is executed at the beginning of the onboard program. The default value of 2 ms is calculated based on maximum 10 onboard programs running simultaneously with equal time slice.
  • You can assign different time slices for each stored onboard program as long as the total of time slice for the running onboard program does not exceed 20 ms at any given time.

For example, suppose you have the following onboard programs currently stored:

  1. Onboard program 1, time slice = 10 ms
  2. Onboard program 2, time slice = 10 ms
  3. Onboard program 3, time slice = 5 ms
  4. Onboard program 4, time slice = 4 ms
  5. Onboard program 5, time slice = 1 ms

    You could run programs 1 and 2 simultaneously without error, because the total time slices of the two running programs is 20 ms. If you then start program 3, an NIMC_invalidTimeSliceError modal error occurs because the new total time slice is 25 ms. The available time slice for an onboard program also depends on the order in which the programs are run, because a user-defined time slice takes effect only when the onboard program actually runs, and not when it is stored.
  6. You can use this function to configure the performance of the onboard programs. The higher the time slice, the longer the onboard program runs per period, and the more work the program can do. However, as one program uses more processing power, the response times of other running onboard programs decreases. You can adjust the time slices to maintain the performance of other onboard programs by running the motion system under a longer watchdog period.
Note  Increasing the time slice of every onboard program using an extended watchdog period puts higher constraints on the motion system, because more time must be spent running the onboard programs.