Skip to content
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

Support for KST101 #14

Open
lucduempelmann opened this issue Oct 24, 2018 · 13 comments
Open

Support for KST101 #14

lucduempelmann opened this issue Oct 24, 2018 · 13 comments

Comments

@lucduempelmann
Copy link

lucduempelmann commented Oct 24, 2018

Hello,
your code really works great for the old APT controller, and also for the KDC101. So many thanks for this, it has really been a great help!!!

Now we need to work with the stepper controller KST101 and actuator ZST213. Although it recognizes something, and also displays the current position (so the connection is there), there is an error message displaying:

Constructed: SingleControllerPort('/dev/ttyUSB1',26001669)
If you see this message, please send a mail with the following information:
- controller type
- stage type
- this data: <MGSG_HW_GET_INFO>(dest=0x1, src=0x50, serial_number=26000000, model_number=b'KST101\x00\x00', type=16, firmware_version=b'\x07\x00\x01\x00', notes_b'KST101 Stepper Controller v 3.1 1\x00', empty_space=b'162009Nov\x00\x00\x00', hw_version=3, mod_state=32, nchs=1)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Destructed: <None on SingleControllerPort('/dev/ttyUSB1', 26001669) channel 1>
Destructed: SingleControllerPort('/dev/ttyUSB1', 26001669)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
.....
.....

this message display until I switch off the controller.

Do you know if something in the code has to be adapted, so we can use this stage? Many thanks for any inputs / help.

Best,
Luc

@lfasnacht
Copy link
Member

Hello!

I'm glad that my code is useful.

The first message is due to the fact that the KST101 controller is not a "known" stage in my detection code. Try adding somewhere stage_name_from_get_hw_info in thorpy/stages/__init__.py something like:

elif controller_type in (26,):
    return 'KST101'

Tell me what happens then.

Cheers,
Laurent

@lucduempelmann
Copy link
Author

Hey Laurent,

many thanks for your really fast response!! Thats really awesome and really helpful.
So with your code, the first error disappears, but now I have the following:
Constructed: SingleControllerPort('/dev/ttyUSB0',26001669)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Exception in Tkinter callback
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Traceback (most recent call last):
File "/usr/lib/python3.5/configparser.py", line 1135, in unify_values
sectiondict = self.sections[section]
KeyError: 'KST101'

Many thanks for any help. Cheers,
Luc

@lfasnacht
Copy link
Member

Hello!

Simply try to find an updated MG17APTServer.ini (you should find it on any Windows computer with Thorlabs APT software installed... I haven't tried recently though)

Laurent

@lucduempelmann
Copy link
Author

Dear Laurent,

many thanks for your input. This partially solves the problem. Unfortunately I still get an error (while the code can read the position, so there is a connection). I used the test.py.

Constructed: SingleControllerPort('/dev/ttyUSB0',26001669)
Traceback (most recent call last):
File "/usr/lib/python3.5/configparser.py", line 1135, in _unify_values
sectiondict = self._sections[section]
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=3028427, enc_count=0, status_bits=2147483648)
KeyError: 'KST101'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 6, in
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=3028427, enc_count=0, status_bits=2147483648)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=3028427, enc_count=0, status_bits=2147483648)
stages = list(discover_stages())
File "/home/slim/Downloads/thorpy-master3/thorpy/comm/discovery.py", line 31, in discover_stages
for stage in p.get_stages().values():
File "/home/slim/Downloads/thorpy-master3/thorpy/comm/port.py", line 247, in get_stages
ret[k] = GenericStage(self, 0x01, stage_name_from_get_hw_info(self._info_message))
File "/home/slim/Downloads/thorpy-master3/thorpy/stages/init.py", line 104, in init
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=3028427, enc_count=0, status_bits=2147483648)
self._conf_stage_id = self._config.getint(ini_section, 'Stage ID')
File "/usr/lib/python3.5/configparser.py", line 816, in getint
fallback=fallback, **kwargs)
File "/usr/lib/python3.5/configparser.py", line 806, in _get_conv
**kwargs)
File "/usr/lib/python3.5/configparser.py", line 800, in _get
return conv(self.get(section, option, **kwargs))
File "/usr/lib/python3.5/configparser.py", line 778, in get
d = self._unify_values(section, vars)
File "/usr/lib/python3.5/configparser.py", line 1138, in _unify_values
raise NoSectionError(section)
configparser.NoSectionError: No section: 'KST101'
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=3028427, enc_count=0, status_bits=2147483648)
Destructed: <KST101 on SingleControllerPort('/dev/ttyUSB0',26001669) channel 1>
Destructed: SingleControllerPort('/dev/ttyUSB0',26001669)

Do you have any idea what would have to be changed? Many thanks in advance.
Luc

@lfasnacht
Copy link
Member

