User avatar
zwieblum
Posts: 99
Joined: Sun Jul 07, 2019 6:55 pm
Contact: Website

Re: Creating a RPI-assisted microscope

Thu Dec 05, 2019 2:48 pm

Well, if you cannot "see" the carrier material your sensor is flooded by the stay light. You'd need a light source from behind your camera to see the reflective material, but that's hard to implement. RPi camera has 8 bit resolution, substract some bits for noise from that value and you will not see the reflective material in back light (low contrast, small objects, blur --> invisible)
Looking for professional help? https://klepp.biz

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Mon Apr 27, 2020 3:11 pm

I am working at IBM Böblingen lab (Germany).
Just saw this article of a microscope built by colleauges of IBM Zurich Research lab (Switzerland).
Any Pi, Raspberry v2 camera and lego pieces result in 10µm resolution microscope:
"IBM open sources $300* fully-functional LEGO®microscope design"
https://medium.com/@IBMResearch/ibm-ope ... 8a6cdc81bf
1_KsvDmNRIrF9J23jv6Tz5dQ.png.jpg
1_KsvDmNRIrF9J23jv6Tz5dQ.png.jpg (73.77 KiB) Viewed 5860 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Fri May 08, 2020 10:38 am

I have used the microscope with a much longer tube and new HQ camera, see details here:
viewtopic.php?f=43&t=273286&p=1657265#p1657265
This tube is definitely too long, since achieved distance is 0.09µm/px although no light microscope can have better resolution than 0.2µm/px:
Image
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Thu Jun 04, 2020 6:35 pm

I really liked @Aardappeltaart's today thread "Macro photography with reversed lens technique":
viewtopic.php?f=43&t=276084

He used a reverse macro ring which I do not have, and I did not want to wait.
So I looked what I had and saw CS to M12 metal lens adapter.
I have two lenses of same parameters, rated 1/2.5" 4mm 3MP.
Whenever I need to combine something, whether it is motors for robots or else, my favorite solution is superglue.
One of the reasons is that it can be separated easily as long as you do not take too much superglue.
So today I did put 4 small dots of superglue onto North, South, West and East of CS lens outer side.
Then I did put the CS to M12 adapter on that, pressed together and made sure that connection is really centered:
20200604_174526.part.25%.jpg
20200604_174526.part.25%.jpg
20200604_174526.part.25%.jpg (66.17 KiB) Viewed 5680 times
I used a flexible tripod first in order to see whether it works at all:
20200604_180755.15%.jpg
20200604_180755.15%.jpg
20200604_180755.15%.jpg (180.76 KiB) Viewed 5680 times

And it did work! This is screenshot of self built userland raspistill with "--focus" option:
viewtopic.php?f=43&t=273358&p=1672332#p1672332
Figure of Merit window with value allows easy focusing:
Image
I did capture 12MP photo with this command (6MB):

Code: Select all

🍓 raspistill -o tst.jpg
https://stamm-wilbrandt.de/en/forum/macro/tst.jpg

I did measure distance from left of left to left of right contact as 3150px.
The metal contacts are 0.5mm apart, so the image is 1000µm/3150px = 0.32µm/px(!).
Quite good, since no optical microscope can go below 0.2µm/px:
https://en.wikipedia.org/wiki/Optical_m ... imitations


Next I moved HQ camera with reverse mounted lens into my microscope aluminum alloy stand:
20200604_184026.15%.jpg
20200604_184026.15%.jpg
20200604_184026.15%.jpg (151.07 KiB) Viewed 5680 times
With Figure of Merit on HDMI monitor for the first time focusing became really easy!
This is screenshot taken with raspi2png via ssh session of the microscope stand experiment:
Image
What you see is the "5" and part of following "m" of "0.5mm" text, as well as one of the metal contacts.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Thu Jun 04, 2020 7:56 pm

I took out one of my micrometers and placed it below HQ camera reverse lens, with white background:
20200604_213101.part.jpg
20200604_213101.part.jpg
20200604_213101.part.jpg (82.75 KiB) Viewed 5649 times

