This is an example application demonstrating building an EtherCAT system using Esmacat

Dependencies:   EsmacatShield X_NUCLEO_IHM01A1

Executing the Example

Table of Contents

    1. Import the program from Example_EtherCAT_System_Using_EASE to your program workspace. Refer to wiki page for details about working with EASE and a Motor shield.https://os.mbed.com/users/esmacat/code/HelloWorld_EASE_Motor_Example/wiki/HelloWorld_EASE_Motor_Example.
    2. Import the

      Import programHelloWorld_EASE_Proximity_Sensor

      Example showing how to integrate EASE with proximity Sensor and Base board

      to your program workspace
    3. Make the hardware connections as per the diagram below.
    4. Create a Esmacat master application program. This will be on the PC.
    5. Compile the imported programs and download the binaries on respective Mbed base boards.
    6. Run the Esmacat master program.

    Logic behind this example

    There are total 3 programs in this example

    1. Example_EtherCAT_System_Using_EASE : The motor is driven in forward direction in steps as long as the data received from the master is 0. Then reverse the direction of motor movement when the data received from the Esmacat master is 10.
    2. HelloWorld_EASE_Proximity_Sensor: This program is slight modification of the "HelloWorld_6180XA1" program provided by STMicrolectronics. For this example the red slider switch on the proximity sensor shield is slid towards "range".
    • Define the CS pin for EASE.
    • Create the SPI object for EASE.
    • Define a variable to hold the data to be sent to Esmacat master.
    • Create an EsmacatShield Slave object.
    • Write the proximity sensor data isinto Esmacat Master's Register 0. This part of the code resides in the function display_refresh().
    • In function int_continous_als_or_range_measure, where the device instances are created. Instead of D13 pin use D7 pin as D13 is being used by EASE for SPI communication.
    • In the main function set up the SPI for EASE.

    3. Esmacat Master application :

    https://os.mbed.com/media/uploads/pratima_hb/master_code_rpm_new4.png

    https://os.mbed.com/media/uploads/pratima_hb/master_code_rpm_new3.png

    1. Read the data from EASE 2 i.e. proximity sensor data, read the data from EASE1 telling if Motor is hard stopped.
    2. If the loop() is being entered the first time then write register 0 with data indicating to EASE1 to rotate the motor in forward direction. Save the start_time in seconds.
    3. Develop a logic to count the number of rotations of the motor based on the proximity sensor reading. Incorporate hysteresis in the logic.
    4. Once the number of rotations reach 10, record the end time and calculate the RPM 1 as 10/(end_time - start_time). Send a command to the motor to reverse the direction of rotation. And record the start time.
    5. Once the number of rotations each 20, record the end time and calculate the RPM 2 as 10/(end_time - start_time) and command the Motor to hard stop by sending data to EASE1.
    6. Once the EASE1 replies saying that the motor is hard stopped, find the average of the RPM1 and RPM2. Print the RPM value and stop the loop.

    All wikipages