XY Plotter Serial Control


#1

I’ve built and set-up the XY plotter, and it works fine with mDraw.

Now I’d like to write my own code to control the plotter over serial, just like GCodeParser with GRemote. I compiled and uploaded the GCodeParser using Arduino 1.0.6, but the code gets stuck inside goto_machine_zero(). When using Serial Monitor, I see “init”, but it never reaches “ok”.

The stepper motors never move.

I think the problem is with the default values of X_MIN_PIN, X_STEP_PIN, X_DIR_PIN and Y_MIN_PIN, Y_STEP_PIN, Y_DIR_PIN.

How can I find the correct values for these? Is there a wiring diagram available? Any help is greatly appreciated!


#2

The pin assignments shown in the software guide for the XYPlotter 2 are the following

XDir 11 XStep 8 XMin 23 XMax 22
YDir 12 YStep 12 yMIn 9 YMax 10

These are shown in a screen capture of the GRemote setup page. The Arduino code shows different assignments.

Your best bet to future-proof your build is not to use these magic numbers, however, but use the Makeblock library, the Mdraw XYBot.ino file shows you this method. However, as some other builders here have pointed out, there is a significant code overhead when using the library calls, so magic numbers do win out when it comes to speed.


#3

Thanks Adrian!

Those numbers didn’t work for me, but thanks for the tip. I found the mDraw file XYBot.ino, which uses MeOrion.h from https://github.com/Makeblock-official/Makeblock-Libraries. That contains the following:

MePort_Sig mePort[15] =
{
{ NC, NC }, { 11, 10 }, { 3, 9 }, { 12, 13 }, { 8, 2 },
{ NC, NC }, { A2, A3 }, { A6, A1 }, { A7, A0 }, { 6, 7 },
{ 5, 4 }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC },
};

Which lists the two pins which connect to each port (Port 1 is pins 11 & 10). With that, I figured it out! These are the values that work for me:

int X_STEP_PIN = 10; //X Motor Port 1
int X_DIR_PIN = 11;
int X_MIN_PIN = A3; //X Limit Switches Port 6
int X_MAX_PIN = A2;
int Y_STEP_PIN = 9; //Y Motor Port 2
int Y_DIR_PIN = 3;
int Y_MIN_PIN = 13; //Y limit switches Port 3
int Y_MAX_PIN = 12;


#4

AH, now those numbers are the ones I have in my GCodeParser.ino file, but I wasn’t able to test it as I no longer have the stepper cards set for the GRemote settings. I didn’t want to post them as I wasn’t sure if I had amended the Processing code or the Arduino code.


#5

These images are what I am currently using. They may or may not help you. I too am writing my own software to send commands to the plotter, these images stop me going insane if I leave the project for a few weeks…!


#6