Serial port controlled stage

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Serial port controlled stage

Jacob Newman (CMP)
Hello all,

I've been trying for weeks to write a *simple* device adapter dll to control our custom made stage (which revolves around the z-axis). I'm finally going to have to admit defeat, as I don't know enough c++ to understand whether I'm editing in the right places, or to track down where I'm going wrong. It's frustrating because my device literally receives one command, and I've had it rotating using the Nikon project as a basis, but I'm getting a device unsupported error so I expect something is trying to make it do things. I also expect that this is a trivial task for somebody who has written device adapters before. 

I'm throwing this out there (before I throw the stage out of the window); if someone wants to earn some cash by knocking me up the adapter dll or would be kind enough to help me out, please get in contact. The device operates by serial port, and I've had it rotating using the code

SendSerialCommand(port_.c_str(),"\x12\xff","");

So once again, this is a desperate plea for paid help!

Regards, Jacob Newman

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

Karl Bellve-3

On Tue, Jan 24, 2012 at 9:04 AM, Jacob Newman (CMP) <[hidden email]> wrote:
Hello all,

I've been trying for weeks to write a *simple* device adapter dll to control our custom made stage (which revolves around the z-axis). I'm finally going to have to admit defeat, as I don't know enough c++ to understand whether I'm editing in the right places, or to track down where I'm going wrong. It's frustrating because my device literally receives one command, and I've had it rotating using the Nikon project as a basis, but I'm getting a device unsupported error so I expect something is trying to make it do things. I also expect that this is a trivial task for somebody who has written device adapters before. 

I'm throwing this out there (before I throw the stage out of the window); if someone wants to earn some cash by knocking me up the adapter dll or would be kind enough to help me out, please get in contact. The device operates by serial port, and I've had it rotating using the code

SendSerialCommand(port_.c_str(),"\x12\xff","");


Hi Jacob,

Look at my cobolt.cpp adapter I wrote for uManager for inspiration. I wrote it in a few hours.


Not sure if it is needed but you don't appear to be terminating your hex string with either a \n or a \r. Some devices won't process serial commands until it sees a terminating string.

Also, make sure you check for an error on SendSerialCommand(). The device might not even be connected to that serial port. 

I could help you out further, but you have the stage and I don't, unless I could remotely log in to look at your code and debug it. 

You are welcome to contact me off list for any programming questions.


--
Cheers,

Karl Bellvé
Biomedical Imaging Group
University of Massachusetts Medical School


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

Thorn, Kurt
Another simple example is the Aladdin pump controller - I put it together in a few days without knowing C++ when I started: https://valelab.ucsf.edu/svn/micromanager2/trunk/DeviceAdapters/Aladdin/Aladdin.cpp

Kurt

On 1/24/2012 6:23 AM, Karl Bellve wrote:

On Tue, Jan 24, 2012 at 9:04 AM, Jacob Newman (CMP) <[hidden email]> wrote:
Hello all,

I've been trying for weeks to write a *simple* device adapter dll to control our custom made stage (which revolves around the z-axis). I'm finally going to have to admit defeat, as I don't know enough c++ to understand whether I'm editing in the right places, or to track down where I'm going wrong. It's frustrating because my device literally receives one command, and I've had it rotating using the Nikon project as a basis, but I'm getting a device unsupported error so I expect something is trying to make it do things. I also expect that this is a trivial task for somebody who has written device adapters before. 

I'm throwing this out there (before I throw the stage out of the window); if someone wants to earn some cash by knocking me up the adapter dll or would be kind enough to help me out, please get in contact. The device operates by serial port, and I've had it rotating using the code

SendSerialCommand(port_.c_str(),"\x12\xff","");


Hi Jacob,

Look at my cobolt.cpp adapter I wrote for uManager for inspiration. I wrote it in a few hours.


Not sure if it is needed but you don't appear to be terminating your hex string with either a \n or a \r. Some devices won't process serial commands until it sees a terminating string.

Also, make sure you check for an error on SendSerialCommand(). The device might not even be connected to that serial port. 

I could help you out further, but you have the stage and I don't, unless I could remotely log in to look at your code and debug it. 

You are welcome to contact me off list for any programming questions.


