Initialization

Navigation:  Unidrive M600-M702 Onboard Programming Reference >

Initialization

Previous pageReturn to chapter overviewNext page

 

Both the Clock and Freewheeling tasks are scanned cyclically. However, the Freewheeling task, if present, will complete one scan BEFORE the Clock task will be scheduled for the first time.

 

If you want to perform any initialization, e.g. initialize drive parameters, you can implement this in the Freewheeling task using code similar to the following. Note that the code shown is Structured Text but a similar scheme can be implemented in ladder, function block or any other of the supported languages.

 

// In the Freewheeling task, declare a flag as follows ...

VAR

// Set this flag to TRUE when the program starts to indicate that the Freewheeling task is

// running for the first time.

//

FirstRun : BOOL := TRUE;

END_VAR

 

 

 

// If this is the first time the Freewheeling task has run, perform any required initialisation.

//

IF FirstRun = TRUE THEN

 

 // Do my initialisation code.

 

 FirstRun := FALSE;

ENDIF

 

// Continue with your normal code that you want to perform on each task

// scan.

...

...

 

// Note: Do NOT code an infinite loop into a task.

 

See Also

 

Tasking Model
Unidrive M Programming Reference