Electronics for 3D scanner
I'll start with an apology. What a shame it turned out! I wanted to assemble the fifth scanner after correcting all the jambs, to do everything soundly, but here the projects, the Unified State Examination, the Olympiads ... In general, everything started spinning, so sorry everyone who was waiting for articles on this topic. For those who are not in the topic, here is a zero article . And those who are in the subject and are still interested, welcome to the cut of the first part. And it will be, as you already understood, about electronics ...
In the process of breaking away from working on a scanner, more than 10 people wrote to me that they needed help with a 3D scanner, most of the questions related to electronics. About her and will be discussed in this article.
What should we do at all? Firstly, we need to control the stepper motor, secondly, we must at least turn the laser on and off, and thirdly, we must somehow exchange data with the computer. Here are the main three tasks that our board must perform. Nothing complicated. That is, we can use almost any microcontroller. I mostly program under STM32, so I took it. Although the general principles of operation will naturally be the same for any controller.
In the third version of the scanner, I took the STM32F030F4 microcontroller. It is distinguished by the more payable case TSSOP20 (at that time, LQFP-based boards didn’t work out even with a photoresist). Of the things we are interested in - a timer with PWM generation and hardware USART. I think problems like “There weren’t enough legs for the motor” do not threaten anyone. This is how I got the wiring:
But this will be the circuit:
I must say that the conductors to the microcontroller are incorrectly drawn in the circuit, but the wiring is correct. The numbering of the components on the diagram and on the board are the same, so see the ratings of the components in the diagram. Not only signed quartz timing. It is located in the upper left corner of the board. By the way, capacitors to it are not necessarily 10 pF. Their nominal value should be in the range from 5 to 20 pF.
You may notice that there are no holes for the PLS pins on the wiring. I just solder them sideways. This can be seen in the very first photo at the beginning of the article. It is also seen on the wiring that in red I combined these pins into groups (G1, G2, etc.).
G1 is a connector for communicating with a computer. From left to right: GND, SWDIO, SWCLK, RX, TX, + 5V.
G2 - power for the laser. Plus from the bottom.
G3 - laser connection. Plus left (your cap).
G4 - motor connection.
As you can guess from the scheme - we drive exactly the unipolar stepper motor. For this, field effect transistors are used. I liked the idea of delivering SMD assemblies. I applied these assemblies. You can take any others. The main condition is the compatibility of the cases (not that the legs of both those and those are 8, but that the pinout is the same). Well, also the fact that transistors must be N-channel.
A separate voltage stabilizer has been made for the laser (lower left corner of the circuit). This allows you to adjust the laser power by adjusting the output voltage of the stabilizer. To do this, you need to change the resistance of the resistor R5. Therefore, it is best to install a potentiometer as R5. The attentive reader will ask: “Why 9V?”. Generally because the laser needs to be powered separately from the motor. A motor is an inductive load, which means it creates power surges that can kill a laser diode. It will not work to power from 5V due to the fact that the voltage drop across the stabilizer is large enough and we may not have enough voltage for its normal operation. Therefore, I set the power supply set to 9V, because I already had it and was perfectly suitable for voltage. The stabilizer is mounted on the radiator, but not soldered to the board.
ATTENTION! This circuit is not a laser diode driver! It connects to it and regulates the supply voltage. That is, if you assembled the laser yourself, then at least you have to put a current-limiting resistor and capacitor.
In general, everything is in circuitry. The board is easily made by LUT. Here is a link to the wiring in SprintLayout .
There are no pictures, no diagrams: everything was assembled on a breadboard (breadbord). The microcontroller took the STM32F401RE. No, such power is certainly not needed. It is just installed in the STM32F401-Nucleo. I liked this board because it has not only pins, but also sockets (as in Arduino), but also because it has ST-Link V2.1 installed. What's so good about him? And the fact that in addition to the programmer there is also a USB-> UART adapter. This means that there will be fewer wires and fewer boards. Of the minuses, it can be noted that it is defined in the system as a flash drive, so that Windows Explorer constantly pops up. But it is so. The little things. Better than wires. The circuit basically remains the same. Three microcircuits can be replaced with one ULN (ULN200x; x = 1,2,3,4). True, the transistors there are designed for less current and generally bipolar, but there is only one case.
But about laser control, you need to say separately. In the fourth version, I decided to make the power adjustable programmatically. In the sense, we can adjust the power according to UART. To control the laser power, we drive a PWM on the TDA2030. The scheme of this block will be as follows:
Speaking innon- human language, this is a non-inverting signal repeater on an operational amplifier. It is needed to amplify the current.. You can give it any power from 5 to 18V - the repeater repeats not only the shape, but also the amplitude of the signal (only the current amplifies), so there is nothing to worry about. Except that the output voltage of the STM32 will be 3.3V. So we can’t squeeze the full power out of the lasers powered by Li-ion batteries — their maximum voltage is 4.2V. But we are definitely not sleeping on a software error. Of course, it is better to put a filter at the output of such an amplifier, but often there is a filter capacitor in lasers, and so the choice is yours.
ATTENTION! If you suddenly decided to make a full-fledged amplifier, and not a repeater, then remember that we control using a PWM, which means that the voltage will jump from the minimum value to the maximum. The laser diode needs very little time to burn out, so if the voltage exceeds the maximum 4.2V (even briefly), then the diode will burn!
There are many boards for controlling motors in RepRap 3D printers. For example, this . Similar boards are easily found by the name of the chip. So why is she good? Firstly, it can control bipolar motors, and any unipolar turns into a bipolar by banal disconnection of the middle taps of the windings (or rather, their non-connection). Secondly, it is easily controlled: one pin sets the direction, and the second we give impulses. Every impulse is a step. And the last feature is the division of steps (microstep). That is, the microcircuit may not take a complete step, but for example 1/2. Not 5 degrees, as the step of the previous scanners would do, but 2.5. And this is not the limit! It supports the division by 16. But in fact, it is not needed.
So I highly recommend it. Saves time, legs (microcontroller of course), but not money. But it's worth it.
I'd better solder the control board to the same STM32F030, because it is cheap and small. Although the latter does not play a role in such a huge box, it can be more likely a minus for some people.
There is nothing much to change in laser control. Everything worked so well on the fourth scanner, and there is no point in changing anything. Is it possible to fasten the DAC, but this is rather an extra headache.
And now print, etch, solder and code, code, code! But about coding in the next article. And this time they will not let me score. I hope most of the questions on electronics I answered. It seems there is nothing particularly complicated and frightening there. I will try to write about the code as soon as possible (throwing out all indecent comments and deleting idle and unnecessary pieces).
Good luck to everyone with projects / diplomas / gatherings in the garage, where this article came in handy!
PS In the circuit, a typo - capacitors near quartz - 10 pF, not 10 nF.
In the process of breaking away from working on a scanner, more than 10 people wrote to me that they needed help with a 3D scanner, most of the questions related to electronics. About her and will be discussed in this article.
General idea
What should we do at all? Firstly, we need to control the stepper motor, secondly, we must at least turn the laser on and off, and thirdly, we must somehow exchange data with the computer. Here are the main three tasks that our board must perform. Nothing complicated. That is, we can use almost any microcontroller. I mostly program under STM32, so I took it. Although the general principles of operation will naturally be the same for any controller.
Third version
In the third version of the scanner, I took the STM32F030F4 microcontroller. It is distinguished by the more payable case TSSOP20 (at that time, LQFP-based boards didn’t work out even with a photoresist). Of the things we are interested in - a timer with PWM generation and hardware USART. I think problems like “There weren’t enough legs for the motor” do not threaten anyone. This is how I got the wiring:
But this will be the circuit:
I must say that the conductors to the microcontroller are incorrectly drawn in the circuit, but the wiring is correct. The numbering of the components on the diagram and on the board are the same, so see the ratings of the components in the diagram. Not only signed quartz timing. It is located in the upper left corner of the board. By the way, capacitors to it are not necessarily 10 pF. Their nominal value should be in the range from 5 to 20 pF.
You may notice that there are no holes for the PLS pins on the wiring. I just solder them sideways. This can be seen in the very first photo at the beginning of the article. It is also seen on the wiring that in red I combined these pins into groups (G1, G2, etc.).
G1 is a connector for communicating with a computer. From left to right: GND, SWDIO, SWCLK, RX, TX, + 5V.
G2 - power for the laser. Plus from the bottom.
G3 - laser connection. Plus left (your cap).
G4 - motor connection.
As you can guess from the scheme - we drive exactly the unipolar stepper motor. For this, field effect transistors are used. I liked the idea of delivering SMD assemblies. I applied these assemblies. You can take any others. The main condition is the compatibility of the cases (not that the legs of both those and those are 8, but that the pinout is the same). Well, also the fact that transistors must be N-channel.
A separate voltage stabilizer has been made for the laser (lower left corner of the circuit). This allows you to adjust the laser power by adjusting the output voltage of the stabilizer. To do this, you need to change the resistance of the resistor R5. Therefore, it is best to install a potentiometer as R5. The attentive reader will ask: “Why 9V?”. Generally because the laser needs to be powered separately from the motor. A motor is an inductive load, which means it creates power surges that can kill a laser diode. It will not work to power from 5V due to the fact that the voltage drop across the stabilizer is large enough and we may not have enough voltage for its normal operation. Therefore, I set the power supply set to 9V, because I already had it and was perfectly suitable for voltage. The stabilizer is mounted on the radiator, but not soldered to the board.
ATTENTION! This circuit is not a laser diode driver! It connects to it and regulates the supply voltage. That is, if you assembled the laser yourself, then at least you have to put a current-limiting resistor and capacitor.
In general, everything is in circuitry. The board is easily made by LUT. Here is a link to the wiring in SprintLayout .
Fourth scanner
There are no pictures, no diagrams: everything was assembled on a breadboard (breadbord). The microcontroller took the STM32F401RE. No, such power is certainly not needed. It is just installed in the STM32F401-Nucleo. I liked this board because it has not only pins, but also sockets (as in Arduino), but also because it has ST-Link V2.1 installed. What's so good about him? And the fact that in addition to the programmer there is also a USB-> UART adapter. This means that there will be fewer wires and fewer boards. Of the minuses, it can be noted that it is defined in the system as a flash drive, so that Windows Explorer constantly pops up. But it is so. The little things. Better than wires. The circuit basically remains the same. Three microcircuits can be replaced with one ULN (ULN200x; x = 1,2,3,4). True, the transistors there are designed for less current and generally bipolar, but there is only one case.
But about laser control, you need to say separately. In the fourth version, I decided to make the power adjustable programmatically. In the sense, we can adjust the power according to UART. To control the laser power, we drive a PWM on the TDA2030. The scheme of this block will be as follows:
Speaking in
ATTENTION! If you suddenly decided to make a full-fledged amplifier, and not a repeater, then remember that we control using a PWM, which means that the voltage will jump from the minimum value to the maximum. The laser diode needs very little time to burn out, so if the voltage exceeds the maximum 4.2V (even briefly), then the diode will burn!
How to do better?
There are many boards for controlling motors in RepRap 3D printers. For example, this . Similar boards are easily found by the name of the chip. So why is she good? Firstly, it can control bipolar motors, and any unipolar turns into a bipolar by banal disconnection of the middle taps of the windings (or rather, their non-connection). Secondly, it is easily controlled: one pin sets the direction, and the second we give impulses. Every impulse is a step. And the last feature is the division of steps (microstep). That is, the microcircuit may not take a complete step, but for example 1/2. Not 5 degrees, as the step of the previous scanners would do, but 2.5. And this is not the limit! It supports the division by 16. But in fact, it is not needed.
So I highly recommend it. Saves time, legs (microcontroller of course), but not money. But it's worth it.
I'd better solder the control board to the same STM32F030, because it is cheap and small. Although the latter does not play a role in such a huge box, it can be more likely a minus for some people.
There is nothing much to change in laser control. Everything worked so well on the fourth scanner, and there is no point in changing anything. Is it possible to fasten the DAC, but this is rather an extra headache.
And now what?
And now print, etch, solder and code, code, code! But about coding in the next article. And this time they will not let me score. I hope most of the questions on electronics I answered. It seems there is nothing particularly complicated and frightening there. I will try to write about the code as soon as possible (throwing out all indecent comments and deleting idle and unnecessary pieces).
Good luck to everyone with projects / diplomas / gatherings in the garage, where this article came in handy!
PS In the circuit, a typo - capacitors near quartz - 10 pF, not 10 nF.