17.Arduino learning notebook - stepper motors experiment

17.Arduino learning notebook - stepper motors experiment


               Juvtmall ( a company supply PCB PrototypingPCBA service and sell kinds of components, modules and so on) ( Catduino has the same function of Arduino) 


Stepper motor is an actuator that converts electrical pulse into angular displacement.
This is the stepper motor used in this experiment


The stepper motor used in the industry is different from this experiment, the following schematic two different types of industrial stepper motor.




Must take a careful look at the instructions before using stepper motor, confirm the four phase or two phase, how to connect each line. This experiment using the stepper motor is four phase, different color lines are defined as follows:

Drive method: (4-1-2 drive)
Wire color
1
2
3
4
5
6
7
8
5 red
+
+
+
+
+
+
+
+
4 orange




3 yellow





2 pink





1 blue





  CCW rotation


The following is the port structure of the motor, port 1,3 for a group; port 2,4 for a group; and port 5 is the common VCC.


Because of the small power of the stepper motor used in this experiment, it can be driven directly by using an ULN2003 chip. If it is a high-power stepper motor, it needs the corresponding drive plate.



ULN2003 is a high-voltage, large current composite transistor array, composed of seven silicon NPN composite transistors. It can be used to drive the stepper motor.
The structure is shown below


The hardware connection diagram is shown below




Download the code to the arduino board to see the effect
ARDUINO CODE
1. / *
2. * the stepping motor is rotated with the potentiometer
3. * (or other sensors) use the analog port 0 for input
4. * use the Stepper. H library file brought by the arduino IDE
5. * /
6. 
7. # include < Stepper. H >
8. 
9. // how many steps are there for the stepper motor to rotate
10.  # define STEPS 100
11. 
12. // attached to, set the steps and pins of the stepper motor
13. Stepper stepper (STEPS, 8, 9, 10, 11);
14. 
15. // define variables is used to store historical readings
16. int previous = 0;
17. 
18. void setup ()
19. {
20. // set the motor speed of 90 steps per minute
21. Stepper. setSpeed (90);
22. }
23. 
24. void loop ()
25. {
26. // obtain the sensor readings
27. int val = analogRead(0);
28. 
29. // mobile steps is the current readings minus the historical readings
30. stepper. step (val - previous);
31. 
32. // save the historical readings
33. previous = val;
34. }


Please contact me:michelle1273110435@gmail.com

评论

此博客中的热门博文

21. Arduino learning notebook-- Experiment of controlling steering engine

20.Arduino learning notebook--Use Arduino Duemilanove to download the bootloader to other chips

19.Arduino learning notebook--Atmega8 makes the minimum arduino system