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 3:fffa53c7aed2, committed 2015-11-18
- Comitter:
- Davidroid
- Date:
- Wed Nov 18 18:45:35 2015 +0000
- Parent:
- 2:e12e4df7a486
- Child:
- 4:cd1b33180e79
- Commit message:
- + Program updated to reflect the modifications to the "StepperMotor" abstract class.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HelloWorld_IHM01A1.lib Wed Nov 18 18:45:35 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/ST-Expansion-SW-Team/code/HelloWorld_IHM01A1/#e12e4df7a486
--- a/X_NUCLEO_IHM01A1.lib Fri Nov 13 12:59:29 2015 +0000 +++ b/X_NUCLEO_IHM01A1.lib Wed Nov 18 18:45:35 2015 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#83a1eb397a65 +https://developer.mbed.org/teams/ST-Expansion-SW-Team/code/X_NUCLEO_IHM01A1/#d3c78f12a78d
--- a/main.cpp Fri Nov 13 12:59:29 2015 +0000 +++ b/main.cpp Wed Nov 18 18:45:35 2015 +0000 @@ -54,7 +54,7 @@ /* Definitions ---------------------------------------------------------------*/ /* Number of steps corresponding to one round angle of the motor. */ -#define ROUND_ANGLE_STEPS 1600 +#define ROUND_ANGLE_STEPS 3200 /* Variables -----------------------------------------------------------------*/ @@ -81,14 +81,14 @@ /* Main Loop. */ while(true) { - /*----- Moving forward of N steps. -----*/ + /*----- Moving. -----*/ /* Printing to the console. */ printf("--> Moving forward %d steps.\r\n", ROUND_ANGLE_STEPS); /* Moving N steps in the forward direction. */ - motor->Move(StepperMotor::CW, ROUND_ANGLE_STEPS); - + motor->Move(StepperMotor::FWD, ROUND_ANGLE_STEPS); + /* Waiting while the motor is active. */ motor->WaitWhileActive(); @@ -102,13 +102,13 @@ wait_ms(2000); - /*----- Moving backward N steps. -----*/ + /*----- Moving. -----*/ /* Printing to the console. */ - printf("--> Moving backward %d steps.\r\n", ROUND_ANGLE_STEPS); - + printf("--> Moving backward %d steps.\r\n", ROUND_ANGLE_STEPS >> 1); + /* Moving N steps in the backward direction. */ - motor->Move(StepperMotor::CCW, ROUND_ANGLE_STEPS); + motor->Move(StepperMotor::BWD, ROUND_ANGLE_STEPS >> 1); /* Waiting while the motor is active. */ motor->WaitWhileActive(); @@ -118,6 +118,7 @@ /* Printing to the console. */ printf(" Position: %d.\r\n", position); + printf("--> Setting Home.\r\n"); /* Setting the current position to be the home position. */ motor->SetHome(); @@ -168,13 +169,13 @@ wait_ms(2000); - /*----- Moving backward. -----*/ + /*----- Running. -----*/ /* Printing to the console. */ - printf("--> Moving backward.\r\n"); + printf("--> Running backward.\r\n"); /* Requesting to run backward. */ - motor->Run(StepperMotor::CCW); + motor->Run(StepperMotor::BWD); /* Waiting until delay has expired. */ wait_ms(6000); @@ -185,7 +186,6 @@ /* Printing to the console. */ printf(" Speed: %d.\r\n", speed); - /*----- Increasing the speed while running. -----*/ /* Printing to the console. */ @@ -222,18 +222,6 @@ printf(" Speed: %d.\r\n", speed); - /*----- Moving forward. -----*/ - - /* Printing to the console. */ - printf("--> Moving forward.\r\n"); - - /* Requesting to run in forward direction. */ - motor->Run(StepperMotor::CW); - - /* Waiting until delay has expired. */ - wait_ms(4000); - - /*----- Requiring hard-stop while running. -----*/ /* Printing to the console. */ @@ -261,13 +249,13 @@ while(1) { /* Requesting to go to a specified position. */ - motor->GoTo(- ROUND_ANGLE_STEPS >> 2); + motor->GoTo(ROUND_ANGLE_STEPS >> 1); /* Waiting while the motor is active. */ motor->WaitWhileActive(); /* Requesting to go to a specified position. */ - motor->GoTo(ROUND_ANGLE_STEPS >> 2); + motor->GoTo(- (ROUND_ANGLE_STEPS >> 1)); /* Waiting while the motor is active. */ motor->WaitWhileActive();