EnableCoherentUpdate not working when...

Announcements

From sunburn to sun earn – we’ve got the power! Watch our #poweringgreen videos now.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins

Hello

I'm using script into IMC102T.

I use a global variable which is read via serial communication.

This variable is refreshed in Task1 via many line into the script code.

So I place it under EnableCoherentUpdate /DoCoherentUpdate section.

This seems work when the the Task1 Number of instruction is < #SET SCRIPT_TASK1_EXECUTION_STEP .

Since I configure #SET SCRIPT_TASK1_EXECUTION_STEP  < Task1 Number of instruction, this coherent update seems not work because some time, some bits are not yet refreshed and pass to 0 value without any reason.

I try the following code where I force bit 0x2000 to be set... but sometime, I read this bit to 0...

It seems the coherent update is also flush RAM to Variable on each slice of execution of task1 ???

 

Modbus_Status is a global variable..

Task 1 Number of instruction: 103

#SET SCRIPT_TASK1_EXECUTION_PERIOD (40)
/*Defines number of lines to be executed every 10ms in Task1*/
#SET SCRIPT_TASK1_EXECUTION_STEP (10)

 

Task1:

 [.... Some code here ....]

EnableCoherentUpdate();

/* Motor Speed Status */
if ( SwFaults == 0)
{
Modbus_Status = (abs_MotorSpeed / 60);
}
else
{
Modbus_Status = 0x8000; /* Motor fault Bit 15 */
}
/* ----- Bit 9 : Start/Stop -------*/
if (FSM_State == FSM_ON)
{
Modbus_Status = Modbus_Status | 0x0200;
}
/* ------ Bit 10 : Direction -------*/
Modbus_Status = Modbus_Status | CurrentDirection;

/* ------ Bit 11 : RBrake over load capacity -------*/
if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_FAULT)
{
Modbus_Status = Modbus_Status | 0x0800;
}

/* ------ Bit 12 : Temp Motor error -------*/
if (GPIO7_IN == MOTOR_TEMPERATURE_NOK)
{
Modbus_Status = Modbus_Status | 0x1000;
}

/* ------ Bit 13 : E9 24V (input Enable) -------*/
// commented for test  if (GPIO15_IN == E24V_OK)
//{
Modbus_Status = Modbus_Status | 0x2000;
//}
/* ------ Bit 14 : PFC error -------*/
if (PFC_SwFaults > 0)
{
Modbus_Status = Modbus_Status | 0x4000;
}

DoCoherentUpdate();

0 Likes
1 Solution
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @AG_Serad,

The coherent update method is used to update MCE parameters or variables, not user-defined variables in the script and the maximum buffer size is 32.

EXECUTION_STEP for a task typically needs to be set to be greater than the number of effective instructions for that task which can be found out from the compiled bytecode file. Please refer to the script app note has some guidelines regarding that aspect. 

App note: https://www.infineon.com/dgdl/Infineon-How_to_Use_iMOTION_Script_Language-ApplicationNotes-v01_01-EN...

 

Thanks,

Krupashankar

View solution in original post

0 Likes
8 Replies
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins

Hello,

Is somebody can answer to my request?

Is CoherentUpdate work over task sliced?

Thank

0 Likes
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @AG_Serad,

From your script, we could see that you are updating a global variable Modbus_Status based on certain condition

EnableCoherentUpdate() -> Will store all the values in the buffer for the different variables.

DoCoherentUpdate() -> Will update the all values into each variable at once.

Try performing coherent updates within several execution steps or please try increasing the number of lines executed in each step.

Could you please tell me why the same global variable is getting updated multiple times within the coherent update block? 

We will also try reproducing the same issue at our end.

 

Thanks,

Krupashankar

 

 

0 Likes

If the number of lines executed in each step is at least or upper to the task1 Number of instruction, there are no problem.

"Could you please tell me why the same global variable is getting updated multiple times within the coherent update block? "

 

Like we can see into the code, this global variable is a Status word. This status word is composed by many bit. Each bit define an information. Then I must refresh each bit according the bit status information.

I use a workarroud which is update a local variable, then only at the end, I write this local variable to the global variable read by serial. The CoherentUpdate is not use anymore.

But I'm curious to know if you can reproduce this problem and/or confirm the coherent update work properly only if the number of line executed on each step is > Number of instruction on the task.. 

