Simple program featuring a few API functions usage of the X_NUCLEO_IHM04A1 library.

Dependencies:   X_NUCLEO_IHM04A1 mbed

Dependents:   SimplePIDBot

Fork of HelloWorld_IHM04A1 by ST Expansion SW Team

This application provides a simple example of usage of the X-NUCLEO-IHM04A1 Brush DC Motor Control Expansion Board.

It shows how to use four unidirectional brush DC motors connected to the board by running the four motor in parallel. At the beginning, no motor is running. Each time the user presses the user button, a new brush DC motor is activated. Motors run during one second, stop during one second and run again.

  • motor 1 runs at 20% of maximum speed.
  • motor 2 runs at 30% of maximum speed.
  • motor 3 runs at 40% of maximum speed.
  • motor 4 runs at 50% of maximum speed.

For the hardware configuration of the expansion board, please refer to the X_NUCLEO_IHM04A1 library web page.

Revision:
1:4d9b9123d9e1
Parent:
0:dcc35ef6effc
Child:
5:4c1e581bbb8b
--- a/main.cpp	Tue May 03 11:46:15 2016 +0000
+++ b/main.cpp	Tue May 17 09:45:43 2016 +0000
@@ -3,13 +3,13 @@
   * @file    Multi/Examples/MotionControl/IHM04A1_ExampleFor4UniDirMotors/Src/main.c 
   * @author  IPC Rennes
   * @version V1.0.0
-  * @date    January 06, 2015
+  * @date    May 16, 2016
   * @brief   This example shows how to use 1 IHM04A1 expansion board with 
   * 4 unidirectionnal Brush DC motors.
   * Each motor has one lead connected to one of the bridge output, 
   * the other lead to the ground. The input bridges are not parallelised.
   * The demo sequence starts when the user button is pressed.
-  * Each time, the user button is pressed, the demo step is changed
+  * Each time, the user button is pressed, one new motor is activated
   ******************************************************************************
   * @attention
   *
@@ -188,17 +188,17 @@
     motor->AttachErrorHandler(Error_Handler);
 
     /* Printing to the console. */
-    printf("Motor Control Application Example for 1 Motor\r\n\n");
+    printf("Motor Control Application Example for 4 Motor\r\n\n");
 
 
     /* Select the configuration with no bridge paralleling, two unidirectionnal motors on bridge A 
        and two unidirectionnal motors on bridge B */
     motor->SetDualFullBridgeConfig(PARALLELING_NONE___2_UNDIR_MOTOR_BRIDGE_A__2_UNDIR_MOTOR_BRIDGE_B);
  
-    /* Set PWM Frequency of bridge A inputs to 10000 Hz */ 
+    /* Set PWM Frequency of bridge A inputs to 1000 Hz */ 
     motor->SetBridgeInputPwmFreq(0,1000);
   
-    /* Set PWM Frequency of bridge B inputs to 25000 Hz */ 
+    /* Set PWM Frequency of bridge B inputs to 2000 Hz */ 
     motor->SetBridgeInputPwmFreq(1,2000);
   
     // Attach button_pressed function to Irq
@@ -210,7 +210,8 @@
 
         if (gStep > 0)
         {
-            /* Set speed of motor 0 to 20 % */
+            printf("Run motor 0 at 20%% of the maximum speed\n");
+            /* Set speed of motor 0 to 20% */
             motor->SetMaxSpeed(0,20);
             /* start motor 0 */
             motor->Run(0, FORWARD);
@@ -218,6 +219,7 @@
 
         if (gStep > 1)
         {
+            printf("Run motor 1 at 30%% of the maximum speed\n");
             /* Set speed of motor 1 to 30 % */
             motor->SetMaxSpeed(1,30);
             /* start motor 1 */
@@ -226,6 +228,7 @@
 
         if (gStep > 2)
         {
+            printf("Run motor 2 at 40%% of the maximum speed\n");
             /* Set speed of motor 2 to 40 % */
             motor->SetMaxSpeed(2,40);
             /* start motor 2 */
@@ -234,6 +237,7 @@
 
         if (gStep > 3)
         {
+            printf("Run motor 3 at 50%% of the maximum speed\n");
             /* Set speed of motor 3 to 50 % */
             motor->SetMaxSpeed(3,50);
             /* start motor 3 */