I have two linear actuators that I want to make sure that they are aligned after "homing".
I'm trying to do that using two end-stops (W1_Home & W2_Home), one on each actuator. When one end-stop is reached I want to disable the stepper:
when W1_Home goes LOW > W1_Disable goes HIGH.
So I made a little test program which works (sort of). The output from the serial monitor shows W1_Disable going HIGH, then LOW, then HIGH again and staying there. Same for W2.
Can anyone see why that might be happening?
Hi,
You are using the PULLUP command, that is an internal resistor is between input pin and 5V.
You need to put your Home switches between digital input and GND.
What do the two 10K resistors do?
Instead of calling your variable W1_Disable, you should call it W1_HOME, likewiser with W2, it is more descriptive of what it is.
You do not want to Disable the actuator, just stop it going in the Home direction, you still need to be able to reverse off the Home switch.
Can you please post a link to specs/data of your actuators?
.
I think that the variables are aptly named. W1_Home is one of the endstops @ the "home" position, and the W1_Disable is a pin that "disables" the stepper motor.
I probably should have mentioned that the two actuators are controlled by two stepper controllers but both controllers are stepped by signal (pin) from the Arduino.
Here is what I' am trying to get to happen:
W1 actuator and W2 actuator are running parallel with one another. I'm using W (width) here but think X as in X-Y. So if W1 & W2 get "out of sync" then I want both W1 & W2 to travel toward HOME, if one (W1 or W2) gets to the endstop before the other, I want to disable that motor and continue to drive the other motor to it's endstop, then enable both motors to get ready to travel in the other direction.
I hope I'm am being clear. I have everything else working but I can't seem to workout the homing of two motors using two controllers but only one pin for pulses.
@UKHeliBob
They are to insure that they stay in a stable LOW state until I pull the pins HIGH via W1_Disable = HIGH
Those pins (6 & 7) are connected to the enable/disable connection on the controllers and are pulled HIGH to disable them.
@cattledog This code is based on what I thought to be true; which is that pulling the Enable pin on the controller HIGH would disable the motor. However after reading @JCA34F comment, I'm not sure and getting more confused by the minute! Thanks!
int W1_Home = 2;
int W2_Home = 3;
int W1_Disable = 6;
int W2_Disable = 7;
void setup() {
Serial.begin(9600);
pinMode(W1_Home, INPUT_PULLUP);
pinMode(W2_Home, INPUT_PULLUP);
pinMode(W1_Disable, INPUT);
pinMode(W2_Disable, INPUT);
}
void loop() {
if (digitalRead(W1_Home) == LOW) {
W1_Disable = HIGH; // OR Should it be (digitalWrite(W1_Disable, HIGH)
}
if (digitalRead(W2_Home) == LOW) {
W2_Disable = HIGH;
}
Serial.print("W1");
Serial.print("\t");
Serial.print(digitalRead(W1_Home));
Serial.print("\t");
Serial.print(digitalRead(W1_Disable));
Serial.print("\t");
Serial.print("\t");
Serial.print("W2");
Serial.print("\t");
Serial.print(digitalRead(W2_Home));
Serial.print("\t");
Serial.println(digitalRead(W2_Disable));
}
If you write an input pin HIGH it will only turn on the internal pullup resistor (about 30k) so 30k in series with a 10k pulldown resistor will put about 1.25V on the DM542T enable pin, too low for a HIGH.
Remove the 10k resistors and set the W1 and W2 disable pins to:
If I were doing that, I would just stop stepping in that direction when the switch is tripped, then step backward until the switch is cleared and call that home. You may have to back step the other motor a different number of steps to get them exactly even.
There are many homing algorithms in the Arduino help sites.
Search "Arduino stepper homing".
And please post your complete code. TNX
Thank you, however, That still doesn't work. I'm obviously missing something in the code, but I can't for the life of me figure out why this doesn't work!
Also, the below works when I set the switching voltage to 5v, tie the ENA+ to 5v, and just physically connect the ENA- to GND. That WILL disable the stepper!