-
Notifications
You must be signed in to change notification settings - Fork 2
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
Error when running test_device.py
with BSC203 and NRT150
#1
Comments
Hello, I have corrected the bug you mentionned. I'll be glad to help you as much as I can but as you can see the code is not very well written ( I mean there is no setup.py and unit test stuff). The motivation of this code is to implement the communication protocol to be able to drive some thorlabs units we have in my lab. The communication layer is done through serial port only . I have the BSC203 controller but not the NRT150/M stage but please let me know if I can help you. sincerely L. |
test_device.py
with BSC203 and NRT150
Hi @lwbe Thanks for your message! It does sort out the previous issue. Then, following the example of test_device.py, I realise that the variables of port, baudrate and timeout needs to be defined which are added as shown below:
However, when running the same script with the uncommented
Questions:
Regards |
Hello thanks for the report. I have changed the readme.md to add a few more information. Essentially the code will run with python2.7 only. I can work on python 3 but for now it is only 2.7. You need pyserial to use this code. I've tried to implement the code in such a way that if you supply a write and read function on your own. In the readme I indicate how to use virtualenv to install packages without touching the system modules. To answer your questions
I realise test_device.py is not correct. If you want to use the library please try someting like
The stages name are in the MG17APTServer.ini file and for NRT150 you can find NRT150E Enc Stage 150mm The serial number can be found using lsusb -v | grep iSerial and for BSC20x series it should start by 70xxx beware that the serial number should be given as a string. Hope this helps and let me know. |
Hello again I updated the codes and made a small doc in the readme on the first page. Let me know if it is understandable. L. |
Hi @lwbe Many thanks for your helpful explanations. Following your comments, the following script
However, I am afraid of not getting the right outputs when calling
Do you have any suggestions? |
Hello, the two lines like keyword MGMSG_HW_STOP_UPDATEMSGS params: 1, 0, 17, 1 are debug info. I will have to turn them off or at least that should be an option. get_info() and get_position() return a variable and if you want to see them you need to print them. So print(d1.get_info()) and print(d1.get_position()) will return the content that you can check. get_info() return a dict() and is perhaps not very easy to read. |
Thanks @lwbe When trying your recommendation
The following bug appears.
I think the bug is related to the reading the response of the controller. For which I have added ftdi.rules and changed the permissions and its group of the USB port of the controller as shown below.
Do you have any idea what would it be? |
Hello, unfortunately I don't remember how I have treated this case. But since I didn't change the code I suspect it is a communication problem. So I have update the code to perform a flush of the serial bus but you need to add the configure() method before doing anything with the device. So please checkout the code from github and in you have to change your code from
to Let me know if this work otherwise I'll write so code to investigate the problem more in depth. sincerely L. |
Thanks Lorenzo I have updated my local repo with your nice updates and tried this
which create this bug
My guess your code is fine but there is something wrong with how the USB port in my Ubuntu18x64bit is configured as it did not received any answer after sending a command. Any ideas on how you configured the USB port on your machine with centos? |
Hello, i will try to send you a piece of code tomorrow to check but I don't have access right now to the computer to check. Did you try as root? Don't forget to use the venv when you are root. Does
return something. Sincerely L. |
Hello, I could find a BSC203 and try to see if I could reproduce your problem but I couldn't. I discovered that the code doesn't work well with BSC203 and so you'll have to checkout the new code. To test I'll propose you to do the configuration one step at a time so after
please type in a python interpreter (or best ipython since it should be installed by the requirements)
Normally the 3 first commands are only write commands and it should work the last one might give you problem since it waits for a return. But if it works please do
Note that since BSC20x is a multi channel that the first channel is connected (it is the 1 at the end of the d1 = Thorlabs_device("70112214", "BSC20x", "NRT150E Enc Stage 150mm", 1) command. And if you get the info I would be interested in the values of
sincerely L. |
Thanks for your comments for using the root account. To be honest I am not sure if this is a good hardware software practice but I will have a go later following your advice for the configuration of the venv. For the lsusb command, see below the output:
Is that what you expect to see? |
Thanks L for your advice on using the python interprete. That said, the following output is generated:
This makes me think that using root access will sort out this issue which I will test later. Also thanks for pointed out the muli-channel version of the BSC203 controller which I hope to confirm the output once I can read the info. |
Hello, i finally found a way to get the same TypeError: 'NoneType' and it seems that it happens when the device receive a wrong message. Did you switch off switch on the controller? If I restart the controller and type
then
return some values and not a TypeError. At least after the d1.configure() the light of the channel should switch on. Let me know if this helps. In anycase I would look if all the hardware is well plugged and start the code. Let me know before we try to dive into pure serial and binary variable. sincerely L. |
Thanks L for your kind help. I have just tried your previous advice and this is the output:
What is remaining to test is the use of Regards |
Testing ThorlabsApt with
|
Hello, it seems that the controller is not responding. I mean writing to it won't show any problems but it seems that this controller is not ready. For now I would restart the controller by switching it on and off (and I also switch several time while the controller is unplugged from wall socket to discharge capacitors) and do the following sequence
and then
If you receive the same error (if the first print(d1.get_info()) fails try to send it a second time I might have to find a correct way to empty the bus)). If it fails again I would try to use the thorlabs apt software or kinetic to check that the device is working. If it is working with apt or kinetics and not with my code could you send me the firmware version of your controller that I can try to find a way to solve this problem with thorlabs. Maybe I'm missing a mandatory step for older (or newer?) hardware. Sorry for not being more helpful. L. |
Thanks L. your replies are indeed very helpful. I have some good news, following this
See below the terminal output for the previous commands
Here the output for
Questions:
Regards |
Hello, good news that you could make it work. The output of the get_info indicates that your BSC203 as a firmware version 2.3.3 while mine is 2.3.1 but it should make no difference I guess. For your questions
Can you try to
I have added some debug info to the code and add a test to check if the movement should end so please pull the code and copy paste the begining of the output. a typical output is we send the command to get the status bit
this the return value the expected value of this should contain a msg_id of 1066but if the stage reaches the end it can return a msg_id value of 1092
some stage (or controller doesn't seem to send the information that the end has been reached and so I look for the value of 'moving reverse' and 'moving forward' if they are both 0 the stage doesn't move.
in the code if I didn't reach the end of movement I ask for the position of the stage
here is the output. This might contain the msg_id of 1092 since it we read the message from the stage
So can you look for the output and see if you have an unexpected msg_id or if you have a move forward or reverse equal both to zero. This doesn't explain why the stage doesn't move. I had the same probleme with a stage and in fact the parameters where so wrong that the stage was indeed moving but very slowly around 100 time slower so can you check it is not really moving. Sincerely L. |
Hi L. I am afraid I will have no access to the linear stages until I come back to the lab on 13 of January 2020 I will then reply back to the above comments. In the meantime, I would like to reiterate my gratitude for your help which is indeed very valuable and I am sure the linear stages will be working soon. |
Hello, OK I'll wait for your response when you'll come back and I would also thank you for using and testing my code. I would probably not have worked on it while the fact that it may be useful makes me want to improve it. Sincerely L. |
Hi @lwbe
First of all, thanks for the nice development of your apt. I realise that your work is very active these days compare to others ones such as https://github.com/freespace/pyAPT. I am wondering if you have tested your application under Ubuntu 18.04x6x with Controller BSC203 and linear stages NRT150/M?
After installing
pip install -r requirements.txt
in my virtual environment and using thisfrom six.moves import configparser
for python3, I have runpython test_device.py
under Ubuntu 18.04x6x with Controller [BSC203] and linear stages [NRT150/M] but I am not sure what I am missing perhaps you have some hints for the following bug:The text was updated successfully, but these errors were encountered: