WHAT ENGINE IS THAT? - Step Motor Laboratory

by Fernando Koyanagi in Workshop > CNC

3164 Views, 9 Favorites, 0 Comments

WHAT ENGINE IS THAT? - Step Motor Laboratory

QUE MOTOR É ESSE? - Laboratório de motor de passo - Pt1
^1D4FC7DAB00F814AABFA96496863E90B97194EC0A479CFEF4B^pimgpsh_fullsize_distr.jpg

What motor is this? Have you ever asked yourself that question? Well, today we are going to address the electrical characteristics of an engine. We’re doing this because scrap robotics often involves some frustration, and my intention, therefore, is to prevent possible frustrations by setting up a STEP ENGINE LAB. Therefore, we will introduce the Multitask programming in ESP32, calculate voltage values and currents, and test several types of step motors.

Resources Used

recursos usados.png

  • ESP WROOM 32
  • TFT LCD Display Module 1.44 "RGB
  • Driver DRV8825
  • 2 potentiometers: 10k and 50k
  • 220uF Electrolytic Capacitor
  • Step Motor

Assembly

Montagem.png

In the assembly, we have a display and a working Floppy engine from older models. It is bipolar, and I took it from a computer. We have the ESP32 sending a signal to the DRV8825, in addition to the potentiometers that allow us to control the speed and the current. We also show a Step Down potentiometer that regulates the voltage on top of the driver.

So I set up here a kind of laboratory, where I can identify which pulse in microseconds I send to the potentiometer, among other parameters of an engine, such as its maximum and minimum values, including current, RPM minute, and the resistance. In the video, I make some demonstrations, including with a 4-wire engine, equivalent to a Nema 23.

Display Mounting

Montagem de display.png

Display Connections

Ligações do display.png

This table indicates how you should connect the Display to ESP32.

Mounting the DRV8825

Montagem do DRV8825.png

DRV8825 Connections

Ligações do DRV8825.png

This table tells you how to connect the Driver to ESP32.

Connecting the Potentiometers

Ligação dos potenciometors 1.png
Ligação dos potenciometors 2.png
Ligação dos potenciometors.png

In this step, to improve the manipulation of the current control of the DRV8825, we changed the adjustment potentiometer of the driver to a larger one, but with the same resistance (10K ohms). This action greatly facilitates manipulation, but requires careful and delicate assembly.

How to Calibrate Data Entry

como calibrar a entrada de dados 1.png
como calibrar a entrada de dados 2.png
como calibrar a entrada de dados 3.png
como calibrar a entrada de dados 4.png
como calibrar a entrada de dados.png

To perform the calibration of the data collected to calculate the voltage on the DRV8825 driver potentiometer cursor, we use Excel.

First, we collect the AD values of the ESP input port that range from 0 to 4095.

With a multimeter, we measure the voltage of the driver potentiometer cursor at all times.

The ESP32 plays the role of the multimeter in this case, which has an AD input of 12 bit and picks up voltage of 3v3. As already mentioned, the reference ranges from 0 to 4095, as it’s 12 bit. If it were 10-bit, like the Arduino Uno, it would be 0 to 1024, that is, with four times less resolution. Therefore, the fact that ESP has four times more resolution is important for our application.

We take the voltage in millivolts of the potentiometer of the 8825, and I vary and analyze which reading is equivalent to the value of the AD. This measurement, in this case, I perform with the multimeter to see the actual value. This is because the input AD of the ESP consumes energy, so it gives a small difference in reading. With Excel, I show this compensation.

In the Excel worksheet, as shown in the figure below, fill in the values collected in the table above and create a scatter plot of points.

Right-click anywhere on the chart, and then click "Add Trend Line."

Then select "Linear," "View Equation in Chart," and "Display R-Square Value in Chart."

Excel then displays a first-degree equation that corrects the problem of scattering the points and finds an average. That is, after I read the AD value of the potentiometer and turned the knob, the equation will confirm what to do with the motor.

Here, Excel generates the linear equation, which will be used in the code. The value of 0.9944 is the standard deviation, that is, the closer to 1, the more confidence I have that the data is correct.

Code

We programmed two Cores. Our diagram is made up of Global Declarations, Global Functions, and Configurations. Then we start with Core 0 and Core 1 as one with a Task and a Loop.

Global Declarations

código1.png

Here are some variables.

Global Functions

código2.png

Here it shows how to print on the display. Always, look at the voltage in millivolts, the Ampere current, the motor RPM, the AD value, and the pulse.

Settings

código3.png
código4.png
código5.png

Here I have the Setup, where I expose the display pinMode and the digitalWrite.

We also have the functions to print on the screen, as well as all the specificities.

Here we start the multicore programming. You have a TaskCreatePinnedToCore function, and the function names are codeForTask1 and codeForTask2, which is a pointer to function. You still see the amount of memory, that is, the size of the stack of the Task, which should be 2000 in both.

Task1

código6.png

In codeForTask1, it does an analogReaddo POTV, which is from the pot reading the speed value. So, I get the speed value and I calculate the Half-Period, which is division by two. In analogRead POTD, we calculate the voltage of the driver. We start for TensaoPot, take the AD reading, and do the mathematical correction of the curve with the first-degree equation pointed out by Excel. After correcting the potentially incorrect value, we calculate the current value of the motor and the RPM. We print the data and set up a delay.

Task2

código7.png

In codeForTask2, we make a digitalWrite LOW, and then a digitalWrite HIGH of Half-Period, forming a full wave, with a period of high and also low, that is, the complete cycle of the step.

Here's a note: when you have dual-core programming, the loop does nothing, because CodeForTask does it all. Then, for the Loop, we determine a delay.

Measuring the Inductance of Step Motors

medindo indutancia.png

To measure the inductance, you need a CSF meter. Even with the coils being equal, because of the position of the motor, the measurements in mH may be different. The correct reading is the lowest reading.

Why Is There a Difference Between the Coils?

medindo indutancia2.png
medindo indutancia3.png
medindo indutancia4.png

Due to the alignment of these coils with the shaft magnet, the measurements may change as the magnet can affect the magnetic field of the coils.

Note that coil A is aligned to one set of magnets on the shaft; therefore the measured value is higher than the other coils measured.

When the coils are not aligned to a shaft magnet assembly, then the measured value is the actual motor inductance value, which is the lowest measured value.

Measuring Step Motors - Nema 17

medindo motores de passo.png

When we talk about the stepper motor, it is interesting to know the DC resistance, inductance, and maximum current.

Practical Test

teste pratico Nema17.png

Here we have the practical test that was shown in the video. This was more for assembly knowledge. But, I advise you not to mount on the protoboard, but rather on the standard board, because this assembly will be a tool that will help you with any engine.

Measuring Step Motors - Large Printer Engine

30.png

Practical Test

31.png

Measuring Step Motors - DVD Driver Engine

34.png

Practical Test

35.png