This quick and dirty controller is designed for an esp32 devkit v4 board (az_delivery) using an optical encoder and an external stepper or servo controller.
This requires minium of 4 pins for step, dir, encoder_a, encoder_b signals. This is the simplest and most basic controller and it may have bugs. Use at your own risk. PR's and questions (via issues) welcome.
The main.cpp
file contains most of the configuration
The items below need to be updated in the file.
int motor_steps = 200;
int microstepping = 8;
int reduction = 40; // This is the indexer gear reduction
int hob_encoder_resolution = 2400;
bool dir = 1; // this controls the motor direction
int led = 25; // the LED pin
#define dirPinStepper 12
#define enablePinStepper 26
#define stepPinStepper 13
int stepper_speed = 150000;
Encoder.cpp requires the A and B encoder pins as well as the pulses per revolution. PPR is the 3rd argument of the initializer for the Encoder class.
int EA = 17;
int EB = 16;
Encoder encoder = Encoder(EA, EB, 600);
To configure the tooth count connect to serial and paste teeth=N
where N is the number of teeth for the gear.
Board
PCB