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:
5:4c1e581bbb8b
Parent:
1:4d9b9123d9e1
Child:
6:b9b32d6c2b40
--- a/main.cpp	Tue May 17 12:56:07 2016 +0000
+++ b/main.cpp	Wed Jun 15 12:51:03 2016 +0000
@@ -112,7 +112,7 @@
   /* Code to be customised */
   /************************/
   /* Get the state of bridge A */
-  uint16_t bridgeState  = motor->CmdGetStatus(0);
+  uint16_t bridgeState  = motor->GetBridgeStatus(0);
   
   if (bridgeState == 0) 
   {
@@ -126,7 +126,7 @@
   }
   
   /* Get the state of bridge B */
-  bridgeState  = motor->CmdGetStatus(1);
+  bridgeState  = motor->GetBridgeStatus(1);
   
   if (bridgeState == 0) 
   {
@@ -212,46 +212,46 @@
         {
             printf("Run motor 0 at 20%% of the maximum speed\n");
             /* Set speed of motor 0 to 20% */
-            motor->SetMaxSpeed(0,20);
+            motor->SetSpeed(0,20);
             /* start motor 0 */
-            motor->Run(0, FORWARD);
+            motor->Run(0, BDCMotor::FWD);
         }
 
         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);
+            motor->SetSpeed(1,30);
             /* start motor 1 */
-            motor->Run(1, FORWARD);
+            motor->Run(1, BDCMotor::FWD);
         }
 
         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);
+            motor->SetSpeed(2,40);
             /* start motor 2 */
-            motor->Run(2, FORWARD);
+            motor->Run(2, BDCMotor::FWD);
         }
 
         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);
+            motor->SetSpeed(3,50);
             /* start motor 3 */
-            motor->Run(3, FORWARD);      
+            motor->Run(3, BDCMotor::FWD);      
         }
 
         if (gStep > 0)
         {
             wait_ms(1000);
         
-            motor->CmdHardHiZ(0);   
-            motor->CmdHardHiZ(1);   
-            motor->CmdHardHiZ(2);   
-            motor->CmdHardHiZ(3);
+            motor->HardHiZ(0);   
+            motor->HardHiZ(1);   
+            motor->HardHiZ(2);   
+            motor->HardHiZ(3);
             
             wait_ms(1000);
         }