Simple controller using Arduino Nano isn't recognized by Openflexure

Hello,

I got my Openflexure Microscope printed and assembled and now I got stucked with the motorisation of the stage.

I am using an Arduino Nano Clone with ATmega328P microcontroller and simple driver boards(https://build.openflexure.org/openflexure-microscope/v6.1.2/docs/#/6_motor_controllers?id=simple-controller-using-arduino-nano). I’ve updated the bootloader of the nano with the standard bootloader and afterwards i’ve uploaded the Sangaboard arduino sketch as mentioned here: https://build.openflexure.org/openflexure-microscope/v6.1.2/docs/#/6_motor_controllers

After wiring all together in Openflexure eV there isn’t any stage available and the movement doesn’t work. Connecting the wired Arduino Nano clone directly to the PC and using Arduino IDE with a stepper sketch, it works.

Anyone could help me please?

I am using a Raspberry Pi 4 B with Openflexure eV.

Cheers
Florian

2 Likes

Hi Florian, it’s a bit late here and I can add some more details in the morning but have you tried

  1. To see if it’s coming up as a USB device using dmesg and/or lsusb?
  2. Connected a serial terminal to the USB serial device, e.g. Arduino’s serial monitor and sending it motor movement commands that way (the commands should be documented somewhere, but you can also look at the sketch itself to figure them out. I think there is also a help command.)

If you install the Sangaboard library for python (wither on the pi, or another computer with python), by running:

pip install sangaboard

You should be able to check that this minimal example moves a motor:

from sangaboard import Sangaboard
with Sangaboard() as sb:
    sb.move_rel([1000,0,0])
    print(sb.position)
    sb.move_rel([-1000,0,0])

We are having some issues with the Nano motor boards. @jc2450 is building one this week to do some debugging.

I believe this issue is actually related to https://gitlab.com/bath_open_instrumentation_group/sangaboard/-/issues/7

I’m currently testing a fix at https://gitlab.com/bath_open_instrumentation_group/sangaboard/-/merge_requests/6

Hopefully I can verify it all this week or early next week, and get an update released.

1 Like

Please install the latest version of the arduino firmware, then run sudo ofm upgrade on your microscope, and reboot. This should fix the issues.

Hi All,

thanks for the help!

@jc2450: With “latest arduino firmware” you mean the “Sangaboard firmware”? Because until now I just uploaded the sketch and neither executed the steps mentioned under https://gitlab.com/bath_open_instrumentation_group/sangaboard/-/blob/master/arduino_code/README.md nor installed the Sangaboard Bootloader.

Hi Florian

Sorry by firmware we mean the ardino sketch in the Sangaboard repository. The readme steps are how to do it with the brand new command line arduino program. You can still upload it in using the IDE.

Do not worry about the bootloader, that is only if you are building a V0.3 or V0.4 surface mount board from scratch. It is the step that allows it to communicate with the sangaboard IDE.

I will edit the READMEs for clarity

Uploading the new arduino sketch and ofm upgrade didn’t resolve the problem.

Executing dmesg showed up the ch341 board
[ 31.162436] ch341 1-1.1:1.0: ch341-uart converter detected
[ 31.165876] usb 1-1.1: ch341-uart converter now attached to ttyUSB0

pip install sangaboard has been executed successfully but sorry, I don’t know how to execute the example code. I created a .py file, added a shebang, made it executeable with chmod u+x but the execution with ./motor_test.py resulted in:

Traceback (most recent call last):
File “./motor_test.py”, line 3, in
from sangaboard import Sangaboard
File “/home/pi/.local/lib/python2.7/site-packages/sangaboard/init.py”, line 1, in
from .sangaboard import Sangaboard
File “/home/pi/.local/lib/python2.7/site-packages/sangaboard/sangaboard.py”, line 55
“baudrate”: 115_200,
^
SyntaxError: invalid syntax

And not to forget: ofm status showed up

● openflexure-microscope-server.service - Flask instance to serve the OpenFlexure Microscope API
Loaded: loaded (/etc/systemd/system/openflexure-microscope-server.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-06-04 11:09:10 CEST; 6h ago
Main PID: 444 (python)
Tasks: 10 (limit: 4915)
Memory: 98.1M
CGroup: /system.slice/openflexure-microscope-server.service
└─444 /var/openflexure/application/openflexure-microscope-server/.venv/bin/python -m openflexure_microscope.api.app

Jun 04 17:26:05 microscope python[444]: abort(503, “No stage connected. Unable to autofocus.”)
Jun 04 17:26:05 microscope python[444]: File “/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/werkzeug/exceptions.py”, line 822, in abort
Jun 04 17:26:05 microscope python[444]: return _aborter(status, *args, **kwargs)
Jun 04 17:26:05 microscope python[444]: File “/var/openflexure/application/openflexure-microscope-server/.venv/lib/python3.7/site-packages/werkzeug/exceptions.py”, line 807, in call
Jun 04 17:26:05 microscope python[444]: raise self.mapping[code](*args, **kwargs)
Jun 04 17:26:05 microscope python[444]: werkzeug.exceptions.ServiceUnavailable: 503 Service Unavailable: No stage connected. Unable to autofocus.
Jun 04 17:26:05 microscope python[444]: 2020-06-04T15:25:54Z <TaskThread at 0xa705edb0: _run> failed with ServiceUnavailable
Jun 04 17:26:05 microscope python[444]: INFO:root:Got Action response quickly
Jun 04 17:26:05 microscope python[444]: INFO:root:Got Action response quickly
Jun 04 17:26:06 microscope python[444]: INFO:root:Got Action response quickly

STOP: An “ofm restart” was missing. Now the stage works as SangaStage!

Thank you all!!! I am totally happy with my microscope and can’t await to upgrade it to the high resolution optics.

Cheers
Florian

2 Likes

Thanks Florin. I have marked Joel’s response as the solution. I am glad you are happy with the microscope!

Edited to say:
I also gave you a microscope builder badge :microscope::slightly_smiling_face:

2 Likes

hi all

  • I assembled the OFM and had the same issue as @Florian-HH -> microscope connected but nano clone and simple motor drivers not working with the microscope but yes form the Arduino Serial Monitor
  • so I followed @jc2450 isntructions from this thread -> reload sangaboard firmware and did ofm upgrade and reboot
  • now I’m getting
    Network error

This is the ofm status
pi@microscope:~ $ ofm status
● ofmserver.service - Gunicorn instance to serve the OpenFlexure Microscope API
Loaded: loaded (/etc/systemd/system/ofmserver.service; enabled; vendor preset
Active: failed (Result: exit-code) since Sun 2020-07-05 20:58:37 -03; 17min a
Process: 463 ExecStart=/home/pi/.openflexure/openflexure-microscope-server/.ve
Main PID: 463 (code=exited, status=3)

jul 05 20:58:36 microscope gunicorn[463]: File "/home/pi/.openflexure/openflex
jul 05 20:58:36 microscope gunicorn[463]: import(module)
jul 05 20:58:36 microscope gunicorn[463]: File "/home/pi/.openflexure/openflex
jul 05 20:58:36 microscope gunicorn[463]: from gevent import monkey
jul 05 20:58:36 microscope gunicorn[463]: ModuleNotFoundError: No module named ’
jul 05 20:58:36 microscope gunicorn[463]: [2020-07-05 20:58:36 -0300] [589] [INF
jul 05 20:58:36 microscope gunicorn[463]: [2020-07-05 20:58:36 -0300] [463] [INF
jul 05 20:58:36 microscope gunicorn[463]: [2020-07-05 20:58:36 -0300] [463] [INF
jul 05 20:58:37 microscope systemd[1]: ofmserver.service: Main process exited, c
jul 05 20:58:37 microscope systemd[1]: ofmserver.service: Failed with result 'ex
lines 1-16/16 (END)

I’m kind of lost now…can you help me please?
Saludos
Nano

Nobody else has chipped in. This is not an issue that I know myself, but there are some things I might try.
Does OFM work if you unplug Sangaboard and run it as effectively a manual microscope?
Are you sure the OFM restart completed?
Finally, there have been many and varied issues caused by bad connection to a Pi camera. As a last resort I would try putting in a new cable there.

hi @WilliamW
Thanks for your answer.
If I unplug the sangaboard doesn’t change the result: Network error
I was able tu use the microscope before conecting the motors on the legacy mode of the last OFeV
And yes, I have read about the cable but want to exhaust possibilities before doing that…
Thanks agains
Saludos

Hi,

What is the Raspbian-OpenFlexure version did you install initially ?
I can try it and check if I can reproduce you error on next satuday.

hi @WilliamW
Thanks for your answer.
If I unplug the sangaboard doen’t change the result: Network error
I was able tu use the microscope before conecting the motors on the legacy mode of the last OFeV
And yes, I have read about the cable but want to exhaust possibilities before doing that… @kaspar @j.stirling can you give me a hint?
Thanks again
Saludos