Dear tec_support,
The wire connections are correct, I even wrote a small validation program to check the all components:
#include <Servo.h>
// Test routine for the X-Y plotter.
// The limit switched are used to active the X & Y steppen motors.
// The servo is toggled when ever the status of the limit switched changes.
Servo penservo; // Pen Servo
//PIN Settings for ORION Board
int X_STEP_PIN = 10;
int X_DIR_PIN = 11;
int X_MIN_PIN = A3; // Limit switch on the left
int X_MAX_PIN = A2; // Limit switch on the right
int Y_STEP_PIN = 9;
int Y_DIR_PIN = 3;
int Y_MIN_PIN = 13; // Limit switch on the bottom
int Y_MAX_PIN = 12; // Limit switch on the top
int SERVO_PIN = A1;
// Default routine to to a step, taken from "GCodeParser\stepper_control.ino"
void do_step(byte STEP_PIN, byte DIR_PIN, byte dir) {
switch (dir << 2 | digitalRead(STEP_PIN) << 1 | digitalRead(DIR_PIN)) {
case 0: /* 0 00 -> 10 */
case 5: /* 1 01 -> 11 */
digitalWrite(STEP_PIN, HIGH);
break;
case 1: /* 0 01 -> 00 */
case 7: /* 1 11 -> 10 */
digitalWrite(DIR_PIN, LOW);
break;
case 2: /* 0 10 -> 11 */
case 4: /* 1 00 -> 01 */
digitalWrite(DIR_PIN, HIGH);
break;
case 3: /* 0 11 -> 01 */
case 6: /* 1 10 -> 00 */
digitalWrite(STEP_PIN, LOW);
break;
}
delayMicroseconds(5);
}
void setup() {
Serial.begin(115200);
penservo.attach(SERVO_PIN);
pinMode(X_STEP_PIN, OUTPUT);
pinMode(X_DIR_PIN, OUTPUT);
pinMode(X_MIN_PIN, INPUT_PULLUP);
pinMode(X_MAX_PIN, INPUT_PULLUP);
pinMode(Y_STEP_PIN, OUTPUT);
pinMode(Y_DIR_PIN, OUTPUT);
pinMode(Y_MIN_PIN, INPUT_PULLUP);
pinMode(Y_MAX_PIN, INPUT_PULLUP);
Serial.println("Start test: Press the limit switches activate the steppen motors X & Y.");
}
int iPrefXmin = 0 ;
int iPrefXmax = 0 ;
int iPrefYmin = 0 ;
int iPrefYmax = 0 ;
int idegs = 70;
void loop() {
// Read limit switches
int iCurXmin = digitalRead (X_MIN_PIN) ;
int iCurXmax = digitalRead (X_MAX_PIN) ;
int iCurYmin = digitalRead (Y_MIN_PIN) ;
int iCurYmax = digitalRead (Y_MAX_PIN) ;
// When left limit switch is pressed move right, also takes in account the right limit switch (will not move to far).
if (iCurXmin == 0 && iCurXmax == 1) do_step(X_STEP_PIN, X_DIR_PIN, 1);
// When right limit switch is pressed move left, also takes in account the left limit switch (will not move to far).
if (iCurXmax == 0 && iCurXmin == 1) do_step(X_STEP_PIN, X_DIR_PIN, 0);
// When bottom limit switch is pressed move up, also takes in account the top limit switch (will not move to far).
if (iCurYmin == 0 && iCurYmax == 1) do_step(Y_STEP_PIN, Y_DIR_PIN, 1);
// When top limit switch is pressed down up, also takes in account the bottom limit switch (will not move to far).
if (iCurYmax == 0 && iCurYmin == 1) do_step(Y_STEP_PIN, Y_DIR_PIN, 0);
// If there is a status change on any of the switches print the current status.
if ((iCurXmin != iPrefXmin) || (iCurXmax != iPrefXmax || iCurYmin != iPrefYmin) || (iCurYmax != iPrefYmax)) {
Serial.print("Limit Switches: X-Min=");
Serial.print(iCurXmin);
Serial.print(", X-Max=");
Serial.print(iCurXmax);
Serial.print(" / Y-Min=");
Serial.print(iCurYmin);
Serial.print(", Y-Max=");
Serial.println(iCurYmax);
//Change the servo a bit
idegs = (idegs==70) ? 110 : 70; // Set either to 70 or 110 degrees
penservo.write(idegs); // Sets the servo position in degrees
//Store current status as previous state
iPrefXmin = iCurXmin ;
iPrefXmax = iCurXmax ;
iPrefYmin = iCurYmin ;
iPrefYmax = iCurYmax ;
}
}
I used the same software you provided earlier, copied sections from it to validate my plotter. All is working well and as expected but not with the firmware you provided. It seems something is wrong with the GCodeParser you provided.
I have tested the GRemote also with the Benbox firmware, this works. But I would really like to have the GCodeParser working.