PiMotion Python Software Interface

Classes

class Pidev(addr=None, password = None, port = 0)

An idealized connection to a specific PiDevice.

Parameters:
  • addr (string) – dot formated ip address of the device (ex: 192.168.1.170)
  • password (string) – password of the device
  • port (int) – ip port

General Methods

Pidev.pidev_scan(ifaddr, timeout_ms, max_results)

Scan for pidev devices

Parameters:
  • ifaddr – interface address (ip address of which network card to use), or “all” for all network cards
  • timeout_ms – timeout (milliseconds) to wait for devices on each network card
  • max_results – maximum number of results requested
Returns:

an array of dictionaries containing address, name, version, device type, software type, password status, and ip port.

Pidev.pidev_trigger(group_trigger, timer1_relative, timer2_relative, timer1_time, timer2_time, manual_trigger)

Multiple/complex triggering

Parameters:
  • group_trigger – enable group trigger (0: disabled, 1: enabled)
  • timer1_relative – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
  • timer2_relative – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
  • timer1_time – nanosecond time for timer 1 (absolute or relative), 0: ignore)
  • timer2_time – nanosecond time for timer 2 (absolute or relative), 0: ignore)
  • manual_trigger – manually trigger (0: ignored, 1: trigger now)
Pidev.pidev_trigger_manual()

Manual trigger

Pidev.pidev_trigger_timer1(relative, time)

Arm timer 1 trigger

Parameters:
  • relative – relative trigger time (0: absolute, 1: relative)
  • time – nanosecond time
Pidev.pidev_trigger_timer2(relative, time)

Arm timer 2 trigger

Parameters:
  • relative – relative trigger time (0: absolute, 1: relative)
  • time – nanosecond time
Pidev.pidev_trigger_group(timer1_relative, timer2_relative, timer1_time, timer2_time, manual_trigger)

Group trigger

Parameters:
  • timer1_relative – enable relative trigger based on timer 1 (0: disabled, 1: enabled)
  • timer2_relative – enable relative trigger based on timer 2 (0: disabled, 1: enabled)
  • timer1_time – nanosecond time for timer 1 (absolute or relative), 0: ignore)
  • timer2_time – nanosecond time for timer 2 (absolute or relative), 0: ignore)
  • manual_trigger – manually trigger (0: ignored, 1: trigger now)
Pidev.pidev_info()

Get information about the device

Returns:dictionary containing software app running, version number, build number, error mask, serial number, and manufacture date
Pidev.pidev_set_password(password)

Change device password

Parameters:password – password string
Pidev.pidev_set_ptp_password(password)

Change device ptp password

Parameters:password – password string
Pidev.pidev_set_timeout_offset(timeout_offset_ms)

Add additional timeout time to all library calls

Parameters:timeout_offset_ms – additional time (milliseconds)
Pidev.pidev_get_temperature()

Get device internal temperature

Pidev.err_register_callback(ifaddr, port, f)

Register error/vmsg callback

Parameters:
  • ifaddr – interface address (ip address of which network card to use), or “all” for all network cards
  • port – ip port
  • f – callback function
Pidev.pidev_get_version()

Pidev version information

Returns:version number
Return type:int
Pidev.pidev_get_build()

Pidev build identifier

Returns:build number
Return type:int
Pidev.pidev_set_id_duration(val)

Identify device by blinking led

Parameters:val (int) – duration (ms) for led blink
Pidev.pidev_get_faults()

Faults bitmask

Returns:faults bitmask
Return type:int
Pidev.pidev_vmsg_test(val)

Echo a message from the device via the messaging protocol

Parameters:val (str) – a test string to echo
Pidev.pidev_clear_faults()

Clear faults bit field

Pidev.pidev_get_connected_devices()
Pidev.vserver_get_domain_name()
Returns:host name string
Return type:str
Pidev.vserver_set_domain_name(val)

Host name (used by dynamic dns)

Parameters:val (str) – host name string
Pidev.vserver_get_port()
Returns:host name string
Return type:int
Pidev.vserver_set_port(val)

Host name (used by dynamic dns)

Parameters:val (int) – host name string

Configuration Methods

Pidev.config_get_dhcp()

Dhcp enable flag

Returns:0 - disabled, 1 - enabled
Return type:int
Pidev.config_set_dhcp(val)

Dhcp enable flag

Parameters:val (int) – 0 - disabled, 1 - enabled
Pidev.config_get_ip_address()

Static ip address of the device

Returns:array of four 8 bit values representing ipv4 address
Return type:int
Pidev.config_set_ip_address(val)

Static ip address of the device

