PiMotion Java Software Interface¶
Types¶
-
public static class
VelocityEntry
¶
public static class VelocityEntry
{
public VelocityEntry(double start_delay, double velocity, double acceleration) {
this.start_delay = start_delay;
this.velocity = velocity;
this.acceleration = acceleration;
}
public double start_delay;
public double velocity;
public double acceleration;
}
-
public static class
TrapezoidalEntry
¶
public static class TrapezoidalEntry
{
public TrapezoidalEntry(double start_delay, long position, double velocity, double acceleration, double deceleration) {
this.start_delay = start_delay;
this.position = position;
this.velocity = velocity;
this.acceleration = acceleration;
this.deceleration = deceleration;
}
public double start_delay; // seconds
public long position; // counts
public double velocity; // counts per sec
public double acceleration; // counts per sec 2
public double deceleration;
};
-
public static class
DaqAcquireDataResult
¶
public static class DaqAcquireDataResult
{
public DaqAcquireDataResult(int samples_acquired, int sample_id)
{
this.samples_acquired = samples_acquired;
this.sample_id = sample_id;
}
public int samples_acquired;
public int sample_id;
};
-
public static class
MtrSegment
¶
public static class MtrSegment
{
public MtrSegment() {
options = 0;
time_ec = 0;
velocity_cpec = 0;
accel_cpecc = 0;
x_c = 0;
hw_var_repeat = 0;
}
public int options;
public long time_ec;
public long velocity_cpec;
public long accel_cpecc;
public long x_c;
public int hw_var_repeat;
};
General Methods¶
-
public static String[][]
pidev_scan
(int timeout_ms, int max_results)¶ Scan for pidev devices
Parameters: - timeout_ms (int) – timeout (milliseconds) to wait for devices on each network card
- max_results (int) – maximum number of results requested
Returns: array of strings containing address, name, version, device type, software type, password status, and ip port
-
public void
pidev_trigger
(int group_trigger, int timer1_relative, int timer2_relative, long timer1_time, long timer2_time, int manual_trigger)¶ Multiple/complex triggering
Parameters: - group_trigger (int) – enable group trigger (0: disabled, 1: enabled)
- timer1_relative (int) – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
- timer2_relative (int) – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
- timer1_time (long) – nanosecond time for timer 1 (absolute or relative), 0: ignore)
- timer2_time (long) – nanosecond time for timer 2 (absolute or relative), 0: ignore)
- manual_trigger (int) – manually trigger (0: ignored, 1: trigger now)
-
public void
pidev_trigger_manual
()¶ Manual trigger
-
public void
pidev_trigger_timer1
(int relative, long time)¶ Arm timer 1 trigger
Parameters: - relative (int) – relative trigger time (0: absolute, 1: relative)
- time (long) – nanosecond time
-
public void
pidev_trigger_timer2
(int relative, long time)¶ Arm timer 2 trigger
Parameters: - relative (int) – relative trigger time (0: absolute, 1: relative)
- time (long) – nanosecond time
-
public void
pidev_trigger_group
(int timer1_relative, int timer2_relative, long timer1_time, long timer2_time, int manual_trigger)¶ Group trigger
Parameters: - timer1_relative (int) – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
- timer2_relative (int) – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
- timer1_time (long) – nanosecond time for timer 1 (absolute or relative), 0: ignore)
- timer2_time (long) – nanosecond time for timer 2 (absolute or relative), 0: ignore)
- manual_trigger (int) – manually trigger (0: ignored, 1: trigger now)
-
public long[]
pidev_info
()¶ Get information about the device
Returns: array of strings: app running, version number, build number, error mask, serial number, and manufacture date
-
public void
pidev_set_password
(String password)¶ Change device password
Parameters: - password (String) – password string
-
public void
pidev_set_ptp_password
(String password)¶ Change device ptp password
Parameters: - password (String) – password string
-
public void
pidev_set_timeout_offset
(int timeout_offset_ms)¶ Add additional timeout time to all library calls
Parameters: - timeout_offset_ms (int) – additional time (milliseconds)
-
public double
pidev_get_temperature
()¶ Get device internal temperature
Returns: double temperature in degrees C
-
public void
err_register_callback
(String ifaddr, int port, String callbackname)¶ Register error/vmsg callback
Parameters:
-
public static String
err_get_string_from_code
(Error error_code)¶ Get error string from code
Parameters: - error_code (Error) – error code
Returns: error string
-
public int
pidev_get_version
()¶ Pidev version information
Returns: int version number
-
public int
pidev_get_build
()¶ Pidev build identifier
Returns: int build number
-
public void
pidev_set_id_duration
(int val)¶ Identify device by blinking led
Parameters: - val (int) – duration (ms) for led blink
-
public int
pidev_get_faults
()¶ Faults bitmask
Returns: int faults bitmask
-
public void
pidev_vmsg_test
(str val)¶ Echo a message from the device via the messaging protocol
Parameters: - val (str) – a test string to echo
-
public void
pidev_clear_faults
()¶ Clear faults bit field
-
public void
pidev_get_connected_devices
()¶
-
public str
vserver_get_domain_name
()¶ Returns: str host name string
-
public void
vserver_set_domain_name
(str val)¶ Host name (used by dynamic dns)
Parameters: - val (str) – host name string
-
public int
vserver_get_port
()¶ Returns: int host name string
-
public void
vserver_set_port
(int val)¶ Host name (used by dynamic dns)
Parameters: - val (int) – host name string
Configuration Methods¶
-
public byte
config_get_dhcp
()¶ Dhcp enable flag
Returns: byte 0 - disabled, 1 - enabled
-
public void
config_set_dhcp
(byte val)¶ Dhcp enable flag
Parameters: - val (byte) – 0 - disabled, 1 - enabled
-
public byte
config_get_ip_address
()¶ Static ip address of the device
Returns: byte array of four 8 bit values representing ipv4 address
-
public void
config_set_ip_address
(byte val)¶ Static ip address of the device
Parameters: - val (byte) – array of four 8 bit values representing ipv4 address
-
public str
config_get_host_name
()¶ Host name (used by dynamic dns)
Returns: str host name string
-
public void
config_set_host_name
(str val)¶ Host name (used by dynamic dns)
Parameters: - val (str) – host name string
-
public void
config_commit
()¶ Commit configuration changes to flash
-
public void
config_reset
()¶ Reset the device
-
public byte
config_get_ptp_master
()¶ Ptp master enable flag
Returns: byte 0 - disabled, 1 - enabled
-
public void
config_set_ptp_master
(byte val)¶ Ptp master enable flag
Parameters: - val (byte) – 0 - disabled, 1 - enabled
-
public byte
config_get_device_group
()¶ Device group identifier
Returns: byte 0 - no group, 1-255 - group identifier
-
public void
config_set_device_group
(byte val)¶ Device group identifier
Parameters: - val (byte) – 0 - no group, 1-255 - group identifier
-
public int
config_get_ip_port
()¶ Network ip port number of the device
Returns: int ip port number
-
public void
config_set_ip_port
(int val)¶ Network ip port number of the device
Parameters: - val (int) – ip port number
-
public int
config_get_msg_port
()¶ Network ip port number for the messaging protocol
Returns: int ip port number
-
public void
config_set_msg_port
(int val)¶ Network ip port number for the messaging protocol
Parameters: - val (int) – ip port number
-
public byte
config_get_device_id
()¶ Unique device identifier of a device within a group
Returns: byte 0 - 255, unique device identifier
-
public void
config_set_device_id
(byte val)¶ Unique device identifier of a device within a group
Parameters: - val (byte) – 0 - 255, unique device identifier
-
public int
config_get_heartbeat_mask
()¶ Bitmask for inter-device heartbeat/faults
Returns: int 32 bit mask
-
public void
config_set_heartbeat_mask
(int val)¶ Bitmask for inter-device heartbeat/faults
Parameters: - val (int) – 32 bit mask
-
public int
config_get_gpio_direction
()¶ Startup gpio channel direction bit field
Returns: int bitfield: 0 - output, 1 - input
-
public void
config_set_gpio_direction
(int val)¶ Startup gpio channel direction bit field
Parameters: - val (int) – bitfield: 0 - output, 1 - input
-
public int
config_get_gpio_pullup
()¶ Startup gpio input pullup enable bitfield
Returns: int bitfield: 0 - pullup disabled, 1 - pullup enabled
-
public void
config_set_gpio_pullup
(int val)¶ Startup gpio input pullup enable bitfield
Parameters: - val (int) – bitfield: 0 - pullup disabled, 1 - pullup enabled
-
public int
config_get_gpio_polarity
()¶ Startup gpio input/output polarity configuration bitfield
Returns: int bitfield: 0 - normal polarity, 1 - inverse polarity
-
public void
config_set_gpio_polarity
(int val)¶ Startup gpio input/output polarity configuration bitfield
Parameters: - val (int) – bitfield: 0 - normal polarity, 1 - inverse polarity
-
public int
config_get_gpio_value
()¶ Startup gpio pin state
Returns: int bitfield: 0 - low, 1 - high
-
public void
config_set_gpio_value
(int val)¶ Startup gpio pin state
Parameters: - val (int) – bitfield: 0 - low, 1 - high
-
public int
config_get_supervisor_port
()¶ Network ip port number for the inter-device protocol
Returns: int ip port number
-
public void
config_set_supervisor_port
(int val)¶ Network ip port number for the inter-device protocol
Parameters: - val (int) – ip port number
-
public int
config_get_fault_handler
(int chan_id)¶ Associated fault handler with fault id
Parameters: - chan_id (int) – fault id
Returns: int fault handler id
-
public void
config_set_fault_handler
(int chan_id, int val)¶ Associated fault handler with fault code
Parameters: - chan_id (int) – fault id
- val (int) – fault handler id
-
public str
config_get_keepalive_name
()¶ Host name (used by dynamic dns)
Returns: str host name string
-
public void
config_set_keepalive_name
(str val)¶ Host name (used by dynamic dns)
Parameters: - val (str) – host name string
-
public int
config_get_keepalive_port
()¶ Network ip port number for the inter-device protocol
Returns: int ip port number
-
public void
config_set_keepalive_port
(int val)¶ Network ip port number for the inter-device protocol
Parameters: - val (int) – ip port number
Time Methods¶
-
public void
vtrigger_set
()¶ Manually trigger waiting operations
-
public long
time_get_clock
()¶ Current clock value (ns)
Returns: long 64 bit nanoseconds
-
public void
time_get_offset_from_master
()¶ Clock offset/difference from master
-
public void
time_get_drift
()¶
-
public void
time_get_kp
()¶
-
public void
time_set_kp
(float val)¶ Parameters: - val (float) –
-
public void
time_get_ki
()¶
-
public void
time_set_ki
(float val)¶ Parameters: - val (float) –
Motor Methods¶
-
public void
mtr_start
(int start_segment, Trigger trigger)¶ Start the motor starting at start_segment (usually 0) using the trigger condition specified.
Parameters: - start_segment (int) – starting segment
- trigger (Trigger) – trigger type. See Trigger Source
-
public void
mtr_reset
()¶ Reset the motor
-
public void
mtr_write_phase_mem
(int[] fields, int shift_value)¶ Write motor phase waveform
Parameters: - fields (int[]) – fields array
- shift_value (int) – shift value
-
public void
mtr_write_phase_mem_default
(int phases, int poles, int encCntsPerRot)¶ Write default motor phase waveform to controller
Parameters: - phases (int) – number of motor phases
- poles (int) – number of motor poles
- encCntsPerRot (int) –
-
public void
mtr_write_phase_mem_stepper
(int microstep_multiplier)¶ Write phase memory for stepper motor
Parameters: - microstep_multiplier (int) – TODO
-
public void
mtr_write_table
(int start_addr, int num_segments, MtrSegment[] segments)¶ Write motion table
Parameters: - start_addr (int) –
- num_segments (int) – number of segments
- segments (MtrSegment[]) – segments array
-
public void
mtr_read_table
(int start_addr, int num_segments, MtrSegment[] segments)¶ Read motion table
Parameters: - start_addr (int) –
- num_segments (int) – number of segments
- segments (MtrSegment[]) – segments array
-
public void
mtr_write_target_position
(long position, int servomode)¶ Write target position
Parameters: - position (long) – position
- servomode (int) – servo mode. See Servo Mode
-
public int
mtr_create_velocity_profile
(double start_velocity, VelocityEntry[] entries, ServoMode servomode, int elec_cycle_div, MtrSegment[] segments)¶ Create a velocity profile
Parameters: - start_velocity (double) – starting velocity
- entries (VelocityEntry[]) –
- servomode (ServoMode) – servo mode. See Servo Mode
- elec_cycle_div (int) – electrical cycles divisor
- segments (MtrSegment[]) – segments array
-
public int
mtr_create_trapezoidal_profile
(long start_position, TrapezoidalEntry[] entries, int elec_cycle_div, MtrSegment[] segments)¶ Create a trapezoidal profile
Parameters: - start_position (long) – starting position
- entries (TrapezoidalEntry[]) –
- elec_cycle_div (int) – electrical cycles divisor
- segments (MtrSegment[]) – segments array
-
public int
mtr_get_elec_cycle_div
()¶ 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.
Returns: int the electrical cycle time divisor.
-
public void
mtr_set_elec_cycle_div
(int 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: - val (int) – 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.
-
public float
mtr_get_kp
()¶ Get the servo loop kp term. see PID Algorithm
Returns: float the active Kp value.
-
public void
mtr_set_kp
(float val)¶ Set the servo loop kp term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - val (float) – value of the Kp. Range of 0.0 to 32768.0
-
public float
mtr_get_ki
()¶ Get the servo loop ki term. see PID Algorithm
Returns: float the active Ki value.
-
public void
mtr_set_ki
(float val)¶ Set the servo loop ki term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - val (float) – value of the Ki. Range of 0.0 to 32768.0. A value of 0 disables the Ki component.
-
public float
mtr_get_kd
()¶ Get the servo loop kd term. see PID Algorithm
Returns: float the active Kd value.
-
public void
mtr_set_kd
(float val)¶ Set the servo loop kd term. this value acts upon the servo loop immediately. see PID Algorithm
Parameters: - val (float) – value of the Ki. Range of 0.0 to 32768.0. A value of 0 disables the Kd component.
-
public int
mtr_get_ilim
()¶ Get the servo loop integration limit. see PID Algorithm
Returns: int the active integration limit value.
-
public void
mtr_set_ilim
(int val)¶ Set the servo loop integration limit. see PID Algorithm
Parameters: - val (int) – value of the integration limit.
-
public float
mtr_get_kvff
()¶ Get the servo loop velocity feed forward. see PID Algorithm
Returns: float value of the velocity feed forwarf (vff)
-
public void
mtr_set_kvff
(float val)¶ Set the servo loop velocity feed forward. see PID Algorithm
Parameters: - val (float) – value of the velocity feed forward (vff)
-
public float
mtr_get_kaff
()¶ Get the servo loop acceleration feed forward. see PID Algorithm
Returns: float value of the acceleration feed forwarf (vff)
-
public void
mtr_set_kaff
(float val)¶ Set the servo loop acceleration feed forward. see PID Algorithm
Parameters: - val (float) – value of the acceleration feed forwarfd(vff)
-
public int
mtr_get_max_pid_output
()¶ Get the maximum pid (servo loop) output. see PID Algorithm
Returns: int the maximum output of the PID loop.
-
public void
mtr_set_max_pid_output
(int 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: - val (int) – current in terms of DAC output.
-
public int
mtr_get_output_polarity
()¶ Get the output polarity of the pid.
Returns: int the polarity of the servo loop. 0 - positive (default), 1 - negative
-
public void
mtr_set_output_polarity
(int val)¶ Set the output polarity of the pid.
Parameters: - val (int) – polarity . 0 - Positive, 1 - negative
-
public short
mtr_get_pid_output
()¶ Get the output of the pid (servo loop).
Returns: short PID output in terms of DAC output (-32768 to 32767).
-
public int
mtr_get_enc_counts_per_rot
()¶ Get the encoder counts per rotation.
Returns: int encoder counts per rotation in terms of counts.
-
public void
mtr_set_enc_counts_per_rot
(int val)¶ Set the encoder counts per rotation of the encoder. a 512 line encoder has 1024 counts per rotation.
Parameters: - val (int) – encoder counts per rotation in terms of counts.
-
public void
mtr_set_enc_polarity
(int val)¶ Set the polarity of the encoder. the encoder counts can be changed to decrement instead of increment by setting the polarity.
Parameters: - val (int) – polarity of the encoder. 0 - Positive polarity (default) 1 - Negative polarity,
-
public int
mtr_get_enc_pos
()¶ Get the encoder position. the value read is the current encoder count.
Returns: int the encoder count in counts. The encoder count will have a range from 0 - encoder_counts_per_rotation.
-
public int
mtr_get_enc_index_pos
()¶ Get the encoder position of the index. every time an index pulse is detected, the encoder position of the index is recorded.
Returns: int index encoder position in counts.
-
public int
mtr_get_enc_index_count
()¶ Get the index counter. every time an index pulse is detected (either forward rotation or reverse rotation) the encoder index count is incremented.
Returns: int index counter in counts.
-
public int
mtr_get_enc_glitch_count
()¶ 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.
Returns: int glitch count.
-
public int
mtr_get_aux_enc_counts_per_rot
()¶ Get the auxiliary encoder counts per rotation.
Returns: int counts per rotation in counts.
-
public void
mtr_set_aux_enc_counts_per_rot
(int 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: - val (int) – encoder counts per rotation in terms of counts.
-
public void
mtr_set_aux_enc_polarity
(int val)¶ Set the polarity of the auxiliary encoder. the encoder counts can be changed to decrement instead of increment by setting the polarity.
Parameters: - val (int) – polarity of the encoder. 0 - Positive polarity (default) 1 - Negative polarity,
-
public long
mtr_get_aux_actual_pos
()¶ Get the actual position from the auxiliary encoder. this is a signed 64 bit value.
Returns: long the actual position of the auxiliary encoder.
-
public int
mtr_get_aux_enc_pos
()¶ Get the auxiliary encoder position. the value read is the current encoder count of the auxiliary encoder input.
Returns: int encoder counts of the auxiliary encoder.
-
public int
mtr_get_aux_enc_index_pos
()¶ Get the auxiliary encoder position of the index. every time an index pulse is detected, the auxiliary encoder position of the index is recorded.
Returns: int encoder position in counts.
-
public int
mtr_get_aux_enc_index_count
()¶ 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.
Returns: int index count. Number of times the encoder has passed the index line.
-
public int
mtr_get_aux_enc_glitch_count
()¶ 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.
Returns: int glitch count.
-
public void
mtr_set_use_aux_enc_for_servo
(int 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: - val (int) – select to use the auxiliary encoder as the input to the trajectory generator and servo loop. 0 - first encoder (default), 1 -auxiliary encoder.
-
public int
mtr_get_mtr_type
()¶ Get the motor type.
Returns: int motor type (MTR_TYPE_3PHASE = 0, MTR_TYPE_STEPPER = 1, MTR_TYPE_VOICECOIL = 2)
-
public void
mtr_set_mtr_type
(int val)¶ Set the motor type. the motor can be a three-phase motor, stepper motor, or voice coil motor.
Parameters: - val (int) – motor type. Valid settings are: MTR_TYPE_3PHASE = 0, MTR_TYPE_STEPPER = 1, MTR_TYPE_VOICECOIL = 2
-
public int
mtr_get_poles
()¶ Get the motor poles.
Returns: int the number of poles.
-
public void
mtr_set_poles
(int val)¶ Set the number of poles of the motor. valid numbers are 2, 4, 6, 8, 12 - 200
Parameters: - val (int) – number of poles of the motor.
-
public void
mtr_get_loop_mode
()¶
-
public void
mtr_set_loop_mode
(int val)¶ Parameters: - val (int) –
-
public int
mtr_get_was_reset
()¶ Get whether the motor was reset or not.
Returns: int returns 0 - motor was not reset, 1 - motor was reset.
-
public int
mtr_get_reset_state
()¶ 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.
Returns: int the reset state.
-
public int
mtr_get_reset_wait_time_ms
()¶ Get the motor reset wait time.
Returns: int the reset wait time in milliseconds.
-
public void
mtr_set_reset_wait_time_ms
(int 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: - val (int) – time in milliseconds to energize the phase.
-
public int
mtr_get_reset_current
()¶ Get the amount of current used during reset.
Returns: int the current in terms of DAC output.
-
public void
mtr_set_reset_current
(int 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: - val (int) – current in terms of DAC output.
-
public int
mtr_get_open_loop_drive_current
()¶ Get the open loop drive current.
Returns: int the open loop drive current.
-
public void
mtr_set_open_loop_drive_current
(int val)¶ Set the open loop drive current. when in mtr_mode_manual, this will be the current energizing the phases of the motor.
Parameters: - val (int) – current in terms of DAC output.
-
public void
mtr_get_manual_loop_current
()¶
-
public void
mtr_set_manual_loop_current
(int val)¶ Parameters: - val (int) –
-
public int
mtr_get_pwr_enable
()¶ Get power state of the amplifier.
Returns: int returns a 0 - Off and a 1 - On
-
public void
mtr_set_pwr_enable
(int val)¶ Set the power state of the amplifier. this will turn all outputs of the amplifiers to off or on.
Parameters: - val (int) – 0 - off, 1 - on
-
public int
mtr_get_traj_gen_enable
()¶ Get if the trajectory generator is enabled.
Returns: int returns a 0 - Off and a 1 - On
-
public void
mtr_set_traj_gen_enable
(int val)¶ Enables or disables the trajectory generator.
Parameters: - val (int) – A value of 0 turns the trajectory generator off. A value of 1 turns the trajectory generator on.
-
public int
mtr_get_traj_gen_table_seg
()¶ Get the active trajectory generator segment.
Returns: int segment entry 0 thru 100
-
public long
mtr_get_traj_gen_current_time
()¶ Get the active time from the trajectory generator.
Returns: long time in ???
-
public void
mtr_get_traj_gen_busy
()¶ Get the busy state of the trajectory generator.
-
public int
mtr_get_phase_size
()¶ Get the current numbers of entries in the phase memory.
Returns: int number of entries.
-
public void
mtr_set_phase_size
(int val)¶ Set the number of entries in the phase memory.
Parameters: - val (int) –
-
public void
mtr_get_phase_mem_shift
()¶
-
public void
mtr_set_phase_mem_shift
(int val)¶ Parameters: - val (int) –
-
public void
mtr_get_phase_offset
()¶ Gets the phase offset.
-
public void
mtr_set_phase_offset
(int val)¶ Parameters: - val (int) –
-
public void
mtr_get_phase_mem_address
()¶
-
public int
mtr_get_max_pos_error
()¶ Get the maximum allowed position error.
Returns: int the maximum position error in counts.
-
public void
mtr_set_max_pos_error
(int 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: - val (int) – error in terms of counts.
-
public int
mtr_get_motion_error
()¶ Get the motion error register.
Returns: int the motion error.
-
public void
mtr_set_motion_error
(int val)¶ Clear all motion errors.
Parameters: - val (int) – set the value to 0 to clear the errors.
-
public int
mtr_get_pos_error
()¶ Get the position error in counts.
Returns: int position error in counts.
-
public void
mtr_get_vel_error
()¶ Get the velocity error in counts per second.
-
public long
mtr_get_target_vel
()¶ Get the target velocity.
Returns: long the target velocity.
-
public long
mtr_get_actual_vel
()¶ Get the actual velocity.
Returns: long the actual velocity.
-
public long
mtr_get_target_pos
()¶ Get the target position.
Returns: long the target position.
-
public long
mtr_get_actual_pos
()¶ Get the actual position.
Returns: long the actual position.
-
public short
mtr_get_dac_output_a
()¶ Get the dac output to phase a of the motor. this is the value that is sent to the dac.
Returns: short the DAC output value for phase A.
-
public short
mtr_get_dac_output_b
()¶ Get the dac output to phase b of the motor. this is the value that is sent to the dac.
Returns: short the DAC output value for phase B.
-
public short
mtr_get_phase_a
()¶ Get the currently selected phase a value from the phase memory table.
Returns: short the value of phase A
-
public short
mtr_get_phase_b
()¶ Get the currently selected phase b value from the phase memory table.
Returns: short the value of phase B
-
public void
mtr_restore_defaults
()¶ Restore motor configuration to power on defaults.
-
public int
mtr_get_profile_finished
()¶ Get the finished state of the profile. if the motor profile has completed the last segment in the table, the profile will be finished.
Returns: int returns the profile finished state. 0 - not finished, 1 - finished.
-
public long
mtr_get_actual_index_pos
()¶ 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.
Returns: long the actual position of the index (64 bit position).
-
public long
mtr_get_aux_actual_index_pos
()¶ 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.
Returns: long the auxiliary actual position of the index (64 bit position).
-
public byte
mtr_get_kvff_shift
()¶ 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.
Returns: byte the value of kvff_shift.
-
public void
mtr_set_kvff_shift
(byte 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: - val (byte) – the amount to shift Kvff right. Valid values of 0 - 15.
-
public byte
mtr_get_kaff_shift
()¶ 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.
Returns: byte the value of kaff_shift.
-
public void
mtr_set_kaff_shift
(byte 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: - val (byte) – the amount to shift Kaff left. Valid values of 0 - 15.
-
public void
mtr_set_biquad_enable
(int val)¶ Set the power state of the amplifier. this will turn all outputs of the amplifiers to off or on.
Parameters: - val (int) – 0 - off, 1 - on
-
public void
mtr_set_biquad_shiftby
(byte 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: - val (byte) – the amount to shift Kaff left. Valid values of 0 - 15.
-
public void
mtr_set_biquad_a0
(int 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: - val (int) – current in terms of DAC output.
-
public void
mtr_set_biquad_a1
(int 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: - val (int) – current in terms of DAC output.
-
public void
mtr_set_biquad_a2
(int 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: - val (int) – current in terms of DAC output.
-
public void
mtr_set_biquad_b1
(int 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: - val (int) – current in terms of DAC output.
-
public void
mtr_set_biquad_b2
(int 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: - val (int) – current in terms of DAC output.
Data Acquisition Methods¶
GPIO Methods¶
-
public int
gpio_get_value
(int chan_id)¶ Gpio pin state
Parameters: - chan_id (int) – bit mask of gpio pins on which operate. For example, 0x0f would only operate on GPIO 0-3, others are ignored.
Returns: int bitfield: 0 - low, 1 - high
-
public void
gpio_set_value
(int chan_id, int val)¶ Gpio pin state
Parameters: - chan_id (int) – bit mask of gpio pins on which operate. For example, 0x0f would only operate on GPIO 0-3, others are ignored.
- val (int) – bitfield: 0 - low, 1 - high. For example, 0x11 would set GPIO 0 and GPIO 4 high (if configured as outputs).
-
public void
gpio_set_polarity
(int chan_id, int val)¶ Gpio input/output polarity configuration bitfield
Parameters: - chan_id (int) –
- val (int) – bitfield: 0 - normal polarity, 1 - inverse polarity
-
public void
gpio_set_pullup
(int chan_id, int val)¶ Gpio input pullup enable bitfield
Parameters: - chan_id (int) –
- val (int) – bitfield: 0 - pullup disabled, 1 - pullup enabled
-
public void
gpio_set_direction
(int chan_id, int val)¶ Gpio channel direction bit field
Parameters: - chan_id (int) –
- val (int) – bitfield: 0 - output, 1 - input
Analog to Digital Converter Methods¶
-
public void
daq_start
(int chan_id, int divisor, int start_sample, int num_samples, Trigger trigger)¶ Start the data acquisition channel
Parameters: - chan_id (int) – channel identifier
- divisor (int) – clock divisor, to derive sampling rate (divisor of 0.001 gives 1kHz sample rate
- start_sample (int) – post-trigger sample number
- num_samples (int) – number of samples
- trigger (Trigger) – trigger type. See Trigger Source
-
public void
daq_listen
(int chan_id)¶ Receive data acquisition channel that has already been started by a different connection
Parameters: - chan_id (int) – channel identifier
-
public void
daq_register_callback
(int chan_id, int samples, int milliseconds, String callbackname)¶ Listen for data acquisition. only needs to be registered once.
Parameters: - chan_id (int) – channel identifier
- samples (int) –
- milliseconds (int) – milliseconds before callback
- callbackname (String) – name of callback function
-
public DaqAcquireDataResult
daq_acquire_data
(int chan_id, int samples, int[] buffer)¶ Listen for data acquisition
Parameters: - chan_id (int) – channel identifier
- samples (int) –
- buffer (int[]) –
-
public int
daq_get_sample
(int chan_id)¶ Get a single data acquistion sample
Parameters: - chan_id (int) – channel identifier