Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 7366_lib TLE5206_lib
Diff: main.cpp
- Revision:
- 0:509b29d50fcb
- Child:
- 2:486bb9b6bd78
diff -r 000000000000 -r 509b29d50fcb main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Jan 29 15:32:49 2019 +0000 @@ -0,0 +1,54 @@ +//Includes +#include "mbed.h" +#include "7366_lib.h" +#include "TLE5206_lib.h" + +// Liaison SPI avec les compteurs +#define SPI_SCLK PA_5 //A4 +#define SPI_MISO PA_6 //A5 +#define SPI_MOSI PA_7 //A6 +#define SPI_CS3 PA_0//A0 +#define SPI_CS2 PA_1 +#define SPI_CS1 PA_3 + +// Vers le pont en H +#define H1_IN1 PA_9 //D1 - PWM1/2 +#define H1_IN2 PA_10 //D0 - PWM1/3 +#define H2_IN1 PA_8 //D9 - PWM1/1 +#define H2_IN2 PB_7 //D4 - PWM17/1 +#define H3_IN1 PB_6 //D5 - PWM16/1 +#define H3_IN2 PA_4 //A3 - PWM3/2 + +#define DECOUP_HACH 50 //us - 20 000 kHz pour les oreilles + + +DigitalOut myled(LED3); + +SPI_7366 compt1(SPI_MOSI, SPI_MISO, SPI_SCLK,SPI_CS1); +SPI_7366 compt2(SPI_MOSI, SPI_MISO, SPI_SCLK,SPI_CS2); +SPI_7366 compt3(SPI_MOSI, SPI_MISO, SPI_SCLK,SPI_CS3); + +TLE5206 moteur1(H1_IN1,H1_IN2); +TLE5206 moteur2(H2_IN1,H2_IN2); +TLE5206 moteur3(H3_IN1,H3_IN2); + +int main() { + compt1.setup(); + compt2.setup(); + compt3.setup(); + + moteur1.setup(DECOUP_HACH); + moteur2.setup(DECOUP_HACH); + moteur3.setup(DECOUP_HACH); + + moteur1.write(-0.4); + moteur2.write(-0.7); + moteur3.write(0.7); + + // Loop + while(1) { + compt3.read_value(); + myled = !myled; + wait(1); + } +} \ No newline at end of file