Prior Device Adapter Modification Help

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Prior Device Adapter Modification Help

xandr
Hello!

I am using a Prior XYStage to make small lateral movements and would like
better control of the XYStage speed. The Prior device adapter, when used
with matlab, gives the option to control speed through the command MaxSpeed
as follows:

mmc.setProperty('XYStage','MaxSpeed',n)

where n is a value of 1 to 100 as a percent of the maximum speed of the
stage. Through use of the prior software it's possible to set the speed in
microns/second but this value is not kept when initializing the stage
through CMMCore protocol in matlab. It seems that the Prior device adaptor
sets the stage speed (um/s) to the hardware default stage speed of 15000
um/s every time the stage is initialized.

My issue is that I would like the stage to move slower than what the n value
of 1 would allow it to move at (150 um/s). The stage is capable of moving at
these slower speeds as I am able to set these values through the prior
software.

I see a couple options to achieve this and maybe one of them or one I am not
aware of will  work:

1. Is there a CMMCore command in matlab that directly modifies this stage
speed value in um/s?
2. Can I send serial ascii commands directly to the stage through CMMCore
and matlab to modify this value? The ascii command being "SMS,v,i" where v
is the value of microns in um/s
3. Can I modify the Prior device adapter to hardcode a different value of v
that will better suit my needs?

Thanks for the help!

Best,
Alex



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

xandr
To address some of my own questions.

1. There is no property which directly modifies stage speed in um/s. The
properties given for my stage are:

/names = mmc.getDevicePropertyNames('XYStage')

names =

mmcorej.StrVector@3220833f

for i = 0:8
disp(names.get(i))
end
Acceleration
Description
MaxSpeed
Port
SCurve
StepSizeX_um (ReadOnly)
StepSizeY_um (ReadOnly)
TransposeMirrorX
TransposeMirrorY/

2. Currently working on sending commands over serial using a combination of
mmc.setSerialPortCommand and mmc.readFromSerialPort. Currently I receive no
errors from either but am not receiving an answer from read.

/>> mmc.setSerialPortCommand('COM3','SMS,100000,i','\r')
>> mmc.readFromSerialPort('COM3')

ans =

mmcorej.CharVector@64a00fe0

>> ans.capacity()

ans =

     0/

Despite setting the command SMS,100000,i which should change the stage
speed, the speed does not actually change when a move command is given. I
may not be communicating properly with the stage controller through serial
even though I receive no errors on setSerialPortCommand.



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

xandr
This post was updated on .
Hooked up the serial monitor and found the following:

*Matlab input*

mmc.setRelativeXYPosition(1000,0);
K>> mmc.setSerialPortCommand('COM3','GR,1000,0','/r')

*Serial write*

000588: 2018-08-10 14:37:39.2114982 +5.3897616

 47 52 2C 31 30 30 30 2C 30 0D                     GR,1000,0.
000592: 2018-08-10 14:39:24.4999910 +105.2631239

 47 52 2C 31 30 30 30 2C 30 2F 72                 GR,1000,0/r


*Serial read*

000590: 2018-08-10 14:37:39.2268434 +0.0152703

 52 0D                                             R.

The carriage return is what I'm missing. The term is not /r or /n or /t. It
seems that in the serial monitor 0D corresponds to a '.' but when I send '.'
through matlab using,

mmc.setSerialPortCommand('COM3','GR,1000,0','.')

it translates the '.' to hex 2E instead of 0D.

Any ideas on which character I should be sending or how to figure out what
the exact serial command is that corresponds to the matlab command,

mmc.setRelativeXYPosition(1000,0);

Thanks,
Sorry for the spam.

Edit: 
I contacted Prior and found that the carriage return they suggest is <cr>. I have tried to use this and setSerialPortCommand still translates these as individual characters in hex instead of the actual carriage return command.

Maybe I need to construct a character vector and send that using mmc.writeToSerialPort. I'm struggling to figure out how to construct a charvector in matlab however.

--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
micro-manager-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

P.Almada
Hi Xandr,