I got unbelievable clear and bright photo with HQ camera, I have never seen anything comparable with v2 or v1 cameras:
Image

The 12MP photo taken is of size 6MB again:
https://stamm-wilbrandt.de/en/forum/macro/tst.3.jpg

This is gimp 100% view of center part of 12MP photo shot of micrometer.
Diversions are 10µm apart, so measured line is 150µm long, and 470px.
150µm/470px = 0.319µm/px
Image
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Aardappeltaart
Posts: 168
Joined: Wed Mar 02, 2016 11:32 am

Re: Creating a RPI-assisted microscope

Thu Jun 04, 2020 8:16 pm

That is cool.

Now I need a microscope stand, that's for sure easier than a tripod.

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Thu Jun 04, 2020 8:57 pm

Aardappeltaart wrote:
Thu Jun 04, 2020 8:16 pm
That is cool.

Now I need a microscope stand, that's for sure easier than a tripod.
I have this 20$ aluminum alloy microscope stand, takes some weeks to arrive in case you buy on aliexpress:
https://www.aliexpress.com/item/32849293798.html
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Fri Jun 05, 2020 8:12 am

Last night I did screw out the lens maximally and measured again.
Got 150µm/527px = 0.285µm/px with still nice photo that way.

Today I tried to put 10cm aluminum tube in between, but got no meaningful photos, just too long:
20200605_090051.10%.jpg
20200605_090051.10%.jpg
20200605_090051.10%.jpg (69.14 KiB) Viewed 5573 times

Next I did put CS to C adapter ring in between, and screwed that one as well as the lens out as much as possible.
That was successful as you can see in below.
This time 714 pixel for 150µm, that is 0.21µm/px.
Knowing that 0.2µm is lowest resolution d for optical microscopes, this setup is fine.

Full 12MP photo is of size 5.6MB:
https://stamm-wilbrandt.de/en/forum/macro/tst.6.jpg
macro.screwed_out_plus_CStoC.png.jpg
macro.screwed_out_plus_CStoC.png.jpg
macro.screwed_out_plus_CStoC.png.jpg (26.94 KiB) Viewed 5573 times

P.S:
Measured longer distances in full 12MP photo, "same" resolution in both directions:
Horizontally: 700µm/3336px = 0.20983µm/px
Vertically: 600µm/2859px = 0.20986µm/px

Full 12MP 4056×3040 photo covers (only!) 0.851mm × 0.638mm area at 0.21µm/px.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Sat Jun 06, 2020 11:29 am

For what I reported sofar, I did superglue a cheap (<10$) CS lens rated 1/2.5" 4mm 3MP onto a (10$) CStoM12 adapter.

Yesterday I received Arducam M12 lens kit for Raspberry HQ camera from Lee:
viewtopic.php?f=43&t=249483&p=1674386#p1674141

I realized today that a CStoM12 adapter allows to screw an M12 lens in reverse as well(!).
So I tried, and it really worked.
The 180° and 130° lenses did need additional CStoC adapter ring in order to avoid lens touching imx477 sensor.
Image


I was not able to get any meaningful images out with 20°, 50° and 70° lenses that way.
180° lens achieves 800µm/3357px = 0.23µm/px, nearly as good as the superglued CS lens before.
And near the best resolution optical microscopes can provide (0.2µm/px):
snapshot.180°.png.jpg
snapshot.180°.png.jpg
snapshot.180°.png.jpg (26.19 KiB) Viewed 5510 times
This is 6MB 12MP photo:
https://stamm-wilbrandt.de/en/forum/macro/tst.180.jpg


130° lens achieves 800µm/1614px = 0.50µm/px:
snapshot.130°.png.jpg
snapshot.130°.png.jpg
snapshot.130°.png.jpg (20.39 KiB) Viewed 5510 times
This is 5.6MB 12MP photo:
https://stamm-wilbrandt.de/en/forum/macro/tst.130.jpg


