Hi ,
Im using a DRV8871 with an ESP32 S£ I originally was following the example on the course untill I relised that a DRV8871 does nt have an enable pin and I need to control speed and direction.
My code uses digitalWrite(direction1,HIGH) then
analogWrite(speed1, speedValue) , the output is 0-255 and 255-0 depending on High to Low settings.
Is this the best way to do it , Im driving a 12V motor pulling 1 A and liked the ability in theory of setting frequency which I would have been able to do using the LED** commands as per the course , but having no enable pin I cant work out how I can use these commands or can I set frequency on the analog pin ??
OK I had a play and have answered my own question with the DRV chip just treat the second input as the enable and it works using the LED code as per below .
if ( strcmp(EspCmd, BSPEEDINC) == 0 )
{
digitalWrite(direction1,HIGH);
if ( speedValue > 20 )
{
speedValue=speedValue-20;
ledcWrite(speed1, speedValue) ;
// analogWrite(speed1, speedValue);
Serial.println(“Speeding Up “) ;
Serial.println(speedValue) ;
}
}
You can apply the parameters as per the course notes using , where in my example enable pin is speed1
ledcAttachChannel(enable1Pin, freq, resolution, pwmChannel);