Theis Rotating Platform Demo code

Dependencies:   X_NUCLEO_IHM01A1_Demo_Code mbed

Fork of Demo_IHM01A1_3-Motors by Arkadi Rafalovich

Revision:
23:f9d35a756e79
Parent:
21:ed054abddfe4
--- a/main.cpp	Mon Mar 14 09:09:02 2016 +0000
+++ b/main.cpp	Wed May 24 09:56:43 2017 +0000
@@ -1,41 +1,52 @@
-/**
- ******************************************************************************
- * @file    main.cpp
- * @author  Davide Aliprandi, STMicroelectronics
- * @version V1.0.0
- * @date    October 14th, 2015
- * @brief   mbed test application for the STMicroelectronics X-NUCLEO-IHM01A1
- *          Motor Control Expansion Board: control of 2 motors.
- ******************************************************************************
- * @attention
- *
- * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *   1. Redistributions of source code must retain the above copyright notice,
- *      this list of conditions and the following disclaimer.
- *   2. Redistributions in binary form must reproduce the above copyright notice,
- *      this list of conditions and the following disclaimer in the documentation
- *      and/or other materials provided with the distribution.
- *   3. Neither the name of STMicroelectronics nor the names of its contributors
- *      may be used to endorse or promote products derived from this software
- *      without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
+////////////////////////////////////////
+//    Rotating Platform Demo Code     //
+//  Arkadiraf@gmail.com - 24/05/2017  //
+////////////////////////////////////////
+
+/*
+   Parts:
+    Nucleo STM32F401RE
+    X-NUCLEO-IHM01A1 - 3 Stepper motor controller
+*/
+
+/*
+    Pinout:
+    Nucleo STM32F401RE
+    PA_5 --> led (DigitalOut)
+
+    PC - Serial 2
+    PA_2 (Tx) --> STLINK
+    PA_3 (Rx) --> STLINK
 
+    X-NUCLEO-IHM01A1 (http://www.st.com/content/ccc/resource/technical/document/data_brief/59/ff/d0/16/94/ff/49/85/DM00122463.pdf/files/DM00122463.pdf/jcr:content/translations/en.DM00122463.pdf)
+    SPI:
+    PA_7 (D11) --> mosi
+    PA_9 (D12) --> miso
+    PA_8 (D13) --> sclk
+
+    Motor 1
+    PA_10(D2) --> flag_irq  (DigitalOut)
+    PA_9 (D8) --> Standby   (DigitalOut)
+    PA_8 (D7) --> MOT1Dir  (DigitalOut)
+    PC_7 (D9) --> MOT1Step (PWM)
+    PB_6 (D10)--> ssel      (DigitalOut)
+
+    Motor 2
+    PA_10(D2) --> flag_irq  (DigitalOut)
+    PA_9 (D8) --> Standby   (DigitalOut)
+    PB_5 (D4) --> MOT2Dir   (DigitalOut)
+    PB_3 (D3) --> MOT2Step  (PWM)
+    PB_6 (D10)--> ssel      (DigitalOut)
+
+    Motor 3
+    PA_10(D2) --> flag_irq  (DigitalOut)
+    PA_9 (D8) --> Standby   (DigitalOut)
+    PB_4 (D5) --> MOT3Dir   (DigitalOut)
+    PB_10(D6) --> MOT3Step  (PWM)
+    PB_6 (D10)--> ssel      (DigitalOut)
+
+
+*/
 
 /* Includes ------------------------------------------------------------------*/
 
@@ -98,15 +109,16 @@
     motor1->SetStepMode(STEP_MODE_1_16);
     motor2->SetStepMode(STEP_MODE_1_16);
     motor3->SetStepMode(STEP_MODE_1_16);
-    /* Increasing the torque regulation current to 500mA. */
+   
+    /* Increasing the torque regulation current. */
     motor1->SetParameter(L6474_TVAL, 1250); // Limit 2.0A
-    motor2->SetParameter(L6474_TVAL, 1700); // Limit 1.7A
-    motor3->SetParameter(L6474_TVAL, 850);  // Limit 1.0A
+    motor2->SetParameter(L6474_TVAL, 1650); // Limit 1.7A
+    motor3->SetParameter(L6474_TVAL, 300);  // Limit 0.28A
     
     /* Max speed to 2400 step/s. */
-    motor1->SetMaxSpeed(1000);
-    motor2->SetMaxSpeed(1000);
-    motor3->SetMaxSpeed(1000);
+    motor1->SetMaxSpeed(750);
+    motor2->SetMaxSpeed(750);
+    motor3->SetMaxSpeed(750);
 
     /* Min speed to 200 step/s. */
     motor1->SetMinSpeed(100);
@@ -114,12 +126,12 @@
     motor3->SetMinSpeed(100);
     
     /* set accelerations */
-    motor1->SetAcceleration(500);
-    motor2->SetAcceleration(500);
-    motor3->SetAcceleration(500);
-    motor1->SetDeceleration(500);
-    motor2->SetDeceleration(500);
-    motor3->SetDeceleration(500);
+    motor1->SetAcceleration(250);
+    motor2->SetAcceleration(250);
+    motor3->SetAcceleration(250);
+    motor1->SetDeceleration(250);
+    motor2->SetDeceleration(250);
+    motor3->SetDeceleration(250);
     
     // Enabling motor
     motor1->Enable();