Regards

 

Edit:

For coherentUpdate, if we have the following code:

EnableCoherentUpdate();

MyGlobalVariable = MyGlobalVariable | 0x4000;

DoCoherentUpdate();

 

Must we understand the first or second following "Pseudo code"?:

EnableCoherentUpdate();  -> MyGlobalVariable_RAM = MyGlobalVariable

MyGlobalVariable = MyGlobalVariable | 0x4000; -> -> MyGlobalVariable_RAM = MyGlobalVariable_RAM | 0x4000;

DoCoherentUpdate();  -> MyGlobalVariable = MyGlobalVariable_RAM

 

OR

 

EnableCoherentUpdate();  -> MyGlobalVariable_RAM = MyGlobalVariable

MyGlobalVariable = MyGlobalVariable | 0x4000; -> -> MyGlobalVariable_RAM = MyGlobalVariable | 0x4000;

DoCoherentUpdate();  -> MyGlobalVariable = MyGlobalVariable_RAM

Or other?

0 Likes
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins

Hello,

Have you reproduce the problem and found the origin?

Regards

0 Likes
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @AG_Serad,

Please find the script which we have used to reproduce the issue.

#SET SCRIPT_TASK0_EXECUTION_PERIOD (40)

/*Defines number of lines to be executed every 10ms in Task1*/

#SET SCRIPT_TASK0_EXECUTION_STEP (1)

 

/* Global variable definition */

int Var_1;

int display_1;

/**************************************************************/

/*Task0 init function*/

Script_Task0_init()

{

/* local variable definition */

int Task0Var1;

Task0Var1 =0; /*Initialize local variable*/

Var_1 =0; /*Initialize global variable*/

display_1 = 1;

}

/*Task0 script function*/

Script_Task0()

{

EnableCoherentUpdate();

Task0Var1 = Task0Var1+1; /*Increment Task0Var1*/

Var_1 = Var_1+1; /*Increment Var1*/

display_1 = 20;

DoCoherentUpdate();

 

}

We have tried to read the global variable display_1 but we could read the value as 20 even when the number of execution step < number of instruction of task

Krupashankar_0-1639060547598.png

The maximum number of global variables which can be used is 30 and in case of using coherent update all the values will be stored into a buffer Please make sure if the buffer is not overflowing

Could you please share your entire script this will help us to understand issue better.

 

Thanks,

Krupashankar

0 Likes
lock attach
Attachments are accessible only for community members.
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins

hEllo,

Is the CONST is included into the global variables?

Your example not represent my default.

If you want be same, you should make unde coherent update:

Var_1 = 0

Var_1 = Var_1+1; /*Increment Var1*/

Var_1 = Var_1+1; /*Increment Var1*/

Var_1 = Var_1+1; /*Increment Var1*/

Var_1 = Var_1+1; /*Increment Var1*/

...

Var_1 = Var_1+1; /*Increment Var1*/

Var_1 = Var_1+1; /*Increment Var1*/

 

Then via the serial link, read as fast as possible Var_1 which must always be on the number of +1 done and never on an intermdiate state (which is the case in my script)

Please find my script (Note the problem was on the end of the file "Update Modbus_Status"

This section was under coherent update, but now, I update a local variable "Local_Modbus_Status"

Then at the end I copy it to Modbus_Status which is the global vairable

 

0 Likes
Krupashankar
Moderator
Moderator
Moderator
500 replies posted 50 likes received 25 likes received

Hi @AG_Serad,

The coherent update method is used to update MCE parameters or variables, not user-defined variables in the script and the maximum buffer size is 32.

EXECUTION_STEP for a task typically needs to be set to be greater than the number of effective instructions for that task which can be found out from the compiled bytecode file. Please refer to the script app note has some guidelines regarding that aspect. 

App note: https://www.infineon.com/dgdl/Infineon-How_to_Use_iMOTION_Script_Language-ApplicationNotes-v01_01-EN...

 

Thanks,

Krupashankar

0 Likes

Hello

According the datasheet, my unerstanding was we can set EXECUTION_STEP lesser than the number of effective instruction to dispatch the CPU load on the time?..

Thank for the precision about the ENableCoherentUpdate, which not working on user-defined variable. This is the reason of my bug! Then the solution to pass by an intermediate variable is the good solution!

 

0 Likes