Parameters:val (int) – array of four 8 bit values representing ipv4 address
Pidev.config_get_host_name()

Host name (used by dynamic dns)

Returns:host name string
Return type:str
Pidev.config_set_host_name(val)

Host name (used by dynamic dns)

Parameters:val (str) – host name string
Pidev.config_commit()

Commit configuration changes to flash

Pidev.config_reset()

Reset the device

Pidev.config_get_ptp_master()

Ptp master enable flag

Returns:0 - disabled, 1 - enabled
Return type:int
Pidev.config_set_ptp_master(val)

Ptp master enable flag

Parameters:val (int) – 0 - disabled, 1 - enabled
Pidev.config_get_device_group()

Device group identifier

Returns:0 - no group, 1-255 - group identifier
Return type:int
Pidev.config_set_device_group(val)

Device group identifier

Parameters:val (int) – 0 - no group, 1-255 - group identifier
Pidev.config_get_ip_port()

Network ip port number of the device

Returns:ip port number
Return type:int
Pidev.config_set_ip_port(val)

Network ip port number of the device

Parameters:val (int) – ip port number
Pidev.config_get_msg_port()

Network ip port number for the messaging protocol

Returns:ip port number
Return type:int
Pidev.config_set_msg_port(val)

Network ip port number for the messaging protocol

Parameters:val (int) – ip port number
Pidev.config_get_device_id()

Unique device identifier of a device within a group

Returns:0 - 255, unique device identifier
Return type:int
Pidev.config_set_device_id(val)

Unique device identifier of a device within a group

Parameters:val (int) – 0 - 255, unique device identifier
Pidev.config_get_heartbeat_mask()

Bitmask for inter-device heartbeat/faults

Returns:32 bit mask
Return type:int
Pidev.config_set_heartbeat_mask(val)

Bitmask for inter-device heartbeat/faults

Parameters:val (int) – 32 bit mask
Pidev.config_get_gpio_direction()

Startup gpio channel direction bit field

Returns:bitfield: 0 - output, 1 - input
Return type:int
Pidev.config_set_gpio_direction(val)

Startup gpio channel direction bit field

Parameters:val (int) – bitfield: 0 - output, 1 - input
Pidev.config_get_gpio_pullup()

Startup gpio input pullup enable bitfield

Returns:bitfield: 0 - pullup disabled, 1 - pullup enabled
Return type:int
Pidev.config_set_gpio_pullup(val)

Startup gpio input pullup enable bitfield

Parameters:val (int) – bitfield: 0 - pullup disabled, 1 - pullup enabled
Pidev.config_get_gpio_polarity()

Startup gpio input/output polarity configuration bitfield

Returns:bitfield: 0 - normal polarity, 1 - inverse polarity
Return type:int
Pidev.config_set_gpio_polarity(val)

Startup gpio input/output polarity configuration bitfield

Parameters:val (int) – bitfield: 0 - normal polarity, 1 - inverse polarity
Pidev.config_get_gpio_value()

Startup gpio pin state

Returns:bitfield: 0 - low, 1 - high
Return type:int
Pidev.config_set_gpio_value(val)

Startup gpio pin state

Parameters:val (int) – bitfield: 0 - low, 1 - high
Pidev.config_get_supervisor_port()

Network ip port number for the inter-device protocol

Returns:ip port number
Return type:int
Pidev.config_set_supervisor_port(val)

Network ip port number for the inter-device protocol

Parameters:val (int) – ip port number
Pidev.config_get_fault_handler(chan_id)

Associated fault handler with fault id

Parameters:chan_id (int) – fault id
Returns:fault handler id
Return type:int
Pidev.config_set_fault_handler(chan_id, val)

Associated fault handler with fault code

Parameters:
  • chan_id (int) – fault id
  • val (int) – fault handler id
Pidev.config_get_keepalive_name()

Host name (used by dynamic dns)

Returns:host name string
Return type:str
Pidev.config_set_keepalive_name(val)

Host name (used by dynamic dns)

Parameters:val (str) – host name string
Pidev.config_get_keepalive_port()

Network ip port number for the inter-device protocol

Returns:ip port number
Return type:int
Pidev.config_set_keepalive_port(val)

Network ip port number for the inter-device protocol

Parameters:val (int) – ip port number

Time Methods

Pidev.vtrigger_set()

Manually trigger waiting operations

Pidev.time_get_clock()

Current clock value (ns)

Returns:64 bit nanoseconds
Return type:int
Pidev.time_get_offset_from_master()

Clock offset/difference from master

