Xunwei 4412 development board-stepper motor-drive and test routines

Xunwei 4412 development board-stepper motor-driver and test routines
and the supporting information of this document are:
1 kernel configuration and stepper motor driver patch package:
topeet_modules_20190319.tar.gz
2 linux-C test routine:
iTOP- 4412-linuxc-stepmotor_V1.0.zip
3 QtE test routine:
iTOP-4412-QtE4.7-step_moter_V1.0.tar
4 Android test routine:
iTOP-4412-Android4.0-stepmotortest-V1.0. zip
Please note that there is no stepper motor driver in the core source code of the CD. You need to add a stepper motor driver before you can use it. The stepper motor uses the IO on the camera interface, and the camera driver needs to be shielded.
1. Hardware connection The
hardware connection is divided into two parts, power supply and control line connection.
As shown in the figure below, it is the schematic diagram of the stepper motor.
Xunwei 4412 development board-stepper motor-drive and test routines
It can be seen from the terminal j2 that the cable and the camera interface of the development board are required. In the right half of the above figure, it can be seen that the power supply can be 5v power supply or usb power supply.
Wire the connection, as shown in the figure below. Choose one of the AC adapter and USB line power supply, as shown in the figure below, it is the USB line power supply.
Xunwei 4412 development board-stepper motor-drive and test routines
It must be noted here that if you are using the default CD kernel image, please do not power on the stepper motor for too long. Because the stepper motor driver chip is pulled up by default, it will cause the stepper motor to be in an abnormal state and cause the motor to heat up.
After the stepping motor drive configuration is completed, when the stepping motor drive is initialized, the drive chip of the stepping motor is pulled down, so that the stepping motor will be in a state of preparation. In this state, there will be no current and no Cause the stepper motor to heat up!
2. The kernel configuration and patch package
can be known from the hardware part. The stepper motor uses the camera interface. The default state of the kernel will compile the camera driver. The camera driver will occupy the four GPIOs used by the motor, so you need to set the camera in the kernel configuration. Drive removed. Then add the driver patch package, recompile the kernel, and burn it into the kernel.
2.1 Kernel configuration
Enter the kernel directory, configure the required default files, use the command "make menuconfig", as shown in the figure below, to enter the configuration interface.
Select "Device Drivers --->" to enter.
Xunwei 4412 development board-stepper motor-drive and test routines
As shown in the figure below, select "Multimedia support --->" to enter the options.
Xunwei 4412 development board-stepper motor-drive and test routines
As shown in the figure below, enter the "Video capture adapters --->" option.
Xunwei 4412 development board-stepper motor-drive and test routines
As shown in the figure below, cancel "OmniVision OV5640 sensor support", this is the configuration option of the camera ov5640.
Xunwei 4412 development board-stepper motor-drive and test routines
As shown in the figure above, cancel the ov5640 option, then save and exit, and get a new .config file.
2.2 Modify the Makefile
and then need to modify the Makefile.
Open the "drivers/char/Makefile" file, as shown in the figure below.
Add the following code:
obj-y += topeet_modules/
Xunwei 4412 development board-stepper motor-drive and test routines
and save and exit.
2.3 Patch package
The driver patch package "topeet_modules_20190319.tar.gz" is put together with the documentation.
The patch package is also placed under "topeet_modules_20190319.tar.gz" in the network disk link "iTOP4412 development board information summary (not including CD content)\iTOP-4412 development board system source code and image (other)\topeet_modules", date There may be changes, just use the latest compressed package.
Copy to the "drivers/char" directory and use the command "tar -vxftopeet_modules_20190319.tar.gz" to decompress, as shown in the figure below.
Xunwei 4412 development board-stepper motor-drive and test routines
2.4 Kernel compilation and testing
Recompile the kernel, burn it to the development board, and start the development board, as shown in the figure below. In the "/dev" directory, you can see the device node "step_motor_driver" is generated.
Xunwei 4412 development board-stepper motor-drive and test routines
At this point, the kernel driver configuration is complete. At this time, power on the stepper motor, and you will find that the four small lights side by side have gone out.
3. The test routine of Linux-C
and then copy the "step_motor_app" file in the "iTOP-4412-linuxc-stepmotor_V1.0.zip" compressed package packaged with this document to the development board (U disk, tf card or nfs can be used ).
As shown in the figure below, copied to the development board, the author's system is the smallest Linux system. If it is an Android system, you need to use "chmod 777 /dev/step_motor_driver" to modify permissions.
Xunwei 4412 development board-stepper motor-drive and test routines
Use the command "./step_motor_app" as shown in the figure below, you can see the following prompts.
Xunwei 4412 development board-stepper motor-drive and test routines
The test routine of the stepper motor needs to pass parameters.
The first parameter is R or L, which is used to set the direction of the stepper motor;
The second parameter is the step angle distance. The step angle distance is 5.625/64 degrees. 4096 step angle distances are 360 ​​degrees, so the range of this parameter is 0-4096, the value of 4096 is one circle, and the minimum recommended is 10.
The third parameter is the speed. The recommended value is between 3000 and 20000. The speed is unstable if it is less than 3000. A demon is provided as "./step_motor_app R 4076 3000".
Using the command "./step_motor_app R 4076 3000", you can see that the stepper motor is turning right and it will stop after one turn, and "./step_motor_app L 4076 3000" will stop after turning left and the user can perform the test Other parameters.
Xunwei 4412 development board-stepper motor-drive and test routines
4. The test routine of QtE4.7 is
packaged with this document "iTOP-4412-QtE4.7-step_moter_V1.0" is the test source resource package of QtE4.7, and the "step_moter" in the source code is the compilation of stepper motor Good qt4.7 program.
Please note that you need to refer to the second section of this document to configure the kernel driver first, and confirm that there is a device node "/dev/step_motor_driver".
The development board burns the QtE4.7 system, copy "step_moter" to the development board, and use the command "./step_moter&" to run, as shown in the figure below.
Xunwei 4412 development board-stepper motor-drive and test routines
In the above interface, the parameters are as follows:
Speed: The speed is controlled by changing the delay. The shorter the delay, the faster the speed. Delay range: 3--20ms.
Num: Set the number of steps, when the value is 4096, one revolution.
Direction: Set the direction of rotation. RIGHT means forward rotation, LEFT means reverse rotation.
START: After setting, click START to start running.
CLOSE: Close the current page.
5.
Android4.0.3 routine test "iTOP-4412-Android4.0-stepmotortest-V1.0.zip" is the test source resource package of Android4.0.3, "stepmotortest.apk" under "bin" in the source package Compiled Android4.0.3 program for stepper motor.
Please note that you need to refer to the second section of this document to configure the kernel driver first, and confirm that there is a device node "/dev/step_motor_driver", as shown in the figure below.
Xunwei 4412 development board-stepper motor-drive and test routines
Enter the command "chmod 777 /dev/step_motor_driver" in the console to modify the permissions.
Xunwei 4412 development board-stepper motor-drive and test routines
Enter the command "chmod 777 /dev/step_motor_driver" in the console to modify the permissions.
Xunwei 4412 development board-stepper motor-drive and test routines
Speed: The speed is controlled by changing the delay. The greater the speed setting, the faster the speed, but it cannot be set to 20.
Steps: Set the number of steps, when the value is 4096, one revolution.
Direction: Set the direction of rotation.
START: After setting, click START to start running.

Guess you like

Origin blog.51cto.com/13962589/2541564