0

I have a BTS7960 h-bridge and I am trying to make a motor to move forward and backward using pwm values. I am using the pi4j library to control the pins.

The pins L_EN and R_EN are initialized as DigitalOutputPins.

Case Study 1
When I am initializing all the R_PWM and L_PWM as DigitalOutputPins the motor can move forward and backward at full speed.

Case Study 2
When I am trying to initialize the R_PWM and L_PWM pins as PwmOutputPins the motor cannot move.

Case Study 3
When I am trying to initialize the R_PWM as DigitalOutputPin and L_PWM as PwmOutputPin the motor moves to one direction only.

It seems that this h-bridge does not work when pin is set to 0 using pwm but it works when pin is set to 0 in digital!

I wonder why this is happening.

If you need to check my source code please see here

  • I do not understand the problem. You should only be applying PWM to one pin at any one time. The other pin should be set low. – joan Dec 8 '18 at 11:09
  • When the other pin is set to low (using DigitalOutputPin) everything is working like a charm but when is set to 0 (using PwmOutputPin) it is not working. I have found a workaround but I am wondering is there any difference between pwm low and digital low values? – LiTTle Dec 8 '18 at 13:08
  • There should be no difference between PWM with duty cycle 0 and setting the pin low. Perhaps this is an unintended feature of the Pi4J implementation. Raise an issue? – joan Dec 8 '18 at 13:20
  • I was reading in a forum that in Arduino it has the same functionality! Please see here (forum.arduino.cc/index.php?topic=148482.0) the answer by dc42. The answer #5 in the sequence, bullet no2. – LiTTle Dec 8 '18 at 15:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.