SLOA312 December   2021 DRV8412 , DRV8424 , DRV8426 , DRV8428 , DRV8434 , DRV8436 , DRV8803 , DRV8804 , DRV8805 , DRV8806 , DRV8844 , DRV8847 , DRV8932 , DRV8935 , DRV8955

PRODUCTION DATA  

  1.   Trademarks
  2. 1Introduction
  3. 2Principle of Operation
    1. 2.1 Unipolar Stepper Motors
    2. 2.2 Bipolar Stepper Motors
  4. 3How to Drive Unipolar Stepper Motors with DRV8xxx Drivers
    1. 3.1 Driving Unipolar Motor with Four-channel Low-side Driver
    2. 3.2 Driving a Unipolar Motor with a Bipolar Driver
    3. 3.3 Driving Unipolar Motor with Four-channel Half-Bridge Driver
      1. 3.3.1 Driving in Full-step Mode
        1. 3.3.1.1 Full-step Mode with One Phase ON
        2. 3.3.1.2 Two Phases ON
      2. 3.3.2 Driving in Half-step Mode
      3. 3.3.3 Example Pseudocode
        1. 3.3.3.1 Code for Full-step with One Phase ON
        2. 3.3.3.2 Code for Full-step with Two Phase ON
        3. 3.3.3.3 Code for Half-step
  5. 4References

Code for Full-step with One Phase ON

1. /// 0111 1011 1101 1110 // input format for full step one phase ON
2. 
3. int in1 = 8;
4. int in2 = 9;
5. int in3 = 10;
6. int in4 = 11;
7.
8. int i = 0;
9. int freq = 200;
10.       unsigned long t_half =0.5*(1000000/freq);
11.
12.       void setup()
13.       { pinMode(in1, OUTPUT);
14.         pinMode(in2, OUTPUT);
15.         pinMode(in3, OUTPUT);
16.         pinMode(in4, OUTPUT);
17.       }
18.
19.       void loop() {
20.         delayMicroseconds(t_half);
21.         i=i+1;
22.         if (i >=4) {i=0;}
23.        switch(i)
24.        {
25.          case 0:
26.            digitalWrite(in1,LOW);
27.            digitalWrite(in3,HIGH);
28.            digitalWrite(in2,HIGH);
29.            digitalWrite(in4,HIGH);
30.          break;
31.          case 1:
32.            digitalWrite(in1,HIGH);
33.            digitalWrite(in3,LOW);
34.            digitalWrite(in2,HIGH);
35.            digitalWrite(in4,HIGH);
36.          break;
37.          case 2:
38.            digitalWrite(in1,HIGH);
39.            digitalWrite(in3,HIGH);
40.            digitalWrite(in2,LOW);
41.            digitalWrite(in4,HIGH);
42.       break;
43.       case 3:
44.            digitalWrite(in1,HIGH);
45.            digitalWrite(in3,HIGH);
46.            digitalWrite(in2,HIGH);
47.            digitalWrite(in4,LOW);
48.       break;
49.       }
50.      }