This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM stability issues (resetting)

I'm using: nrf52832, SDK 15.0, SoftDevice S132 v6.0.

I'm trying to control a motor using an H-Bridge. If I simply do a nrf_gpio_pin_write to set forward/reverse to 1/0 or vice versa, there is no issue. I can change motor directions quickly.

However, I want to control the motor speed as well. When I use PWM outputs to control forward/reverse, the system will crash/reset when I try to change the motor direction. I can add a delay in the code where, between changing direction, I set both forward and reverse to 0 and wait 600ms. When I add this delay, everything works, but I want to minimize or remove this delay (400ms in unstable, 500ms is mostly stable, 600ms is stable).

I've tried two different h-bridge boards with different chips (L9110S with simply forward/reverse and TB6612FNG with 0/1 on forward/reverse and a single PWM input for speed) and have seen the same issue.

Why is the PWM output so much more sensitive to noise/back-emf? And can I do something to avoid it? Or should I be using something other than PWM? (I've tried both the PWM driver and the low power PWM code).

A few notes: I've tried capacitors across the motor. The design requires a single shared power source (batteries). I'm regulating it to 3.3v.

UPDATE: I decided to do my own PWM type code without using the library and had the same problem. I then realized I've been using certain pins for PWM and when I could successfully reverse the motor before, I was using two different pins. After some testing [simply using nrf_gpio_pin_write] pins P0.11 and P0.14 are working for forward/reverse (and combinations using P0.12 and P0.13 are not). I am using a board I bought online, so there's a possibility that it's a factor.

UPDATE 2018-07-24: For testing, I'm just having it alternate forward/reverse every 2 seconds and it will sometimes reset. It might run for 10 seconds, it might run for more than a minute. I thought RTT might give me some insight but I don't see any error info--I do see debug messages I added. Any thoughts on why this is happening are appreciated.

Also, after the chip resets, I've read NRF_POWER->RESETREAS, and I get a value of 0.

Related