mirror of
https://github.com/modelec/PAMI-2025.git
synced 2026-01-18 16:27:30 +01:00
Ajout de la configuration du projet, des fichiers de wowki ainsi que le contrôle des moteurs pas à pas.
This commit is contained in:
37
.gitignore
vendored
37
.gitignore
vendored
@@ -1,32 +1,5 @@
|
||||
# Prerequisites
|
||||
*.d
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Compiled Dynamic libraries
|
||||
*.so
|
||||
*.dylib
|
||||
*.dll
|
||||
|
||||
# Fortran module files
|
||||
*.mod
|
||||
*.smod
|
||||
|
||||
# Compiled Static libraries
|
||||
*.lai
|
||||
*.la
|
||||
*.a
|
||||
*.lib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
|
||||
10
.vscode/extensions.json
vendored
Normal file
10
.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
// See http://go.microsoft.com/fwlink/?LinkId=827846
|
||||
// for the documentation about the extensions.json format
|
||||
"recommendations": [
|
||||
"platformio.platformio-ide"
|
||||
],
|
||||
"unwantedRecommendations": [
|
||||
"ms-vscode.cpptools-extension-pack"
|
||||
]
|
||||
}
|
||||
89
diagram.json
Normal file
89
diagram.json
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"version": 1,
|
||||
"author": "Anonymous maker",
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "board-esp32-devkit-c-v4",
|
||||
"id": "esp",
|
||||
"top": 180.74,
|
||||
"left": -265.1,
|
||||
"rotate": 90,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-a4988",
|
||||
"id": "drv1",
|
||||
"top": 91.4,
|
||||
"left": -206,
|
||||
"rotate": 270,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-stepper-motor",
|
||||
"id": "stepper1",
|
||||
"top": -140.39,
|
||||
"left": -258.77,
|
||||
"attrs": { "size": "17" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-a4988",
|
||||
"id": "drv2",
|
||||
"top": 91.4,
|
||||
"left": -33.2,
|
||||
"rotate": 270,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-stepper-motor",
|
||||
"id": "stepper2",
|
||||
"top": -140.39,
|
||||
"left": -85.97,
|
||||
"attrs": { "size": "17" }
|
||||
},
|
||||
{
|
||||
"type": "wokwi-a4988",
|
||||
"id": "drv3",
|
||||
"top": 91.4,
|
||||
"left": -378.8,
|
||||
"rotate": 270,
|
||||
"attrs": {}
|
||||
},
|
||||
{
|
||||
"type": "wokwi-stepper-motor",
|
||||
"id": "stepper3",
|
||||
"top": -140.39,
|
||||
"left": -431.57,
|
||||
"attrs": { "size": "17" }
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
["esp:TX", "$serialMonitor:RX", "", []],
|
||||
["esp:RX", "$serialMonitor:TX", "", []],
|
||||
["drv1:1B", "stepper1:B-", "green", ["v0"]],
|
||||
["drv1:1A", "stepper1:B+", "green", ["v0"]],
|
||||
["drv1:2A", "stepper1:A+", "green", ["v0"]],
|
||||
["drv1:2B", "stepper1:A-", "green", ["v0"]],
|
||||
["drv2:1B", "stepper2:B-", "green", ["v0"]],
|
||||
["drv2:1A", "stepper2:B+", "green", ["v0"]],
|
||||
["drv2:2A", "stepper2:A+", "green", ["v0"]],
|
||||
["drv2:2B", "stepper2:A-", "green", ["v0"]],
|
||||
["drv3:1B", "stepper3:B-", "green", ["v0"]],
|
||||
["drv3:1A", "stepper3:B+", "green", ["v0"]],
|
||||
["drv3:2A", "stepper3:A+", "green", ["v0"]],
|
||||
["drv3:2B", "stepper3:A-", "green", ["v0"]],
|
||||
["drv3:STEP", "esp:33", "gold", ["v28.8", "h86.4"]],
|
||||
["drv1:STEP", "esp:32", "gold", ["v28.8", "h-38.4"]],
|
||||
["drv1:SLEEP", "drv1:RESET", "green", ["v9.6", "h-9.6", "v9.6"]],
|
||||
["drv2:RESET", "drv2:SLEEP", "green", ["v9.6", "h9.6"]],
|
||||
["drv3:RESET", "drv3:SLEEP", "green", ["v9.6", "h9.6"]],
|
||||
["esp:14", "drv3:ENABLE", "green", ["v-19.05", "h-124.8"]],
|
||||
["esp:27", "drv1:ENABLE", "green", ["v0"]],
|
||||
["esp:26", "drv2:ENABLE", "green", ["v-28.65", "h144"]],
|
||||
["esp:16", "drv1:DIR", "blue", ["v9.6", "h144"]],
|
||||
["esp:4", "drv3:DIR", "blue", ["v19.2", "h-57.6", "v-201.6"]],
|
||||
["drv2:DIR", "esp:2", "blue", ["v211.2", "h-288"]],
|
||||
["drv2:STEP", "esp:13", "gold", ["v76.8", "h-105.6"]]
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
37
include/README
Normal file
37
include/README
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the convention is to give header files names that end with `.h'.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
lib/README
Normal file
46
lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into the executable file.
|
||||
|
||||
The source code of each library should be placed in a separate directory
|
||||
("lib/your_library_name/[Code]").
|
||||
|
||||
For example, see the structure of the following example libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
Example contents of `src/main.c` using Foo and Bar:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries by scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
15
platformio.ini
Normal file
15
platformio.ini
Normal file
@@ -0,0 +1,15 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:esp32dev]
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
framework = arduino
|
||||
lib_deps = teemuatlut/TMCStepper@^0.7.3
|
||||
92
src/main.cpp
Normal file
92
src/main.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <TMCStepper.h>
|
||||
|
||||
// Courant max moteur (en mA)
|
||||
#define R_SENSE 0.11f // Valeur typique pour TMC2209
|
||||
#define CURRENT 800 // Courant RMS souhaité
|
||||
|
||||
// UART
|
||||
#define TX_PIN1 17
|
||||
#define RX_PIN1 16
|
||||
|
||||
// Moteur 1
|
||||
#define DIR_PIN1 4
|
||||
#define STEP_PIN1 33
|
||||
|
||||
// Moteur 2
|
||||
#define DIR_PIN2 16
|
||||
#define STEP_PIN2 32
|
||||
|
||||
// Moteur 3
|
||||
#define DIR_PIN3 2
|
||||
#define STEP_PIN3 13
|
||||
|
||||
// Instances TMC2209
|
||||
TMC2209Stepper driver1(&Serial1, R_SENSE, 0b00);
|
||||
TMC2209Stepper driver2(&Serial1, R_SENSE, 0b01);
|
||||
TMC2209Stepper driver3(&Serial1, R_SENSE, 0b10);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial1.begin(115200, SERIAL_8N1, RX_PIN1, TX_PIN1);
|
||||
|
||||
pinMode(STEP_PIN1, OUTPUT);
|
||||
pinMode(DIR_PIN1, OUTPUT);
|
||||
pinMode(STEP_PIN2, OUTPUT);
|
||||
pinMode(DIR_PIN2, OUTPUT);
|
||||
pinMode(STEP_PIN3, OUTPUT);
|
||||
pinMode(DIR_PIN3, OUTPUT);
|
||||
|
||||
// Initialisation des drivers
|
||||
driver1.begin();
|
||||
driver1.rms_current(CURRENT);
|
||||
driver1.microsteps(16);
|
||||
driver1.en_spreadCycle(false); // Utilise StealthChop
|
||||
driver1.pdn_disable(true); // UART uniquement
|
||||
|
||||
driver2.begin();
|
||||
driver2.rms_current(CURRENT);
|
||||
driver2.microsteps(16);
|
||||
driver2.en_spreadCycle(false);
|
||||
driver2.pdn_disable(true);
|
||||
|
||||
driver3.begin();
|
||||
driver3.rms_current(CURRENT);
|
||||
driver3.microsteps(16);
|
||||
driver3.en_spreadCycle(false);
|
||||
driver3.pdn_disable(true);
|
||||
|
||||
Serial.println("Drivers initialisés.");
|
||||
}
|
||||
|
||||
void stepMotor(int stepPin, int dirPin, bool direction, int steps, int delay_us)
|
||||
{
|
||||
digitalWrite(dirPin, direction);
|
||||
for (int i = 0; i < steps; i++)
|
||||
{
|
||||
digitalWrite(stepPin, HIGH);
|
||||
delayMicroseconds(delay_us);
|
||||
digitalWrite(stepPin, LOW);
|
||||
delayMicroseconds(delay_us);
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// Exemple : chaque moteur fait 200 pas dans un sens, puis dans l'autre
|
||||
stepMotor(STEP_PIN1, DIR_PIN1, true, 200, 1000);
|
||||
delay(500);
|
||||
stepMotor(STEP_PIN1, DIR_PIN1, false, 200, 1000);
|
||||
|
||||
stepMotor(STEP_PIN2, DIR_PIN2, true, 200, 1000);
|
||||
delay(500);
|
||||
stepMotor(STEP_PIN2, DIR_PIN2, false, 200, 1000);
|
||||
|
||||
stepMotor(STEP_PIN3, DIR_PIN3, true, 200, 1000);
|
||||
delay(500);
|
||||
stepMotor(STEP_PIN3, DIR_PIN3, false, 200, 1000);
|
||||
|
||||
delay(2000);
|
||||
}
|
||||
11
test/README
Normal file
11
test/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
4
wokwi.toml
Normal file
4
wokwi.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[wokwi]
|
||||
version = 1
|
||||
firmware = '.pio/build/esp32dev/firmware.bin'
|
||||
elf = '.pio/build/esp32dev/firmware.bin'
|
||||
Reference in New Issue
Block a user