Build an etherCAT slave with a Motor Shield Base Board having Arduino UNO form factor.

Dependencies:   EsmacatShield X_NUCLEO_IHM01A1

Information about Esmacat and EASE is provided in the link below. https://os.mbed.com/users/esmacat/code/EASE_Example/wiki/Homepage

Information about the hardware needs and setup is provided in the link below. https://os.mbed.com/users/esmacat/code/EASE_Example/wiki/Hardware-Setup

Information about the structure of the system and it's software is provided in the link below. https://os.mbed.com/users/esmacat/code/EASE_Example/wiki/Software

Files at this revision

API Documentation at this revision

Comitter:
pratima_hb
Date:
Wed Feb 12 22:08:37 2020 +0000
Parent:
39:1270497828ca
Commit message:
cosmetic changes

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Feb 06 22:44:58 2020 +0000
+++ b/main.cpp	Wed Feb 12 22:08:37 2020 +0000
@@ -165,32 +165,24 @@
 
 int main()
 {
-    /*----- Initialization of EASE -----*/
 
-   
-    /*----- Initialization. -----*/
-
-    /* Initializing SPI bus. */
+    /* Initializing SPI bus for Motor  */
     DevSPI dev_spi(D11, D12, D13);// SPI device for the motor
     dev_spi.setup(8, 3, 3E6);      // Set-up SPI device for the motor
-    
+/* EASE slave object creation and Initializing SPI bus for EASE */    
     EsmacatShield slave(spi, selectPin);    //Define Chip Selector Pin
     slave.setup_spi();                      //Setup SPI for EASE
 
-
     /* Initializing Motor Control Component. */
     motor = new L6474(D2, D8, D7, D3, D10, dev_spi);//PWM pin is set to D3 as D9 is used by EASE
     if (motor->init(&init) != COMPONENT_OK) {
         exit(EXIT_FAILURE);
     }
-
+    
     /* Attaching and enabling interrupt handlers. */
     motor->attach_flag_irq(&flag_irq_handler);
     motor->enable_flag_irq();
-    
-
-
-
+ 
     while(1)
     {
         // This part of the code sets up the Mode 1 for SPI to be used for
@@ -206,8 +198,7 @@
         wait_us(1000);  
            /* Printing to the console. */
         printf("--> Moving to position : %d\r\n", ease_read[0]);
-      
-        
+              
         // This part of the code sets up the Mode 1 for SPI to be used for
         // communication with EASE. This is needed because SPI for EASE operates
         // in Mode 1 which is different than what the motor shield SPI operates in.
@@ -215,8 +206,7 @@
         wait_us(200); 
         
         // command the motor to go to a set postion
-        motor->go_to(ease_read[0]);
-        
+        motor->go_to(ease_read[0]);       
     
         /* Getting current position. */
        int position = motor->get_position();