PiMotion C Software Interface¶
Data Structures¶
-
trapezoidal_entry_t
¶ typedef struct { double start_delay; // seconds int64_t position; // counts double velocity; // counts per sec double acceleration; // counts per sec 2 double deceleration; } trapezoidal_entry_t;
-
velocity_entry_t
¶ typedef struct { double start_delay; // seconds double velocity; // counts per sec double acceleration; // counts per sec 2 } velocity_entry_t;
-
mtr_segment_t
¶ typedef struct { uint32_t options; uint64_t time_ec; // electrical cycle int64_t velocity_cpec; int64_t accel_cpecc; int64_t x_c; uint32_t hw_var_repeat; // hardware uses this location to keep track of how many repeats have been done. Write as 0 only! } mtr_segment_t;
-
pidev_scan_t
¶ typedef struct { char addr[PIDEV_SCAN_ADDR_STR_LEN]; char name[PIDEV_SCAN_NAME_STR_LEN]; char version[PIDEV_SCAN_VER_STR_LEN]; char device[PIDEV_SCAN_DEV_STR_LEN]; char sw[PIDEV_SCAN_SW_STR_LEN]; uint32_t security; uint32_t port; } pidev_scan_t;
-
err_callback_t
¶ typedef void (*err_callback_t)(const char* msg, void* user_data);
-
daq_callback_t
¶ typedef void (*daq_callback_t)(uint32_t chan_id, uint32_t num_samples, void* user_data);
General Functions¶
-
uint32_t
pidev_scan
(const char* ifaddr, uint32_t timeout_ms, pidev_scan_t* results, uint32_t max_results)¶ Scan for pidev devices
Parameters: - ifaddr (const char*) – interface address (ip address of which network card to use), or “all” for all network cards
- timeout_ms (uint32_t) – timeout (milliseconds) to wait for devices on each network card
- results (pidev_scan_t*) – results array
- max_results (uint32_t) – maximum number of results requested
Returns: The number of entries found
-
uint32_t
pidev_init
(const char* pidev_address, const char* password, uint32_t port)¶ Initialize connection to device
Parameters: - pidev_address (const char*) – device ip address (for example: “192.168.1.100”)
- password (const char*) – device password, or NULL for default
- port (uint32_t) – device ip port or 0 for default
Returns: Reference handle to be used in subsequent calls.
-
uint32_t
pidev_end
(uint32_t handle)¶ Close connection to device
Parameters: - handle (uint32_t) – handle returned from pidev_init
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_trigger
(uint32_t handle, uint8_t group_trigger, uint8_t timer1_relative, uint8_t timer2_relative, uint64_t timer1_time, uint64_t timer2_time, uint8_t manual_trigger)¶ Multiple/complex triggering
Parameters: - handle (uint32_t) – handle returned from pidev_init
- group_trigger (uint8_t) – enable group trigger (0: disabled, 1: enabled)
- timer1_relative (uint8_t) – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
- timer2_relative (uint8_t) – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
- timer1_time (uint64_t) – nanosecond time for timer 1 (absolute or relative), 0: ignore)
- timer2_time (uint64_t) – nanosecond time for timer 2 (absolute or relative), 0: ignore)
- manual_trigger (uint8_t) – manually trigger (0: ignored, 1: trigger now)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_trigger_manual
(uint32_t handle)¶ Manual trigger
Parameters: - handle (uint32_t) – handle returned from pidev_init
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_trigger_timer1
(uint32_t handle, uint8_t relative, uint64_t time)¶ Arm timer 1 trigger
Parameters: - handle (uint32_t) – handle returned from pidev_init
- relative (uint8_t) – relative trigger time (0: absolute, 1: relative)
- time (uint64_t) – nanosecond time
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_trigger_timer2
(uint32_t handle, uint8_t relative, uint64_t time)¶ Arm timer 2 trigger
Parameters: - handle (uint32_t) – handle returned from pidev_init
- relative (uint8_t) – relative trigger time (0: absolute, 1: relative)
- time (uint64_t) – nanosecond time
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_trigger_group
(uint32_t handle, uint8_t timer1_relative, uint8_t timer2_relative, uint64_t timer1_time, uint64_t timer2_time, uint8_t manual_trigger)¶ Group trigger
Parameters: - handle (uint32_t) – handle returned from pidev_init
- timer1_relative (uint8_t) – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
- timer2_relative (uint8_t) – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
- timer1_time (uint64_t) – nanosecond time for timer 1 (absolute or relative), 0: ignore)
- timer2_time (uint64_t) – nanosecond time for timer 2 (absolute or relative), 0: ignore)
- manual_trigger (uint8_t) – manually trigger (0: ignored, 1: trigger now)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_info
(uint32_t handle, uint32_t* sw, uint32_t* version, uint32_t* build, uint64_t* error_mask, uint32_t* serial, uint32_t* date)¶ Get information about the device
Parameters: - handle (uint32_t) – handle returned from pidev_init
- sw (uint32_t*) – software app running (0: bootloader, 1: main app)
- version (uint32_t*) – decimal version number (for example 100 = v1.00)
- build (uint32_t*) – build number
- error_mask (uint64_t*) – error mask/bitfield
- serial (uint32_t*) – unit serial number
- date (uint32_t*) – manufacture date
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_set_password
(uint32_t handle, const char* password)¶ Change device password
Parameters: - handle (uint32_t) – handle returned from pidev_init
- password (const char*) – password string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_set_ptp_password
(uint32_t handle, const char* password)¶ Change device ptp password
Parameters: - handle (uint32_t) – handle returned from pidev_init
- password (const char*) – password string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_set_timeout_offset
(uint32_t handle, uint32_t timeout_offset_ms)¶ Add additional timeout time to all library calls
Parameters: - handle (uint32_t) – handle returned from pidev_init
- timeout_offset_ms (uint32_t) – additional time (milliseconds)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_get_temperature
(uint32_t handle, double* val)¶ Get device internal temperature
Parameters: - handle (uint32_t) – handle returned from pidev_init
- val (double*) – temperature in degrees C
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
err_register_callback
(const char* ifaddr, uint32_t port, err_callback_t callback, void* user_data)¶ Register error/vmsg callback
Parameters: - ifaddr (const char*) – interface address (ip address of which network card to use), or “all” for all network cards
- port (uint32_t) – ip port
- callback (err_callback_t) – callback function
- user_data (void*) – user data associated with callback
Returns: Error code on failure. 0 - Success. See Error Codes.
-
char*
err_get_string_from_code
(uint32_t error_code)¶ Get error string from code
Parameters: - error_code (uint32_t) – error code
Returns: error string.
-
uint32_t
pidev_get_version
(uint32_t handle, uint32_t *val)¶ Pidev version information
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Version number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_get_build
(uint32_t handle, uint32_t *val)¶ Pidev build identifier
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Build number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_set_id_duration
(uint32_t handle, uint32_t val)¶ Identify device by blinking led
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – duration (ms) for led blink
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_get_faults
(uint32_t handle, uint32_t *val)¶ Faults bitmask
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Faults bitmask
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_vmsg_test
(uint32_t handle, char val)¶ Echo a message from the device via the messaging protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (char) – a test string to echo
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_clear_faults
(uint32_t handle)¶ Clear faults bit field
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
pidev_get_connected_devices
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
vserver_get_domain_name
(uint32_t handle, char *val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (char *) – pointer to requested value. Host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
vserver_set_domain_name
(uint32_t handle, char val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (char) – host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
vserver_get_port
(uint32_t handle, uint32_t *val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
vserver_set_port
(uint32_t handle, uint32_t val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
Configuration Functions¶
-
uint32_t
config_get_dhcp
(uint32_t handle, uint8_t *val)¶ Dhcp enable flag
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. 0 - disabled, 1 - enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_dhcp
(uint32_t handle, uint8_t val)¶ Dhcp enable flag
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – 0 - disabled, 1 - enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_ip_address
(uint32_t handle, uint8_t *val)¶ Static ip address of the device
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. Array of four 8 bit values representing ipv4 address
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_ip_address
(uint32_t handle, uint8_t val)¶ Static ip address of the device
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – array of four 8 bit values representing ipv4 address
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_host_name
(uint32_t handle, char *val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (char *) – pointer to requested value. Host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_host_name
(uint32_t handle, char val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (char) – host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_commit
(uint32_t handle)¶ Commit configuration changes to flash
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_reset
(uint32_t handle)¶ Reset the device
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_ptp_master
(uint32_t handle, uint8_t *val)¶ Ptp master enable flag
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. 0 - disabled, 1 - enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_ptp_master
(uint32_t handle, uint8_t val)¶ Ptp master enable flag
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – 0 - disabled, 1 - enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_device_group
(uint32_t handle, uint8_t *val)¶ Device group identifier
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. 0 - no group, 1-255 - group identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_device_group
(uint32_t handle, uint8_t val)¶ Device group identifier
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – 0 - no group, 1-255 - group identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_ip_port
(uint32_t handle, uint32_t *val)¶ Network ip port number of the device
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_ip_port
(uint32_t handle, uint32_t val)¶ Network ip port number of the device
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_msg_port
(uint32_t handle, uint32_t *val)¶ Network ip port number for the messaging protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_msg_port
(uint32_t handle, uint32_t val)¶ Network ip port number for the messaging protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_device_id
(uint32_t handle, uint8_t *val)¶ Unique device identifier of a device within a group
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. 0 - 255, unique device identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_device_id
(uint32_t handle, uint8_t val)¶ Unique device identifier of a device within a group
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – 0 - 255, unique device identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_heartbeat_mask
(uint32_t handle, uint32_t *val)¶ Bitmask for inter-device heartbeat/faults
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. 32 bit mask
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_heartbeat_mask
(uint32_t handle, uint32_t val)¶ Bitmask for inter-device heartbeat/faults
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – 32 bit mask
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_gpio_direction
(uint32_t handle, uint32_t *val)¶ Startup gpio channel direction bit field
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Bitfield: 0 - output, 1 - input
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_gpio_direction
(uint32_t handle, uint32_t val)¶ Startup gpio channel direction bit field
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – bitfield: 0 - output, 1 - input
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_gpio_pullup
(uint32_t handle, uint32_t *val)¶ Startup gpio input pullup enable bitfield
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Bitfield: 0 - pullup disabled, 1 - pullup enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_gpio_pullup
(uint32_t handle, uint32_t val)¶ Startup gpio input pullup enable bitfield
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – bitfield: 0 - pullup disabled, 1 - pullup enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_gpio_polarity
(uint32_t handle, uint32_t *val)¶ Startup gpio input/output polarity configuration bitfield
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Bitfield: 0 - normal polarity, 1 - inverse polarity
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_gpio_polarity
(uint32_t handle, uint32_t val)¶ Startup gpio input/output polarity configuration bitfield
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – bitfield: 0 - normal polarity, 1 - inverse polarity
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_gpio_value
(uint32_t handle, uint32_t *val)¶ Startup gpio pin state
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Bitfield: 0 - low, 1 - high
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_gpio_value
(uint32_t handle, uint32_t val)¶ Startup gpio pin state
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – bitfield: 0 - low, 1 - high
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_supervisor_port
(uint32_t handle, uint32_t *val)¶ Network ip port number for the inter-device protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_supervisor_port
(uint32_t handle, uint32_t val)¶ Network ip port number for the inter-device protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_fault_handler
(uint32_t handle, uint32_t *val, uint32_t chan_id)¶ Associated fault handler with fault id
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) – fault id
- val (uint32_t *) – pointer to requested value. Fault handler id
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_fault_handler
(uint32_t handle, uint32_t chan_id, uint32_t val)¶ Associated fault handler with fault code
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) – fault id
- val (uint32_t) – fault handler id
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_keepalive_name
(uint32_t handle, char *val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (char *) – pointer to requested value. Host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_keepalive_name
(uint32_t handle, char val)¶ Host name (used by dynamic dns)
Parameters: - handle (uint32_t) – handle to the device.
- val (char) – host name string
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_get_keepalive_port
(uint32_t handle, uint32_t *val)¶ Network ip port number for the inter-device protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
config_set_keepalive_port
(uint32_t handle, uint32_t val)¶ Network ip port number for the inter-device protocol
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – ip port number
Returns: Error code on failure. 0 - Success. See Error Codes.
Time Functions¶
-
uint32_t
vtrigger_set
(uint32_t handle)¶ Manually trigger waiting operations
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_get_clock
(uint32_t handle, uint64_t *val)¶ Current clock value (ns)
Parameters: - handle (uint32_t) – handle to the device.
- val (uint64_t *) – pointer to requested value. 64 bit nanoseconds
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_get_offset_from_master
(uint32_t handle)¶ Clock offset/difference from master
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_get_drift
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_get_kp
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_set_kp
(uint32_t handle, float_fix16_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_get_ki
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
time_set_ki
(uint32_t handle, float_fix16_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
Motor Functions¶
-
uint32_t
mtr_start
(uint32_t handle, uint32_t start_segment, uint32_t trigger)¶ Start the motor starting at start_segment (usually 0) using the trigger condition specified.
Parameters: - handle (uint32_t) – handle returned from pidev_init
- start_segment (uint32_t) – starting segment
- trigger (uint32_t) – trigger type. See Trigger Source
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_reset
(uint32_t handle)¶ Reset the motor
Parameters: - handle (uint32_t) – handle returned from pidev_init
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_phase_mem
(uint32_t handle, uint32_t num_fields, uint32_t* fields, uint32_t shift_value)¶ Write motor phase waveform
Parameters: - handle (uint32_t) – handle returned from pidev_init
- num_fields (uint32_t) – number of elements in the fields array
- fields (uint32_t*) – fields array
- shift_value (uint32_t) – shift value
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_phase_mem_default
(uint32_t handle, uint32_t phases, uint32_t poles, uint32_t enc_cnts_per_rot)¶ Write default motor phase waveform to controller
Parameters: - handle (uint32_t) – handle returned from pidev_init
- phases (uint32_t) – number of motor phases
- poles (uint32_t) – number of motor poles
- enc_cnts_per_rot (uint32_t) – number of encoder counts per rotation
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_phase_mem_default_buffer
(uint32_t phases, uint32_t poles, uint32_t enc_cnts_per_rot, uint32_t* phasemem, uint32_t phasemem_size, uint32_t* calc_phase_size, uint32_t* shift_value)¶ Write default motor phase waveform to a buffer
Parameters: - phases (uint32_t) – number of motor phases
- poles (uint32_t) – number of motor poles
- enc_cnts_per_rot (uint32_t) – number of encoder counts per rotation
- phasemem (uint32_t*) – phasemem buffer
- phasemem_size (uint32_t) – length of phasemem buffer
- calc_phase_size (uint32_t*) – calculated phase mem size
- shift_value (uint32_t*) – shift value
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_phase_mem_stepper
(uint32_t handle, uint32_t microstep_multiplier)¶ Write phase memory for stepper motor
Parameters: - handle (uint32_t) – handle returned from pidev_init
- microstep_multiplier (uint32_t) – TODO
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_table
(uint32_t handle, uint32_t start_segment, uint32_t num_segments, const mtr_segment_t* segments)¶ Write motion table
Parameters: - handle (uint32_t) – handle returned from pidev_init
- start_segment (uint32_t) – starting segment
- num_segments (uint32_t) – number of segments
- segments (const mtr_segment_t*) – segments array
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_read_table
(uint32_t handle, uint32_t start_segment, uint32_t num_segments, mtr_segment_t* segments)¶ Read motion table
Parameters: - handle (uint32_t) – handle returned from pidev_init
- start_segment (uint32_t) – starting segment
- num_segments (uint32_t) – number of segments
- segments (mtr_segment_t*) – segments array
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_write_target_position
(uint32_t handle, int64_t position, uint32_t servomode)¶ Write target position
Parameters: - handle (uint32_t) – handle returned from pidev_init
- position (int64_t) – position
- servomode (uint32_t) – servo mode. See Servo Mode
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_create_velocity_profile
(uint32_t handle, double start_velocity, uint32_t num_velocity_entries, const velocity_entry_t* velocity_entries, uint32_t servomode, uint32_t elec_cycle_div, uint32_t* num_segments, mtr_segment_t* segments)¶ Create a velocity profile
Parameters: - handle (uint32_t) – handle returned from pidev_init
- start_velocity (double) – starting velocity
- num_velocity_entries (uint32_t) – number of entries in velocity_entries array
- velocity_entries (const velocity_entry_t*) – velocity profile array
- servomode (uint32_t) – servo mode. See Servo Mode
- elec_cycle_div (uint32_t) – electrical cycles divisor
- num_segments (uint32_t*) – number of segments
- segments (mtr_segment_t*) – segments array
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_create_trapezoidal_profile
(uint32_t handle, int64_t start_position, uint32_t num_trapezoidal_entries, const trapezoidal_entry_t* trapezoidal_entries, uint32_t elec_cycle_div, uint32_t* num_segments, mtr_segment_t* segments)¶ Create a trapezoidal profile
Parameters: - handle (uint32_t) – handle returned from pidev_init
- start_position (int64_t) – starting position
- num_trapezoidal_entries (uint32_t) – number of entries in velocity_entries array
- trapezoidal_entries (const trapezoidal_entry_t*) – trapezoidal profile array
- elec_cycle_div (uint32_t) – electrical cycles divisor
- num_segments (uint32_t*) – number of segments
- segments (mtr_segment_t*) – segments array
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_elec_cycle_div
(uint32_t handle, uint32_t *val)¶ Get the electrical cycle time divisor. this value is used to set the electrical cycle time clock. it is calculated by dividing the base clock rate default_clk_pimotion by this value. example: elec_cycle_div = default_clk_pimotion * 0.001.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The electrical cycle time divisor.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_elec_cycle_div
(uint32_t handle, uint32_t val)¶ Set the electrical cycle time divisor. this value is used to set the electrical cycle time clock. the electrical cycle time is calculated by dividing the base clock rate default_clk_pimotion by this value.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – the electrical cycle time divisor. To calculate the divisor do the following: divisor = DEFAULT_CLK_PIMOTION * 0.001 where 0.001 is the period in seconds.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kp
(uint32_t handle, float_fix16_t *val)¶ Get the servo loop kp term. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t *) – pointer to requested value. The active kp value.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kp
(uint32_t handle, float_fix16_t val)¶ Set the servo loop kp term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) – value of the Kp. Range of 0.0 to 32768.0
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_ki
(uint32_t handle, float_fix16_t *val)¶ Get the servo loop ki term. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t *) – pointer to requested value. The active ki value.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_ki
(uint32_t handle, float_fix16_t val)¶ Set the servo loop ki term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) – value of the Ki. Range of 0.0 to 32768.0. A value of 0 disables the Ki component.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kd
(uint32_t handle, float_fix16_t *val)¶ Get the servo loop kd term. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t *) – pointer to requested value. The active kd value.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kd
(uint32_t handle, float_fix16_t val)¶ Set the servo loop kd term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) – value of the Ki. Range of 0.0 to 32768.0. A value of 0 disables the Kd component.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_ilim
(uint32_t handle, int32_t *val)¶ Get the servo loop integration limit. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t *) – pointer to requested value. The active integration limit value.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_ilim
(uint32_t handle, int32_t val)¶ Set the servo loop integration limit. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – value of the integration limit.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kvff
(uint32_t handle, float_fix16_t *val)¶ Get the servo loop velocity feed forward. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t *) – pointer to requested value. Value of the velocity feed forwarf (vff)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kvff
(uint32_t handle, float_fix16_t val)¶ Set the servo loop velocity feed forward. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) – value of the velocity feed forward (vff)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kaff
(uint32_t handle, float_fix16_t *val)¶ Get the servo loop acceleration feed forward. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t *) – pointer to requested value. Value of the acceleration feed forwarf (vff)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kaff
(uint32_t handle, float_fix16_t val)¶ Set the servo loop acceleration feed forward. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (float_fix16_t) – value of the acceleration feed forwarfd(vff)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_max_pid_output
(uint32_t handle, int32_t *val)¶ Get the maximum pid (servo loop) output. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t *) – pointer to requested value. The maximum output of the pid loop.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_max_pid_output
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_output_polarity
(uint32_t handle, uint32_t *val)¶ Get the output polarity of the pid.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The polarity of the servo loop. 0 - positive (default), 1 - negative
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_output_polarity
(uint32_t handle, uint32_t val)¶ Set the output polarity of the pid.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – polarity . 0 - Positive, 1 - negative
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_pid_output
(uint32_t handle, int16_t *val)¶ Get the output of the pid (servo loop).
Parameters: - handle (uint32_t) – handle to the device.
- val (int16_t *) – pointer to requested value. Pid output in terms of dac output (-32768 to 32767).
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_enc_counts_per_rot
(uint32_t handle, uint32_t *val)¶ Get the encoder counts per rotation.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Encoder counts per rotation in terms of counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_enc_counts_per_rot
(uint32_t handle, uint32_t val)¶ Set the encoder counts per rotation of the encoder. a 512 line encoder has 1024 counts per rotation.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – encoder counts per rotation in terms of counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_enc_polarity
(uint32_t handle, uint32_t val)¶ Set the polarity of the encoder. the encoder counts can be changed to decrement instead of increment by setting the polarity.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – polarity of the encoder. 0 - Positive polarity (default) 1 - Negative polarity,
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_enc_pos
(uint32_t handle, uint32_t *val)¶ Get the encoder position. the value read is the current encoder count.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The encoder count in counts. the encoder count will have a range from 0 - encoder_counts_per_rotation.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_enc_index_pos
(uint32_t handle, uint32_t *val)¶ Get the encoder position of the index. every time an index pulse is detected, the encoder position of the index is recorded.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Index encoder position in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_enc_index_count
(uint32_t handle, uint32_t *val)¶ Get the index counter. every time an index pulse is detected (either forward rotation or reverse rotation) the encoder index count is incremented.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Index counter in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_enc_glitch_count
(uint32_t handle, uint32_t *val)¶ Get the encoder glitch count. any time the encoder enters a state that is unexpected, the encoder glitch count is incremented. the encoder glitch count should remain at zero unless there is a bad connection or faulty encoder.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Glitch count.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_enc_counts_per_rot
(uint32_t handle, uint32_t *val)¶ Get the auxiliary encoder counts per rotation.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Counts per rotation in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_aux_enc_counts_per_rot
(uint32_t handle, uint32_t val)¶ Set the auxiliary encoder counts per rotation. this is the number of counts for a full rotation of the encoder. for example, if the encoder was a 512 line encoder, the number of counts per rotation would be 512 * 4 = 1024.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – encoder counts per rotation in terms of counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_aux_enc_polarity
(uint32_t handle, uint32_t val)¶ Set the polarity of the auxiliary encoder. the encoder counts can be changed to decrement instead of increment by setting the polarity.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – polarity of the encoder. 0 - Positive polarity (default) 1 - Negative polarity,
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_actual_pos
(uint32_t handle, int64_t *val)¶ Get the actual position from the auxiliary encoder. this is a signed 64 bit value.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The actual position of the auxiliary encoder.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_enc_pos
(uint32_t handle, uint32_t *val)¶ Get the auxiliary encoder position. the value read is the current encoder count of the auxiliary encoder input.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Encoder counts of the auxiliary encoder.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_enc_index_pos
(uint32_t handle, uint32_t *val)¶ Get the auxiliary encoder position of the index. every time an index pulse is detected, the auxiliary encoder position of the index is recorded.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Encoder position in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_enc_index_count
(uint32_t handle, uint32_t *val)¶ Get the auxiliary encoder index counter. every time an index pulse is detected on the auxiliary encoder, (either forward rotation or reverse rotation) the auxiliary encoder index count is incremented. note: this value will not change on encoders that do not have an index option.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Index count. number of times the encoder has passed the index line.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_enc_glitch_count
(uint32_t handle, uint32_t *val)¶ Get the auxiliary encoder glitch count. any time the auxiliary encoder enters a state that is unexpected, the encoder glitch count is incremented. the encoder glitch count should remain at zero unless there is a bad connection or faulty encoder.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Glitch count.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_use_aux_enc_for_servo
(uint32_t handle, uint32_t val)¶ Sets which encoder is used for the trajectory generator and servo loop (pid). defaultly the trajectory generator and the servo loop use the first encoder input (not the auxiliary).
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – select to use the auxiliary encoder as the input to the trajectory generator and servo loop. 0 - first encoder (default), 1 -auxiliary encoder.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_mtr_type
(uint32_t handle, uint32_t *val)¶ Get the motor type.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Motor type (mtr_type_3phase = 0, mtr_type_stepper = 1, mtr_type_voicecoil = 2)
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_mtr_type
(uint32_t handle, uint32_t val)¶ Set the motor type. the motor can be a three-phase motor, stepper motor, or voice coil motor.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – motor type. Valid settings are: MTR_TYPE_3PHASE = 0, MTR_TYPE_STEPPER = 1, MTR_TYPE_VOICECOIL = 2
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_poles
(uint32_t handle, uint32_t *val)¶ Get the motor poles.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The number of poles.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_poles
(uint32_t handle, uint32_t val)¶ Set the number of poles of the motor. valid numbers are 2, 4, 6, 8, 12 - 200
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – number of poles of the motor.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_loop_mode
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_loop_mode
(uint32_t handle, uint32_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_was_reset
(uint32_t handle, uint32_t *val)¶ Get whether the motor was reset or not.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Returns 0 - motor was not reset, 1 - motor was reset.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_reset_state
(uint32_t handle, uint32_t *val)¶ Gets the current state the motion controller is in during reset. states are: 0 - idle, 1 - commutation_1, 2 - commutation_2, 3 - commutation_3, 4 - error, 5 - running.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The reset state.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_reset_wait_time_ms
(uint32_t handle, uint32_t *val)¶ Get the motor reset wait time.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The reset wait time in milliseconds.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_reset_wait_time_ms
(uint32_t handle, uint32_t val)¶ Set the motor reset wait time. this is the amount of time the motor will be energized at a fixed phase during reset to determine the commutation angle.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – time in milliseconds to energize the phase.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_reset_current
(uint32_t handle, uint32_t *val)¶ Get the amount of current used during reset.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The current in terms of dac output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_reset_current
(uint32_t handle, uint32_t val)¶ Set the amount of current used during reset. the value set with this call will be the amount of current sent to a motor phase during reset.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_open_loop_drive_current
(uint32_t handle, uint32_t *val)¶ Get the open loop drive current.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The open loop drive current.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_open_loop_drive_current
(uint32_t handle, uint32_t val)¶ Set the open loop drive current. when in mtr_mode_manual, this will be the current energizing the phases of the motor.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_manual_loop_current
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_manual_loop_current
(uint32_t handle, uint32_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_pwr_enable
(uint32_t handle, uint32_t *val)¶ Get power state of the amplifier.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Returns a 0 - off and a 1 - on
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_pwr_enable
(uint32_t handle, uint32_t val)¶ Set the power state of the amplifier. this will turn all outputs of the amplifiers to off or on.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – 0 - off, 1 - on
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_traj_gen_enable
(uint32_t handle, uint32_t *val)¶ Get if the trajectory generator is enabled.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Returns a 0 - off and a 1 - on
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_traj_gen_enable
(uint32_t handle, uint32_t val)¶ Enables or disables the trajectory generator.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – A value of 0 turns the trajectory generator off. A value of 1 turns the trajectory generator on.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_traj_gen_table_seg
(uint32_t handle, uint32_t *val)¶ Get the active trajectory generator segment.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Segment entry 0 thru 100
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_traj_gen_current_time
(uint32_t handle, uint64_t *val)¶ Get the active time from the trajectory generator.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint64_t *) – pointer to requested value. Time in ???
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_traj_gen_busy
(uint32_t handle)¶ Get the busy state of the trajectory generator.
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_size
(uint32_t handle, uint32_t *val)¶ Get the current numbers of entries in the phase memory.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Number of entries.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_phase_size
(uint32_t handle, uint32_t val)¶ Set the number of entries in the phase memory.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_mem_shift
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_phase_mem_shift
(uint32_t handle, uint32_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_offset
(uint32_t handle)¶ Gets the phase offset.
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_phase_offset
(uint32_t handle, uint32_t val)¶ Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) –
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_mem_address
(uint32_t handle)¶ Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_max_pos_error
(uint32_t handle, int32_t *val)¶ Get the maximum allowed position error.
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t *) – pointer to requested value. The maximum position error in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_max_pos_error
(uint32_t handle, int32_t val)¶ Set the maximum allowed position error. if the position error exceeds this value, the motor will shutdown and a position error will be generated.
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – error in terms of counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_motion_error
(uint32_t handle, uint32_t *val)¶ Get the motion error register.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. The motion error.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_motion_error
(uint32_t handle, uint32_t val)¶ Clear all motion errors.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – set the value to 0 to clear the errors.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_pos_error
(uint32_t handle, int32_t *val)¶ Get the position error in counts.
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t *) – pointer to requested value. Position error in counts.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_vel_error
(uint32_t handle)¶ Get the velocity error in counts per second.
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_target_vel
(uint32_t handle, int64_t *val)¶ Get the target velocity.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The target velocity.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_actual_vel
(uint32_t handle, int64_t *val)¶ Get the actual velocity.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The actual velocity.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_target_pos
(uint32_t handle, int64_t *val)¶ Get the target position.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The target position.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_actual_pos
(uint32_t handle, int64_t *val)¶ Get the actual position.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The actual position.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_dac_output_a
(uint32_t handle, int16_t *val)¶ Get the dac output to phase a of the motor. this is the value that is sent to the dac.
Parameters: - handle (uint32_t) – handle to the device.
- val (int16_t *) – pointer to requested value. The dac output value for phase a.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_dac_output_b
(uint32_t handle, int16_t *val)¶ Get the dac output to phase b of the motor. this is the value that is sent to the dac.
Parameters: - handle (uint32_t) – handle to the device.
- val (int16_t *) – pointer to requested value. The dac output value for phase b.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_a
(uint32_t handle, int16_t *val)¶ Get the currently selected phase a value from the phase memory table.
Parameters: - handle (uint32_t) – handle to the device.
- val (int16_t *) – pointer to requested value. The value of phase a
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_phase_b
(uint32_t handle, int16_t *val)¶ Get the currently selected phase b value from the phase memory table.
Parameters: - handle (uint32_t) – handle to the device.
- val (int16_t *) – pointer to requested value. The value of phase b
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_restore_defaults
(uint32_t handle)¶ Restore motor configuration to power on defaults.
Parameters: - handle (uint32_t) – handle to the device.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_profile_finished
(uint32_t handle, uint32_t *val)¶ Get the finished state of the profile. if the motor profile has completed the last segment in the table, the profile will be finished.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t *) – pointer to requested value. Returns the profile finished state. 0 - not finished, 1 - finished.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_actual_index_pos
(uint32_t handle, int64_t *val)¶ Get the actual (64bit) position of the index. every time an index pulse is detected, the actual position of the index is recorded. see actual position.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The actual position of the index (64 bit position).
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_aux_actual_index_pos
(uint32_t handle, int64_t *val)¶ Get the actual (64bit) position of the auxiliary encoder index. every time an index pulse of the auxiliary encoder is detected, the auxiliary actual position of the index is recorded. see actual position.
Parameters: - handle (uint32_t) – handle to the device.
- val (int64_t *) – pointer to requested value. The auxiliary actual position of the index (64 bit position).
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kvff_shift
(uint32_t handle, uint8_t *val)¶ Gets the amount of bits to shift the kvff (velocity feed forward) term right. velocity_feed_forward = kvff >> kvff_shift. see PID Algorithm and velocity feed forward.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. The value of kvff_shift.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kvff_shift
(uint32_t handle, uint8_t val)¶ Sets the amount of bits to shift the kvff (velocity feed forward) term right. velocity_feed_forward = kvff >> kvff_shift. see PID Algorithm and velocity feed forward.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – the amount to shift Kvff right. Valid values of 0 - 15.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_get_kaff_shift
(uint32_t handle, uint8_t *val)¶ Gets the amount of bits to shift the kaff (velocity feed forward) term left. acceleration_feed_forward = kaff << kaff_shift. see PID Algorithm and acceleration feed forward.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t *) – pointer to requested value. The value of kaff_shift.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_kaff_shift
(uint32_t handle, uint8_t val)¶ Sets the amount of bits to shift the kaff (velocity feed forward) term left. acceleration_feed_forward = kaff << kaff_shift. see PID Algorithm and acceleration feed forward.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – the amount to shift Kaff left. Valid values of 0 - 15.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_enable
(uint32_t handle, uint32_t val)¶ Set the power state of the amplifier. this will turn all outputs of the amplifiers to off or on.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint32_t) – 0 - off, 1 - on
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_shiftby
(uint32_t handle, uint8_t val)¶ Sets the amount of bits to shift the kaff (velocity feed forward) term left. acceleration_feed_forward = kaff << kaff_shift. see PID Algorithm and acceleration feed forward.
Parameters: - handle (uint32_t) – handle to the device.
- val (uint8_t) – the amount to shift Kaff left. Valid values of 0 - 15.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_a0
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_a1
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_a2
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_b1
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
mtr_set_biquad_b2
(uint32_t handle, int32_t val)¶ Set the maximum pid (servo loop) current output. this sets the positive and negative outputs. example: 10000 would set a limit of positive limit of 10000 and a negative limit of -10000. see PID Algorithm
Parameters: - handle (uint32_t) – handle to the device.
- val (int32_t) – current in terms of DAC output.
Returns: Error code on failure. 0 - Success. See Error Codes.
Data Acquisition Functions¶
GPIO Functions¶
-
uint32_t
gpio_get_value
(uint32_t handle, uint32_t *val, uint32_t chan_id)¶ Gpio pin state
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) – bit mask of gpio pins on which operate. For example, 0x0f would only operate on GPIO 0-3, others are ignored.
- val (uint32_t *) – pointer to requested value. Bitfield: 0 - low, 1 - high
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
gpio_set_value
(uint32_t handle, uint32_t chan_id, uint32_t val)¶ Gpio pin state
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) – bit mask of gpio pins on which operate. For example, 0x0f would only operate on GPIO 0-3, others are ignored.
- val (uint32_t) – bitfield: 0 - low, 1 - high. For example, 0x11 would set GPIO 0 and GPIO 4 high (if configured as outputs).
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
gpio_set_polarity
(uint32_t handle, uint32_t chan_id, uint32_t val)¶ Gpio input/output polarity configuration bitfield
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) –
- val (uint32_t) – bitfield: 0 - normal polarity, 1 - inverse polarity
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
gpio_set_pullup
(uint32_t handle, uint32_t chan_id, uint32_t val)¶ Gpio input pullup enable bitfield
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) –
- val (uint32_t) – bitfield: 0 - pullup disabled, 1 - pullup enabled
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
gpio_set_direction
(uint32_t handle, uint32_t chan_id, uint32_t val)¶ Gpio channel direction bit field
Parameters: - handle (uint32_t) – handle to the device.
- chan_id (uint32_t) –
- val (uint32_t) – bitfield: 0 - output, 1 - input
Returns: Error code on failure. 0 - Success. See Error Codes.
Analog to Digital Converter Functions¶
-
uint32_t
daq_start
(uint32_t handle, uint32_t chan_id, uint32_t divisor, uint32_t start_sample, uint32_t num_samples, uint32_t trigger)¶ Start the data acquisition channel
Parameters: - handle (uint32_t) – handle returned from pidev_init
- chan_id (uint32_t) – channel identifier
- divisor (uint32_t) – clock divisor, to derive sampling rate (divisor of 0.001 gives 1kHz sample rate
- start_sample (uint32_t) – post-trigger sample number
- num_samples (uint32_t) – number of samples
- trigger (uint32_t) – trigger type. See Trigger Source
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
daq_listen
(uint32_t handle, uint32_t chan_id)¶ Receive data acquisition channel that has already been started by a different connection
Parameters: - handle (uint32_t) – handle returned from pidev_init
- chan_id (uint32_t) – channel identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
daq_register_callback
(uint32_t handle, uint32_t chan_id, uint32_t num_samples, uint32_t milliseconds, daq_callback_t callback, void* user_data)¶ Listen for data acquisition. only needs to be registered once.
Parameters: - handle (uint32_t) – handle returned from pidev_init
- chan_id (uint32_t) – channel identifier
- num_samples (uint32_t) – number of samples collected before callback
- milliseconds (uint32_t) – milliseconds before callback
- callback (daq_callback_t) – callback function
- user_data (void*) – user data associated with callback
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
daq_acquire_data
(uint32_t handle, uint32_t chan_id, uint32_t num_samples, int32_t* buffer, uint32_t* samples_acquired, uint32_t* sample_id)¶ Listen for data acquisition
Parameters: - handle (uint32_t) – handle returned from pidev_init
- chan_id (uint32_t) – channel identifier
- num_samples (uint32_t) – number of samples
- buffer (int32_t*) –
- samples_acquired (uint32_t*) – actual number of samples aquired
- sample_id (uint32_t*) – sample identifier
Returns: Error code on failure. 0 - Success. See Error Codes.
-
uint32_t
daq_get_sample
(uint32_t handle, uint32_t chan_id, int32_t* sample)¶ Get a single data acquistion sample
Parameters: - handle (uint32_t) – handle returned from pidev_init
- chan_id (uint32_t) – channel identifier
- sample (int32_t*) – data acquisition sample
Returns: Error code on failure. 0 - Success. See Error Codes.