Pidev.time_get_drift()
Pidev.time_get_kp()
Pidev.time_set_kp(val)
Parameters:val (float) –
Pidev.time_get_ki()
Pidev.time_set_ki(val)
Parameters:val (float) –

Motor Methods

Pidev.mtr_start(start_segment, trigger)

Start the motor starting at start_segment (usually 0) using the trigger condition specified.

Parameters:
  • start_segment – starting segment
  • trigger – trigger type. See Trigger Source
Pidev.mtr_reset()

Reset the motor

Pidev.mtr_write_phase_mem(fields, shift_value)

Write motor phase waveform

Parameters:
  • fields – fields array
  • shift_value – shift value
Pidev.mtr_write_phase_mem_default(phases, poles, enc_cnts_per_rot)

Write default motor phase waveform to controller

Parameters:
  • phases – number of motor phases
  • poles – number of motor poles
  • enc_cnts_per_rot – number of encoder counts per rotation
Pidev.mtr_write_phase_mem_default_buffer(phases, poles, enc_cnts_per_rot, buf)

Write default motor phase waveform to a buffer

Parameters:
  • phases – number of motor phases
  • poles – number of motor poles
  • enc_cnts_per_rot – number of encoder counts per rotation
  • buf – numpy preallocated buffer of type np.ndarray[np.uint32_t, ndim=1]
Pidev.mtr_write_phase_mem_stepper(microstep_multiplier)

Write phase memory for stepper motor

Parameters:microstep_multiplier – TODO
Pidev.mtr_write_table(start_segment, segments)

Write motion table

Parameters:
  • start_segment – starting segment
  • segments – segments array
Pidev.mtr_read_table(start_segment, num_segments)

Read motion table

Parameters:
  • start_segment – starting segment
  • num_segments – number of segments
Pidev.mtr_write_target_position(position, servomode=0)

Write target position

Parameters:
  • position – position
  • servomode=0
Pidev.mtr_create_velocity_profile(start_velocity, profile, servomode, elec_cycle_div)

Create a velocity profile

Parameters:
  • start_velocity – starting velocity
  • profile
  • servomode – servo mode. See Servo Mode
  • elec_cycle_div – electrical cycles divisor
Pidev.mtr_create_trapezoidal_profile(start_position, profile, servomode, elec_cycle_div)

Create a trapezoidal profile

Parameters:
  • start_position – starting position
  • profile
  • servomode – servo mode. See Servo Mode
  • elec_cycle_div – electrical cycles divisor
