Ardunio uno, L293D motor driver, IRF520 and linear actuator

Good day everyone! Can anyone help me integrate (code) the extend and retract of 12V linear actuator with this schematic diagram and code. i want to extend the actuator automatically after the car not moving for 3 seconds and the retract the actuator after 10 seconds.

code of the movement of the car only.

#include <AFMotor.h>

//initial motors pin

AF_DCMotor motor2(2, MOTOR12_1KHZ); 
AF_DCMotor motor3(3, MOTOR34_1KHZ);


char command; 

void setup() 
{       
  Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
}

void loop(){
  if(Serial.available() > 0){ 
    command = Serial.read(); 
    Stop(); //initialize with motors stoped
    //Change pin mode only if new command is different from previous.   
    //Serial.println(command);
    switch(command){
    case 'F':  
      forward();
      break;
    case 'B':  
       back();
      break;
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    }
  } 
}

void forward()
{
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255);//Define maximum velocity
  motor3.run(FORWARD); //rotate the motor clockwise
  
}

void back()
{
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(BACKWARD); //rotate the motor anti-clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(FORWARD);  //rotate the motor clockwise
}

void right()
{
  motor2.setSpeed(255); //Define maximum velocity
  motor2.run(FORWARD); //rotate the motor clockwise
  motor3.setSpeed(255); //Define maximum velocity
  motor3.run(BACKWARD); //rotate the motor anti-clockwise
} 

void Stop()
{
  motor2.setSpeed(0); //Define minimum velocity
  motor2.run(RELEASE); //rotate the motor clockwise
  motor3.setSpeed(0); //Define minimum velocity
  motor3.run(RELEASE); //stop the motor when release the button
}

Make a test code for the actuator and make sure You master it. Then integrate it into the car moving code.

1 Like

Post a link to the IRF520 module.

The IRF520 alone is a poor choice for Arduino, because it is not a logic level MOSFET. To turn it on fully, 10V must be applied to the gate, so some support circuitry is required.

Hi, here's the link.
https://shp.ee/fiekg9v

That MOSFET module won't work well. Maybe light a few LEDs, but certainly not useful to control high current motors.

This module uses a logic level MOSFET that can handle motors up to 3.6 Amperes, which is probably not enough for a typical linear actuator. Check the stall current rating of yours, as the motor driver has to be able to handle that. The linear actuators I use require 7 A @ 12V to start moving.

What if i use this? Tb6612fng
https://shp.ee/87hqv9i

As the product page clearly states, that motor driver can handle 1 A continuous duty.

What is the start/stall current of your linear actuator?

Here is theLinear actuator.

What does the actuator data sheet tell you about the start/stall current?

I cant find the data sheet on the internet. All i have is that data attach o the linear acuator

Actually have more than enough if you use your Ohmmeter to measure the resistance of the motor. disconnected from the project, and use Ohms law to compute the current through that resistance.

I cant find the data sheet on the internet.

The very first hit using the search phrase "la-m-12 linear actuator data sheet" turned up this data sheet.

If that is the correct one, the maximum current draw is stated to be 5 Amperes at 12V, but I assume that is the maximum loaded current, not the start/stall current.

However, 5A will quickly burn out out the actuator if under heavy load. Pay strict attention to the duty cycle ratings stated elsewhere in the data sheet.

I recommend using a motor driver that can handle at least 7 Amperes maximum. This is one such, which can handle 9 A peak if wired in single channel mode.


On the right is my linear actuator

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.