Difference between revisions of "Project Example: Main Motion (Ladder Diagram)"

From SoftMC-Wiki
Jump to: navigation, search
(Created page with "MM LD Creation")
 
Line 1: Line 1:
MM LD Creation
+
 
 +
The task's purpose is to use motion Function Blocks such as MC_MoveRelative, MC_MoveVelocity and mc_halt. <br/>
 +
The main program initializes a startup process in the softMC. <br/>
 +
After the startup process is done, the program sets 'Done' variable and a global variable. <br/>
 +
After 'Done' variable is set, programs 'Axis1' and 'Axis2' are called. <br/>
 +
The application uses two drives and their outputs. <br/>
 +
<br/>
 +
 
 +
After installation of device description file (created by the Configurator) to Device Repository, the drive's address will be declared in the Axis Pool:
 +
 
 +
[[File:Motion A1.PNG|border|600px]]          [[File:FF A2.PNG|border|600px]]
 +
<br/>
 +
<br/>
 +
 
 +
In the EtherCAT Slaves section, we can find the I/O mapping for each device.
 +
In the picture below input1, input2, Input3, Input4, Input5, Input11, Output1, Output2, Outout3, Output4 and Output5 are declared as new variables (can also be mapped as existing variables):
 +
 
 +
[[File:Motion CDHD I_O.PNG|border|600px]]
 +
<br/>
 +
<br/>
 +
 
 +
The main program uses 'softMC_Startup' FB ('mc_st' Instance) to initialize a startup process in the softMC. A rising edge detection will set the 'Done' variable (and also a global variable) and then call programs 'Axis1' and 'Axis2':
 +
 
 +
[[File:Motion main program LD.PNG|border|600px]]
 +
<br/>
 +
<br/>
 +
 
 +
==Declaration Section==
 +
The declaration section in the Axis programs contains the following instances (as shown in the next picture):<br/>
 +
1. MC_POWER_01 - an instance of MC_Power FB.<br/>
 +
  This Function Block enables/disables an axis.<br/>
 +
  If the axis is associated with a real drive, a state machine is invoked to enable/disable the drive via PDO.<br/>
 +
  If the axis is simulated, a MC-Basic subroutine is invoked to enable/disable the axis.<br/>
 +
2. MC_MoveVelocity_01 - an instance of MC_MoveVelocity FB.<br/>
 +
  This Function Block commands a never ending controlled motion at a specified velocity.<br/>
 +
3. MC_halt_01 - an instance of MC_halt FB.<br/>
 +
  This Function Block commands a controlled motion stop. The axis is moved to the state ‘DiscreteMotion’, until the velocity is zero. With the ‘Done’ output set, the state is transferred to ‘Standstill’.<br/>
 +
4. MC_MoveRelative_01 - an instance of MC_MoverRelative FB.<br/>
 +
  This Function Block commands a controlled motion of a specified distance relative to the set position at the time of the execution.<br/>
 +
5. mc_recet_01 - an instance of MC_Reset FB.<br/>
 +
  This Function Block makes the transition from the state ‘ErrorStop’ to ‘Standstill’ or ‘Disabled’ by resetting all internal axis-related errors. It does not affect the output of the FB instances.<br/>
 +
<br/>
 +
<br/>
 +
[[File:Motion Axis1 declaration.PNG|border|600px]]
 +
 
 +
 
 +
==Implementation Section==
 +
Note: Programs 'Axis1' and 'Axis2' are similar.<br/>
 +
Output5 is turned on when POU is called.<br/>
 +
Input1, Input2, Input3 and Input4 are attached to Output1, Output2, Output3 and Output4 respectively.<br/>
 +
If Output1 is triggered, the MC_Power FB is enabled. <br/>
 +
<br/>
 +
[[File:Motion Axis1 implementation LD.PNG|border|600px]]
 +
<br/>
 +
 
 +
If Axis is enabled, Input4 is not on, MC_MoveRelative_01.Busy has a False value and a rising edge is detected in Input2, then MC_MoveVelocity FB is executed with a positive direction.<br/>
 +
 
 +
If Axis is enabled, Input4 is not on, MC_MoveRelative_01.Busy has a False value and a rising edge is detected in Input3, then MC_MoveVelocity FB is executed with a negative direction.<br/>
 +
<br/>
 +
[[File:Motion Axis1 implementation1 LD.PNG|border|600px]]
 +
<br/>
 +
 
 +
When a falling edge is detected in Input2 or Input3, then a boolean variable 'stop_jog" is  triggered. <br/>
 +
