Motorised microscope with CNC pendant
In this article, I show you the updated version of my motorized microscope. In one of my older videos, I introduced my motorized microscope and explained all the principles. Now, I show you the updated version. The main feature is that I incorporated the recently introduced CNC pendant into the system. Since the CNC pendant operates at 5 V and it also has a lot of wires, I decided to expand my previous board and make it compatible with the pendant. Apart from this step, I also did other things to make the board better.
Changes
Signal handling
So, the main change is that I made the board compatible with my CNC pendant. There are two main implications of this CNC pendant. First of all, the pendant operates at 5 V, whereas the Teensy 4.0 and the rest of the circuit are 3.3 V-compatible only. So, there is no way to directly connect the output signals of the CNC pendant to the microcontroller without damaging it. Therefore, I added an SN74LVC245A chip between the microcontroller and the CNC pendant to act as a unidirectional level shifter. On the encoder side, the level shifter is at 5V and on the Teensy’s side, it is at 3.3V. I only connected three signals via the level shifter: the emergency switch and the two outputs (A and B) of the encoder wheel. Due to the nature of the emergency switch, I had to add a pull-up resistor to its side that connects to the level shifter. Otherwise, it would float, and it would not provide a stable signal. I added the pull-up resistor directly to the CNC pendant by soldering a 10 kOhm resistor to the emergency switch and connecting the other end of the resistor to the 5V of the encoder. The rest of the pins on the level shifter chip are broken out, and they are available for other purposes if needed.
However, there are many more outputs on the CNC pendant. We need to read the rotary switches, too! This is solved by the MCP23018 chip, which is an I2C IO expander. Actually, in this scenario, it is also a level-shifter. The CNC pendant’s signals are still 5V. The input pins of the IO expander are 5V-compatible, and the I2C bus is at 3.3V. So, this way it is also doing a sort of level shifting. The signals of the rotary switches are polled in every loop() iteration of the code, and if there’s any change on the IO expander, the code takes care of it. There are a few unused pins left on the IO expander, and they are available on the PCB for other purposes if needed.
Since the CNC pendant has many outputs, I decided to add a connector to it. It is more professional and easier to use. I use a total of 18 wires, but the pendant actually has a few more, so I decided to use a 25-pin DSUB connector for this task. Cheap and reliable.
Adding the CNC pendant made the three buttons on the front panel of the old version unnecessary, so I removed them. There is no more “button control mode” in the device. Also, I found it cumbersome to use the buttons, so I had good reasons to remove them.
Powering the device
As I mentioned before, the CNC pendant requires 5V for its operation. In my recent hack, I added an additional DC-DC converter that provided 5V to the Teensy microcontroller. However, this was just a hack, and it was not part of the PCB. So, in this version, there is an additional DC-DC converter which is set up to provide 5V. The 5V rail is available on the PCB via dedicated pins, and it also goes to the CNC pendant via the DSUB connector as well as to the 5V pin of the Teensy. The rest of the circuit still operates at 3.3V, so nothing else gets 5V.
Since the Teensy is supplied with 5V externally in my circuit, I had to make a little modification to it. I explained this modification in my previous article.
Just to quickly reiterate: When the device is used with controllers such as a joystick or a CNC pendant, the microcontroller must be powered externally. I did not want to have it constantly plugged into a USB power supply. Therefore, I decided to power the microcontroller externally. This is done by providing 5V to its 5V pin. By default, this pin is physically connected to the VUSB pin. So, when the device is powered externally, it is not possible to use it via USB at the same time. This is a problem when we want to program the microcontroller when it is sitting inside the circuit, or we want to have the possibility to control the stepper motors by sending commands to them from the computer.
However, the designer of Teensy thought about this, and there’s a tiny tab on the bottom side of the PCB that can be cut so that the 5V and VUSB become separated. But this raises another “issue”. When the user wants to program it via USB, the device won’t receive any power. To solve this, I soldered a pin into the VUSB connector, and I physically connected the pin with the 5V pin, essentially restoring the cut trace with a piece of wire. So, I can remove the microcontroller from the PCB, program it on my computer and then put it back.
Limit switches
Depending on the limit switches used and the configuration applied to the TMC429, one might need to use a pull-up or a pull-down resistor for each switch. I added a slot for each limit switch connector that allows the user to pull the signal up or down with an appropriate resistor. I used 4.7 kOhm resistors for the 3.3V signals, and they work just fine. The X and Y axes are similar. The TMC429 is configured to be active low, and the resistors connect the signal pin to the ground of the circuit. The Z-axis is a bit different because I do not use any limit switches, but I rely on the StallGuard feature of the TMC2209. In the very first image in this article, one can see a red wire going from the left-hand stepper driver (Z-axis) to one of the pins (pin 8) of the Teensy 4.0. This is exactly the StallGuard pin connected to one of the pins on the microcontroller to catch when the StallGuard is tripped.
Get the PCB from my PCBWay project page
Limit switch connector zones with the necessary resistors. The Z-axis is slightly different because it uses StallGuard instead of limit switches.
Enclosure
To accommodate the PCB inside the plastic enclosure, I first had to design an adapter that allows me to firmly fix the PCB inside the enclosure. The enclosure has several well-defined mounting holes, but they do not match the holes of the PCB. The adapter allows proper mounting.
Both the front panel and the rear panel were redesigned. The front panel became simpler because I removed a toggle switch and three push buttons. Now, it only has a 2004 LCD, a toggle switch and an LED.
The rear panel is a new addition because in my previous project, I just carved out all the holes. But it was ugly and time-consuming. Now, it was just time-consuming, because I still had to model the enclosure and the rear panel, but the print turned out to be great, and everything fits well. With these 3D-printed panels, the whole device looks more professional.
Use my affiliate link to buy the relevant products!
