Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Commit

Permalink
Merge branch 'dev' into v6.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
i-make-robots committed Jun 27, 2018
2 parents ae9023e + 7479e1a commit d65f1cf
Show file tree
Hide file tree
Showing 13 changed files with 372 additions and 128 deletions.
32 changes: 26 additions & 6 deletions Makelangelo-firmware.ino
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ void set_tool_offset(int toolID, float *pos) {


/**
* @param results array of NUM_AXIES floats
* @return the position + active tool offset
*/
void get_end_plus_offset(float *results) {
Expand Down Expand Up @@ -697,11 +698,22 @@ void parseMessage() {
#endif
}

/**
* M203 X2000 Y5000 Z200 etc...
* adjust the max feedrate of each axis
*/
void adjustMaxFeedRates() {
int i;
for(i=0;i<NUM_MOTORS;++i) {
maxFeedRate[i] = parseNumber(MotorNames[i], maxFeedRate[i]);
}
}

/**
* M226 P[a] S[b]
* Wait for pin a to be in state b (1 or 0). if P or S are missing, wait for user to press click wheel on LCD
* Command is ignored if there is no LCD panel (and no button to press)
* Wait for pin a to be in state b (1 or 0).
* If there is an LCD and P or S are missing, wait for user to press click wheel on LCD.
* If there is no LCD, P must be specified.
*/
void pauseForUserInput() {
wait_for_empty_segment_buffer();
Expand Down Expand Up @@ -759,6 +771,8 @@ void processCommand() {
case 6: toolChange(parseNumber('T', current_tool)); break;
case 17: motor_engage(); break;
case 18: motor_disengage(); break;
case 20: SD_listFiles(); break;
case 42: adjustPinState(); break;
case 100: help(); break;
case 101: parseLimits(); break;
case 102: printConfig(); break;
Expand All @@ -779,9 +793,9 @@ void processCommand() {
case 3: parseArc(0); break; // counter-clockwise
case 4: parseDwell(); break;
case 28: robot_findHome(); break;
#if MACHINE_STYLE == POLARGRAPH
#if MACHINE_STYLE == POLARGRAPH
case 29: calibrateBelts(); break;
#endif
#endif
case 54:
case 55:
case 56:
Expand Down Expand Up @@ -811,11 +825,15 @@ void processCommand() {
break;
#if MACHINE_STYLE == POLARGRAPH
case 11: makelangelo5Setup(); break;
case 12: recordHome();
case 12: recordHome(); break;
#endif
#ifdef MACHINE_HAS_LIFTABLE_PEN
case 13: setPenAngle(parseNumber('Z',axies[2].pos)); break;
#endif
case 14: // get machine style
Serial.print(F("D14 "));
Serial.println(MACHINE_STYLE_NAME);
break;
default: break;
}
}
Expand Down Expand Up @@ -1003,7 +1021,9 @@ void setup() {
for(int i=0;i<NUM_AXIES;++i) {
pos[i]=0;
}
#ifdef MACHINE_HAS_LIFTABLE_PEN
if(NUM_AXIES>=3) pos[2]=PEN_UP_ANGLE;
#endif
teleport(pos);
#ifdef MACHINE_HAS_LIFTABLE_PEN
setPenAngle(PEN_UP_ANGLE);
Expand All @@ -1029,7 +1049,7 @@ void Serial_listen() {
if (c == '\r') continue;
if (sofar < MAX_BUF) serialBuffer[sofar++] = c;
if (c == '\n') {
serialBuffer[sofar] = 0;
serialBuffer[sofar-1] = 0;

// echo confirmation
// Serial.println(F(serialBuffer));
Expand Down
8 changes: 6 additions & 2 deletions Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ class Vector3 {
}


Vector3 operator * ( const Vector3 &b ) const { // vector * vector
Vector3 operator * ( const Vector3 &b ) const { // dot(this,b)
return Vector3( x * b.x, y * b.y, z * b.z );
}


Vector3 operator ^ ( const Vector3 &b ) const { // cross(a,b)
Vector3 operator ^ ( const Vector3 &b ) const { // cross(this,b)
float nx, ny, nz;

nx = y * b.z - z * b.y;
Expand All @@ -263,6 +263,10 @@ class Vector3 {
}


/**
* @axis vector3 axis around which to rotate counter-clockwise
* @param angle radians
*/
void rotate( Vector3 &axis, float angle ) {
float sa = (float)sin( angle );
float ca = (float)cos( angle );
Expand Down
86 changes: 86 additions & 0 deletions board_mks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#ifndef BOARD_MKS_H
#define BOARD_MKS_H
//------------------------------------------------------------------------------
// Makelangelo - firmware for various robot kinematic models
// [email protected] 2013-12-26
// Copyright at end of file. Please see
// http://www.github.com/MarginallyClever/makelangeloFirmware for more information.
//------------------------------------------------------------------------------

// NOTE: MKS boards are identical to RAMPS boards, except that they have a few extra features.

#if MOTHERBOARD == BOARD_MKS

#define MAX_MOTORS (5)

#define MOTOR_0_DIR_PIN (55)
#define MOTOR_0_STEP_PIN (54)
#define MOTOR_0_ENABLE_PIN (38)
#define MOTOR_0_LIMIT_SWITCH_PIN (3) /* X min */

#define MOTOR_1_DIR_PIN (61)
#define MOTOR_1_STEP_PIN (60)
#define MOTOR_1_ENABLE_PIN (56)
#define MOTOR_1_LIMIT_SWITCH_PIN (14) /* Y min */

#define MOTOR_2_DIR_PIN (48)
#define MOTOR_2_STEP_PIN (46)
#define MOTOR_2_ENABLE_PIN (62)
#define MOTOR_2_LIMIT_SWITCH_PIN (18) /* Z Min */

#define MOTOR_3_DIR_PIN (28)
#define MOTOR_3_STEP_PIN (26)
#define MOTOR_3_ENABLE_PIN (24)
#define MOTOR_3_LIMIT_SWITCH_PIN (2) /* X Max */

#define MOTOR_4_DIR_PIN (34)
#define MOTOR_4_STEP_PIN (36)
#define MOTOR_4_ENABLE_PIN (30)
#define MOTOR_4_LIMIT_SWITCH_PIN (15) /* Y Max */

#define MAX_BOARD_SERVOS (4)
#define SERVO0_PIN (11) /* Servo 1 */
#define SERVO1_PIN (6)
#define SERVO2_PIN (5)
#define SERVO3_PIN (4)

#define LIMIT_SWITCH_PIN_LEFT (MOTOR_0_LIMIT_SWITCH_PIN)
#define LIMIT_SWITCH_PIN_RIGHT (MOTOR_1_LIMIT_SWITCH_PIN)

// Smart controller settings
#define BEEPER 37 /* Pin on SMART Adapter */
#define LCD_PINS_RS 16 /* Pin on SMART Adapter */
#define LCD_PINS_ENABLE 17 /* Pin on SMART Adapter */
#define LCD_PINS_D4 23 /* Pin on SMART Adapter */
#define LCD_PINS_D5 25 /* Pin on SMART Adapter */
#define LCD_PINS_D6 27 /* Pin on SMART Adapter */
#define LCD_PINS_D7 29 /* Pin on SMART Adapter */

// Encoder rotation values
#define BTN_EN1 31 /* Pin on SMART Adapter */
#define BTN_EN2 33 /* Pin on SMART Adapter */
#define BTN_ENC 35 /* Pin on SMART Adapter */

#define KILL_PIN 41 /* Pin on SMART Adapter */

// SD card settings
#define SDPOWER -1
#define SDSS 53
#define SDCARDDETECT 49

#define LCD_HEIGHT 4
#define LCD_WIDTH 20

#define BLEN_C 2
#define BLEN_B 1
#define BLEN_A 0
#define encrot0 0
#define encrot1 2
#define encrot2 3
#define encrot3 1

#endif // BOARD_MKS


#endif // BOARD_MKS_H

6 changes: 3 additions & 3 deletions board_teensylu.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef BOARD_RAMPS_H
#define BOARD_RAMPS_H
#ifndef BOARD_TEENSYLU_H
#define BOARD_TEENSYLU_H
//------------------------------------------------------------------------------
// Makelangelo - firmware for various robot kinematic models
// [email protected] 2013-12-26
Expand Down Expand Up @@ -27,5 +27,5 @@
#endif


#endif // BOARD_RAMPS_H
#endif // BOARD_TEENSYLU_H

7 changes: 6 additions & 1 deletion configure.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
#error "The number of servos needed is more than this board supports."
#endif

#if NUM_SERVOS + NUM_MOTORS != NUM_AXIES
// not always the case! Skycam has more motors than axies.
//#error "NUM_SERVOS + NUM_MOTORS != NUM_AXIES"
#endif

// for serial comms
#define BAUD (57600) // How fast is the Arduino talking?
Expand Down Expand Up @@ -194,8 +198,9 @@ extern float acceleration;
extern Motor motors[NUM_MOTORS+NUM_SERVOS];
extern const char *AxisNames;
extern const char *MotorNames;
extern float maxFeedRate[NUM_MOTORS];

extern char lcd_message[LCD_MESSAGE_LENGTH];
extern char lcd_message[LCD_MESSAGE_LENGTH+1];


#endif // CONFIGURE_H
Expand Down
15 changes: 12 additions & 3 deletions lcd.ino
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int lcd_turn = 0;
char lcd_click_old = HIGH;
char lcd_click_now = false;
uint8_t speed_adjust = 100;
char lcd_message[LCD_MESSAGE_LENGTH];
char lcd_message[LCD_MESSAGE_LENGTH+1];

int menu_position_sum = 0, menu_position = 0, screen_position = 0, num_menu_items = 0, ty, screen_end;

Expand Down Expand Up @@ -133,8 +133,17 @@ void LCD_status_menu() {
get_end_plus_offset(offset);
lcd.setCursor( 0, 0); lcd.print('X'); LCD_print_float(offset[0]);
lcd.setCursor(10, 0); lcd.print('Z'); LCD_print_float(offset[2]);
#if MACHINE_STYLE == POLARGRAPH && defined(USE_LIMIT_SWITCH)
lcd.setCursor(19, 0); lcd.print(( digitalRead(LIMIT_SWITCH_PIN_LEFT) == LOW ) ? '*':' ');
#endif

lcd.setCursor( 0, 1); lcd.print('Y'); LCD_print_float(offset[1]);
lcd.setCursor(10, 1); lcd.print('F'); LCD_print_long(speed_adjust); lcd.print(F("% "));
#if MACHINE_STYLE == POLARGRAPH && defined(USE_LIMIT_SWITCH)
lcd.setCursor(19, 1); lcd.print(( digitalRead(LIMIT_SWITCH_PIN_RIGHT) == LOW ) ? '*':' ');
#endif


//lcd.setCursor(10, 1); lcd.print('F'); LCD_print_float(feed_rate);
//lcd.setCursor( 0, 1); lcd.print(F("Makelangelo #")); lcd.print(robot_uid);
lcd.setCursor( 0, 2);
Expand Down Expand Up @@ -346,7 +355,6 @@ void LCD_start_menu() {
MENU_END
}


void LCD_update_long(char *name, long &value) {
lcd.clear();
do {
Expand Down Expand Up @@ -463,6 +471,7 @@ void LCD_init() {
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
pinMode(BEEPER,OUTPUT);
digitalWrite(BEEPER,LOW);

pinMode(BTN_EN1, INPUT);
pinMode(BTN_EN2, INPUT);
pinMode(BTN_ENC, INPUT);
Expand All @@ -471,11 +480,11 @@ void LCD_init() {
digitalWrite(BTN_ENC, HIGH);
current_menu = LCD_status_menu;
menu_position_sum = 1; /* 20160313-NM-Added so the clicking without any movement will display a menu */

lcd_message[0] = 0;
#endif // HAS_LCD
}


/**
This file is part of makelangelo-firmware.
Expand Down
22 changes: 16 additions & 6 deletions motor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//------------------------------------------------------------------------------
// GLOBALS
//------------------------------------------------------------------------------

Motor motors[NUM_MOTORS+NUM_SERVOS];
Segment line_segments[MAX_SEGMENTS];
Segment *working_seg = NULL;
Expand All @@ -23,8 +24,6 @@ volatile int last_segment=0;
int step_multiplier, nominal_step_multiplier;
unsigned short nominal_OCR1A;

Servo servos[NUM_SERVOS];

// used by timer1 to optimize interrupt inner loop
int steps_total;
int steps_taken;
Expand Down Expand Up @@ -72,7 +71,8 @@ int global_step_dir_5;


const char *MotorNames="LRUVWT";
const char *AxisNames="XYZUVW";
const char *AxisNames="XYZUVWT";
float maxFeedRate[NUM_MOTORS];


//------------------------------------------------------------------------------
Expand Down Expand Up @@ -155,6 +155,7 @@ void motor_setup() {
// set the switch pin
pinMode(motors[i].limit_switch_pin,INPUT);
digitalWrite(motors[i].limit_switch_pin,HIGH);
maxFeedRate[i] = MAX_FEEDRATE;
}

long steps[NUM_MOTORS+NUM_SERVOS];
Expand Down Expand Up @@ -229,6 +230,12 @@ void motor_engage() {
for(i=0;i<NUM_MOTORS;++i) {
digitalWrite(motors[i].enable_pin,LOW);
}
/*
#if MACHINE_STYLE == ARM6
// DM320T drivers want high for enabled
digitalWrite(motors[4].enable_pin,HIGH);
digitalWrite(motors[5].enable_pin,HIGH);
#endif*/
}


Expand All @@ -237,7 +244,12 @@ void motor_disengage() {
int i;
for(i=0;i<NUM_MOTORS;++i) {
digitalWrite(motors[i].enable_pin,HIGH);
}
}/*
#if MACHINE_STYLE == ARM6
// DM320T drivers want low for disabled
digitalWrite(motors[4].enable_pin,LOW);
digitalWrite(motors[5].enable_pin,LOW);
#endif*/
}


Expand Down Expand Up @@ -563,7 +575,6 @@ ISR(TIMER1_COMPA_vect) {
#endif

#if NUM_SERVOS>0
//move the z axis
servos[0].write(working_seg->a[NUM_MOTORS].step_count);
#endif

Expand Down Expand Up @@ -806,7 +817,6 @@ void motor_line(long *n,float new_feed_rate) {
//Serial.print('\t'); Serial.print(old_seg.a[i].step_count);
//Serial.print('\t'); Serial.print(new_seg.a[i].step_count);
//Serial.print('\t'); Serial.print(new_seg.a[i].dir);
//Serial.print('\t'); Serial.print(new_seg.a[i].dir);
//Serial.print('\t'); Serial.print(new_seg.a[i].absdelta);
//Serial.println();
}
Expand Down
Loading

0 comments on commit d65f1cf

Please sign in to comment.