Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
674 changes: 533 additions & 141 deletions firmware/command.cpp

Large diffs are not rendered by default.

69 changes: 23 additions & 46 deletions firmware/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,31 @@
#include "globals.h"

struct Command {
Command * next;
char cmd_class;
uint8_t cmd_id;
uint16_t x,
y,
e,
f;
int16_t i,
j;
Command() {
this->cmd_class = '?';
this->cmd_id = 0;
this->x = 0;
this->y = 0;
this->e = 0;
this->f = modal_feedrate;
this->i = 0;
this->j = 0;
this->next = NULL;
}
Command( char * buf );
Command( uint16_t x, uint16_t y, uint16_t e, uint16_t f ) {
this->cmd_class = '?';
this->cmd_id = 0;
this->x = x;
this->y = y;
this->e = e;
this->f = f;
this->i = 0;
this->j = 0;
this->next = NULL;
}
Command( uint16_t x, uint16_t y, uint16_t e, uint16_t f, int16_t i, int16_t j ) {
this->cmd_class = '?';
this->cmd_id = 0;
this->x = x;
this->y = y;
this->e = e;
this->f = f;
this->i = i;
this->j = j;
this->next = NULL;
}
uint8_t execute();
Command * next;
char cmd_class;
uint8_t s,p,
cmd_id;
#ifdef Z_DRIVER_ENABLED
int32_t z;
#endif
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below, please annotate #endifs with the conditions that they're ending, i.e., change this one to:

#endif // Z_DRIVER_ENABLED

int32_t x,
y;
#ifdef E_DRIVER_ENABLED
int32_t e;
#endif
uint16_t f;
int16_t c;
//#ifdef SUPPORTARCMOVES
int32_t i,
j;
//#endif
Command( char * buf );
uint8_t execute();
};

void print_command( HardwareSerial s, Command * c );
void parse_g_command( Command * c, char **buf_ptr, char *line );


void parse_m_command( Command * c, char **buf_ptr, char *line );
void report_position();
void parseOutParameters(Command * c, char **buf_ptr);
#endif
117 changes: 111 additions & 6 deletions firmware/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,133 @@
#define CONST_H

#include <Arduino.h>

//#define HOMEONSTART
#define BAUDRATE 115200
#define EASYCNCCONTROLLER
#ifdef EASYCNCCONTROLLER
#define EASYCNC_BUSY 4
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent these

#define EASYCNC_IDLE 0
#endif
//#define DEBUG_MOVE
//#define DEBUG_OUTPUT
//#define DEBUG_EXECUTE
//#define DEBUG_QUEUE
//#define DEBUG_CURVE
//#define DEBUG_SERIAL
//#define DEBUG_POWER

#define STEPS_PER_MM ( 1600l / 15 )
#define UM_PER_STEP ( 15000l / 1600l )
// MOTHERBOARDS
// 1 = RAMPS14
// 2 = GRBL

//#define CNCBOARD RAMPS14
#define MOTHERBOARD 1
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#define a constant for RAMPS14 and GRBL so that we can use those instead of the magic numbers of "1" and "2".

//
#define LASERPRUSA
//#define CNCTesla


#define HOMESPEED 1000
#define Z_DRIVER_ENABLED

//#define E_DRIVER_ENABLED

#define SUPPORTLINENUMBERING
# define SUPPORTARCMOVES
// shut laser Off when stopping
#define LASERRESETSTOZERO
#define MAXSPEED 1000

// Models
// 1 = belts
// 2 = drives
#define DRIVEMODEL 1
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, some additional defines to avoid magic numbers won't hurt anything.


#if DRIVEMODEL == 1
#define HOMEDELAY 10
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to be a rate? We should add an explanatory comment.

#define MAXSPEED 5000
//#define STEPS_PER_MM ( 106.67 )
//#define STEPS_PER_MM ( 53.335 )
#define STEPS_PER_MM 100l
#define XSTEPS_PER_MM 100l
#define YSTEPS_PER_MM 100l
#define ESTEPS_PER_MM 100l
#ifdef Z_DRIVER_ENABLED
#define ZSTEPS_PER_MM 100l
#endif
#endif

#if DRIVEMODEL == 2
#define HOMEDELAY 1
#define MAXSPEED 50000
//#define STEPS_PER_MM ( 200.0 )
#define STEPS_PER_MM 800l
#define XSTEPS_PER_MM 800l
#define YSTEPS_PER_MM 800l
#define ESTEPS_PER_MM 100l
#ifdef Z_DRIVER_ENABLED
#define ZSTEPS_PER_MM 1600l
#endif
#endif



#define MAX_X 53 * STEPS_PER_MM
#define MAX_Y 100 * STEPS_PER_MM
//#define UM_PER_STEP ( 15000l / 1600l )

#ifdef LASERPRUSA
#define MAX_X 320l * XSTEPS_PER_MM
#define MAX_Y 630l * YSTEPS_PER_MM
#define MAX_Z 500l * ZSTEPS_PER_MM
#endif


#ifdef CNCTesla
#define MAX_X 190l * XSTEPS_PER_MM
#define MAX_Y 250l * YSTEPS_PER_MM
#define MAX_Z 100l * ZSTEPS_PER_MM
#endif

#if MOTHERBOARD == 1
#define BUFFER_SIZE 1024
#define QUEUESIZE 2
#endif


#if MOTHERBOARD == 2
#define BUFFER_SIZE 512
#define QUEUESIZE 2
#endif


//#define INVERSE_X
//#define INVERSE_Y
//#define INVERSE_Z

#ifdef INVERSE_X
#define X_POS LOW
#define X_NEG HIGH

#else
#define X_POS HIGH
#define X_NEG LOW
#endif

#ifdef INVERSE_Y
#define Y_POS LOW
#define Y_NEG HIGH
#else
#define Y_POS HIGH
#define Y_NEG LOW
#endif

#ifdef INVERSE_Z
#define Z_POS LOW
#define Z_NEG HIGH
#else
#define Z_POS HIGH
#define Z_NEG LOW
#endif
// Higher numbers give higher max speed, but also higher min speed...
#define RATE_FACTOR 10l
#define RATE_FACTOR 100l

#endif
Loading