Hi All,
I have created the library below
https://github.com/digitalbirth/BTS7960AD
BTS7960AD is an Arduino library for controlling a linear actuator using a BTS7960 motor driver module.
I would like to get some insight into how I can control 2 or more actuators at the same time
I would define and initialize the actuators as below.
BTS7960AD actuator1(R_EN, R_PWM, R_IS, L_EN, L_PWM, L_IS, sensor, strokeLength, debug);
BTS7960AD actuator2(R_EN, R_PWM, R_IS, L_EN, L_PWM, L_IS, sensor, strokeLength, debug);
void setup() {
Serial.begin(115200); // setup Serial Monitor to display information
actuator1.init(); // reset actuator EEPROM id's
actuator1.begin(); // set up actuator pins
actuator2.begin();
actuator1.enable(true); // enable driver pins
actuator2.enable(true);
actuator1.calibrate(127); // set min / max actuator values
actuator2.calibrate(127)
}
void loop() {
Serial.println("Extending 50mm full speed");
actuator1.actuateByDistance(strokeLength, 1, 255); //this will complete first
actuator2.actuateByDistance(strokeLength, 1, 255); //then this will start after first has completed
}
To get the actuators moving at the same time, the only way I can think of is to create a loop to set the distance 1mm at a time for each actuator.
But this is why I am here, is there any other way I could do this?
I would ideally like to keep the code in the library rather than the sketch
how can I control both instances in the library? do I set a global variable?