Unable to control Firgelli actuator with ibt-2 controller

Hi,

I’m attempting to extend and retract a Firgelli FA-OS-400 linear actuator using an ibt-2 motor controller and an Arduino Uno. The product page (Optical Feedback Linear Actuators | Firgelli Automations Canada) claims that this actuator should be compatible wth this controller.

My wiring is as follows:

  • 12v battery - and + to the 1st and 2nd terminals on the ibt-2
  • motor + and - to 3rd and 4th terminals on the ibt-2
  • ibt-2 vcc to arduino 5v
  • ibt-2 ground to arduino ground
  • ibt-2 R_EN and L_EN to arduino 5v
  • ibt-2 R_PWM and L_PWM to arduino pins 5 and 6

My code to control the motors is as follows:

int RPWM_Output = 5;
int LPWM_Output = 6;

int dir = 0;

void setup() {
  pinMode(RPWM_Output, OUTPUT);
  pinMode(LPWM_Output, OUTPUT);
  Serial.begin(9600);
  Serial.setTimeout(100);
}
void loop() {
  if (Serial.available()) {
    String ch = Serial.readStringUntil("\n");
    if (ch == "a\n") {
      dir = -1;
    } else if (ch == "b\n") {
      dir = 1;
    }
   analogWrite(LPWM_Output, 0);
   analogWrite(RPWM_Output, 0);
   delay(1000);
  }

  if (dir == -1) {
    // reverse rotation
    int reversePWM = 255;
    analogWrite(LPWM_Output, 0);
    analogWrite(RPWM_Output, reversePWM);
  }
  else if (dir == 1) {
    // forward rotation
    int forwardPWM = 50;
    analogWrite(LPWM_Output, forwardPWM);
    analogWrite(RPWM_Output, 0);
  }
  delay(10);
}

What I would expect this to do is that when “a” is input over serial, the actuator will move in one direction, and when “b” is input, it will move in the reverse direction. Instead, I’m seeing the following behavior:

  • Initially, pressing “a” causes the actuator to begin extending as expected.
  • If I then press “b”, the actuator will retract.
  • However, if I press “a” a second time, the actuator will stop instead of moving upwards, and my multimeter will show 0v going to the motor.
  • If I enter “b” again, the actuator will lower, but inputing “a” a second time will just cause it to stop again.
  • If I restart the Arduino, the motor will extend once, and then the same issue occurs.

Any ideas on how I can get the actuator to extend more than once, without having to restart every time?

Code tags used properly on the first post. Karma++

I do not know what the cause is, but I see you are using big S String.
Many in the arduino world say that this causes grief with memory corruption.

If I were troubleshooting this, I would want to confirm that the results of the serial read are what I expect.

That’s a good point. I tried printing out the direction during each iteration of the loop, and it seems to change correctly in response to inputs, so I’m guessing that’s not the issue.

I also connected a multimeter to the two output pins, and measured the voltages on each of them. The output appears to be correct, so I think the issue is that either I’m not understanding what outputs to send to the motor controller correctly, or that the controller is defective.