Finally 90° lens achieves 800µm/816px = 0.98µm/px.
While center is sharp (with the help of raspistill's "--focus" option), circle at borders is not:
snapshot.90°.png.jpg
snapshot.90°.png.jpg
snapshot.90°.png.jpg (19.81 KiB) Viewed 5510 times
This is 5.5MB 12MP photo:
https://stamm-wilbrandt.de/en/forum/macro/tst.90.jpg
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Sun Jun 07, 2020 10:27 am

I took the Arducam 180° lens and the Arducam CStoM12 adapter again, and screwed in the lens reversed as yesterday.
Then I screwed the CStoM12 adapter as far as possible.
I realized that the stop was not triggered by the ring, but by the 180° lens having contact to the glass plate on imx477.
(*) Then I brought micrometer into fodus with raspistill's "--focus", did "raspistill -o tst.180.0.jpg" and measured a length in µm and pixels.
Next I inserted a CStoC adapter ring in between, and screwed everything together until stop.
Now I repeated (*).
I repeated this with two and three CStoC adapter rings in between as well.
The CStoC adapter rings I used add 0.55mm (measured with micrometer).
But I have a different looking CStoC adapter ring, likely the one that came with HD camera, and that does add 0.6mm?!?

Then I computed the µm/px values for 0/1/2/3 CStoC adapter rings in between:

Code: Select all

🍓 echo "300/778" | bc -ql
.38560411311053984575
🍓 echo "200/742" | bc -ql
.26954177897574123989
🍓 echo "100/579" | bc -ql
.17271157167530224525
🍓 echo "100/790" | bc -ql
.12658227848101265822
🍓 

0.386µm/px and 0.270µm/px are above minimal resolution d=0.2µm for optical microscopes.
I did view the 4 captured photos at 100%, and the top two look nice.
The0.173µm/px and 0.127µm/px at bottom already started to look not nice anymore:
M12.180°.reversed.0-3_adapters.jpg
M12.180°.reversed.0-3_adapters.jpg
M12.180°.reversed.0-3_adapters.jpg (126.83 KiB) Viewed 5433 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

xkubazz
Posts: 39
Joined: Sun May 10, 2020 3:18 pm

Re: Creating a RPI-assisted microscope

Sun Jun 07, 2020 11:44 am

Those are really impressive results, I need to lay my hands on one of those or a dedicated microscope C-mount lens.

I don't have a micrometer glass slide, but tried to measure resolution of my current setup (35mm photo lens with 56mm extension tube) by taking picture of my phone - Samsung Galaxy Note 5, 518ppi screen.
pentile.jpg
pentile.jpg (231.78 KiB) Viewed 5404 times
(measurement taken from: https://i-cdn.phonearena.com/images/art ... 1-horz.jpg and scaled to match higher ppi of my phone)
Astrophotography with Raspberry Pi HQ Camera
https://terramex.neocities.org/astro/

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Sun Jun 07, 2020 1:29 pm

OK, I took the CS mount with 20mm distant screws from one v1 camera and tested microscope with v2 and v2 camera (HQ camera results above).

Summay:
It is easy to capture with resolutions just above (and below) minimal resolution d=0.2µm optical microscopes can do.with HQ, v2 and v1 camera.

You can do eg. with Arducam M12 180° lens with CStoM12 mount for 20$:
https://www.uctronics.com/arducam-180-d ... amera.html

For v2 and v1 camera you need a CS lens mount in addition, 3pcs for 5$:
https://www.aliexpress.com/item/32723643810.html

Above HQ camera has demonstrated 0.21µm/px.
v2 camera sample has 150µm/607px = 0.247µm/px.
v1 camera sample has 200µm/712px = 0.280µm/px.

You can slightly change µm/px by screwing out/in.
You can do bigger reductions in µm/px by inserting one or more CStoC adapters (one comes with HQ camera).

8MP 4.8MB v2 photo of micrometer: https://stamm-wilbrandt.de/en/forum/tst.180.v2.jpg
5MP 2.5MB v1 photo of micrometer: https://stamm-wilbrandt.de/en/forum/tst.180.v1.jpg

I did not fully fixate v1 and v2 camera setups in microscope stand (below is taken with v1 5MP camera).
Because of image sensors were not parallel to surface, not everything is captured in clear:
snapshot.png.jpg
snapshot.png.jpg
snapshot.png.jpg (61.66 KiB) Viewed 5384 times

This is full package with v1 camera:
ov5647 sensor board on left, CS lens mount screwed in, CStoM12 adapter screwed in, and M12 180° lens screwed in reversed.
I had to Dremel away small part of metal base of CS lens mount, for having space for the sunny connector (see left).
20200607_150154.part.20%.jpg
20200607_150154.part.20%.jpg
20200607_150154.part.20%.jpg (59 KiB) Viewed 5381 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Tue Jun 09, 2020 9:22 pm

Now that Raspberry microscope with resolution as good as best possible for optical microscopes is done, I wanted to use micro stepping two-axis sliding table (I bought 3 for 1.60$/pc). Operational range of that table is 2.4mm × 2.4mm:
https://www.aliexpress.com/item/32972295033.html
Image

Yesterday I did solder breadboard cables to one of the motors and tried to drive the motor with uln2003 stepper driver, without success. Today I tried same with another mini stepper motor, again without success. Finally I did what I read should not be done, drive a stepper motor directly from microcontroller digital pins. I was lucky that it worked, and the resolution is amazing. Stepper moves 1400 steps or 10mm, that is 7.143µm only per step(!). Details in this posting:
https://forum.arduino.cc/index.php?topi ... msg4635662

This is video of setup and action:
https://youtu.be/GeJ47Lah6nU
miniStepper.Uno.jpg
miniStepper.Uno.jpg
miniStepper.Uno.jpg (132.22 KiB) Viewed 5281 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Wed Jun 10, 2020 6:32 am

Half stepping works as well, now 3.57µm per step allows for 14 steps per 50µm, and that is the side length of the center micrometer squares:
https://forum.arduino.cc/index.php?topi ... msg4636130
Image

Unlike the current mini stepper motor, the two sliding table motors have tiny springs attached, so positioning there might be more precise than with currently tested mini stepper motor:
sliding_table_motor_spring.jpg
sliding_table_motor_spring.jpg
sliding_table_motor_spring.jpg (79.25 KiB) Viewed 5264 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Aardappeltaart
Posts: 168
Joined: Wed Mar 02, 2016 11:32 am

Re: Creating a RPI-assisted microscope

Wed Jun 10, 2020 9:43 am

FYI, I took some more pictures of my good old rusty ruler (1mm) with several reverse mounted lenses
35mm_1mm.jpeg
35mm_1mm.jpeg (179.33 KiB) Viewed 5234 times
35mm Pentax
16mm_1mm.jpeg
16mm_1mm.jpeg (148.49 KiB) Viewed 5234 times
16mm Raspberry Pi lens
6mm_1mm.jpeg
6mm_1mm.jpeg (39.35 KiB) Viewed 5234 times
6mm Raspberry Pi lens.

No surprise, 6mm reversed is of no use,: ~1000px / .15mm.

All done with a C-mount Pentax K-mount adapter and Pentax reverse macro ring, and needed step up rings.

Also stability is a thing, I need to move to a house with concrete floors: wooden is to wobbly. :shock:

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Wed Jun 10, 2020 9:50 pm

HermannSW wrote:
Wed Jun 10, 2020 6:32 am
Unlike the current mini stepper motor, the two sliding table motors have tiny springs attached, so positioning there might be more precise than with currently tested mini stepper motor:
Today I was able to drive the sliding table with soldered cables as I did with the other micro stepper motor yesterday.
Regardless of what resolution full- or half- stepping allow for, micro-stepping allows to get 1/256th precision of half-stepping!
What can be seen here is 20 loops with 8 half-steps per loop in one direction, then in the other.
I measured distance as 0.8mm, therefore 800µm/(8*20)=5µm per step, with micro-stepping less than 1µm per step should be doable.
Image


I have broken out my 1st micrometer (1mm with 100 diversions in one direction) already, and did cut white background for micrometer, here on 2nd of my sliding tables:
20200610_235136.15%.jpg
20200610_235136.15%.jpg
20200610_235136.15%.jpg (126.33 KiB) Viewed 5180 times

P.S:
Regarding precision, I did let the Arduino Uno run the code since I took the video unattended for more than 2.5 hours now, and it is still running. For my eyes the sliding table still moves between the same endpoints as two hours ago. This is an indicator of high precision/repeatability, which of course needs to be validated visually as soon as I will put the sliding table under Pi microscope in few hours and with micrometer placed on sliding table. I use the setup with two CStoC adapter rings between HQ camera and Arducam CStoM12 adapter with 180° M12 lens screwed in reverse, everything screwed in maximally. I want to get repeatable results. Although 100µm/579px=0.173µm/px is less than d=0.2µm which Wikipedia stated is best optical microscopes can do, I think it is close enough to 0.2µm/px for now.


P.P.S:
Screwing the reverse mount 180° lens out does increase µm/px, but it should be recreatable. I remembered the (measured 2.5mm thick) lock rings from Arducam M12 lens kit and did screw that onto 180° lens before I screwed the lens into CStoM12 adapter reversed. Now lens is at recreatable position (everything screwed in as much as possible), 2.5mm closer to imx477 sensor. That gives 150µm/710px=0.21µm/px and is slightly above d=0.2µm optical best:
710px_150µm.jpg
710px_150µm.jpg
710px_150µm.jpg (33.78 KiB) Viewed 5143 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Thu Jun 11, 2020 12:43 pm

Before soldering cables to 2nd sliding table motor and building full blown program to control the sliding table, I wanted to have a sneak preview on how µm range movements look like under HQ camera microscope.

I realized that it was too late last night, I took the code with 4 full-steps per loop, and not the one with 8 half-steps. Did not replace it today for 1st experiment under microscope. This was the setup:
20200611_122910.part.50%.jpg
20200611_122910.part.50%.jpg
20200611_122910.part.50%.jpg (90.72 KiB) Viewed 5120 times

For being able to place sliding table onto yellow box without problems, I had to pinch off two plastic standoffs, here marked in photo of my 2nd sliding table:
Image


I used this command for focusing first, and then later captured video of it as well while stepper motor was active:

Code: Select all

userland/build/bin/raspistill --focus -t 0
The audio of video in interesting, the stepper motor movements with delay in between sound for me like a pendulum clock. The 30fps animation at 16.6% size was created from first 6 seconds of the 24 second video:
https://www.youtube.com/watch?v=XDhekZpAO1U
Image


I noticed that for each forward and backward cycle center of camera moved a bit right.
I did single step the video and determined scale position of right border of Figure of Merit rectangle.
̶I̶ ̶t̶h̶e̶n̶ ̶d̶e̶t̶e̶r̶m̶i̶n̶e̶d̶ ̶t̶h̶e̶ ̶a̶v̶e̶r̶a̶g̶e̶ ̶b̶a̶c̶k̶ ̶a̶n̶d̶ ̶f̶w̶d̶ ̶d̶e̶l̶t̶a̶s̶ ̶a̶s̶-̶1̶2̶.̶9̶5̶µ̶m̶ ̶a̶n̶d̶ ̶1̶4̶.̶2̶µ̶m̶.̶
̶K̶n̶o̶w̶i̶n̶g̶ ̶t̶h̶a̶t̶ ̶s̶t̶e̶p̶p̶e̶r̶ ̶d̶i̶d̶ ̶5̶*̶4̶=̶2̶0̶ ̶f̶u̶l̶l̶s̶t̶e̶p̶s̶,̶ ̶a̶ ̶f̶u̶l̶l̶-̶s̶t̶e̶p̶ ̶i̶n̶ ̶f̶o̶r̶w̶a̶r̶d̶ ̶d̶i̶r̶e̶c̶t̶i̶o̶n̶ ̶i̶s̶ ̶1̶4̶.̶2̶µ̶m̶/̶2̶0̶=̶7̶.̶1̶µ̶m̶(̶!̶)̶.̶
I then determined the average back and fwd deltas as -129.5µm and 142µm.
Knowing that stepper did 5*4=20 fullsteps, a full-step in forward direction is 142µm/20=7.1µm(!).
sliding_table_1.jpg
sliding_table_1.jpg
sliding_table_1.jpg (27.13 KiB) Viewed 5120 times

Smartphone did record 1920x1080@30fps video, this is frame 10 of video where stepper motor moves (right click for 100% view):
frame.0010.png.jpg
frame.0010.png.jpg
frame.0010.png.jpg (108.88 KiB) Viewed 5120 times

P.S:
I forgot the most important point, explanation why 20 steps forward and backward behave differently.
From the 2.5h run last night I mentioned in P.S of previous posting we know that the stepper motor works fine.
Otherwise the sliding table would not have kept in place for 2.5h and would have hit either of the boundaries.
So explanation seems to be that I did not fixate
  1. yellow box on microscope stand
  2. sliding table on yellow box
  3. white cardboard on sliding table
  4. shard with micrometer on white cardboard piece
I will fix 2-4 and see whether that is enough (I expect it).


P.P.S:
In frame 10 shown above only initial and end position of movement can be seen.
Intermediate positions seem not to accumulate enough light to show up.


P.P.P.S:
Video of same 20 full-step move in each direction from smartphone with 4x zoom:
https://www.youtube.com/watch?v=F4ofE4plZrc
Image


P.P.P.P.S
Just measured, movement is quick:
80 digitalWrites plus 20 1ms delays in for-loop take 21-22ms in total.
Last edited by HermannSW on Thu Jun 11, 2020 8:22 pm, edited 1 time in total.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Thu Jun 11, 2020 9:34 pm

I did little dots of superglue for steps 2-4, and it looked like that it was enough -- but it was not. I did capture 12MP photos every 3 seconds with raspistill timelapse, while stepper motor did 20 full-steps every second, with alternate directions:

Code: Select all

🍓 raspistill -t 1800000 -tl 3000 -o tl.%04d.jpg
mmal: Frame 215 is 553 ms late
mmal: Frame 242 is 214 ms late
mmal: Frame 296 is 427 ms late
mmal: Frame 336 is 324 ms late
mmal: Frame 441 is 297 ms late
mmal: Frame 545 is 493 ms late
mmal: Frame 588 is 288 ms late
🍓 

Then I compared frame 6 and frame 597, and there was a slight difference that was not between frame 4 and frame 6.
So I did cut out left middle area from frames 6 and 597 and made an animated .gif from that.
Now the difference can be seen more easily, maybe 2µm (diversions are 10µm apart) per half hour.
So while this really is not much, I will try to get rid of that by superglueing yellow box to something really heavy.
x.anim.gif
x.anim.gif
x.anim.gif (101.1 KiB) Viewed 5056 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

aBUGSworstnightmare
Posts: 3890
Joined: Tue Jun 30, 2015 1:35 pm

Re: Creating a RPI-assisted microscope

Fri Jun 12, 2020 6:31 am

Please allow a question: what is your target? You want to test if your stepper will/can come back ro the same position? Is there some kind of gears in your table or are the steppers directly driving it? Considered backlash in the 'drive train'?

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Fri Jun 12, 2020 6:30 pm

aBUGSworstnightmare wrote:
Fri Jun 12, 2020 6:31 am
Please allow a question: what is your target? You want to test if your stepper will/can come back ro the same position?
You are right, it is probably as precise as it can be for toy hobbyist solution.
Although the result is not bad. Stepper motor did move 5*4=20 full-steps each second of half an hour.
That is 1800*20=36000 stepper motor steps, each producing 7.1µm move of sliding table, with only 2µm off in total.

Is there some kind of gears in your table or are the steppers directly driving it? Considered backlash in the 'drive train'?
I see no gears, link to 16MP smartphone photo for more details:
https://stamm-wilbrandt.de/en/forum/20200612_201021.jpg
20200612_201021.15%.jpg
20200612_201021.15%.jpg
20200612_201021.15%.jpg (140.58 KiB) Viewed 4944 times

I did solder 4 cables to the 2nd sliding table stepper motor, because the flat ribbon cable connections being 0.5mm apart are impossible to use for me. After testing that neighbouring cables are not shorted with multimeter, I made a connector by superglueing the 8 female headers together -- not an a single line, but will work:
20200612_200738.15%.jpg
20200612_200738.15%.jpg
20200612_200738.15%.jpg (94.65 KiB) Viewed 4944 times
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Fri Jun 12, 2020 11:00 pm

Now both motors of precision two-axis microscope sliding-table work.
I created kind of a "hello world" sketch, 40 half-steps to the right, then 40 half-steps up, and finally 40 half-steps of both stepper motors in the other direction, together:
https://forum.arduino.cc/index.php?topi ... msg4640208

I created a 16.6% size animation from 1920x1080@30fps smartphone video:
https://www.youtube.com/watch?v=EkLfPyaDM5Y
Image


Right side of Figure of Merit rectangle moves from position 21 to 41 with 40 half-steps. That is 200µm/40=5µm per half-step.
Unfortunately micrometer axis is not parallel to moving direction.
The middle of right side of Figure of Merit rectangle is at bottom position 41.
Next the middle is at top position 40.
Slope angle is atan(1/20)=2.9° only.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

aBUGSworstnightmare
Posts: 3890
Joined: Tue Jun 30, 2015 1:35 pm

Re: Creating a RPI-assisted microscope

Sat Jun 13, 2020 5:27 am

HermannSW wrote:
Fri Jun 12, 2020 6:30 pm
Is there some kind of gears in your table or are the steppers directly driving it? Considered backlash in the 'drive train'?
I see no gears, link to 16MP smartphone photo for more details:
https://stamm-wilbrandt.de/en/forum/20200612_201021.jpg
20200612_201021.15%.jpg
the 'gear' is the white nut and the thread on your motor shaft. There you will have some tiny backlash. If your able to measure it you get to know the no of steps, hence your software is able to compensate. Use a dial gauge to measure it; drive i.e. 20 steps in one direction, than 20 steps back. The value on the gauge is your backlash. Compensate in SW and repeat the test.

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Sat Jun 13, 2020 7:38 am

the 'gear' is the white nut and the thread on your motor shaft. There you will have some tiny backlash. If your able to measure it you get to know the no of steps, hence your software is able to compensate. Use a dial gauge to measure it; drive i.e. 20 steps in one direction, than 20 steps back. The value on the gauge is your backlash.
I agree on that measuring is needed. I do have a 42$ 0.001mm resolution electronic micrometer for measurements in 1µm steps:
https://forum.arduino.cc/index.php?topic=645745.0
Image
But the spring of that electronic micrometer is different to the springs in two-axis sliding-table, and I would measure something different than what I am interested in.

I will use the cross micrometer from calibration slide I used before (1DIV=0.01):
viewtopic.php?f=43&t=210605&p=1563791#p1562024
Image
That allows for measurements in X and Y direction. Because it is a calibration slide, I know that diversions are 10µm aparrt and can use that for measurements, with the real springs in real environment. So the Raspberry HQ camera with 180° M12 lens mounted reversed and 0.21µm/px will be my contactless dial gauge under real conditions.

The ⌀0.07mm filled circle looks promising for repeated movement tests as well. Center of view would need to move just outside of filled circle (in 5µm half-steps, or even finer if I add micro-stepping) around the circle. I would need to add a "crosshair" HDMI overlay to "raspistill --focus -t 0" preview, similar to Figure of Merit. Crosshair keeping outside of filled circle will indicate minimal backlash. Since moving around filled circle this will test all direction movement of sliding-table.

Next steps:
  1. use Arduino Accelstepper library for better dealing with needed(?) stepper movement acceleration
    (do not reinvent the wheel)
  2. use logic analyzer to find out why I was not able to make uln2003 stepper driver work with A+/A-/B+/B- stepper motors
    (would eliminate the directly drive from Arduino Uno digital pins issue)
  3. measure with constant voltage power supply, what current is used by the stepper motor coils (for 5V as of now)
  4. create interactive program that allows to specify how many half-steps to move in +X,-X,+Y,-Y direction
    (Arduino sketch using Serial Monitor input, or Raspberry code over /dev/ttyUSB0 -- I program the Arduino Uno via IDE installed on Pi4B since some days now)
  5. implement micro-stepping, which is not even available in Accelstepper library
    (going from pattern 1010 to 1000 is a half step, doing so with PWM on pin3 would allow for 256 steps with Arduino analogWrite(), or 25-40000 steps with Raspberry pigpio C interface, in between!)
  6. analog sliding-table HQ microscope feedback µm range video game
    (racing, more on that later)
  7. ...
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

User avatar
zwieblum
Posts: 99
Joined: Sun Jul 07, 2019 6:55 pm
Contact: Website

Re: Creating a RPI-assisted microscope

Sat Jun 13, 2020 7:59 am

What about using GRBL+CNC shield for the steppers?
Looking for professional help? https://klepp.biz

User avatar
HermannSW
Posts: 4825
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Creating a RPI-assisted microscope

Sat Jun 13, 2020 3:06 pm

zwieblum wrote:
Sat Jun 13, 2020 7:59 am
What about using GRBL+CNC shield for the steppers?
Sounds interesting, new v1.1 repo here:
https://github.com/gnea/grbl
Supports exactly 3 axis, maybe I can use a Nema17 stepper I have to turn mircoscope stand wheel and move along Z axis for focusing ... getting maximal Figure of Merit value by turning wheel with hand is a puzzle somtimes.

Arduino CNC hat is not expensive; but input voltage range of hat is 12-36V, so two 12Vto5V step-down converters are needed for the sliding-table tiny 5V stepper motors to be controlled by hat?


I have answer for (c) of todo list from previous posting, was lucky that coil current draw is only 1mV above what Arduino Uno digital pins can deliver (https://store.arduino.cc/arduino-uno-rev3):
20200613_161140.10%.jpg
20200613_161140.10%.jpg
20200613_161140.10%.jpg (69.85 KiB) Viewed 4764 times

This is the final setup, shard with micrometer superglued onto white cardboard superglued on two-axis sliding-table superglued on yellow light box for height superglued on heavy black box for keeping everything in place. The black box is placed on aluminum alloy microscope stand, and then moved around on that for getting micrometer into view of HQ camera microscope. Moving to target positions <10µm away by hand is a puzzle sometimes:
20200613_161657.15%.jpg
20200613_161657.15%.jpg
20200613_161657.15%.jpg (166.62 KiB) Viewed 4764 times

I did measure exactly that 600µm of a saved 12MP photo are 2877 pixels (using gimp).
Then I did run raspistill with "--roi" option for getting 4× zoom preview:

Code: Select all

🍓 ~/userland/build/bin/raspistill --focus -t 0 --roi 0.375,0.375,0.25,0.25 
From raspi2png snapshot I measured 150µm as 720 pixels.
And I was lucky that this zoom resulted in one pixel of 12MP HQ camera frame per 1 display pixel (my HDMI display is 1360x768).
Contol calculation for determining effect of slight difference in µm/px values is good.
Center of micrometer diversions are 10µm apart, or 48 pixels):

Code: Select all

🍓 echo "600/2877" | bc -ql
.20855057351407716371
🍓 echo "150/720" | bc -ql
.20833333333333333333
🍓 echo "150/720*2877" | bc -ql
599.37499999999999999041
🍓 

I used sketch from last night for doing N=20 steps only (instead 40) with 4× zoom of preview. That moves 100µm, looking at bottom right corner of Figure of Merit: from bottom of position 3 of micrometer to bottom of position 13, to just above postion 12.5 (because micrometer axis is not 100% parallel to sliding table x-axis), and back to start (bottom of position 3):
Image
Last edited by HermannSW on Sat Jun 13, 2020 3:27 pm, edited 2 times in total.
https://github.com/Hermann-SW/memrun
https://stamm-wilbrandt.de/2wheel_balancing_robot
https://stamm-wilbrandt.de/en#raspcatbot
https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/en/Raspberry_camera.html

Return to “Camera board”