Thorlabs / Motion_Control_Examples

Software examples for Thorlabs motion control products (e.g. T-Cube, K-Cube, and benchtop brushless, DC, stepper, and Piezo motor controllers)
MIT License
71 stars 28 forks source link

TrigOUT_AtPositionFwd parameters can only be changed under UseDeviceSettings with KBD101 #47

Closed Omnistic closed 2 months ago

Omnistic commented 5 months ago

This is partly my fault for combining multiple examples from the repository, but I wanted to make sure what I observed is the intended behavior.

To change the trigger configuration to TrigOUT_AtPositionFwd on I/O 1, one has to do:

trigger_config_params = kcube.GetTriggerConfigParams()
trigger_config_params.Trigger1Mode = KCubeTriggerConfigSettings.TriggerPortMode.TrigOUT_AtPositionFwd
kcube.SetTriggerConfigParams(trigger_config_params)

This works for me for any DeviceSettingsUseOptionType (UseDeviceSettings, UseFileSettings, or UseConfiguredSettings) when calling:

m_config = kcube.LoadMotorConfiguration(
            serial_no,
            DeviceConfiguration.DeviceSettingsUseOptionType.UseDeviceSettings,
        )

However, when I want to change the parameters of the TrigOUT_AtPositionFwd, such as the pulse width or the trigger count, with such a piece of code:

trigger_params_params = kcube.GetTriggerParamsParams()
trigger_params_params.TriggerCountFwd = 45
kcube.SetTriggerParamsParams(trigger_params_params)

This only works with DeviceSettingsUseOptionType as UseDeviceSettings. Those parameters are ignored if DeviceSettingsUseOptionType is UseFileSettings or UseConfiguredSettings. No error is thrown, but I noticed with an oscilloscope.

It was quite confusing to me because I had DeviceSettingsUseOptionType as UseFileSettings and I was able to change the trigger configuration to have TrigOUT_InMotion. Therefore I assumed I could also change it to TrigOUT_AtPositionFwd, which maybe works (?), but what is for sure is that the parameters are never taken into account (at least for me). So, changing the number of trigger counts didn't have an effect until I changed back to UseDeviceSettings.

Please let me know if that is indeed the intended behavior or whether I am not understanding something from the API (very likely). Thank you and take care,

Omni

TrumanMetz commented 2 months ago

Hi Omni, My apologies for the confusion. This is actually intentional, UseFileSettings and UseConfiguredSettings are based of the defaultSetting.xml that's loaded in when those options are selected. Since the xml doesn't house the trigger settings it'll just ignore anything you try to set. I hope this helps.