Arduino sketch compile problem

Hello,

I have built a FLexscope on top of a Raspberry Pi, and I am now sorting out software issues. I do get an image in the Open Flexure app, but I have not yet been able to compile and upload the Arduino sketch to the nano (ATmega328p) that should drive the 3 stepper boards. Thus, no moving stage.

I am using the Arduino 1.8.13 IDE, the six month old arduino_code_sangaboard_sangaboard sketch from the Bath Open Instrumentation Gitlab site, and the StepperF_alt.h document. The error I get includes the following: ‘‘void Stepper::stepMotor(int)’ is private within this context’. I’ll c/p the full error message, .h document, and sangaboard sketch below. (edit: I removed the sangaboard sketch)

So far I have been able to shoot all problems that arose during building, but this is over my head. Any help would be appreciated!

Thank you, best regards, Jan-Maarten


Error message:


Arduino: 1.8.13 (Linux), Board: “Arduino Nano, ATmega328P”

motors[motor]->stepMotor(((current_pos[motor] % 8) + 8) % 8); //forgive the double-modulo; I need 0-7 even for -ve numbers
^
In file included from /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:17:0:
/tmp/arduino_build_769587/sketch/StepperF_alt.h:103:10: note: declared private here
void stepMotor(int this_step);
^~~~~~~~~
/home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino: In function ‘void releaseMotor(int)’:
arduino_code_sangaboard_sangaboard:187:29: error: ‘void Stepper::stepMotor(int)’ is private within this context
motors[motor]->stepMotor(8);
^
In file included from /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:17:0:
/tmp/arduino_build_769587/sketch/StepperF_alt.h:103:10: note: declared private here
void stepMotor(int this_step);
^~~~~~~~~
Using library EEPROM at version 2.0 in folder: /tmp/arduino-1.8.13/hardware/arduino/avr/libraries/EEPROM
exit status 1
‘void Stepper::stepMotor(int)’ is private within this context


The .h file:


/*

  • Stepper.h - Stepper library for Wiring/Arduino - Version 1.1.0
  • Original library (0.1) by Tom Igoe.
  • Two-wire modifications (0.2) by Sebastian Gassner
  • Combination version (0.3) by Tom Igoe and David Mellis
  • Bug fix for four-wire (0.4) by Tom Igoe, bug fix from Noah Shibley
  • High-speed stepping mod by Eugene Kozlenko
  • Timer rollover fix by Eugene Kozlenko
  • Five phase five wire (1.1.0) by Ryan Orendorff
  • This library is free software; you can redistribute it and/or
  • modify it under the terms of the GNU Lesser General Public
  • License as published by the Free Software Foundation; either
  • version 2.1 of the License, or (at your option) any later version.
  • This library is distributed in the hope that it will be useful,
  • but WITHOUT ANY WARRANTY; without even the implied warranty of
  • MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  • Lesser General Public License for more details.
  • You should have received a copy of the GNU Lesser General Public
  • License along with this library; if not, write to the Free Software
  • Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

*/

// ensure this library description is only included once
#ifndef Stepper_h
#define Stepper_h

// library interface description
class Stepper {
public:
// constructors:
// Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2);
Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
int motor_pin_3, int motor_pin_4);
// Stepper(int number_of_steps, int motor_pin_1, int motor_pin_2,
// int motor_pin_3, int motor_pin_4,
// int motor_pin_5);

// speed setter method:
void setSpeed(long whatSpeed);

// mover method:
void step(int number_of_steps);

int version(void);

private:
void stepMotor(int this_step);

int direction;            // Direction of rotation
unsigned long step_delay; // delay between steps, in ms, based on speed
int number_of_steps;      // total number of steps this motor can take
int pin_count;            // how many pins are in use.
int step_number;          // which step the motor is on

// motor pin numbers:
int motor_pin_1;
int motor_pin_2;
int motor_pin_3;
int motor_pin_4;
int motor_pin_5;          // Only 5 phase motor

unsigned long last_step_time; // time stamp in us of when the last step was taken

};

#endif

Where did you get this version of stepperF_alt.h? It is different from the one in the repository. Your one has step motor as a private class, the version in the repo it is public.

Thank you for the link! I googled for StepperF_alt.h and was sent here → https://github.com/fr293/motor_board/blob/master/RicheBetaAlt.ino

Thanks again, the repository version of the StepperF_alt.h got me further. However, the Arduino compiler still throws an error, I’ll include the error message below. Again, help would be greatly appreciated!


Arduino: 1.8.13 (Linux), Board: “Arduino Nano, ATmega328P”
/tmp/ccNbeS8O.ltrans0.ltrans.o: In function stepMotor': /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:182: undefined reference to Stepper::stepMotor(int)’
/tmp/ccNbeS8O.ltrans0.ltrans.o: In function setup': /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:121: undefined reference to Stepper::Stepper(int, int, int, int, int)’
/home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:122: undefined reference to Stepper::Stepper(int, int, int, int, int)' /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:123: undefined reference to Stepper::Stepper(int, int, int, int, int)’
/home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:130: undefined reference to Stepper::setSpeed(long)' /tmp/ccNbeS8O.ltrans0.ltrans.o: In function releaseMotor’:
/home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:187: undefined reference to Stepper::stepMotor(int)' /home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:187: undefined reference to Stepper::stepMotor(int)’
/home/pi/Downloads/arduino_code_sangaboard_sangaboard/arduino_code_sangaboard_sangaboard.ino:187: undefined reference to `Stepper::stepMotor(int)’
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino Nano.

Are you running this on your Pi? At least until recently the Arduino IDE for the Pi was not a recent enough release. The version number you give is 1.8 though, which is higher than the 1.6 required.

Yes, I am running the 1.8 Arduino IDE on the pi. I downloaded the 32 bit ARM linux version from the arduino site, which installs and runs fine on the Open Flexure Raspbian OS. Maybe an idea for the developers to include the necessary Arduino tools and sketches in their distro?

(update) I get the same error when I try to compile the sketch from my laptop (running windows).

(update2) I figured it out, the arduino sketch requires both the StepperF_alt.cpp and a StepperF_alt.h to be in the same folder with it.

1 Like

I think you’re missing the stepperF_alt.cpp file from the repository: https://gitlab.com/bath_open_instrumentation_group/sangaboard/-/blob/master/arduino_code/sangaboard/StepperF_alt.cpp

1 Like

Great news. It would be good for us to move to the arduino CLI system they released. Even though CLI may be a little less friendly to some, it should allow us to set the compiler paths explicitly rather than rely on a lot of manual configuration.