Hey ya’ll
Had a question about the DRV8834 Low-Voltage Stepper Motor Driver Carrier
On the product page it says:
Optional pin jumpers
The CONFIG pin on the DRV8834 can be used to select between its default indexer mode, which is intended for controlling stepper motors, and an alternate phase/enable mode that can be used to drive two DC motors. It is not made available by default (to avoid conflicts when using the DRV8834 carrier as a drop-in replacement for our other stepper motor driver carriers), but it can be connected to the pin labeled “(CFG)” by bridging the surface mount jumper indicated in the picture below. A second jumper can be bridged to make the current limit reference voltage available on the pin labeled “(REF)”.
When I power on my circuit as before, with the Config connection bridged, everything works, but the DC motor spins immediately. I have it soldered to B1 / B2 .
My question is how do I control a DC motor when using the DRV8834 in optional config mode as the driver?
Is there a way to switch on/off the rotation and direction of the DC motor and if so, how do I do this in Arduino IDE? I looked through the documentation but didn’t find any examples to go by.
Here is my sketch:
#include <Wire.h>
#include <Qduino.h>
#include “FPS_GT511C3.h”
#include “SoftwareSerial.h”// set up software serial pins for Arduino’s w/ Atmega328P’s
// FPS (TX) is connected to pin 4 (Arduino’s Software RX)
// FPS (RX) is connected through a converter to pin 5 (Arduino’s Software TX)
//FPS_GT511C3 fps(4, 5); // (Arduino SS_RX = pin 4, Arduino SS_TX = pin 5)/If using another Arduino microcontroller, try commenting out line 53 and
uncommenting line 62 due to the limitations listed in the
library’s note => https://www.arduino.cc/en/Reference/softwareSerial . Do
not forget to rewire the connection to the Arduino/// FPS (TX) is connected to pin 10 (Arduino’s Software RX)
// FPS (RX) is connected through a converter to pin 11 (Arduino’s Software TX)
FPS_GT511C3 fps(8, 9); // (Arduino SS_RX = pin 8, Arduino SS_TX = pin 9)// defines pins numbers
const int stepPin = 2;
const int dirPin = 3;
int piezoPin = 12;qduino q; // initialize the library
void setup()
{Serial.begin(9600); //set up Arduino’s hardware serial UART
delay(100);
fps.Open(); //send serial command to initialize fps
fps.SetLED(true); //turn on LED so fps can see fingerprint
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
q.setup();}
void loop()
{
// Identify fingerprint test
if (fps.IsPressFinger())
{
fps.CaptureFinger(false);
int id = fps.Identify1_N();/*Note: GT-521F52 can hold 3000 fingerprint templates GT-521F32 can hold 200 fingerprint templates GT-511C3 can hold 200 fingerprint templates. GT-511C1R can hold 20 fingerprint templates. Make sure to change the id depending on what model you are using */ if (id <200) //<- change id value depending model you are using {//if the fingerprint matches, provide the matching template ID q.setRGB(GREEN); Serial.print("Verified ID:"); Serial.println(id); tone(piezoPin, 1000, 300); delay(100); tone(piezoPin, 2000, 200); delay(100); tone(piezoPin, 1000, 100); digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction // Makes 200 pulses for making one full cycle rotation for(int x = 0; x < 2000; x++) { digitalWrite(stepPin,HIGH); delayMicroseconds(1000); digitalWrite(stepPin,LOW); delayMicroseconds(1000); } delay(1000); digitalWrite(dirPin,HIGH); for(int x = 0; x < 2000; x++) { digitalWrite(stepPin,HIGH); delayMicroseconds(1000); digitalWrite(stepPin,LOW); delayMicroseconds(1000); } } else {//if unable to recognize Serial.println("Finger not found"); tone(piezoPin, 800, 100); delay(100); tone(piezoPin, 600, 200); delay(100); tone(piezoPin, 300, 400); delay(1000); }
}
else
{
Serial.println(“Please press finger”);
}
delay(100);
}
Just to clarify, the sketch works flawlessly with a Stepper motor, but the steppers I have are slightly too weak for my project and I only have mini DC gear motors to work with until the new steppers are in.
Any ideas?