WHAT ENGINE IS THAT? - Step Motor Laboratory



Posted in TechnologyCnc

Introduction: WHAT ENGINE IS THAT? - Step Motor Laboratory

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects. New tutorials on Tuesdays and Fridays.

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.

Step 1: Resources Used

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

Step 2: Assembly

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.

Step 3: Display Mounting

Step 4: Display Connections

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

Step 5: Mounting the DRV8825

Step 6: DRV8825 Connections

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

Step 7: Connecting the Potentiometers

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.

Step 8: How to Calibrate Data Entry

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.

Step 9: 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.

Step 10: Global Declarations

Here are some variables.

Step 11: Global Functions

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.

Step 12: Settings

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.

Step 13: Task1

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.

Step 14: Task2

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.

Step 15: Measuring the Inductance of Step Motors

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.

Step 16: Why Is There a Difference Between the Coils?

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.

Step 17: Measuring Step Motors - Nema 17

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

Step 18: Practical Test

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.

Step 19: Measuring Step Motors - Large Printer Engine

Step 20: Practical Test

Step 21: Measuring Step Motors - DVD Driver Engine

Step 22: Practical Test



    • Microcontroller Contest

      Microcontroller Contest
    • Science of Cooking

      Science of Cooking
    • Spotless Contest

      Spotless Contest

    We have a be nice policy.
    Please be positive and constructive.