Hi @chuckmcknight, in my code I’m using the steppers from the XY Plotter but instead of a pencil or a laser I’m using a pump connected via a Me Dual DC Motor Driver.
Here is my code:
#include "MeAuriga.h"
MeDCMotor pump2(PORT_4);
MeLimitSwitch x_limitSwitchMin(PORT_7, SLOT1);
MeLimitSwitch x_limitSwitchMax(PORT_7, SLOT2);
MeLimitSwitch y_limitSwitchMin(PORT_8, SLOT1);
MeLimitSwitch y_limitSwitchMax(PORT_8, SLOT2);
MeLimitSwitch y_limitSwitchMinScaffale(PORT_9, SLOT1);
MeLimitSwitch y_limitSwitchMaxScaffale(PORT_9, SLOT2);
===================
pump2.run(255);
while
(
!x_limitSwitchMax.touched() &&
!(y_limitSwitchMax.touched() || y_limitSwitchMaxScaffale.touched())
) {
/*
MOVE UP
*/
while (!y_limitSwitchMax.touched() && !y_limitSwitchMaxScaffale.touched()) {
checkYLimitSwitchMax();
}
/*
MOVE RIGHT
*/
int initialPosition = x_stepper.currentPosition();
while (!x_limitSwitchMax.touched() && x_stepper.currentPosition() != (initialPosition - 400)) {
checkXLimitSwitchMax(initialPosition);
}
/*
MOVE DOWN
*/
while (!y_limitSwitchMin.touched() && !y_limitSwitchMinScaffale.touched()) {
checkYLimitSwitchMin();
}
/*
MOVE RIGHT
*/
initialPosition = x_stepper.currentPosition();
while (!x_limitSwitchMax.touched() && x_stepper.currentPosition() != (initialPosition - 400)) {
checkXLimitSwitchMax(initialPosition);
}
}
pump2.stop();
==================
void checkYLimitSwitchMax() {
//Serial.println("checkYLimitSwitchMax");
if ((!y_limitSwitchMax.touched() && !y_limitSwitchMaxScaffale.touched())) {
moveUpStepper();
}
}
void moveUpStepper() {
stopXStepper();
restoreYStepper();
y_stepper.move(-10);
y_stepper.run();
checkYLimitSwitchMax();
}
void checkYLimitSwitchMin() {
if (!y_limitSwitchMin.touched() && !y_limitSwitchMinScaffale.touched()) {
moveDownStepper();
}
}
void moveDownStepper() {
stopXStepper();
restoreYStepper();
y_stepper.move(10);
y_stepper.run();
checkYLimitSwitchMin();
}
void checkXLimitSwitchMax(int initialPosition) {
if (!x_limitSwitchMax.touched() && x_stepper.currentPosition() != (initialPosition - 400)) {
moveRightStepper(initialPosition);
}
}
void moveRightStepper(int initialPosition) {
restoreXStepper();
stopYStepper();
x_stepper.move(-10);
x_stepper.run();
checkXLimitSwitchMax(initialPosition);
}
If launched, the y_stepper motor stops while moving, it makes a strage noise (like if there’s an obstacle and can’t go on) and the board crashes and reboots.
If you comment the pump2.run() method, everything works fine.
The MeAuriga is connected to current via Wall Adapter 12V 3A (http://amzn.eu/iLlSa0j) .
Please let me know,
Diego