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
Revision 34:0dee9a606869, committed 2019-04-24
- Comitter:
- scherfa2
- Date:
- Wed Apr 24 21:08:27 2019 +0000
- Parent:
- 33:de144094bdd1
- Commit message:
- asdf
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Buttons.cpp Wed Apr 24 21:08:27 2019 +0000
@@ -0,0 +1,30 @@
+#include "SETUP.h"
+
+extern volatile bool buttonSTART_pressed; // Used in the main loop
+extern volatile bool buttonSTART_enabled; // Used for debouncing
+extern Timeout buttonSTART_timeout; // Used for debouncing
+
+// Enables button when bouncing is over
+void buttonSTART_enabled_cb(void)
+{
+ buttonSTART_enabled = true;
+}
+void buttonSTART_diable_cb(void)
+{
+ buttonSTART_enabled = false;
+}
+
+// ISR handling button pressed event
+void buttonSTART_onpressed_cb(void)
+{
+ if (buttonSTART_enabled) { // Disabled while the button is bouncing
+ buttonSTART_enabled = false;
+ buttonSTART_pressed = true; // To be read by the main loop
+
+ buttonSTART_timeout.attach(callback(buttonSTART_enabled_cb), 0.03); // Debounce time 300 ms
+ }
+}
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Buttons.h Wed Apr 24 21:08:27 2019 +0000 @@ -0,0 +1,8 @@ +#ifndef MBED_Buttons_H +#define MBED_Buttons_H + +void buttonSTART_enabled_cb(); +void buttonSTART_diable_cb(); +void buttonSTART_onpressed_cb(); + +#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PWM2.cpp Wed Apr 24 21:08:27 2019 +0000
@@ -0,0 +1,11 @@
+#include "SETUP.h"
+
+
+extern PwmOut Servo;
+
+void ServoAusschuss(float periode, float duty)
+{
+ Servo.period(periode);
+ Servo = duty;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWM2.h Wed Apr 24 21:08:27 2019 +0000 @@ -0,0 +1,7 @@ + +#ifndef MBED_PWM2_H +#define MBED_PWM2_H + +void ServoAusschuss(float periode, float duty); + +#endif
--- a/SETUP.h Mon Apr 22 11:56:38 2019 +0000 +++ b/SETUP.h Wed Apr 24 21:08:27 2019 +0000 @@ -38,6 +38,8 @@ #include "DevSPI.h" #include "XNucleoIHM02A1.h" #include "Display.h" +#include "Buttons.h" +#include "PWM2.h" // ----------------------------------------------------------------------------- // GPIO
--- a/STEPPER_INIT.cpp Mon Apr 22 11:56:38 2019 +0000
+++ b/STEPPER_INIT.cpp Wed Apr 24 21:08:27 2019 +0000
@@ -1,80 +1,16 @@
#include "SETUP.h"
+#include "STEPPER_INIT.h"
/* Variables -----------------------------------------------------------------*/
-/* Motor Control Expansion Board. */
-XNucleoIHM02A1 *x_nucleo_ihm02a1_1;
-XNucleoIHM02A12 *x_nucleo_ihm02a1_2;
-
-/* Initialization parameters of the motors connected to the expansion board. */
-L6470_init_t init[L6470DAISYCHAINSIZE] = {
- /* First Motor. */
- {
- 9.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. */
- 300.0, /* Motor initial speed [step/s]. */
- 500.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
- 500.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
- 992.0, /* Motor maximum speed [step/s]. */
- 0.0, /* Motor minimum speed [step/s]. */
- 602.7, /* Motor full-step speed threshold [step/s]. */
- 3.06, /* Holding kval [V]. */
- 3.06, /* Constant speed kval [V]. */
- 3.06, /* Acceleration starting kval [V]. */
- 3.06, /* Deceleration starting kval [V]. */
- 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */
- 392.1569e-6, /* Start slope [s/step]. */
- 643.1372e-6, /* Acceleration final slope [s/step]. */
- 643.1372e-6, /* Deceleration final slope [s/step]. */
- 0, /* Thermal compensation factor (range [0, 15]). */
- 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
- 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
- StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
- 0xFF, /* Alarm conditions enable. */
- 0x2E88 /* Ic configuration. */
- },
+extern L6470B **motors2;
+extern L6470 **motors;
- /* Second Motor. */
- {
- 9.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. */
- 300.0, /* Motor initial speed [step/s]. */
- 500.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
- 500.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
- 992.0, /* Motor maximum speed [step/s]. */
- 0.0, /* Motor minimum speed [step/s]. */
- 602.7, /* Motor full-step speed threshold [step/s]. */
- 3.06, /* Holding kval [V]. */
- 3.06, /* Constant speed kval [V]. */
- 3.06, /* Acceleration starting kval [V]. */
- 3.06, /* Deceleration starting kval [V]. */
- 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */
- 392.1569e-6, /* Start slope [s/step]. */
- 643.1372e-6, /* Acceleration final slope [s/step]. */
- 643.1372e-6, /* Deceleration final slope [s/step]. */
- 0, /* Thermal compensation factor (range [0, 15]). */
- 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
- 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
- StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
- 0xFF, /* Alarm conditions enable. */
- 0x2E88 /* Ic configuration. */
- }
-};
-
-void SchrittmotorenInit()
+void SpleisserMotorFWD()
{
- /* Initializing Motor Control Expansion Board. */
- x_nucleo_ihm02a1_2 = new XNucleoIHM02A12(&init[0], &init[1],IRQ_FLAG_MOTOR, IRQ_BUSY_MOTOR, STB_MOTOR, SPI_CS_1, SPI_MOSI, SPI_MISO, SPI_CLK );
- x_nucleo_ihm02a1_1 = new XNucleoIHM02A1(&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. */
- L6470B **motors2 = x_nucleo_ihm02a1_2->get_components();
- L6470 **motors = x_nucleo_ihm02a1_1->get_components();
-}
+ printf("Warten\r\n");
+ motors[1]->run(StepperMotor::FWD,100);;
+
+}
--- a/STEPPER_INIT.h Mon Apr 22 11:56:38 2019 +0000 +++ b/STEPPER_INIT.h Wed Apr 24 21:08:27 2019 +0000 @@ -1,6 +1,10 @@ #ifndef STEPPER_INIT_H #define STEPPER_INIT_H -void SchrittmotorenInit(); + + + + +void SpleisserMotorFWD(); #endif
--- a/ST_DUO.cpp Mon Apr 22 11:56:38 2019 +0000
+++ b/ST_DUO.cpp Wed Apr 24 21:08:27 2019 +0000
@@ -2,17 +2,48 @@
int StatusDUO=DUO_DEFAULT;
+extern volatile bool buttonSTART_pressed;
+extern volatile bool buttonSTART_enabled;
+extern PwmOut Servo;
+
+void EntryDuoStart()
+{
+ gotoxy(1,1);
+ DisplaySendeString("Modus: DUO-Betrieb");
+ gotoxy(1,3);
+ DisplaySendeString("Betrieb gestartet");
+
+ SpleisserMotorFWD();
+
+ //Test pwm
+ ServoAusschuss(0.001, 0.5);
+
+ StatusDUO=DUO_START;
+}
+
void EntryDUO()
{
switch(StatusDUO)
{
case DUO_DEFAULT:
- printf("DUO_MODUS\n\r");
- Thread::wait(1000);
+ printf("DUO_MODUS\r\n");
+ // SpleisserMotorFWD();
+
+
+ if(buttonSTART_pressed==true)
+ {
+ buttonSTART_pressed=false;
+ buttonSTART_diable_cb();
+ EntryDuoStart();
+
+ }
+
break;
case DUO_START:
+ printf("DUO_START\r\n");
+
break;
case DUO_FilamentIN:
--- a/X_NUCLEO_IHM02A1.lib Mon Apr 22 11:56:38 2019 +0000 +++ b/X_NUCLEO_IHM02A1.lib Wed Apr 24 21:08:27 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/scherfa2/code/X_NUCLEO_IHM02A1/#226ee8900244 +https://os.mbed.com/users/scherfa2/code/X_NUCLEO_IHM02A1/#d7771e6776b0
--- a/main.cpp Mon Apr 22 11:56:38 2019 +0000
+++ b/main.cpp Wed Apr 24 21:08:27 2019 +0000
@@ -4,59 +4,108 @@
/* Status Spleisser definieren*/
int StatusSpleisser = ST_SOLO;
+/*Buttons initialisieren*/
+InterruptIn buttonSTART(USER_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
+
+/*PWMs initialisieren*/
+PwmOut Servo(PB_4);
+
/*Input initalisieren für Status Spleisser*/
DigitalIn InputKontrollmodul(COM_SIGNAL);
+/* Motor Control Expansion Board. */
+XNucleoIHM02A1 *x_nucleo_ihm02a1_1;
+XNucleoIHM02A12 *x_nucleo_ihm02a1_2;
+/* Initialization parameters of the motors connected to the expansion board. */
+L6470_init_t init[L6470DAISYCHAINSIZE] = {
+ /* First Motor. */
+ {
+ 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. */
+ 300.0, /* Motor initial speed [step/s]. */
+ 500.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
+ 500.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
+ 992.0, /* Motor maximum speed [step/s]. */
+ 0.0, /* Motor minimum speed [step/s]. */
+ 602.7, /* Motor full-step speed threshold [step/s]. */
+ 3.06, /* Holding kval [V]. */
+ 3.06, /* Constant speed kval [V]. */
+ 3.06, /* Acceleration starting kval [V]. */
+ 3.06, /* Deceleration starting kval [V]. */
+ 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */
+ 392.1569e-6, /* Start slope [s/step]. */
+ 643.1372e-6, /* Acceleration final slope [s/step]. */
+ 643.1372e-6, /* Deceleration final slope [s/step]. */
+ 0, /* Thermal compensation factor (range [0, 15]). */
+ 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
+ 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
+ StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
+ 0xFF, /* Alarm conditions enable. */
+ 0x2E88 /* Ic configuration. */
+ },
+
+ /* Second Motor. */
+ {
+ 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. */
+ 300.0, /* Motor initial speed [step/s]. */
+ 500.0, /* Motor acceleration [step/s^2] (comment for infinite acceleration mode). */
+ 500.0, /* Motor deceleration [step/s^2] (comment for infinite deceleration mode). */
+ 992.0, /* Motor maximum speed [step/s]. */
+ 0.0, /* Motor minimum speed [step/s]. */
+ 602.7, /* Motor full-step speed threshold [step/s]. */
+ 3.06, /* Holding kval [V]. */
+ 3.06, /* Constant speed kval [V]. */
+ 3.06, /* Acceleration starting kval [V]. */
+ 3.06, /* Deceleration starting kval [V]. */
+ 61.52, /* Intersect speed for bemf compensation curve slope changing [step/s]. */
+ 392.1569e-6, /* Start slope [s/step]. */
+ 643.1372e-6, /* Acceleration final slope [s/step]. */
+ 643.1372e-6, /* Deceleration final slope [s/step]. */
+ 0, /* Thermal compensation factor (range [0, 15]). */
+ 3.06 * 1000 * 1.10, /* Ocd threshold [ma] (range [375 ma, 6000 ma]). */
+ 3.06 * 1000 * 1.00, /* Stall threshold [ma] (range [31.25 ma, 4000 ma]). */
+ StepperMotor::STEP_MODE_1_128, /* Step mode selection. */
+ 0xFF, /* Alarm conditions enable. */
+ 0x2E88 /* Ic configuration. */
+ }
+};
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-InterruptIn button1(USER_BUTTON);
-volatile int idx = 0;
-volatile bool button1_pressed = false; // Used in the main loop
-volatile bool button1_enabled = true; // Used for debouncing
-Timeout button1_timeout; // Used for debouncing
-
-// Enables button when bouncing is over
-void button1_enabled_cb(void)
-{
- button1_enabled = true;
-}
-
-// ISR handling button pressed event
-void button1_onpressed_cb(void)
-{
- if (button1_enabled) { // Disabled while the button is bouncing
- button1_enabled = false;
- button1_pressed = true; // To be read by the main loop
-
- if(idx<4){
- idx++;
- }
- else{idx=1;}
-
- button1_timeout.attach(callback(button1_enabled_cb), 0.03); // Debounce time 300 ms
- }
-}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-
-
-
+L6470B **motors2;
+L6470 **motors;
/* Main ----------------------------------------------------------------------*/
int main()
{
- /*----- Initialization. -----*/
+/*----- 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 );
- SchrittmotorenInit();
- button1.fall(callback(button1_onpressed_cb)); // Attach ISR to handle button press event
+/* 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
while(1)
{