If axis is enabled and 'stop_jog' is TRUE, the MC_halt FB is executed.<br/>
 +
If Input2 and Input3 are not on, Input 4 is on, then MC_MoveRelative is executed.<br/>
 +
If Input11 is on, then MC_Reset is executed.<br/>
 +
<br/>
 +
[[File:Motion Axis1 implementation2 LD.PNG|border|600px]]
 +
<br/>
 +
<br/>
 +
 
 +
 
 +
 
 +
==Visualization==
 +
 
 +
The program is controlled by a graphic interface:
 +
<br/>
 +
 
 +
[[File:Motion Visualization.PNG|border|600px]]
 +
<br/>
 +
<br/>
 +
When the startup process of softMC is done, the blue lamp is turned on.<br/>
 +
The user can turn on and off Input 1-4 for each drive and watch their status in the green lamps.

Revision as of 12:44, 19 February 2017

The task's purpose is to use motion Function Blocks such as MC_MoveRelative, MC_MoveVelocity and mc_halt.
The main program initializes a startup process in the softMC.
After the startup process is done, the program sets 'Done' variable and a global variable.
After 'Done' variable is set, programs 'Axis1' and 'Axis2' are called.
The application uses two drives and their outputs.

After installation of device description file (created by the Configurator) to Device Repository, the drive's address will be declared in the Axis Pool:

Motion A1.PNG FF A2.PNG

In the EtherCAT Slaves section, we can find the I/O mapping for each device. In the picture below input1, input2, Input3, Input4, Input5, Input11, Output1, Output2, Outout3, Output4 and Output5 are declared as new variables (can also be mapped as existing variables):

Motion CDHD I O.PNG

The main program uses 'softMC_Startup' FB ('mc_st' Instance) to initialize a startup process in the softMC. A rising edge detection will set the 'Done' variable (and also a global variable) and then call programs 'Axis1' and 'Axis2':

Motion main program LD.PNG

Declaration Section

The declaration section in the Axis programs contains the following instances (as shown in the next picture):
1. MC_POWER_01 - an instance of MC_Power FB.

  This Function Block enables/disables an axis.
If the axis is associated with a real drive, a state machine is invoked to enable/disable the drive via PDO.
If the axis is simulated, a MC-Basic subroutine is invoked to enable/disable the axis.

2. MC_MoveVelocity_01 - an instance of MC_MoveVelocity FB.

  This Function Block commands a never ending controlled motion at a specified velocity.

3. MC_halt_01 - an instance of MC_halt FB.

  This Function Block commands a controlled motion stop. The axis is moved to the state ‘DiscreteMotion’, until the velocity is zero. With the ‘Done’ output set, the state is transferred to ‘Standstill’.

4. MC_MoveRelative_01 - an instance of MC_MoverRelative FB.

  This Function Block commands a controlled motion of a specified distance relative to the set position at the time of the execution.

5. mc_recet_01 - an instance of MC_Reset FB.

  This Function Block makes the transition from the state ‘ErrorStop’ to ‘Standstill’ or ‘Disabled’ by resetting all internal axis-related errors. It does not affect the output of the FB instances.



Motion Axis1 declaration.PNG


Implementation Section

Note: Programs 'Axis1' and 'Axis2' are similar.
Output5 is turned on when POU is called.
Input1, Input2, Input3 and Input4 are attached to Output1, Output2, Output3 and Output4 respectively.
If Output1 is triggered, the MC_Power FB is enabled.

Motion Axis1 implementation LD.PNG

If Axis is enabled, Input4 is not on, MC_MoveRelative_01.Busy has a False value and a rising edge is detected in Input2, then MC_MoveVelocity FB is executed with a positive direction.

If Axis is enabled, Input4 is not on, MC_MoveRelative_01.Busy has a False value and a rising edge is detected in Input3, then MC_MoveVelocity FB is executed with a negative direction.

Motion Axis1 implementation1 LD.PNG

When a falling edge is detected in Input2 or Input3, then a boolean variable 'stop_jog" is triggered.
If axis is enabled and 'stop_jog' is TRUE, the MC_halt FB is executed.
If Input2 and Input3 are not on, Input 4 is on, then MC_MoveRelative is executed.
If Input11 is on, then MC_Reset is executed.

Motion Axis1 implementation2 LD.PNG


Visualization

The program is controlled by a graphic interface:

600px

When the startup process of softMC is done, the blue lamp is turned on.
The user can turn on and off Input 1-4 for each drive and watch their status in the green lamps.