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 mbed-rtos X_NUCLEO_IHM02A1
Diff: main.cpp
- Revision:
- 35:758191d5c6e1
- Parent:
- 34:0dee9a606869
- Child:
- 37:a74d377d8f74
--- a/main.cpp Wed Apr 24 21:08:27 2019 +0000
+++ b/main.cpp Sun May 05 16:18:20 2019 +0000
@@ -1,18 +1,45 @@
+/* ------------------------ INCLUDE ----------------------------------------- */
#include "SETUP.h"
+/* ---------------------------- END ----------------------------------------- */
+
+
+/* Zum testen */
+DigitalOut myled(LED1);
+DigitalIn mybutton(USER_BUTTON);
+
+
+
+/* ----------------------- INITIALISIERUNG ---------------------------------- */
+/* -------------------------------------------------------------------------- */
/* Status Spleisser definieren*/
int StatusSpleisser = ST_SOLO;
+
/*Buttons initialisieren*/
-InterruptIn buttonSTART(USER_BUTTON);
-
+InterruptIn buttonSTART(START_BUTTON);
volatile bool buttonSTART_pressed = false; // Used in the main loop
volatile bool buttonSTART_enabled = true; // Used for debouncing
Timeout buttonSTART_timeout; // Used for debouncing
+InterruptIn buttonAbbruch(ABBRUCH_BUTTON);
+volatile bool buttonAbbruch_pressed = false; // Used in the main loop
+volatile bool buttonAbbruch_enabled = true; // Used for debouncing
+Timeout buttonAbbruch_timeout; // Used for debouncing
+
+
/*PWMs initialisieren*/
-PwmOut Servo(PB_4);
+PwmOut Servo (SERVO_PWM);
+PwmOut Cutter_1 (CUTTER_ARC_1);
+PwmOut Cutter_2 (CUTTER_ARC_2);
+PwmOut Spleisser_1 (SPLEISSER_ARC_1);
+PwmOut Spleisser_2 (SPLEISSER_ARC_2);
+
+/*Lichtschranken*/
+DigitalIn LS_1(LICHTSCHRANKE_1); // HIGH - kein Filament / LOW - Filament
+DigitalIn LS_2(LICHTSCHRANKE_2); // HIGH - kein Filament / LOW - Filament /* Mit LS_x.read(); auslesen */
+DigitalIn LS_3(LICHTSCHRANKE_3); // HIGH - kein Filament / LOW - Filament
/*Input initalisieren für Status Spleisser*/
DigitalIn InputKontrollmodul(COM_SIGNAL);
@@ -25,7 +52,7 @@
L6470_init_t init[L6470DAISYCHAINSIZE] = {
/* First Motor. */
{
- 12.0, /* Motor supply voltage in V. */
+ 12.0, /* Motor supply voltage in V. */
400, /* Min number of steps per revolution for the motor. */
1.7, /* Max motor phase voltage in A. */
3.06, /* Max motor phase voltage in V. */
@@ -80,34 +107,52 @@
}
};
-
-
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
+/* Motor Objekte */
L6470B **motors2;
L6470 **motors;
+/* --------------------------------- END ------------------------------------ */
+/* -------------------------------------------------------------------------- */
-/* Main ----------------------------------------------------------------------*/
+
+
+
+
+
+/* ---------------------------------- MAIN ---------------------------------- */
+/* -------------------------------------------------------------------------- */
int main()
{
-/*----- Initialization. -----*/
+
/* Initializing Motor Control Expansion Board. */
-x_nucleo_ihm02a1_2 = new XNucleoIHM02A12(&init[0], &init[1],A4, A5, D4, D2, D11, D12, D3 );
-x_nucleo_ihm02a1_1 = new XNucleoIHM02A1(&init[0], &init[1], A4, A5, D4, A2, D11, D12, D3 );
-
+x_nucleo_ihm02a1_1 = new XNucleoIHM02A1 (&init[0], &init[1], IRQ_FLAG_MOTOR, IRQ_BUSY_MOTOR, STB_MOTOR, SPI_CS_1, SPI_MOSI, SPI_MISO, SPI_CLK );
+x_nucleo_ihm02a1_2 = new XNucleoIHM02A12(&init[0], &init[1], IRQ_FLAG_MOTOR, IRQ_BUSY_MOTOR, STB_MOTOR, SPI_CS_2, SPI_MOSI, SPI_MISO, SPI_CLK );
+
/* Building a list of motor control components. */
motors2 = x_nucleo_ihm02a1_2->get_components();
-motors = x_nucleo_ihm02a1_1->get_components();
-
-buttonSTART.fall(callback(buttonSTART_onpressed_cb)); // Attach ISR to handle button press event
+motors = x_nucleo_ihm02a1_1->get_components();
+
+/* Attach ISR to handle button press event */
+buttonSTART.fall(callback(buttonSTART_onpressed_cb));
+buttonAbbruch.fall(callback(buttonAbbruch_onpressed_cb));
+
+/* Init PWM */
+Init_Servo();
+Init_Cutter();
+Init_Spleisser();
- while(1)
+/*Display*/
+wait_ms(250);
+DisplayInit();
+
+
+
+
+
+
+ /* -------------------- ---- STATE_MACHINE ------------------------------ */
+ while(1)
{
switch (StatusSpleisser)
{
@@ -134,4 +179,11 @@
}
}
+ /* ------------------------------ END ----------------------------------- */
+
+
+
+
}
+/* --------------------------------- END ------------------------------------ */
+/* -------------------------------------------------------------------------- */
\ No newline at end of file