2017年4月15日 星期六

nrf52: Use PWM to control DC motor rotate speed.

DC motor rotate speed is directly proportional  to supply voltage and current. But it is very difficult to use software to control supply voltage and current . So use on/off time to control the DC motor is a better solution.

In my project I use TI DRV8837  to driver. DRV8837  has H-bridge structure to control motor forward/reverse rotate. So just simply add pwm input to DRV8837 then we can control the DC motor rotate speed.

1.Connect three gpio to DRV8837 nSleep , IN1 , IN2 .


2.Config PWM module and connect to IN1,IN2.   

3.Now we can control DC motor rotate speed from 0 to 100% and rotate forward/reverse.



NOTICE!: It very danger when motor change rotate direction because it will shortly to turn both side H-bridge ON.It will need a short dead zone to prevent this situation.Luckily DRV8837 has build- in protection function when both IN1 IN2 are high the output will be low to stop the motor.

Ref:
     1. DRV883x datasheet 
     2. H-bridge
        

沒有留言:

張貼留言

Linux driver: How to enable dynamic debug at booting time for built-in driver.

 Dynamic debug is useful for debug driver, and can be enable by: 1. Mount debug fs #>mount -t debugfs none /sys/kernel/debug 2. Enable dy...