The escape character is \, not /. If you use /r, it will be interpreted as two characters, the character "/" and the character "r", represented in hex by 2F 72. This is shown on your serial monitor output. The hex character 0D (or just D: https://ascii.cl/) is actually carrier return, selected using "\r".
Kind regards,
Pedro

On Fri, 10 Aug 2018 at 19:50, xandr <[hidden email]> wrote:
Hooked up the serial monitor and found the following:

*Matlab input*

/mmc.setRelativeXYPosition(1000,0);
K>> mmc.setSerialPortCommand('COM3','GR,1000,0','/r')/

*Serial write*

/000588: 2018-08-10 14:37:39.2114982 +5.3897616

 47 52 2C 31 30 30 30 2C 30 0D                     GR,1000,0.
000592: 2018-08-10 14:39:24.4999910 +105.2631239

 47 52 2C 31 30 30 30 2C 30 2F 72                 GR,1000,0/r
/

*Serial read*

/000590: 2018-08-10 14:37:39.2268434 +0.0152703

 52 0D                                             R./

The carriage return is what I'm missing. The term is not /r or /n or /t. It
seems that in the serial monitor 0D corresponds to a '.' but when I send '.'
through matlab using,

mmc.setSerialPortCommand('COM3','GR,1000,0','.')

it translates the '.' to hex 2E instead of 0D.

Any ideas on which character I should be sending or how to figure out what
the exact serial command is that corresponds to the matlab command,

mmc.setRelativeXYPosition(1000,0);

Thanks,
Sorry for the spam.




--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

xandr
Pedro,

Thanks for your suggestion. That is definitely a mistake made out of my
inexperience. Because I wasn't exactly sure whether it was \ or / I actually
tried both and combinations of every carriage return I could find. When I
use a command in CMMCore that is not setSerialPortCommand for example,
setOriginXY(), the command processes, no problem.

public void *setRelativeXYPosition*(double dx,
                                  double dy)
                           throws java.lang.Exception
Sets the relative position of the XY stage in microns. Uses the current XY
stage device.
Throws:
java.lang.Exception

*mmc.setRelativeXYPosition(1000,0);*

000324: 2018-08-13 10:07:08.9373530 +236.6919397

 47 52 2C 31 30 30 30 2C 30 0D                     GR,1000,0.

It seems that when I use setSerialPortCommand('COM3','GR,1000,0','~'), where
'~' is the carriage return according to umanager CMMCore, it does not
process the "term" command as the carriage return. Below are the written
commands, as read by the serial monitor, to some of the ones that I've
tried.

public void *setSerialPortCommand*(java.lang.String portLabel,
                                 java.lang.String command,
                                 java.lang.String term)
                          throws java.lang.Exception
Throws:
java.lang.Exception


*mmc.setSerialPortCommand('COM3','GR,1000,0','\')*

000254: 2018-08-13 09:55:37.0318851 +519.2710341

 47 52 2C 31 30 30 30 2C 30 5C                     GR,1000,0\

 *mmc.setSerialPortCommand('COM3','GR,1000,0','\r')*

000264: 2018-08-13 09:56:30.7025205 +4.3566227

 47 52 2C 31 30 30 30 2C 30 5C 72                  GR,1000,0\r

*mmc.setSerialPortCommand('COM3','GR,1000,0','\r\n')*

000274: 2018-08-13 09:57:26.0473851 +15.1106333

 47 52 2C 31 30 30 30 2C 30 5C 72 5C 6E            GR,1000,0\r\n

*mmc.setSerialPortCommand('COM3','GR,1000,0','<cr>')*

000284: 2018-08-13 09:58:26.6709867 +9.5449009

 47 52 2C 31 30 30 30 2C 30 3C 63 72 3E            GR,1000,0<cr>

*mmc.setSerialPortCommand('COM3','GR,1000,0','/')*

000294: 2018-08-13 09:59:11.4630913 +14.0332166

 47 52 2C 31 30 30 30 2C 30 2F                     GR,1000,0/

*mmc.setSerialPortCommand('COM3','GR,1000,0','/r')*

000304: 2018-08-13 09:59:41.5345591 +3.2652757

 47 52 2C 31 30 30 30 2C 30 2F 72                  GR,1000,0/r

*mmc.setSerialPortCommand('COM3','GR,1000,0','/r/n')*

000314: 2018-08-13 10:00:34.4784453 +3.4416371

 47 52 2C 31 30 30 30 2C 30 2F 72 2F 6E            GR,1000,0/r/n




--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

P.Almada
That is odd. I have the same stages and used the same command, with "\r". Have you tried double quotes versus single quotes? Matlab interprets those slightly differently.

On Mon, 13 Aug 2018 at 15:09, xandr <[hidden email]> wrote:
Pedro,

Thanks for your suggestion. That is definitely a mistake made out of my
inexperience. Because I wasn't exactly sure whether it was \ or / I actually
tried both and combinations of every carriage return I could find. When I
use a command in CMMCore that is not setSerialPortCommand for example,
setOriginXY(), the command processes, no problem.

public void *setRelativeXYPosition*(double dx,
                                  double dy)
                           throws java.lang.Exception
Sets the relative position of the XY stage in microns. Uses the current XY
stage device.
Throws:
java.lang.Exception

*mmc.setRelativeXYPosition(1000,0);*

000324: 2018-08-13 10:07:08.9373530 +236.6919397

 47 52 2C 31 30 30 30 2C 30 0D                     GR,1000,0.

It seems that when I use setSerialPortCommand('COM3','GR,1000,0','~'), where
'~' is the carriage return according to umanager CMMCore, it does not
process the "term" command as the carriage return. Below are the written
commands, as read by the serial monitor, to some of the ones that I've
tried.

public void *setSerialPortCommand*(java.lang.String portLabel,
                                 java.lang.String command,
                                 java.lang.String term)
                          throws java.lang.Exception
Throws:
java.lang.Exception


*mmc.setSerialPortCommand('COM3','GR,1000,0','\')*

000254: 2018-08-13 09:55:37.0318851 +519.2710341

 47 52 2C 31 30 30 30 2C 30 5C                     GR,1000,0\

 *mmc.setSerialPortCommand('COM3','GR,1000,0','\r')*

000264: 2018-08-13 09:56:30.7025205 +4.3566227

 47 52 2C 31 30 30 30 2C 30 5C 72                  GR,1000,0\r

*mmc.setSerialPortCommand('COM3','GR,1000,0','\r\n')*

000274: 2018-08-13 09:57:26.0473851 +15.1106333

 47 52 2C 31 30 30 30 2C 30 5C 72 5C 6E            GR,1000,0\r\n

*mmc.setSerialPortCommand('COM3','GR,1000,0','<cr>')*

000284: 2018-08-13 09:58:26.6709867 +9.5449009

 47 52 2C 31 30 30 30 2C 30 3C 63 72 3E            GR,1000,0<cr>

*mmc.setSerialPortCommand('COM3','GR,1000,0','/')*

000294: 2018-08-13 09:59:11.4630913 +14.0332166

 47 52 2C 31 30 30 30 2C 30 2F                     GR,1000,0/

*mmc.setSerialPortCommand('COM3','GR,1000,0','/r')*

000304: 2018-08-13 09:59:41.5345591 +3.2652757

 47 52 2C 31 30 30 30 2C 30 2F 72                  GR,1000,0/r

*mmc.setSerialPortCommand('COM3','GR,1000,0','/r/n')*

000314: 2018-08-13 10:00:34.4784453 +3.4416371

 47 52 2C 31 30 30 30 2C 30 2F 72 2F 6E            GR,1000,0/r/n




--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

xandr
Same result with "" instead of ''.

That is heartening, however, that you are able to use these commands and get
a result. Just to clarify since I didn't include all of the information in
the OP. I'm using a Prior, Proscan III controller with H117P1I4 stage. Is
this similar to what you have?



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Prior Device Adapter Modification Help

xandr
Just wanted to update my progress for anyone in the future who might be
dealing with this.

I have a Prior Proscan III XY stage which I'm using to command small
movements through matlab and umanager. My issue was that the MaxSpeed
property only commanded the stage to move at a percentage (1-100) of the set
stage speed of 15000 um/s. The issue was that there was no property to set
the stage speed directly.

I tried to set the stage speed directly through a serial port command,
SMS,n,i, where n is the stage speed in um/s. Trying to use the method
setSerialPortCommand(Port,Command,Term) was not working because of some
issue in translation between the ascii command 'SMS,10000,i\r' where '\r'
the "term" was not being translated into the proper carriage return.

To fix this, instead of sending ascii commands, I send a character vector
(in matlab character array) which properly translates the carriage return
and commands the Proscan III controller to change the stage speed. To
construct the character array in matlab I use the char() function and input
an array of decimal values.

mmc.setSerialPortCommand('COM3',char([83 77 83 44 uint16(int2str(100*5000))
44 105 13]),'');

which translates to

mmc.setSerialPortCommand('COM3', 'SMS,500000,i\r','')

Best of luck to anyone with this issue in the future.

Best,
Alex



--
Sent from: http://micro-manager.3463995.n2.nabble.com/

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general