Arduino Mega in for OpenStage

Hi All,
Our electronics workshop have built me a very nice working version of the OpenStage (https://doi.org/10.1371/journal.pone.0088977) which uses an Arduino Mega 2560 to drive it. With some help I have been able to control the stage using Python in Windows PowerShell but would really like to be able to control it via Micro-Manager but I cannot add it to a hardware configuration by following the instructions here (https://micro-manager.org/wiki/Arduino). Has anyone had any success using an Arduino Mega 2560 in Micro-Manager?
Any help much appreciated.
Best,
Ben

Yes the Arduino mega will work with micromanager. The trick is to make sure that the firmware you load into the mega uses the same communication protocol as the driver you are using in micromanager. Also, make sure that you install the arduino IDE software which will load an appropriate driver for the mega on to York computer

Very interesting. I own a mega myself as a playground for Arduino and added some serial libs to my application to send commands to the Arduino. I would have used it for a datalogger with multiplex.

Here my serial JavaFX example:

which can also be found here as a general example:

As far as it is noted you can control the stage with simple serial commands, right?:

https://journals.plos.org/plosone/article/figure/image?size=large&download=&id=info:doi/10.1371/journal.pone.0088977.t003

from:

MicroManager supports BeanShell (I once tested 1.4 on forum request) and thus this could be used for a small script to create a GUI with serial commands.

But I don’t know if that is feasible. Just an idea.

To throw in some more thoughts: The issue is not so much the Arduino Mega, as the communication protocol between the computer and the device. I found the definition of that protocol as a figure in the article. With that protocol in had, you could write Beanshell commands to move the stage (as @bio7 suggested), but that would not make the rest of Micro-Manager aware of the stage, i.e., you could not easily use it in conjunction of the rest of the application. To do that, you will need a matching device adapter (code written in C++ that “glues” the device to MMCore, the device abstraction layer).

There are two ways you could go about this. You could modify the firmware running on the Arduino to mimic the protocol of a stage that is supported by Micro-Manager (such as ASI, Prior, or others). Or (which is probably the better way), you can write a device adapter in C++ yourself (or ask someone else to do so). I noted some difficulties in the protocol (the stage wants a command for all its axes everytime, whereas MM splits out the XY and Z axes as separate devices), but that is nothing that can not be coded around.

Hope this helps to understand the project!

1 Like

Hi @Austin_ARC, @Bio7 and @nicost,
Thanks very much for your replies, I see that I am either going to need to to learn C++ or make friends with a kind soul who will help me as ideally I need the system to be easy to use so it looks like a device adapter is the way to go, thanks @nicost for the explaination.

My immediate probelm is that I cannot get Micro-Manager to allow me to add the stage to a Hardware Configuration. As yet I ahve been reluctant to send the firmware detailed here https://valelab4.ucsf.edu/svn/micromanager2/trunk/DeviceAdapters/Arduino/AOTFcontroller/AOTFcontroller.ino as it refers to the Arduino being used as an AOTF controller not a stage controller. Will it still work?

Best,
Ben

My immediate probelm is that I cannot get Micro-Manager to allow me to add the stage to a Hardware Configuration. As yet I ahve been reluctant to send the firmware detailed here https://valelab4.ucsf.edu/svn/micromanager2/trunk/DeviceAdapters/Arduino/AOTFcontroller/AOTFcontroller.ino as it refers to the Arduino being used as an AOTF controller not a stage controller. Will it still work?

No, it will not work as an XYStage. To add an XYStage in a hardware conifiguration, you will need a Device Adapter (written in C++) for that stage controller (in your case, the OpenStage). Putting other firmware on your controller will not help, since that firmware will not control your stage. Other than the two options I described above (re-write the firmware to mimic the command set of an XY stage for which a device adapter is available, or writing a new device adapter), there is not much to do at this stage.

Hi, you could look at my https://micro-manager.org/wiki/CustomArduino page describing what Nico suggested: to mimic an existing protocol in the Arduino. An example is included that mimics a Z-stage using Marzhauser L-Step protocol. You could easily extend this for an XY stage.
Jerome

1 Like