Hello all, I have an issue with making my linear actuator set-up work. This is the linear actuator that I have:
I have the one with the 150mm stroke and max. speed of 1 mm/s.
Here you can also find some data sheets. But the only sheet I got with the linear actuator said this:
“LINEAR ACTUATOR (BHTGA-SS)
wiring instructions
The four wires on the linear actuator are the switch signal wires,
A group of Red and Blue,
A group of Black and White
Black and white are normally open for the upper switch,
Red and blue are the normally open outlets of the lower switch.
The stepper motor is four wires:
A group of black and green
A group of red and blue”
The linear actuator has 8 wires in total: 4 for the stepper motor (red, blue, black, green) and 4 other wires (I think switch signal wires? : white, blue, red, black).
Here are the other components I am using for my set-up:
| - | power supply (0-30V, 0-10A, brand: Jesverty) |
|---|---|
| - | red and black wires with alligator clips. These wires go in the power supply and can offer power to the set-up |
| - | Arduino Uno |
| - | Twotrees Stepper Motor Driver, TB6600 4A 9-42V Nema 17/23 CNC Control Single Axis Hybrid. |
| - | Xinhuangduo stepper motor linear actuator. Model: BHTGA-SS-150-1. Stroke 150mm. Maximum speed: 1mm/s. Thrust 750N. |
| - | Laptop, with USB-cable to the Arduino |
Now I am having trouble how to wire this (since I have barely any knowledge in this field). This is what I came up with after a lot of trial and error and research:
Wiring the Linear Actuator:
The linear actuator has two groups of wires: one for the switch signals and the other for the stepper motor.
Switch Signal Wires:
Group 1 (Red and Blue):
- Connect the Red wire to PUL+ on the stepper motor driver.
- Connect the Blue wire to a digital input pin on the Arduino (e.g., Pin 11).
Group 2 (Black and White):
- Connect the Black wire to DIR+ on the stepper motor driver.
- Connect the White wire to a different digital input pin on the Arduino (e.g., Pin 12).
Stepper Motor Wires:
- Group 1 (Black and Green):
- Connect the Black wire to the A- on the stepper motor driver.
- Connect the Green wire to the A+ on the stepper motor driver.
- Group 2 (Red and Blue):
- Connect the Red wire to the B- on the stepper motor driver.
- Connect the Blue wire to the B+ on the stepper motor driver.
Connecting to the Stepper Motor Driver:
-
High Voltage (VCC): Connect the positive lead from the power supply to VCC and the negative lead to GND on the stepper motor driver.
-
Signal Wires:
- Connect ENA- to a digital pin on the Arduino (e.g., Pin 8).
- Connect ENA+ to the +5V on the Arduino.
- Connect DIR- to a digital pin on the Arduino (e.g., Pin 9).
- Connect PUL- to a digital pin on the Arduino (e.g., Pin 10).
Microstepping and Current Settings:
- Set the microstepping using the switches on the driver according to your preference. Start with moderate setting of 1/8 micro step, then adjust based on specific needs. (SW1=OFF, SW2=ON, SW3=OFF)
- Set the current using the switches on the driver based on the stepper motor's current rating. In your case, you may start with 2.5A (SW4=OFF, SW5=ON, SW6=ON) and adjust as needed.
Connecting to the Arduino Uno:
- Connect GND on the Arduino to the GND on the stepper motor driver.
Arduino Code:
- Write an Arduino script that controls the linear actuator's movement using the digital pins connected to ENA, DIR, and PUL. Implement the logic for extending and retracting based on your specifications.
Can anyone tell me if this wiring would be sufficient? Because I tried this set-up with a lot of different codes in Arduino and the linear actuator does not retract or extend. I do hear the stepper motor making sounds, but it does not rotate.
Is it likely a wiring issue or a coding issue? An example of a code I have tried is this one (and tried many different codes and adjustments after this one):
#include <AccelStepper.h>
// Define motor connections and parameters
AccelStepper stepper(AccelStepper::DRIVER, 10, 9, 8);
void setup() {
// Set up motor properties
stepper.setMaxSpeed(1000.0); // Set the maximum speed in steps per second (adjust as needed)
stepper.setAcceleration(500.0); // Set the acceleration in steps per second^2 (adjust as needed)
// Set up limit switches
pinMode(11, INPUT_PULLUP); // Pin 11 for the lower limit switch
pinMode(12, INPUT_PULLUP); // Pin 12 for the upper limit switch
}
void loop() {
// Check if the lower limit switch is pressed
if (digitalRead(11) == LOW) {
// Lower limit reached, retract the actuator
stepper.moveTo(0);
while (stepper.distanceToGo() != 0) {
stepper.run();
}
}
// Check if the upper limit switch is pressed
if (digitalRead(12) == LOW) {
// Upper limit reached, extend the actuator
stepper.moveTo(150); // Adjust the target position as needed
while (stepper.distanceToGo() != 0) {
stepper.run();
}
}
}