--
Cheers,

Karl Bellvé
Biomedical Imaging Group
University of Massachusetts Medical School



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

Jacob Newman (CMP)
Hello everyone,

Thank you for your prompt responses.

I had a go at editing the Aladdin project and low and behold it loaded no problems at all. I am now able to rotate our stage by setting a property in the preset window.

I think my problems may have been that I was trying to edit a stage, rather than a basic device.

Thanks and regards,

Jacob Newman

On 24 Jan 2012, at 17:29, Kurt Thorn wrote:

Another simple example is the Aladdin pump controller - I put it together in a few days without knowing C++ when I started: https://valelab.ucsf.edu/svn/micromanager2/trunk/DeviceAdapters/Aladdin/Aladdin.cpp

Kurt

On 1/24/2012 6:23 AM, Karl Bellve wrote:

On Tue, Jan 24, 2012 at 9:04 AM, Jacob Newman (CMP) <[hidden email]> wrote:
Hello all,

I've been trying for weeks to write a *simple* device adapter dll to control our custom made stage (which revolves around the z-axis). I'm finally going to have to admit defeat, as I don't know enough c++ to understand whether I'm editing in the right places, or to track down where I'm going wrong. It's frustrating because my device literally receives one command, and I've had it rotating using the Nikon project as a basis, but I'm getting a device unsupported error so I expect something is trying to make it do things. I also expect that this is a trivial task for somebody who has written device adapters before. 

I'm throwing this out there (before I throw the stage out of the window); if someone wants to earn some cash by knocking me up the adapter dll or would be kind enough to help me out, please get in contact. The device operates by serial port, and I've had it rotating using the code

SendSerialCommand(port_.c_str(),"\x12\xff","");


Hi Jacob,

Look at my cobolt.cpp adapter I wrote for uManager for inspiration. I wrote it in a few hours.


Not sure if it is needed but you don't appear to be terminating your hex string with either a \n or a \r. Some devices won't process serial commands until it sees a terminating string.

Also, make sure you check for an error on SendSerialCommand(). The device might not even be connected to that serial port. 

I could help you out further, but you have the stage and I don't, unless I could remotely log in to look at your code and debug it. 

You are welcome to contact me off list for any programming questions.


--
Cheers,

Karl Bellvé
Biomedical Imaging Group
University of Massachusetts Medical School



------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d


_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

lashford
In reply to this post by Jacob Newman (CMP)
Jacob,
       I would be pleased to help you. Do you have a document that you can send me that gives the serial commands that the stage responds to? I assume that the command you included in your email was a rotate command for  255 (something),  steps I would presume. So I would need to know more info about the steps / degree ... and any other supported commands.  One thing I would point out that you may not be aware of. The SendSerialCommand() sends c-type strings. This means that if you have a Hex 0 as the argument or in the string you are sending  for the move command it would not actually be sent. It would only send the data before the hex 0 as it will be seen as an end of string. I use a send command that sends n bytes and does not require the end of string for any case where I am not certain that the output data will not include the null character within the data. The truncation can be very troublesome and not always obvious.
        I can also recommend some tools that I find very useful for such testing. One is called VSPE. This is the Virtual Serial Port Emulator from Interlogic  
http://www.eterlogic.com/Products.VSPE.html
This tool costs about $29.00 but is worth much more. You can define virtual serial ports and virtual port pairs. With a pair of ports what is sent to one port appears on the other.  What I do is assign one to my MicroManager adapter  then the other to a terminal program (in place of your serial stage in this case).
The terminal program I use is also excellent and is called Indigo and is from Shade Blue http://www.shadeblue.com/ 
 this is a 39.00 program and is excellent.
With Indigo setup as my device I can see the exact strings (in hex if I like or hex/Ascii) that are or would  be seen by my hardware.  It is quick to find truncated strings or errors in your building of the commands that might not be seen otherwise.
      If all this does not help and you would like someone to just do the Adapter for you I would be pleased to do that.
      Thanks
       Louis Ashford
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

Jacob Newman (CMP)
Hi Louis,

Thank you for your thorough reply.

