
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 5:8065b587ade0, committed 2015-11-20
- Comitter:
- Davidroid
- Date:
- Fri Nov 20 18:02:01 2015 +0000
- Parent:
- 4:cd1b33180e79
- Child:
- 6:32166bfc04b0
- Commit message:
- + FlagIRQHandler and ErrorHandler examples added.
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 Thu Nov 19 14:26:05 2015 +0000 +++ b/X_NUCLEO_IHM01A1.lib Fri Nov 20 18:02:01 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#a47569fc7534 +https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#f7e0c3621f77
--- a/main.cpp Thu Nov 19 14:26:05 2015 +0000 +++ b/main.cpp Fri Nov 20 18:02:01 2015 +0000 @@ -63,6 +63,82 @@ L6474 *motor; +/* Functions -----------------------------------------------------------------*/ + +/** + * @brief This is an example of user handler for the flag interrupt. + * @param None + * @retval None + * @note If needed, implement it, and then attach and enable it: + * + motor->AttachFlagIRQ(&FlagIRQHandler); + * + motor->EnableFlagIRQ(); + * To disable it: + * + motor->DisbleFlagIRQ(); + */ +void FlagIRQHandler(void) +{ + /* Set ISR flag. */ + motor->isrFlag = TRUE; + + /* Get the value of the status register. */ + unsigned int status = motor->GetStatus(); + + /* Check HIZ flag: if set, power brigdes are disabled. */ + if ((status & L6474_STATUS_HIZ) == L6474_STATUS_HIZ) + { /* HIZ state. Action to be customized. */ } + + /* Check direction. */ + if ((status & L6474_STATUS_DIR) == L6474_STATUS_DIR) + { /* Forward direction is set. Action to be customized. */ } + else + { /* Backward direction is set. Action to be customized. */ } + + /* 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 in HIZ state. */ + if ((status & L6474_STATUS_NOTPERF_CMD) == L6474_STATUS_NOTPERF_CMD) + { /* Command received by SPI can't be performed. Action to be customized. */ } + + /* Check WRONG_CMD flag: if set, the command does not exist. */ + if ((status & L6474_STATUS_WRONG_CMD) == L6474_STATUS_WRONG_CMD) + { /* The command received by SPI does not exist. Action to be customized. */ } + + /* Check UVLO flag: if not set, there is an undervoltage lock-out. */ + if ((status & L6474_STATUS_UVLO) == 0) + { /* Undervoltage lock-out. Action to be customized. */ } + + /* Check TH_WRN flag: if not set, the thermal warning threshold is reached. */ + if ((status & L6474_STATUS_TH_WRN) == 0) + { /* Thermal warning threshold is reached. Action to be customized. */ } + + /* Check TH_SHD flag: if not set, the thermal shut down threshold is reached. */ + if ((status & L6474_STATUS_TH_SD) == 0) + { /* Thermal shut down threshold is reached. Action to be customized. */ } + + /* Check OCD flag: if not set, there is an overcurrent detection. */ + if ((status & L6474_STATUS_OCD) == 0) + { /* Overcurrent detection. Action to be customized. */ } + + /* Reset ISR flag. */ + motor->isrFlag = FALSE; +} + +/** + * @brief This is an example of user handler for the errors. + * @param error error-code. + * @retval None + * @note If needed, implement it, and then attach it: + * + motor->AttachErrorHandler(&ErrorHandler); + */ +void ErrorHandler(uint16_t error) +{ + /* Printing to the console. */ + printf("Error: %d.\r\n", error); + + /* Aborting the program. */ + exit(EXIT_FAILURE); +} + + /* Main ----------------------------------------------------------------------*/ int main() @@ -71,7 +147,7 @@ DevSPI dev_spi(D11, D12, D13); /* Initializing Motor Control Component. */ - motor = new L6474(D8, D7, D9, D10, dev_spi); + motor = new L6474(D2, D8, D7, D9, D10, dev_spi); if (motor->Init(NULL) != COMPONENT_OK) return false;