This is an example application demonstrating building an EtherCAT system using Esmacat
Dependencies: EsmacatShield X_NUCLEO_IHM01A1
Basic Information of Esmacat
Information about Esmacat and EASE is provided in the link below. https://os.mbed.com/users/pratima_hb/code/EASE_Example/wiki/Homepage
Information about the hardware needs and setup is provided in the link below. https://os.mbed.com/users/pratima_hb/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/pratima_hb/code/EASE_Example/wiki/Software
About this example
This is an example application to demonstrate the ease with which a system, which communicates over EtherCAT, can be build. It measures the RPM of a motor using a proximity sensor.
Following lists the hardware required
- 2 x Mbed boards with Arduino UNO form factor (NUCLEO-F103RB)
- 2 x EASE boards
- 1 x proximity sensor shield (X_NUCLEO_6180XA1)
- 1 x Motor shield (X-NUCLEO-IHM01A1)
- 1 x stepper motor
- 1 x Ethernet POE injector with a 24VDC power supply
- 2 x Ethernet cables
- Keyboard, mouse, and monitor
- PC with Linux/Windows OS installed
- DC power supply for motor
Click here to know more about this Example
Revision 34:543d0d1147d9, committed 2017-03-01
- Comitter:
- Davidroid
- Date:
- Wed Mar 01 13:31:48 2017 +0000
- Parent:
- 33:b7c72f06bc38
- Child:
- 35:2b44ed4ec7a0
- Commit message:
- Fitting mbed coding style.
Changed in this revision
X_NUCLEO_IHM01A1.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_IHM01A1.lib Fri Oct 28 13:50:25 2016 +0000 +++ b/X_NUCLEO_IHM01A1.lib Wed Mar 01 13:31:48 2017 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#c4d0fee5ce75 +http://developer.mbed.org/teams/ST/code/X_NUCLEO_IHM01A1/#6e5198e46287
--- a/main.cpp Fri Oct 28 13:50:25 2016 +0000 +++ b/main.cpp Wed Mar 01 13:31:48 2017 +0000 @@ -70,8 +70,7 @@ /* Variables -----------------------------------------------------------------*/ /* Initialization parameters. */ -L6474_Init_t init = -{ +L6474_Init_t init = { 160, /* Acceleration rate in pps^2. Range: (0..+inf). */ 160, /* Deceleration rate in pps^2. Range: (0..+inf). */ 1600, /* Maximum speed in pps. Range: (30..10000]. */ @@ -120,11 +119,12 @@ /* Get the value of the status register. */ unsigned int status = motor->GetStatus(); - + /* Check NOTPERF_CMD flag: if set, the command received by SPI can't be performed. */ /* This often occures when a command is sent to the L6474 while it is not in HiZ state. */ - if ((status & L6474_STATUS_NOTPERF_CMD) == L6474_STATUS_NOTPERF_CMD) + if ((status & L6474_STATUS_NOTPERF_CMD) == L6474_STATUS_NOTPERF_CMD) { printf(" WARNING: \"FLAG\" interrupt triggered. Non-performable command detected when updating L6474's registers while not in HiZ state.\r\n"); + } /* Reset ISR flag. */ motor->isr_flag = FALSE; @@ -142,8 +142,9 @@ /* Initializing Motor Control Component. */ motor = new L6474(D2, D8, D7, D9, D10, dev_spi); - if (motor->Init(&init) != COMPONENT_OK) + if (motor->Init(&init) != COMPONENT_OK) { exit(EXIT_FAILURE); + } /* Attaching and enabling interrupt handlers. */ motor->AttachFlagIRQ(&FlagIRQHandler); @@ -186,8 +187,9 @@ printf("--> Doubling the microsteps.\r\n"); /* Doubling the microsteps. */ - if (!motor->SetStepMode((StepperMotor::step_mode_t) STEP_MODE_1_16)) + if (!motor->SetStepMode((StepperMotor::step_mode_t) STEP_MODE_1_16)) { printf(" Step Mode not allowed.\r\n"); + } /* Waiting. */ wait_ms(DELAY_1); @@ -348,8 +350,7 @@ motor->SetHome(); /* Infinite Loop. */ - while (1) - { + while (true) { /* Requesting to go to a specified position. */ motor->GoTo(STEPS_1 >> 1);