-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set/Reset trigger with pyLabLib for Thorlabs KDC101 #78
Comments
Dear Anna, If I understand you correctly, you want to use Trig1 and Trig2 as digital inputs and have a way to determine their state inside a Python script? If so, then, as far as I can see, first you need to specify them as general purpose inputs by calling stage.setup_kcube_trigio(trig1_mode="in_gpio", trig2_mode="in_gpio")
# ...
status=stage.get_status() # a list of all active status flags; the interesting ones are "digio1" and "digio2"
trig1_state="digio1" in status
trig2_state="digio2" in status I haven't tested it, but that should work according to the documentation. Let me know if that works for you. Sincerely, Alexey. |
Dear Alexey, that works perfectly fine, thank you so much for your help. I didnt know how to access "digio1", learned something new! Have a nice weekend and kind regards, Anna |
Dear Alexey, I dont know if it's me but I can't seem to find any way to actually write to an output. Now I can at least use the trigger as an input but I dont see any way to set them using the pylablib. In the DLL library Thorlabs provides (Thorlabs.MotionControl.KCube.DCServo.h) there is the function Kind regards, |
Dear Anna, You're right, setting digital output is not implmeneted in pylablib yet. Strangely enough, while I could find such a command in the APT manual, it does not seem to apply to KDC101 specifically. Furthermore, I could not find how to do it in the Kinesis software either. Are you sure that the DLL method works in your case? Nevertheless, you can try to execute the APT request by using the stage.setup_kcube_trigio(trig1_mode="out_gpio", trig2_mode="out_gpio") # need to configure the outputs
stage.send_comm(0x0213,0xFF) # should turn all outputs on
stage.send_comm(0x0213,0x00) # should turn all outputs off
stage.send_comm(0x0213,0x01) # should, hopefully, turn only the first output on
stage.send_comm(0x0213,0x02) # should, hopefully, turn only the second output on Let me know if it works! Sincerely, Alexey. |
Dear all,
I have been trying to find a solution for this for a while now but I am pretty much stuck.
Background: I have some sensors connected to an Arudino, which react depending on the distance (MTS50 stage from Thorlabs for movement, KDC101 controller). I run another script on my host to control the KDC101 with pyLabLib. Both scripts on their own are working just fine, but I need to use the Trig1 and Trig2 as Inputs to save the distance of the stage whenever a sensor switched from active to inactive. I soldered GPIOs to the SMA ouput and fed them into my Arduino as DigitalInputs.
Now to the question: how do I poll on the state of the two IO signals using functions given in
pylablib.devices.Thorlabs.kinesis.KinesisMotor
(usingget_kcube_trigio_parameters(), setup_kcube_trigio() get_kcube_trigpos_parameters() setup_kcube_trigpos()
)?trig_mode obviously sets the type of the inputs and trig_pol sets whether it is active high or active low. But how to I read the actual state of the I/Os that I set with the Arduino?
I hope I have made myself clear and I am sorry if this is a rather dumb question, I am not the best coder there is out there. :D
Anyways, thank you very much in advance, I'd really appreciate your help.
Kind regards,
Anna
The text was updated successfully, but these errors were encountered: