Electronic – How to get right voltage output with Bts7960b H-Bridge

#nodemcudc motorh-bridgemotordrivervoltage

I am using a NodeMCU to control a BTS7960b motor driver. (datasheet of the BTS7960)
This driver controls a 12v dc motor. This image shows my wiring (without the display and the buttons and with a NodeMCU instead of the Arduino nano).

My problem is, when the driver is set to maximum speed (the pins L_EN and R_EN set to high, as well as either LPWM or RPWN to 255 [pin naming visible on this page]) the output voltage to the motor is consistently only 3v instead of 12v. Because of that my 180 RPM high torque motor just runs with about ~42 RPM.
Decreasing the speed also decreases the output voltage. E.g. setting the speed to 150 decreases the voltage to ~1.8v.
It doesn't matter in which direction the motor is turning.

The motor, NodeMCU and driver are powered by the same power supply with a buck converter. I get the same behavior with 3.3v and 5v on the NodeMCU and the driver.
What am I doing wrong?

Thanks for the help! 🙂

Best Answer

Thanks to the hints of @Peter Karlsen I figured it out:

I was used to the 8 bit resolution for PMW of the Arduino boards. But since my NodeMCU uses an ESP8266 Chip the PMW resolution is 10 bit [reference]. So the max value is not 255 but 1023.

Changing the values in my code solved the problem.