-
The ESP32 code
2 days ago • 0 commentsThe control program on the ESP32 communicates with the laptop through the serial port. It gets the commands with characters and communicates back when the stepper motor is finished. I kept it simple. The first command is to forward a frame. That is 'A'. The upper case letter is for the first stepper motor (the tooth wheel) and the lower case letter for the other stepper motor at the reel. 'B' and 'b: are a frame backward. Cc and Dd are for a single step. Ee and Ff for continuous turning. (And later Gg and HH for a third frame.) It replies with E1 and E2 when the turning is finished. (In hindsight I should have used E and e). Also the speed and the acceleration can be adjusted with WwXx for halving and doubling the acceleration and YyZz for the speed.
A friend once told me: don’t write any code yourself; everything is already written. That’s true. For every task several libraries have been written and the Arduino IDE let you choose the one you like. The most time goes into choosing the library.
An important condition is to be able to have two stepper motors turning simultaneously. So the routines should be non-blocking. I settled for AccelStepper. It also has the nice feature that it can slowly accelerate and decelerate. In this way the film is protected against a too aggressive tooth wheel.
The only function missing is a callback function when the stepper motor is finished turning. I wanted to include ths function using inheritance, but for some unknown reason I did not get this working, even after trying for a whole evening. So I went for the quick and dirty way to just add functions and duplicate them for the two steppers.
The ESP32 source code is in the file section.
-
The control electronics
05/22/2024 at 20:07 • 0 commentsThe control of the digitizer consists of a PC (laptop) running (through Virtualbox) Linux mint. A C++ program (control) reads the serial port of the ESP32 and captures the frame by invoking the fswebcam program to get a picture from the microscope.
The ESP32 runs a program (stepper) which gets commands through the serial ports to run the stepper motors and sends back a notification when the stepper motor has reached its target position.
A variable PWM module (powered from the ESP32) controls the strength of the LED.
-
The first prototype
05/20/2024 at 20:26 • 0 commentsFor a first try, I take the configuration of the manual viewer as layout. I need two stepper motors. The first one is connected to the wheel with tooth that grab into the holes in the film. It has 12 tooth, so 1/12 turn of this wheel advances one frame. The second stepper motor (although it could have been a normal motor) turns the spool. It should be able to slip, so I made a few different clutches.
I used the simple 28BYJ-48 geared stepper motors with ULN2003 drivers.
I made a frame and holders for the stepper motors in OpenScad and sliced it with Cura.
The best clutch was an outer ring with spring-like pins, and an inside wheel with an curved surface.
Problems with this first prototype:
- The film was too loose around the wheel, so it slipped.
- The microscope holder was off.
- And it was too dense to tweak.
So the second prototype has to be wider, several options for the guarding wheels to get enough tension, and a proper place for the microscope.