This is followup on the last postings in this thread:
https://forum.arduino.cc/index.php?topic=649270.msg4642386#msg4642386
This thread will focus on in progress work for controlling microscope two-axis sliding-table stepper motors, and the 28BYJ48 stepper motor I superglued to microscope stand wheel.
It all started with being able to make new Raspberry HQ camera microscope by mounting an 180° M12 lens reversed as macro lens in the distance needed with several extension rings and CStoM12 adapter ring. Optical microscopes best resolution is d=0.2µm:
... the resolution d ... In practice the lowest value of d obtainable with conventional lenses is about 200 nm. ...
I was interested in getting down to that resolution, and images from 100 divisions of 1mm long micrometer look nice (centers of neighboring divisions are 10µm apart, or 48 pixel at 0.21µm/px). Right click for 100% view of 1360x768 HDMI monitor screenshot. Zoom was chosen so that pixels of monitor preview map 1:1 onto pixels of center part of 12MP frame captured by HQ camera:
After that was done, I started work on getting microscope two-axis sliding table working (I bought three for 1.60$/pc(!) on aliexpress.com):
https://www.aliexpress.com/item/32972295033.html
I had problems in controlling the A+/A-/B+/B- pins of both stepper motors with uln2003 stepper motor driver. So I did what I know is not good, driving these (tiny) micro stepper motors directly from Arduino Uno digital pins. I was lucky that a single coil did draw only 21mA, just above maximal rating of 20mA for an Arduino Uno digital pin per datasheet. This was 1st time getting one of the two stepper motors working, I measured distance for 20 loops of 8 half-steps as 0.8mm, therefore 800µm/(8*20)=5µm per step:
Next I was able to repeatedly position exactly despite backlash of stepper motors, by making sure that final approaching target position is done with constant torque and from same direction. I recorded a youtube video where 4 positions 5µm apart get positioned 100 times:
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=210605&start=100#p1680357
Vertical positioning was done by hand. Although Raspberry raspistill command new "--focus" feature eases focusing a lot, I wanted to have finer control of Z axis movement. I decided to superglue 28BYJ48 stepper motor to microscope stand wheel and try out, and it really worked. A full stepper revolution of 2048 full-steps did move 18mm wide, that is 8.8µm per single full-step(!). This is a sequence of screenshots taken for doing a single full-step downwards and then capture screenshot and repeat. Never moved that fine grained (8.8µm step wise) for focusing:
This is current 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. On the microscope stand you see Raspberry HQ camera looking down, connected to Pi4B with a 1m long flat ribbon cable. Right click for details in 2299x2855 part from 16MP smartphone photo:
Next steps are:
- drive sliding-table stepper motors with uln2003 stepper driver (doable after noticing that uln2003 inverts signals)
- implement micro-stepping for all three stepper motors for 1µm steps in xyz directions (should be doable)
- control all three steppers with single Arduino Uno although it has 6 PWM pins only
I worked on the last step already. For each of the two coils of a stepper motor PWM is needed only on one side. Proof of concept breadboard is complete for one stepper currently, three 74HC00N 4xNAND and one 74HC04N 6×Inverter can completely deal with three stepper motors. uln2003 stepper driver inverts signals (OUT_i = NOT(IN_i), and LED_i displays IN_i). Output on two lines of one NAND will be 1 and NOT(pwm), positions decided by second input line. So uln2003 inversion will generate 0 and pwm from that. Maybe the 28BYJ48 stepper needs to be treated differently:
I used this sketch to test the circuit:
void setup() {
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(7, 0); analogWrite(6, 255);
digitalWrite(8, 0); analogWrite(9, 255);
}
int l=0, st=192, i;
void loop() {
int i;
digitalWrite(7, l%2);
digitalWrite(8, (l>>1)%2);
++l;
for(i=254; i>st; --i) {
analogWrite(6,i); delay(20);
}
for(i=254; i>st; --i) {
analogWrite(9,i); delay(20);
}
for(i=st; i<255; ++i) {
analogWrite(6,i); delay(20);
}
for(i=st; i<255; ++i) {
analogWrite(9,i); delay(20);
}
}
And I did record a video, below you can see that the two inner uln2003 leds have pwm at that point in time: