Hello,
We are using the Arduino Motor Shield to control a two-wire linear actuator. We noticed that there is always a 1 second lag between the time that the pins are activated and the time motor actually starts moving. I tested the response time of the actuator by connecting it straight to a battery supply and the motor starts moving right away. What could be causing this lag issue?
The following is the simple sketch being used:
String serialCommand;
String ACTExtend("act_extend");
String ACTRetract("act_retract");
String ACTStop("act_stop");
bool bACTIsMoving = false;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
}
void loop() {
// put your main code here, to run repeatedly:
// if there's any serial available, read it:
while (Serial.available() > 0) {
serialCommand = Serial.readString();
serialCommand.trim();
if(serialCommand == ACTExtend)
{
//forward @ full speed
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at full speed
digitalWrite (LED_BUILTIN, LOW);
}
else if(serialCommand == ACTRetract)
{
//reverse @ full speed
digitalWrite(12, LOW); //Establishes backward direction of Channel A
digitalWrite(9, LOW); //Disengage the Brake for Channel A
analogWrite(3, 255); //Spins the motor on Channel A at half speed
}
else if(serialCommand == ACTStop)
{
//stop moving
digitalWrite(9, HIGH); //Engage the Brake for Channel A
}
}
}
Thanks,
-brian