Pages

Friday, 17 July 2020

Notes about step motor ROHS 28BYJ-48

1 Key parameters



  • stripe angle is 5.625°/64, which means:
    • the motor has a step angle of 5.625°
    • the output shaft is driven by a 64:1 gear ratio.
So, for the motor to rotate 360°,it needs (360/5.625)=64 steps. For the output shaft to rotate 360°, it needs 64*64 = 4096 steps, and every step is (360/4096)=0.088°. 



Usually, we care more about the output shaft. 

  • RPM is about 15 rpm
    • so it runs at most (15*4096/60) = 1024 steps per second.
    • Also means, one step needs at least (1/1024) = 0.98 ms. 
  • Step sequences
    • Step 1, Orange: 0, Yellow: 1, Pink:  1 Blue:  1
    • Step 2, Orange: 0Yellow: 0, Pink:  1 Blue:  1
    • Step 3, Orange: 1Yellow: 0, Pink:  1 Blue:  1
    • Step 4, Orange: 1Yellow: 0, Pink:  0 Blue:  1
    • Step 5, Orange: 1Yellow: 1, Pink:  0 Blue:  1
    • Step 6, Orange: 1Yellow: 1, Pink:  0 Blue:  0
    • Step 7, Orange: 1Yellow: 1, Pink:  1 Blue:  0
    • Step 8, Orange: 0Yellow: 1, Pink:  1 Blue:  0
If we connect (orange, yellow, pink, blue) to the lower 4 bits (bit:3, bit:2, bit:1, bit: 0) of a 8bits port, then the steps can be easily represented by [0x07, 0x03, 0x0B, 0x09, 0x0D, 0x0C, 0x0E, 0x06]

  • Drive Voltage: 5V
    • This motor needs a big current, so Arduino cannot drive it directly. Instead, usually, a ULN2003 chip works as a middle man between Arduino and the motor.

2 Example code in C

Let's assume the connection is as : 




        unsigned char steps[8] = {
                0x07, 0x03, 0x0B, 0x09, 0x0D, 0x0C, 0x0E, 0x06
        };

        DDRB |= 0xF;
        while(1){
                int i=0;
                for(i=0; i<8; i++){
                        PORTB = (PORTB & 0xF0) | steps[i];
                        _delay_ms(1);
                }
                 }

In this example, every step takes 1ms, so the motor runs 360° every (4096*1)=4096ms=4s.

3. Need a driver?

A motor driver is easy to write as long as the principle is in your mind. An important thing to consider is to use a timer-interrupt to drive the motor instead of _delay_ms(1).

I Will update when I finish one.

No comments:

Post a Comment