error working with SC10
Mendelevium9555 opened this issue · 10 comments
I have been experimenting with the SC10 shutter controller and have been facing an issue getting it to work.
import instruments as
sc = ik.thorlabs.SC10.open_serial("COM6", 9600, timeout=100)
print(sc.name)
print(sc.enable)
After I call any sc.XXXX command at first time, everything works fine. But the code will fail if I make a second command, showing
instruments.errors.AcknowledgementError: Incorrect ACK message received
Yes can you report what version you are using?
Sorry for the late reply. The version I used is v0.6.0
. I will install the v1.0.0b1
as you guy suggested. Additionally, I am confused about how to enable the shutter to open. By looking at the code, I feel it should be sc.enable = True
, but I got the error from sendcmd
, showing Incorrect prompt message received
. Will it be fixed in the pre-release version? I will have a try, or my command to enable the shutter is not correct? Thanks for your help.
I have updated the version to v1.0.0b1
and the issue has been solved. Thanks for your help. However, I still have a question on how to set the shutter to be enabled. I have also tried sc.sendcmd("ens=1")
but it did not work as well.
Two things that come to mind to check:
- Did you check what mode your shutter is in? In order to see it open / close depending on what you send to enabled, you should make sure that it's (for testing purposes) set to manual. Something like this should work, assuming
inst
is the opened instrument:I hope the shutter opens then. If this works, could you try to open the shutter twice in a row and see if it stays open? Would be good to see how it behaves, see below.inst.mode = inst.Mode.manual inst.enable = True
- If this does not work, then the manual might actually be correct (not always the case). The manual states that the shutter is simply toggled by sending
ens
, without any arguments. However,ik
currently uses abool_property
to enable / disable the shutter, which means it sendsens=1
to open orens=0
to close. Assuming 1 worked, the last comment would check if it simply toggles (and ignores the=1
, or if it actually reads the=1
and sets the property accordingly. If (1) above failed, can you, after setting the shutter to manual mode, send the following command:inst.sendcmd("ens")
? If the shutter then opens (but not in 1), there is indeed still a bug in this class, but should be easily fixable.
I hope one of these points work, don't have a good number 3 in mind right now. Let us know if this helps and what you find. Thanks!
Finally, I used
inst.mode = inst.Mode.manual
inst.sendcmd("ens")
and it works. Using other options will pop up the same error.
Thanks for your support. I think there might be a bug in bool_property
.
Thanks for checking. Looks like there is an error in the bool_property
. I propose the following:
- We rewrite the
inst.enable
routine to not use a bool property as it is currently, but rather implement it by itself. - Property read should return the status as per manual
- Property write: First read the current status, then send the status requested by the user (if necessary): This would mean that
inst.enable = True
would still open the shutter andinst.enable = False
would still close it, but a command is only sent if the status is actually the opposite of what the user requests.
I think that this solution would remain in the ik
spirit. Thoughts @scasagrande?
Yeah, if the device is expecting ens
to simply toggle the state, then your suggestion is correct @trappitsch
We've had to do something similar to other instruments, where the commands aren't idempotent
From @Mendelevium9555 report and the manual, it seems to me as if indeed it is a toggle and not a setting. I rewrote the enable
command as described above, see PR #370
@Mendelevium9555: This should now be fixed. Would be great if you could install the latest version directly from GitHub with
pip install -U git+https://www.github.com/instrumentkit/InstrumentKit.git
You should then be available to run the shutter as you would expect, i.e., with sc.enable = True
or sc.enable = False
. Let us know if it works or not, since you have the hardware. Thanks!