1

I have written a simple script to get angle measurements from a magnetic sensor. The script works very well on Windows. However, when compiling the script on a Linux VirtualBox (Ubuntu 20.04), the sensor repeats the first angle reading and does not change from this, despite the angle changing. There are no errors/warnings given by Windows or Linux at any stage of compiling/uploading.

Uploading the script on Windows and then viewing in Linux serial monitor works. However, uploading it on Linux and then viewing in Windows serial monitor does not work ("Board is not available"), even when connecting the board to Linux and not Windows.

I've compared both systems and everything seems to be the same: the same Arduino Uno R3 board, Arduino IDE 1.8.19 on both systems, Arduino AVR Boards 1.8.3 on both, "Arduino Uno" selected as the board on both, the library is SimpleFOC v2.2.0 on both. The only difference I can see is that the Windows port is COM3, whereas the Linux port is /dev/ttyACM0.

My script is the following and I would appreciate any help or advice to get this working on Linux. Thank you.

#include <SimpleFOC.h>

#define PI 3.1415926535897932384626433832795

// Magnetic sensor instance
MagneticSensorSPI AS5x4x = MagneticSensorSPI(8, 14, 0x3FFF);

void setup() {
  // initialize magnetic sensor hardware
  AS5x4x.init();

  // use monitoring with serial
  Serial.begin(9600);

  Serial.println("Ready.");
  _delay(1000);
}

void loop() {
  Serial.println(AS5x4x.getAngle()); // display angle
}
6
  • Compile/upload under linux and then move the board to the windows system and open the serial monitor. And vice versa. Let us know if the behaviour follows from the system that it was compiled/uploaded from or the system that it is attached to. If it follows the system it was built/uploaded from, maybe provide version numbers to everything IDE, libraries, board core, etc.
    – timemage
    Commented May 5, 2023 at 14:17
  • Windows upload + Linux serial monitor works. Linux upload + Windows serial monitor does not work ("Board is not available"). Using Arduino 1.8.19 on both Windows and Ubuntu; Arduino Uno R3 board. Thanks for any further help/suggestions.
    – Vuro H
    Commented May 5, 2023 at 14:28
  • The "everything IDE, libraries, board core, etc" Realistically, you liable to be the only person that can definitively answer this question. Whether or not you should is a different question. In either case, the information needed to answer it should be in the question when it it is answered. You're almost certainly going to find a difference in what you have installed. But simply pointing that out alone is not a useful answer. The "board core" I mentioned is the version that lists in your Boards Manager for whatever board you're using.
    – timemage
    Commented May 5, 2023 at 14:35
  • 1
    Ok, I've compared both systems but everything seems to be the same... Arduino IDE 1.8.19 on both systems, Arduino AVR Boards 1.8.3 on both, the library is SimpleFOC v2.2.0 on both. Let me know if you've any other suggestions, thanks again for help.
    – Vuro H
    Commented May 5, 2023 at 17:56
  • Please compare the selected Arduino board, too. Did the compile and upload work without error on Linux? Did Linux upload and Linux serial monitor work, before you connect the Arduino to Windows? Please add these important information to your question by editing it, do not post a comment. I suggest to take the tour to learn how this site works. It is not a forum. Commented May 6, 2023 at 7:37

1 Answer 1

0

It turns out that the Arduino Library Manager was giving me incorrect information about the library version installed. By removing the library it was using and then installing the correct library that corresponds to the required version number, the code now works well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.