I'll have a look on Monday (I don't have a Windows computer at home), to see if an updated configuration file can help. Unfortunately I don't have the hardware...

Can you post your modified version somewhere? (a github repository would do)

@lucduempelmann
Copy link
Author

I just made a fork with my changes (I hope you can access it). Sorry I am not an Git expert. The code as it is works with the other stages, but not yet with the KST101.

@lfasnacht
Copy link
Member

Ok, so I've had a look in the software. Let's try the following:

In thorpy/stages/__init__.py, try returning instead of return 'KST101' return 'ZST213(B)'.

If it works, I suggest doing instead the following:

First, edit to add 26 to the line:

elif controller_type in (27, 63, 83, 2197): 

to get:

elif controller_type in (26, 27, 63, 83, 2197): 

Then you should add a sub-condition to detect the correct type. Unfortunately it won't work with the same logic, because it doesn't seem that it uses the same methods as the TDC for stage detection. Let me know?

@lucduempelmann
Copy link
Author

lucduempelmann commented Oct 29, 2018

Thanks!! So when I did the first (exchange of KST101 into ZST213(B)), it gave me:

Constructed: SingleControllerPort('/dev/ttyUSB0',26001669)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=0, enc_count=0, status_bits=2147483648)
Constructed: <ZST213(B) on SingleControllerPort('/dev/ttyUSB0',26001669) channel 1>
[<ZST213(B) on SingleControllerPort('/dev/ttyUSB0',26001669) channel 1>]
Stage: ZST213(B)
Position: 0.000mm
Status: homed, channel enabled
Velocity parameters: velocity: 0.000-4569.668mm/s, acceleration: 1096.720mm/s²
Homing parameters: velocity: 4569.668mm/s, direction: 2, limit_switch: 1, offset_distance: 761.756mm
....

so it worked (it recognized the ZST213(B), e.g. I could also move it with s.position. But the parameters were all wrong (not corresponding to the MG17APTServer file.

I then added '26' as described and included:
elif stage_type == 0x0C:
return 'ZST213(B)'
I guess stage_type == 0x0C is not completely correct. Where do I get this information? If I run this I again get the following (although I can now control the motor):

Constructed: SingleControllerPort('/dev/ttyUSB0',26001669)
If you see this message, please send a mail with the following information:
controller type
stage type
this data: <MGMSG_HW_GET_INFO>(dest=0x1, src=0x50, serial_number=26000000, model_number=b'KST101\x00\x00', type=16, firmware_version=b'\x07\x00\x01\x00', notes=b'KST101 Stepper Controller v3.1 1\x00', empty_space=b'162009Nov\x00\x00\x00', hw_version=3, mod_state=32, nchs=1)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=49152, enc_count=0, status_bits=2147484672)
Unhandled message <MGMSG_MOT_GET_STATUSUPDATE>(dest=0x1, src=0x50, chan_ident=1, position=49152, enc_count=0, status_bits=2147484672)
Constructed: <Z606(B) on SingleControllerPort('/dev/ttyUSB0',26001669) channel 1>
[<Z606(B) on SingleControllerPort('/dev/ttyUSB0',26001669) channel 1>]
Stage: Z606(B)
Position: 2.000mm
Status: homed, channel enabled
Velocity parameters: velocity: 0.000-182.365mm/s, acceleration: 43.768mm/s²
Homing parameters: velocity: 182.365mm/s, direction: 2, limit_switch: 1, offset_distance: 30.400mm
....

So I think if I get the sub-condition right, it should work. Can you help?

@lucduempelmann
Copy link
Author

Hello,
Do you have any idea what stage_type I would have to add, when including the sub-condition?
elif stage_type == 0x??:
return 'ZST213(B)'
Is this information documented somewhere? Or could Thorlabs help here?
Many thanks for any information.

@Knoose
Copy link

Knoose commented Apr 4, 2019

@lucduempelmann, would you be willing to help me get things going? I've tried on both Windows and Mac and can't seem to get the device to be discovered (trying with a KDC101).

@lucduempelmann
Copy link
Author

lucduempelmann commented Apr 6, 2019 via email

@Knoose
Copy link

Knoose commented Apr 10, 2019

I was able to get it working on my mac by replacing pyserial with pylibftdi. However, the status_homed property always returns true. I am using your updated server file but that still does not help.

@lucduempelmann
Copy link
Author

Hi Knoose, so I checked the software with the KDC101 and a Z812B actuator and everything works nicely. But I am using it on Linux. I also tried Windows, but this didn't work for me due to the libraries etc. But maybe this could be fixed, will give an update.
For Windows I am using https://github.com/mcleu/PyAPT, which is not supported anymore, but still works fine, also for the Kinesis modules.
Maybe you can post your error, to find out what the problem is?
I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants