MicroManager firmware for Arduino Nano Every

Dear all,

MicroManager can control various microscope functions through an Arduino. For this to function, the corresponding firmware must be uploaded to an Arduino.

While trying to do so for an Arduino Nano Every, I stumbled upon the problem that the Atmega 4809 chip in the Nano Every has different port registers compared to the regular Arduino, and so the regular firmware does not work.

I was wondering if anyone already ported the regular Arduino firmware to work with the Arduino Nano Every? Some alternative firmware is listed on github, but these do not seem compatible with the Nano Every?

Great question! If anyone has ported the firmware to other processor architectures, I’d be happy to include it in the MM source code repository, so that people do not have to chase around to find it;)

1 Like

Thanks Nico! I may try to update the firmware myself to work with the Nano, but unfortunately have little experience with Arduinos and I don’t really know how easy / difficult it would be to do this. Will be sure to let you know if I manage to get it to work!

Sorry for using processor-specific code. It makes it work so much faster that it was worth it (at the expense of what you are dealing with now). Arduinos are quite a bit of fun, and a great way to get some idea of how embedded systems work. I recently did something similar for an Arduino Due, and got that too work without too much hassle. Good luck and don’t hesitate to ask questions if you get stuck!

Haha yeah that’s what I figured from reading the documentation. Mostly it seems a case of swapping out the port registers, which is not too difficult. After some adjustments I changed out the registers necessary to get the firmware to compile: MicroManager.zip (4.1 KB)

Unfortunately, since I am not in the lab much these days I cannot yet test it out. Will update this thread as soon as I am able to verify whether the updated firmware works on our microscopes.

So, this took a bit more work than I expected. Turns out the port mapping on a Nano Every is very different from the regular Arduino, specifically because it has many more registers with fewer pins per register.

This meant that I could not simply pick a new register to use and let that be it, since you’d get at most three digital outputs instead of six (with the exception for the D register, but that happens to be the only analog input register and I did not want to sacrifice it). The B register (with three digital output pins available) overlaps with the few PWM-controlled analog output pins, and I did not want to sacrifice those either, and the E register overlaps with the build-in LED. It’s a right mess.

Instead, I mapped outputs via a function to several registers in sequence. I expect this will slow down execution somewhat, though since the ATMEGA4809 is a good deal faster than the chip used in the original Arduino, maybe not by much. I cannot measure it here, and at least for my application it does not matter.

On the upside, since I was able to pick a new pin layout, I’ve simply ordered the digital pins in sequence as they appear on the board, so it’s a lot easier to remember where each subsequent pin goes.

For my purposes, I wanted to use the PWM-outs to control an analog device directly (well, through a simple RF circuit) so the Analog-out for DAC1 and DAC2 are PWM-controlled in this version, instead of controlling a TLV5618.

Code and pin-layout diagram are now in GitHub: https://github.com/MattNeuro/MicroManagerArduino. From what I can test, the digital outs and the PWM-outs work as expected. I don’t know whether anyone uses the input trigger or analog inputs, they should work, but I cannot test them so YMMV.