Example program for library X-NUCLEO-IHM12A1 using two low voltage dual brush DC motors

Dependencies:   X_NUCLEO_IHM12A1 mbed

Fork of HelloWorld_IHM12A1 by ST Expansion SW Team

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

It shows how to use 2 bidirectional brush DC motors connected to the board by executing a 13 steps loop:

  • Step 0) Motor 0 runs in forward at 100% of max speed, Motor 1 is inactive
  • Step 1) Motor 0 runs in forward at 75% of max speed, Motor 1 runs in backward at 100% of max speed
  • Step 2) Motor 0 runs in forward at 50% of max speed, Motor 1 runs in backward at 75% of max speed
  • Step 3) Motor 0 runs in forward at 25% of max speed, Motor 1 runs in backward at 50% of max speed
  • Step 4) Motor 0 is stopped, Motor 1 runs in backward at 25% of max speed
  • Step 5) Motor 0 runs in backward at 25% of max speed, Motor 1 is stopped
  • Step 6) Motor 0 runs in backward at 50% of max speed, Motor 1 runs in forward at 25% of max speed
  • Step 7) Motor 0 runs in backward at 75% of max speed, Motor 1 runs in forward at 50% of max speed
  • Step 8) Motor 0 runs in backward at 100% of max speed, Motor 1 runs in forward at 75% of max speed
  • Step 9) Motor 0 runs in backward at 100% of max speed, Motor 1 runs in forward at 100% of max speed
  • Step 10) Stop both motors and disable bridges
  • Step 11) Motor 0 runs in forward at 100% of max speed, Motor 1 runs in forward at 100% of max speed
  • Step 12) Stop both motors and enter standby mode

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

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Fri Mar 24 14:13:53 2017 +0000
Parent:
5:7517162fb2b9
Child:
7:500c397c7dba
Commit message:
With the new version of the library.

Changed in this revision

X-NUCLEO-IHM12A1.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/X-NUCLEO-IHM12A1.lib	Fri Mar 24 11:01:02 2017 +0100
+++ b/X-NUCLEO-IHM12A1.lib	Fri Mar 24 14:13:53 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM12A1/#232e0c730f59
+https://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM12A1/#07acd6934359
--- a/main.cpp	Fri Mar 24 11:01:02 2017 +0100
+++ b/main.cpp	Fri Mar 24 14:13:53 2017 +0000
@@ -47,7 +47,7 @@
 /* Variables -----------------------------------------------------------------*/
 
 /* Initialization parameters of the motor connected to the expansion board. */
- Stspin240_250_init_t init =
+ STSpin240_250_init_t init =
  {
   20000, /* Frequency of PWM of Input Bridge A in Hz up to 100000Hz             */
   20000, /* Frequency of PWM of Input Bridge B in Hz up to 100000Hz             */
@@ -57,7 +57,7 @@
  };
 
 /* Motor Control Component. */
-STSPIN240_250 *motor;
+STSpin240_250 *motor;
 
 /* Functions -----------------------------------------------------------------*/
 
@@ -120,11 +120,11 @@
   
   /* Initializing Motor Control Component. */
   #if (defined TARGET_NUCLEO_F030R8)||(defined TARGET_NUCLEO_F334R8)
-  motor = new STSPIN240_250(D2, D9, D6, D7, D5, D4, A2);
+  motor = new STSpin240_250(D2, D9, D6, D7, D5, D4, A2);
   #elif (defined TARGET_NUCLEO_L152RE)
-  motor = new STSPIN240_250(D2, D9, D6, D7, D5, D4, A3);
+  motor = new STSpin240_250(D2, D9, D6, D7, D5, D4, A3);
   #else
-  motor = new STSPIN240_250(D2, D9, D6, D7, D5, D4, A0);
+  motor = new STSpin240_250(D2, D9, D6, D7, D5, D4, A0);
   #endif
   if (motor->init(&init) != COMPONENT_OK) exit(EXIT_FAILURE);
 
@@ -261,7 +261,7 @@
         default: {
           printf("STEP 12: Stop both motors and enter standby mode\r\n");
           /* Stop both motors and put chip in standby mode */
-          motor->Reset();    
+          motor->reset();    
           break;
         }
     }