Our stage is a stepper motor with 400 steps, and each hex 12FF command rotates the stage by one step. I have now managed to write and run a device adapter that can control the stage. It is not implemented as a stage within Micromanager, because it is of type CGenericBase, but I am able to control it by making a property preset and changing the property value. My task now is to write a java plugin with some buttons to control the device. I'm hoping that won't be too hard - from the examples online, it looks quite easy to interface with the connected devices using Java.

Regards,

Jacob

On 25 Jan 2012, at 21:05, lashford wrote:

> Jacob,
>       I would be pleased to help you. Do you have a document that you can
> send me that gives the serial commands that the stage responds to? I assume
> that the command you included in your email was a rotate command for  255
> (something),  steps I would presume. So I would need to know more info about
> the steps / degree ... and any other supported commands.  One thing I would
> point out that you may not be aware of. The SendSerialCommand() sends c-type
> strings. This means that if you have a Hex 0 as the argument or in the
> string you are sending  for the move command it would not actually be sent.
> It would only send the data before the hex 0 as it will be seen as an end of
> string. I use a send command that sends n bytes and does not require the end
> of string for any case where I am not certain that the output data will not
> include the null character within the data. The truncation can be very
> troublesome and not always obvious.
>        I can also recommend some tools that I find very useful for such
> testing. One is called VSPE. This is the Virtual Serial Port Emulator from
> Interlogic  
> http://www.eterlogic.com/Products.VSPE.html
> This tool costs about $29.00 but is worth much more. You can define virtual
> serial ports and virtual port pairs. With a pair of ports what is sent to
> one port appears on the other.  What I do is assign one to my MicroManager
> adapter  then the other to a terminal program (in place of your serial stage
> in this case).
> The terminal program I use is also excellent and is called Indigo and is
> from Shade Blue http://www.shadeblue.com/ 
> this is a 39.00 program and is excellent.
> With Indigo setup as my device I can see the exact strings (in hex if I like
> or hex/Ascii) that are or would  be seen by my hardware.  It is quick to
> find truncated strings or errors in your building of the commands that might
> not be seen otherwise.
>      If all this does not help and you would like someone to just do the
> Adapter for you I would be pleased to do that.
>      Thanks
>       Louis Ashford
>
>
> --
> View this message in context: http://micro-manager.3463995.n2.nabble.com/Serial-port-controlled-stage-tp7220452p7225109.html
> Sent from the Micro-Manager mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> micro-manager-general mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/micro-manager-general


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

lashford
      I am not quite sure I understand. Do you need to send (n) number of '12FF' commands to rotate (n) degrees? How do you know where your home or zero point is? What if you wish to move to your current location -1 degree?  Do you have to issue 399 '12FF' commands?
       These were just questions that came to mind as I was considering your interface. I am always thinking about speed so this seemed to me to be somewhat inefficient. It would be ok so long as you were always moving a small delta angle in the same direction. I am guessing that I am missing something and you have other commands than just the 12FF.
       It sounds to me like building a plug-in to give you the user interface you wish may be the right way to go. You could do this with your adapter but you would need to track your position in that code and then expose a + and - move command that would in one case issue one 12FF command in the other 399 of them. You could add a 'zero' command that would make any location your effective home and then track moves from there. You could even add commands that moved say 10 degrees + or - or a command that you would pass a + or - value and in the adapter you calculate the number of commands to send based upon the delta from your virtual home.  It all seems a little awkward to me.
      Do you have control of the firmware for the stepper controller?  You might have built all that into that level and given you commands to rotate absolute (n), relative (n) and home. There are some very inexpensive and simple usb/serial stepper controllers even in the ($80) price range. The Phidgets 1063 is one that comes to mind.
      I guess this is all not too much help to you as you are where you are and need to get your system up and going as quickly as possible (it is always that way isn’t it?).
      Good luck with your plug-in I will be interested to hear you do with that.
      Louis Ashford
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Serial port controlled stage

lashford
In reply to this post by Jacob Newman (CMP)
Jacob,
       I realize after thinking about it that possibly what you have is a very high resolution stage that through a combination of gearing is giving you 4864 micro-steps per degree and that your command is an absolute value for position. That makes more sense to me at least so you can ignore most of my last email as I was thinking about it incorrectly.
      Louis
Loading...