GCode Parser Problem?


#1

Hey there i build the x y plotter and with mdraw it works perfectly fine and it really is an awesome product.
But when i load the GCodeParser ino into the Board it seems like the plotter doesnt know where to end. Ill post the code which i use. Maybe i have a wrong setup/GcodeParser im using Plotter v2 with an orion Board.
So when i load the gcodeparser and i want to control it via GRemote it goes into the step init but he just drives against one of the axis without stopping.

Code

`#include <Servo.h>
// define the parameters of our machine.
float X_STEPS_PER_INCH = 48;
float X_STEPS_PER_MM = 40;
int X_MOTOR_STEPS = 100;

float Y_STEPS_PER_INCH = 48;
float Y_STEPS_PER_MM = 40;
int Y_MOTOR_STEPS = 100;

float Z_STEPS_PER_INCH = 48;
float Z_STEPS_PER_MM = 40;
int Z_MOTOR_STEPS = 100;

//our maximum feedrates
long FAST_XY_FEEDRATE = 2000;
long FAST_Z_FEEDRATE = 2000;

// Units in curve section
#define CURVE_SECTION_INCHES 0.019685
#define CURVE_SECTION_MM 0.5

// Set to one if sensor outputs inverting (ie: 1 means open, 0 means closed)
// RepRap opto endstops are not inverting.
int SENSORS_INVERTING = 1;

// How many temperature samples to take. each sample takes about 100 usecs.

/****************************************************************************************

  • digital i/o pin assignment
  • this uses the undocumented feature of Arduino - pins 14-19 correspond to analog 0-5
    ****************************************************************************************/

// Port 1 Uno/Orion
int X_DIR_PIN = 10;
int X_STEP_PIN = 11;

//Port 8 Uno/Orion
int X_MIN_PIN = A0;
int X_MAX_PIN = A7;

// Port 6 Uno/Orion
int Y_DIR_PIN = 3;
int Y_STEP_PIN = 9;

// Port 6 Uno/Orion
int Y_MIN_PIN = A3;
int Y_MAX_PIN = A2;

// Port 7 Uno
// Z_DIR_PIN Not used for mini servo. The pin specified belongs to Port 3 for some reason.
int Z_DIR_PIN = 13;
int Z_STEP_PIN = A1;

// Port 6 Uno/Orion (Duplicate Y_MIN_PIN and Y_MAX_PIN)
int Z_MIN_PIN = A3;
int Z_MAX_PIN = A2;

int X_ENABLE_PIN = 4;
int Y_ENABLE_PIN = 4;
int Z_ENABLE_PIN = 4;
int Z_ENABLE_SERVO = 1;
#define COMMAND_SIZE 128

char commands[COMMAND_SIZE];
byte serial_count;
int no_data = 0;

Servo servo;

int currentPosServo = 90;
int targetPosServo = 90;
bool comment = false;
void setup()
{
//Do startup stuff here
Serial.begin(115200);
if(Z_ENABLE_SERVO==1){
servo.attach(Z_STEP_PIN);
}
//other initialization.
init_process_string();
init_steppers();
process_string(“G90”,3);//Absolute Position
Serial.println(“start”);
}

void loop()
{

char c;
//read in characters if we got them.
if (Serial.available() > 0)
{
	c = Serial.read();
	no_data = 0;
	//newlines are ends of commands.
	if (c != '\n')
	{
		if(c==0x18){
			Serial.println("Grbl 1.0");
		}else{
                      if (c == '('){
                        comment = true;
                      }
                      // If we're not in comment mode, add it to our array.
                      if (!comment)
                      {
                        commands[serial_count] = c;
                				serial_count++;
                      }
                      if (c == ')'){
                        comment = false; // End of comment - start listening again
                      }
                    }
			
	}
}else
{
	no_data++;
	delayMicroseconds(100);

//if theres a pause or we got a real command, do it
if (serial_count && (c == '\n' || no_data > 100))
{
	//process our command!
	process_string(commands, serial_count);
	//clear command.
	init_process_string();
}

//no data?  turn off steppers
if (no_data > 1000){
	disable_steppers();
}
    }

// return;
// delay(5);
// int dPos = abs(currentPosServo-targetPosServo);
// if(currentPosServo<targetPosServo){
// currentPosServo += dPos>8?6:1;
// }else if(currentPosServo>targetPosServo){
// currentPosServo -= dPos>8?6:1;
// }

}`

Maybe you could post your code :slight_smile:
Thanks in advance!


#2

The stepper motor switch settings for mDraw will not be correct for GRemote, for a start, but also there was a change in which axis was designated X and which designated Y which could mean that in gRemote the code is not looking at the right limit switch

