I'm struggling with this project to the point I ended up buying an oscilloscope. I'm far from being an electronics expert but am an old mechanical engineer. I'm working on using a 12V bilge pump as a water pump for a nutrient tank for a hydroponic system. The wiring component is quite simple once you know that in order to turn the pump in one direction, the other direction is also required otherwise the controller does not work (10 hours of life gone) There are 2 signals needed for the right direction and 2 for the left direction (that never gets used for a pump but the BTS7960 will not work when disconnected). I'm using the <BTS7960.h> library to create some sketches for testing with an Uno R3, Nano, and D1Mini. The problem I have with the D1 mini is the PWM signal isn't long enough for the motor to function at all. The sketch works great with the Uno and Nano. I do have to use different pins for the different controllers
Obviously, I'd prefer to use the Di for the controller as I also have 3 flow meters attached to the output that will be used to control the pump speed through Home Assistant.
For the Nano
Controller Pin6 R_PWM - analogWrite(Pin, Speed) Right Turn PWM input to controller (required)
Controller Pin7 R_EN - digitalWrite(GPIO, HIGH or LOW) output Digital H to enable, Low to disable (required)
Controller Pin9 L_PWM - analogWrite(Pin, Speed) Left Turn PWM input to controller (required)
Controller Pin8 L_EN - digitalWrite(GPIO, HIGH or LOW) output Digital H to enable, Low to disable (required)
For the D1 Mini
Controller D0 Pin 16 R_PWM - analogWrite(Pin, Speed) Right Turn PWM input to controller (required)
Controller D3 Pin 0 R_EN - digitalWrite(GPIO, HIGH or LOW) output Digital H to enable, Low to disable (required)
Controller D4 Pin 2 L_PWM - analogWrite(Pin, Speed) Left Turn PWM input to controller (required)
Controller D5 Pin 14 L_EN - digitalWrite(GPIO, HIGH or LOW) output Digital H to enable, Low to disable (required)
The sketch runs waiting for an input from the user to manually set the PWM speed between -255 and 0 for
#include <BTS7960.h>
// Sketch for D1Mini Working with new pins 03/26/21
/***************************************************
Copyright (c) 2019 Luis Llamas
(www.luisllamas.es)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License
****************************************************/
// PINOUT
/*
WeMos Arduino C Pin BTS7960
D0 16 R_PWM (1)
D1 5 SCL (Serial Clock)
D2 4 SDA (Serial Data)
D3 0 R_EN (3)
D4 2 L_PWM (2)
D5 14 L_EN (4)
D6 12
D7 13
D8 15
TX 1
RX 3
*/
BTS7960 m1(16,2,0,14);
int speed = 0;
void setup()
{
Serial.begin(9600);
Serial.println("Be sure to enable 'No line ending' in Monitor window");
// analogWriteFreq(36790); Didn't work
}
void loop()
{
Serial.println("Enter Pump Speed Negative for Left, Positive for Right");
Serial.println("between -255 and 255. Anything else to stop");
while (Serial.available() == 0)
{
}
speed = Serial.parseInt();
if (speed <0){
Serial.print("Setting Motor Speed to left at ");
Serial.println(speed);
Serial.println();
}
else {
Serial.print("Setting Motor Speed to right at ");
Serial.println(speed);
Serial.println();
}
if (speed >= -255 && speed <= 255){
m1.enable();
m1.setSpeed(speed);
}
else
{
Serial.println("Pump Stopped");
m1.stop();
m1.disable();
delay(2000);
}
}
In the image you can see the timings of the signals and that is what I'm struggling with. The Signal for the D1 mini is way too short and I'm asking for some help.
