I got this error message after I added in the part
//// Start #1 for parsing serial
and ending at
// end #1:
Before that, it compiled fine.
Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp: In member function 'availableForWrite':
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino\HardwareSerial.cpp:203:1: internal compiler error: Segmentation fault
}
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper.exe: fatal error: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.15.0_x86__mdqgnx93n4wtt\hardware\tools\avr/bin/avr-gcc returned 1 exit status
compilation terminated.
c:/program files/windowsapps/arduinollc.arduinoide_1.8.15.0_x86__mdqgnx93n4wtt/hardware/tools/avr/bin/../lib/gcc/avr/5.4.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
from this code:
[code]
// MultiStepper.pde
// -*- mode: C++ -*-
// Use MultiStepper class to manage multiple steppers and make them all move to
// the same position at the same time for linear 2d (or 3d) motion.
#include <AccelStepper.h>
#include <MultiStepper.h>
// EG X-Y position bed driven by 2 steppers
// Alas its not possible to build an array of these with different pins for each :-(
AccelStepper J1axis(1, A0, A1);
AccelStepper J2axis(1, A6, A7);
AccelStepper J3axis(1, 46, 48);
// Up to 10 steppers can be handled as a group by MultiStepper
MultiStepper steppers;
// Define the Pins used
// limit switches
// J1/x limit min on ramps 1.4
const int J1calPin = 3;
// J2/y limit min on ramps 1.4
const int J2calPin = 14;
// J3/z limit min on rmaps 1.4
const int J3calPin = 18;
// Stepper Travel Variables
int J1move_finished = 1; // Used to check if move is completed
long J1initial_homing = -1; // Used to Home Stepper at startup
int J2move_finished = 1; // Used to check if move is completed
long J2initial_homing = -1; // Used to Home Stepper at startup
int J3move_finished = 1; // Used to check if move is completed
long J3initial_homing = -1; // Used to Home Stepper at startup
//// Start #1 for parsing serial
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars]; // temporary array for use when parsing
// variables to hold the parsed data
float XCoordinate = 0;
float YCoordinate = 0;
float ZCoordinate = 0;
float R, S, T;
float AngleThetaOne;
float AngleThetaTwo;
float AngleThetaThree;
char messageFromPC[numChars] = {0};
int StepsPerDegreeOne = 88; //calibrate steps per degree of Theta One
int StepsPerDegreeTwo = 88; // calibrate steps per degree for Theta Two
int StepsPerDegreeThree = 88; // calibrate steps per degree for Theta Three
float J1position = 0;
float J2position = 0;
float J3position = 0;
int J1move = 0;
int J2move = 0;
int J3move = 0;
int X = 0;
int Y = 0;
int Z = 0;
float J1newPosition = 0;
float J2newPosition = 0;
float J3newPosition = 0;
int F = 0, f;
float Q1, W1, E1;
float Q0, Q4, W0, W4, E2;
float Q3, W3, E3;
boolean newData = false;
// end #1
void setup() {
Serial.begin(9600);
// my addition to set x,y, z enable pins to output
pinMode (38, OUTPUT); // x enable pin
pinMode (56, OUTPUT); // y enable pin
pinMode (62, OUTPUT); // z enable pin
digitalWrite (38, LOW); // x enable
digitalWrite (56, LOW); // y enable
digitalWrite (62, LOW); // z enable
pinMode(J1calPin, INPUT_PULLUP);
pinMode(J2calPin, INPUT_PULLUP);
pinMode(J3calPin, INPUT_PULLUP);
// end of my addition
// Configure each stepper
J1axis.setMaxSpeed(500);
J2axis.setMaxSpeed(500);
J3axis.setMaxSpeed(500);
J1axis.setCurrentPosition(0);
J2axis.setCurrentPosition(0);
J3axis.setCurrentPosition(0);
// Then give them to MultiStepper to manage
steppers.addStepper(J1axis);
steppers.addStepper(J2axis);
steppers.addStepper(J3axis);
// Set Max Speed and Acceleration of each Steppers at startup for homing
J1axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J1axis.setAcceleration(1000.0); // Set Acceleration of Stepper
J2axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J2axis.setAcceleration(1000.0); // Set Acceleration of Stepper
J3axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J3axis.setAcceleration(1000.0); // Set Acceleration of Stepper
// Start Homing procedure of Stepper Motor at startup
Serial.print("Stepper is Homing . . . . . . . . . . . ");
while (digitalRead(J1calPin)) { // Make the Stepper move CCW until the switch is activated
J1axis.moveTo(J1initial_homing); // Set the position to move to
J1initial_homing++; // Decrease by 1 for next move if needed
J1axis.run(); // Start moving the stepper
delay(5);
}
J1axis.setCurrentPosition(0); // Set the current position as zero for now
J1axis.setMaxSpeed(3000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J1axis.setAcceleration(3000.0); // Set Acceleration of Stepper
J1initial_homing = 1;
while (!digitalRead(J1calPin)) { // Make the Stepper move CW until the switch is deactivated
J1axis.moveTo(J1initial_homing);
J1axis.run();
J1initial_homing--;
delay(5);
}
J1axis.setCurrentPosition(0);
Serial.println("J1 Homing Completed");
Serial.println("");
J1axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Faster for regular movements)
J1axis.setAcceleration(1000.0); // Set Acceleration of Stepper
//J2 homing
while (digitalRead(J2calPin)) { // Make the Stepper move CCW until the switch is activated
J2axis.moveTo(J2initial_homing); // Set the position to move to
J2initial_homing--; // Decrease by 1 for next move if needed
J2axis.run(); // Start moving the stepper
delay(5);
}
J2axis.setCurrentPosition(0); // Set the current position as zero for now
J2axis.setMaxSpeed(3000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J2axis.setAcceleration(3000.0); // Set Acceleration of Stepper
J2initial_homing = 1;
while (!digitalRead(J2calPin)) { // Make the Stepper move CW until the switch is deactivated
J2axis.moveTo(J2initial_homing);
J2axis.run();
J2initial_homing++;
delay(5);
}
J2axis.setCurrentPosition(0);
Serial.println("J2 Homing Completed");
Serial.println("");
J2axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Faster for regular movements)
J2axis.setAcceleration(1000.0); // Set Acceleration of Stepper
// J3 homing
while (digitalRead(J3calPin)) { // Make the Stepper move CCW until the switch is activated
J3axis.moveTo(J3initial_homing); // Set the position to move to
J3initial_homing--; // Decrease by 1 for next move if needed
J3axis.run(); // Start moving the stepper
delay(5);
}
J3axis.setCurrentPosition(0); // Set the current position as zero for now
J3axis.setMaxSpeed(3000.0); // Set Max Speed of Stepper (Slower to get better accuracy)
J3axis.setAcceleration(3000.0); // Set Acceleration of Stepper
J3initial_homing = 1;
while (!digitalRead(J3calPin)) { // Make the Stepper move CW until the switch is deactivated
J3axis.moveTo(J3initial_homing);
J3axis.run();
J3initial_homing++;
delay(5);
}
J3axis.setCurrentPosition(0);
Serial.println("J3 Homing Completed");
Serial.println("");
J3axis.setMaxSpeed(1000.0); // Set Max Speed of Stepper (Faster for regular movements)
J3axis.setAcceleration(1000.0); // Set Acceleration of Stepper
}
void loop() {
long positions[3]; // Array of desired stepper positions
positions[0] = 1000;
positions[1] = -100;
positions[2] = -100;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(100);
// Move to a different coordinate
positions[0] = 5000;
positions[1] = -5000;
positions[2] = -3000;
steppers.moveTo(positions);
steppers.runSpeedToPosition(); // Blocks until all are in position
delay(100);
}
I believe this is a bug specific to the 5.4.0-atmel3.6.1-arduino2 version of avr-gcc used by Arduino AVR Boards 1.6.22 and newer. It has been reported here:
(but note the error message is not exactly the same)
Here's the workaround:
Tools > Board > Boards Manager
Wait for downloads to finish.
When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
Click "Install".
Wait for installation to finish.
Click "Close".
Due to a bug, this workaround doesn't work with Arduino IDE 1.8.6, but it will work with any other version of the Arduino IDE.
If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.
I didn't actually test this with your code since I don't have the time to hunt down and install the libraries, etc. right now.