Pidev.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:the electrical cycle time divisor.
Return type:int
Pidev.mtr_set_elec_cycle_div(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.
Pidev.mtr_get_kp()

Get the servo loop kp term. see PID Algorithm

Returns:the active Kp value.
Return type:float
Pidev.mtr_set_kp(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
Pidev.mtr_get_ki()

Get the servo loop ki term. see PID Algorithm

Returns:the active Ki value.
Return type:float
Pidev.mtr_set_ki(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.
Pidev.mtr_get_kd()

Get the servo loop kd term. see PID Algorithm

Returns:the active Kd value.
Return type:float
Pidev.mtr_set_kd(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.
Pidev.mtr_get_ilim()

Get the servo loop integration limit. see PID Algorithm

Returns:the active integration limit value.
Return type:int
Pidev.mtr_set_ilim(val)

Set the servo loop integration limit. see PID Algorithm

Parameters:val (int) – value of the integration limit.
Pidev.mtr_get_kvff()

Get the servo loop velocity feed forward. see PID Algorithm

Returns:value of the velocity feed forwarf (vff)
Return type:float
Pidev.mtr_set_kvff(val)

Set the servo loop velocity feed forward. see PID Algorithm

Parameters:val (float) – value of the velocity feed forward (vff)
Pidev.mtr_get_kaff()

Get the servo loop acceleration feed forward. see PID Algorithm

Returns:value of the acceleration feed forwarf (vff)
Return type:float
Pidev.mtr_set_kaff(val)

Set the servo loop acceleration feed forward. see PID Algorithm

Parameters:val (float) – value of the acceleration feed forwarfd(vff)
Pidev.mtr_get_max_pid_output()

Get the maximum pid (servo loop) output. see PID Algorithm

Returns:the maximum output of the PID loop.
Return type:int
Pidev.mtr_set_max_pid_output(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.
Pidev.mtr_get_output_polarity()

Get the output polarity of the pid.

Returns:the polarity of the servo loop. 0 - positive (default), 1 - negative
Return type:int
Pidev.mtr_set_output_polarity(val)

Set the output polarity of the pid.

Parameters:val (int) – polarity . 0 - Positive, 1 - negative
Pidev.mtr_get_pid_output()

Get the output of the pid (servo loop).

Returns:PID output in terms of DAC output (-32768 to 32767).
Return type:int
Pidev.mtr_get_enc_counts_per_rot()

Get the encoder counts per rotation.

Returns:encoder counts per rotation in terms of counts.
Return type:int
Pidev.mtr_set_enc_counts_per_rot(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.
Pidev.mtr_set_enc_polarity(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,
Pidev.mtr_get_enc_pos()

Get the encoder position. the value read is the current encoder count.

Returns:the encoder count in counts. The encoder count will have a range from 0 - encoder_counts_per_rotation.
Return type:int
Pidev.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:index encoder position in counts.
Return type:int
Pidev.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:index counter in counts.
Return type:int
Pidev.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:glitch count.
Return type:int
Pidev.mtr_get_aux_enc_counts_per_rot()

Get the auxiliary encoder counts per rotation.

Returns:counts per rotation in counts.
Return type:int
Pidev.mtr_set_aux_enc_counts_per_rot(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.
Pidev.mtr_set_aux_enc_polarity(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,
Pidev.mtr_get_aux_actual_pos()

Get the actual position from the auxiliary encoder. this is a signed 64 bit value.

Returns:the actual position of the auxiliary encoder.
Return type:int
Pidev.mtr_get_aux_enc_pos()

Get the auxiliary encoder position. the value read is the current encoder count of the auxiliary encoder input.

Returns:encoder counts of the auxiliary encoder.
Return type:int
Pidev.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:encoder position in counts.
Return type:int
Pidev.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:index count. Number of times the encoder has passed the index line.
Return type:int
Pidev.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:glitch count.
Return type:int
Pidev.mtr_set_use_aux_enc_for_servo(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.
Pidev.mtr_get_mtr_type()

Get the motor type.

Returns:motor type (MTR_TYPE_3PHASE = 0, MTR_TYPE_STEPPER = 1, MTR_TYPE_VOICECOIL = 2)
Return type:int
Pidev.mtr_set_mtr_type(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
Pidev.mtr_get_poles()

Get the motor poles.

Returns:the number of poles.
Return type:int
Pidev.mtr_set_poles(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.
Pidev.mtr_get_loop_mode()
Pidev.mtr_set_loop_mode(val)
Parameters:val (int) –
Pidev.mtr_get_was_reset()

Get whether the motor was reset or not.

Returns:returns 0 - motor was not reset, 1 - motor was reset.
Return type:int
Pidev.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:the reset state.
Return type:int
Pidev.mtr_get_reset_wait_time_ms()

Get the motor reset wait time.

Returns:the reset wait time in milliseconds.
Return type:int
Pidev.mtr_set_reset_wait_time_ms(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.
Pidev.mtr_get_reset_current()

Get the amount of current used during reset.

Returns:the current in terms of DAC output.
Return type:int
Pidev.mtr_set_reset_current(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.
Pidev.mtr_get_open_loop_drive_current()

Get the open loop drive current.

Returns:the open loop drive current.
Return type:int
Pidev.mtr_set_open_loop_drive_current(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.
Pidev.mtr_get_manual_loop_current()
Pidev.mtr_set_manual_loop_current(val)
Parameters:val (int) –
Pidev.mtr_get_pwr_enable()

Get power state of the amplifier.

Returns:returns a 0 - Off and a 1 - On
Return type:int
Pidev.mtr_set_pwr_enable(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
Pidev.mtr_get_traj_gen_enable()

Get if the trajectory generator is enabled.

Returns:returns a 0 - Off and a 1 - On
Return type:int
Pidev.mtr_set_traj_gen_enable(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.
Pidev.mtr_get_traj_gen_table_seg()

Get the active trajectory generator segment.

Returns:segment entry 0 thru 100
Return type:int
Pidev.mtr_get_traj_gen_current_time()

Get the active time from the trajectory generator.

Returns:time in ???
Return type:int
Pidev.mtr_get_traj_gen_busy()

Get the busy state of the trajectory generator.

Pidev.mtr_get_phase_size()

Get the current numbers of entries in the phase memory.

Returns:number of entries.
Return type:int
Pidev.mtr_set_phase_size(val)

Set the number of entries in the phase memory.

Parameters:val (int) –
Pidev.mtr_get_phase_mem_shift()
Pidev.mtr_set_phase_mem_shift(val)
Parameters:val (int) –
Pidev.mtr_get_phase_offset()

Gets the phase offset.

Pidev.mtr_set_phase_offset(val)
Parameters:val (int) –
Pidev.mtr_get_phase_mem_address()
Pidev.mtr_get_max_pos_error()

Get the maximum allowed position error.

Returns:the maximum position error in counts.
Return type:int
Pidev.mtr_set_max_pos_error(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.
Pidev.mtr_get_motion_error()

Get the motion error register.

Returns:the motion error.
Return type:int
Pidev.mtr_set_motion_error(val)

Clear all motion errors.

Parameters:val (int) – set the value to 0 to clear the errors.
Pidev.mtr_get_pos_error()

Get the position error in counts.

Returns:position error in counts.
Return type:int
Pidev.mtr_get_vel_error()

Get the velocity error in counts per second.

Pidev.mtr_get_target_vel()

Get the target velocity.

Returns:the target velocity.
Return type:int
Pidev.mtr_get_actual_vel()

Get the actual velocity.

Returns:the actual velocity.
Return type:int
Pidev.mtr_get_target_pos()

Get the target position.

Returns:the target position.
Return type:int
Pidev.mtr_get_actual_pos()

Get the actual position.

Returns:the actual position.
Return type:int
Pidev.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:the DAC output value for phase A.
Return type:int
Pidev.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:the DAC output value for phase B.
Return type:int
Pidev.mtr_get_phase_a()

Get the currently selected phase a value from the phase memory table.

Returns:the value of phase A
Return type:int
Pidev.mtr_get_phase_b()

Get the currently selected phase b value from the phase memory table.

Returns:the value of phase B
Return type:int
Pidev.mtr_restore_defaults()

Restore motor configuration to power on defaults.

Pidev.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:returns the profile finished state. 0 - not finished, 1 - finished.
Return type:int
Pidev.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:the actual position of the index (64 bit position).
Return type:int
Pidev.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:the auxiliary actual position of the index (64 bit position).
Return type:int
Pidev.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:the value of kvff_shift.
Return type:int
Pidev.mtr_set_kvff_shift(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 (int) – the amount to shift Kvff right. Valid values of 0 - 15.
Pidev.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:the value of kaff_shift.
Return type:int
Pidev.mtr_set_kaff_shift(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 (int) – the amount to shift Kaff left. Valid values of 0 - 15.
Pidev.mtr_set_biquad_enable(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
Pidev.mtr_set_biquad_shiftby(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 (int) – the amount to shift Kaff left. Valid values of 0 - 15.
Pidev.mtr_set_biquad_a0(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.
Pidev.mtr_set_biquad_a1(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.
Pidev.mtr_set_biquad_a2(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.
Pidev.mtr_set_biquad_b1(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.
Pidev.mtr_set_biquad_b2(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

Pidev.gpio_get_value(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:bitfield: 0 - low, 1 - high
Return type:int
Pidev.gpio_set_value(chan_id, 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).
Pidev.gpio_set_polarity(chan_id, val)

Gpio input/output polarity configuration bitfield

Parameters:
  • chan_id (int) –
  • val (int) – bitfield: 0 - normal polarity, 1 - inverse polarity
Pidev.gpio_set_pullup(chan_id, val)

Gpio input pullup enable bitfield

Parameters:
  • chan_id (int) –
  • val (int) – bitfield: 0 - pullup disabled, 1 - pullup enabled
Pidev.gpio_set_direction(chan_id, val)

Gpio channel direction bit field

Parameters:
  • chan_id (int) –
  • val (int) – bitfield: 0 - output, 1 - input

Analog to Digital Converter Methods

Pidev.daq_start(chan_id, divisor, start_sample, num_samples, trigger)

Start the data acquisition channel

Parameters:
  • chan_id – channel identifier
  • divisor – clock divisor, to derive sampling rate (divisor of 0.001 gives 1kHz sample rate
  • start_sample – post-trigger sample number
  • num_samples – number of samples
  • trigger – trigger type. See Trigger Source
Pidev.daq_listen(chan_id)

Receive data acquisition channel that has already been started by a different connection

Parameters:chan_id – channel identifier
Pidev.daq_register_callback(chan_id, samples, milliseconds, f)

Listen for data acquisition. only needs to be registered once.

Parameters:
  • chan_id – channel identifier
  • samples
  • milliseconds – milliseconds before callback
  • f – callback function
Pidev.daq_acquire_data(chan_id, samples, np.ndarray[np.int32_t, ndim=1] buf)

Listen for data acquisition

Parameters:
  • chan_id – channel identifier
  • samples
  • np.ndarray[np.int32_t
  • buf – numpy preallocated buffer of type np.ndarray[np.int32_t, ndim=1]
Pidev.daq_get_sample(chan_id)

Get a single data acquistion sample

Parameters:chan_id – channel identifier