The correct motherboard code for mDraw is xybot.ino. Reading this code will show you what you would have to do to change GCodeParser to work properly, but from what I remember discovering, you would also need to make some changes to GRemote as well. This becomes complicated as both the Processing language and the ControlP5 library needed to build GRemote were taken to new version last year, and the GRemote code no longer compiles with the new ControlP5 library. You would need to obtain both Processing2 and the earlier ControlP5 library to rebuild GRemote.

It is probably simplest to stick with mDraw, given that it works.


#3

Thanks for your help!
I assume that im not the only one using GRemote with this robot and i even saw some running projects which work perfectly fine. Are there any other Programms which i can you use to control the plotter via GRemote?

I even found a new Parser called GCodeParser_Makeblock_Orion(XY-Plotter-V2.02)
Since i have the Orion Version this should actually work.
But when i start gremote and select the com port all it say is:
trolP5
port open: COM15
=> oÙ
port reset, sending init sequence
No glyph found for the Ù (\u00EB) character
<= $1 X10 Y9 Z15
=> start
firmware start, sending init sequence
<= $1 X10 Y9 Z15
=> oÙ

But the Plotter isnt moving at all

It looks like i found diffrent pins layouts some are using for the x stepper motor port 1 and for y motor port 2
for me in mdraw it works when i set x stepper motor to port 2 and y to port 1
but when i do so in the parser it still doesnt work

so i changed the x stepper motor to 2 and y to port 1 and changed the code

int X_STEP_PIN = 10;
int X_DIR_PIN = 11;
int X_ENABLE_PIN = -1;
int X_MIN_PIN = A3; //X Limit Switches Port 6
int X_MAX_PIN = A2;

int Y_STEP_PIN = 9;
int Y_DIR_PIN = 3;
int Y_ENABLE_PIN = -1;
int Y_MIN_PIN = 13;
int Y_MAX_PIN = 12;

int Z_STEP_PIN = A1;
int Z_DIR_PIN = -1;
int Z_ENABLE_PIN = -1;
int Z_MIN_PIN = -1;
int Z_MAX_PIN = -1;
int Z_ENABLE_SERVO = 1;

still not able to get my plotter to move with the same text in the cmd line


Application code and Gremote
#4

There is a post in the forums discussing this same topic, pins to use inm GRemote, which might help you

http://forum.makeblock.cc/t/xy-plotter-serial-control/5050


#5

Hi Adrian,

yes i saw exactly this post and changed all the pins as described and shown in this forum post but however i cant get to move the plotter using gremote maybe i would need to change the settings in GRemote it self currently im using these settings

edit changed the settings fitting on the code i currently use

@tec_support
maybe a makeblock employee help?
Maybe you guys got a new parser for me?


#6

You will have to enter the correct pin settings in the GRemote Settings tab each time, yes. You will also have to change the stepper control board switches from HHH to HHL when using GRemote, then change them back to HHH when returning to mDraw.


#7

Hi Adrian

I did all this, i changed the pin Layout and Set the Same settings in gremote but still it Doesnt work i also checked the Stepper settings and Made sure it is Set up correctly at this point im getting frustrated i already tried out different Layouts but i just cant get it to work


#8

I’m a bit puzzled here since you say that mDraw works for you, so why do you want to use GRemote? The only thing I remember it did that mDraw won’t do is stream a file of GCode commands. I don’t think the suppliers support GRemote anyway.


#9

I want to use GCode because i want to use it with a Python Script


#10

So i want to Send a GCode File
I want to Drive around a Board and not Draw anything
I want to use a antenna as the Pen and do some Electronic measurements and I want to Pause the Programm Automaticly so i can then Start a WiFi measurement and then continue after some time.
I will write a Python Script regarding this but first i need to make sure i can Send GCode because i cant do that with mdraw


#11

Since mDraw is already written in Python., it would be simpler to alter the code to allow it to open a file of GCode commands and send them one at a time to the motherboard, which is what I intend to do as my next project.

Incidentally, you can already issue GCode direct to the motherboard from mDraw, it’s a one-line box at the bottom right of mDraw. But it doesn’t clear away the command you issue.


#12

Yeah it would be pretty cool if mdraw has like a Box where you can just GCode or even just Upload a GCode File i don’t know how to do this. I will first try to use another GCode Programm


#13

So i just tried to use the Arduino Seriel Monitor and there i can enter GCode and the plotter will move…
i then tried the Universal Gcode sender there i get an error: Grbl has not finished booting.
pretty strange

Edit okay i fixed it, i set the firmware to TinyG and now im able to send gcode

For User Wondering you may also see this thread


#14