Yes, my knowledge on the subject is pretty weak, I generally avoid arduino and appreciate the help… I also believe that not everyone can know everything and that it’s important to package things up as a foundation that can be stood upon. Hopefully all this will help evolve the project to the point where you don’t need to know how to program an STM32 in order to get your motor working… it give an error:
At least I can use software serial to get on with some stuff.
Are you sure this encoder works with simplefoc? it’s the sc60228DC. I thought you prescribed one that was known to work, but the thread on the subject indicates it’s not quite ready yet:
https://community.simplefoc.com/t/angle-sensor-spi-support-sc60228dc/1682/58
I’m trying to use the code snippets in that thread to see if I can at least read angle values from the chip. I have it connected in place with a magnet on the fan. So far, apparently the source code has errors which confuse the simpleFOC directory with the simpleFOC_drivers directory. I have been copying files to where it appears to expect to find them so I can carry on … compiling now, I don’t know why this latest version of arduino takes so long to do everything…
update: ok I hit a dead end again. It keeps being unable to find the files that need to be connected, the header files etc. The simpleFOC folders and SimpleFOC_drivers folders got mixed up at some point, or the files used to all be under simpleFOC and when they were separated something went wrong. The files still refer to the old directory structure. I tried correcting the files and that fixes the error for one but it keeps invoking endless more that it doesn’t even need to refer to, I can’t correct them all only to find out it still doesn’t work. If I try to merge the directory structures copies are produced and it gives errors about multiple copies of the same file.
The errors all look like this:
In file included from c:\Users\anthony\Documents\Arduino\libraries\SimpleFOCDrivers\src\encoders\aeat8800q24\MagneticSensorAEAT8800Q24.cpp:1:
c:\users\anthony\documents\arduino\libraries\simplefocdrivers\src\encoders\aeat8800q24\magneticsensoraeat8800q24.h:5:10: fatal error: common/base_classes/Sensor.h: No such file or directory
5 | #include “common/base_classes/Sensor.h”
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
Compilation error: exit status 1
They can be corrected by copying …/…/Simple_FOC/src/ before the name.
ok I got things to compile by merging the directories
I tire this code, to check the angle sensor. Probably I mucked something up althoguh it’s not clear if the driver etc. is good to go yet.
#include “SoftwareSerial.h”
#include <SimpleFOCDrivers.h>
#include “encoders/sc60228/MagneticSensorSC60228.h”
// SENSOR SPI SC60228
// SPI2 PINS
#define CSN2 PA4
#define CLK2 PA5
#define MISO2 PB4
#define MOSI2 PB5
#define SS_USB_RX PA15
#define SS_USB_TX PA2
// BAUD RATE MUST BE BETWEEN 9600…38400
// ANY OTHER BAUD RATE WILL CHOKE
SoftwareSerial SoftSerialUSB(SS_USB_RX, SS_USB_TX);
MagneticSensorSC60228 sensorSC60228(CSN2);
SPIClass SPISensor(MOSI2, MISO2, CLK2);
void setup()
{
//set pins for Software Serial communication
SoftSerialUSB.begin(38400);
pinMode(SS_USB_RX, INPUT);
pinMode(SS_USB_TX, OUTPUT);
sensorSC60228.init(&SPISensor);
delay(1000);
}
void loop()
{
SoftSerialUSB.println(“TEST SSERIAL_USB”);
Serial.print(">> ");
Serial.println(sensorSC60228.getAngle());
sensorSC60228.update();
delay(100);
}
it prints the “TEST SSERIAL_USB” about 8 times and then halts. Same on every reset.
I have an AS5600 encoder fortunately, I can try that if this encoder isn’t good to go yet. I am concerned the RPM limit will be an issue but it might be ok… It worked with the Uno. I am baffled at this directory structure problem, it does not seem to have anything to do with the encoder.