try to fix submodule

This commit is contained in:
2023-11-09 19:02:15 -05:00
parent c1d45aa443
commit deea94b076
366 changed files with 40228 additions and 2 deletions

View File

@@ -0,0 +1,62 @@
# SAMD Support
SimpleFOC supports many SAMD21 MCUs, really any SAMD21 supported by Arduino core should work.
## Pin assignments
The SAMD chips have some very powerful PWM features, but do not have flexible pin assignments.
You should be able to use *most* (but not all!), pin combinations for attaching your motor's PWM pins. Please ignore the board descriptions and pinout diagrammes regarding PWM-pins on SAMD boards. They are pretty much all incorrect to varying degrees of awfulness.
On SAMD we use TCC and TC timer peripherals (built into the SAMD chip) to control the PWM. Depending on the chip there are various timer units, whose PWM outputs are attached to various different pins, and it is all very complicated. Luckily SimpleFOC sets it all up automatically *if* there is a compatible configuration for those pins.
Not all timers are created equal. The TCC timers are pretty awesome for PWM motor control, while the TC timers are just ok for the job. So to get best performance, you want to use just TCC timer pins if you can.
By enabling
```
#define SIMPLEFOC_SAMD_DEBUG
```
in drivers/hardware_specific/samd_mcu.cpp<br>
you will see a table of pin assignments printed on the serial console, as well as the timers SimpleFOC was able to find and configure on the pins you specified. You can use this to optimize your choice of pins if you want.
You can configure up to 12 pins for PWM motor control, i.e. 6x 2-PWM motors, 4x 3-PWM motors, 3x 4-PWM motors or 2x 6-PWM motors.
## PWM control modes
All modes (3-PWM, 6-PWM, Stepper 2-PWM and Stepper 4-PWM) are supported.
For 2-, 3- amd 4- PWM, any valid pin-combinations can be used. If you stick to TCC timers rather than using TC timers, then you'll get getter PWM waveforms. If you use pins which are all on the same TCC unit, you'll get the best result, with the PWM signals all perfectly aligned as well.
For 6-PWM, the situation is much more complicated:<br>
TC timers cannot be used for 6-PWM, only TCC timers.
For Hardware Dead-Time insertion, you must use H and L pins for one phase from the same TCC unit, and on the same channel, but using complementary WOs (Waveform Outputs, i.e. PWM output pins). Check the table to find pins on the same channel (like TCC0-0) but complementary WOs (like TCC0-0[0] and TCC0-0[4] or TCC1-0[0] and TCC1-0[2]).
For Software Dead-Time insertion, you must use the same TCC and different channels for the H and L pins of the same phase.
Note: in all of the above note that you *cannot* set the timers or WOs used - they are fixed, and determined by the pins you selected. SimpleFOC will find the best combination of timers given the pins, trying to use TCC timers before TC, and trying to keep things on the same timers as much as possible. If you configure multiple motors, it will take into account the pins already assigned to other motors.
So it is matter of choosing the right pins, nothing else.
Note also: Unfortunately you can't set the PWM frequency. It is currently fixed at 24KHz. This is a tradeoff between limiting PWM resolution vs
increasing frequency, and also due to keeping the pin assignemts flexible, which would not be possible if we ran the timers at different rates.
## Status
Currently, SAMD21 is supported, and SAMD51 is unsupported. SAMD51 support is in progress.
Boards tested:
* Arduino Nano 33 IoT
* Arduino MKR1000
* Arduino MKR1010 Wifi
* Seeduino XIAO
* Feather M0 Basic
Environments tested:
* Arduino IDE
* Arduino Pro IDE
* Sloeber

View File

@@ -0,0 +1,64 @@
// show the infos for SAMD pin assignment on serial console
// set this #define SIMPLEFOC_SAMD_DEBUG in drivers/hardware_specific/samd21_mcu.h
#include "Arduino.h"
#include <Wire.h>
#include <SimpleFOC.h>
// this is for an AS5048B absolute magnetic encoder on I2C address 0x41
MagneticSensorI2C sensor = MagneticSensorI2C(0x41, 14, 0xFE, 8);
// small BLDC gimbal motor, 7 pole-pairs
BLDCMotor motor = BLDCMotor(7);
// 3-PWM driving on pins 6, 5 and 8 - these are all on the same timer unit (TCC0), but different channels
BLDCDriver3PWM driver = BLDCDriver3PWM(6,5,8);
// velocity set point variable
float target_velocity = 2.0f;
// instantiate the commander
Commander command = Commander(SerialUSB);
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("Initializing...");
sensor.init();
Wire.setClock(400000);
motor.linkSensor(&sensor);
driver.voltage_power_supply = 9;
driver.init();
motor.linkDriver(&driver);
motor.controller = MotionControlType::velocity;
motor.PID_velocity.P = 0.2f;
motor.PID_velocity.I = 20;
motor.PID_velocity.D = 0.001f;
motor.PID_velocity.output_ramp = 1000;
motor.LPF_velocity.Tf = 0.01f;
motor.voltage_limit = 9;
//motor.P_angle.P = 20;
motor.init();
motor.initFOC();
// add target command T
command.add('T', doTarget, "target velocity");
Serial.println(F("Motor ready."));
Serial.println(F("Set the target velocity using serial terminal:"));
delay(100);
}
void loop() {
// Serial.print("Sensor: ");
// Serial.println(sensor.getAngle());
motor.loopFOC();
motor.move(target_velocity);
// user communication
command.run();
}