Imc102t-f064: Uart1 -> rs232 / rs485

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

About the user Mode UART allowing to drive the motor speed via the UART port.

(I asked through another post how configure the Node address...)

On the Reference Manual (v1.3 2020-4-26) §2.3.8 to connect multiple nodes to the same network, this is ok for me, I understand.

Now, into my application, tha master will be distant, the we could use RS232 transciver to convert TTL<-> +12/-12V signal.
The scheme on §2.3.8 remain ok.

The communication is like the Modbus, then the Half duplex is Ok.
Then, now, the master for us is RS485.
So we must always listen data on Rx Way, then "get" the line when we want respond (Tx way)

To do that, the device need a signal of type "RTS/CTS":
i.e: Logical 0 to listen the line, then when we want send a response, then get the line by set signal to logical level 1.

Is this type of output is automaticcaly managed by the IMC102?
Or must use the script to customize the UART and the manage the RTS/CTS line?

Thank
0 Likes
7 Replies
dakh_4791506
Employee
Employee
First like received First solution authored
IMC102T does not have built-in flow control using RTS/CTS. I don't have past experience with this type of flow control, but perhaps it can be implemented in Script using GPIO pins for RTS and CTS, and Configurable UART driver methods (see 2.6.11.3).
0 Likes
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins
Hello

I think use script to mange this could be a good solution.

Unfortunately, the CPU load seems to be high only with PFC and MCE activated.. (about70%)

Then I already make a small Brake resistor control (to control a resistance to decrease DCBus when motor is in regeneration phase)
and a very small algortihm to make cycle from 0 to 2400rpm, CPU load is already about 90..95%...

So I think I must use an external processor to be compliant with the wanted external modbus into RS485.

What is you advice concerning the CPU load?

Bellow the script code:

#SET SCRIPT_USER_VERSION (1.00)

/**************************************************************/
/*Script execution time for Task0 in ms, maximum value 65535 */
/**************************************************************/
#SET SCRIPT_TASK0_EXECUTION_PERIOD (5)
/* Defines number of lines to be executed every 1ms in Task0 */
#SET SCRIPT_TASK0_EXECUTION_STEP (10)

/**************************************************************/
/*Script execution time for Task1 in 10ms, maximum value 65535 */
/**************************************************************/
#SET SCRIPT_TASK1_EXECUTION_PERIOD (10)
/*Defines number of lines to be executed every 10ms in Task1*/
#SET SCRIPT_TASK1_EXECUTION_STEP (20)


/**************************************************************/
/* constant definition */
/**************************************************************/
CONST int VDCBus_RBrakeLevelOn = 3402; /* 4095 = 499.42V, ratio = 0.12195. 415V = #3402 */
CONST int VDCBus_RBrakeLevelOff = 3361; /* 4095 = 499.42V, ratio = 0.12195. 420V = #3361 */

CONST int VDCBus_RBrakePeriodMs = 5500; /* = Ton / Period = 5500ms / 293ms */
CONST int VDCBus_RBrakeIncStep = 190; /* = Ton / Period = 5500ms / 293ms */

/* RBrake FSM State constant */
CONST int VDCBUS_RBRAKE_STATE_OFF = 0;
CONST int VDCBUS_RBRAKE_STATE_ON = 1;

/* Movement FSM state constant */
CONST int FSM_STOP = 0;
CONST int FSM_ON = 1;
CONST int FSM_DECELERATING = 2;



/**************************************************************/
/* Global variable definition */
/**************************************************************/
int Modbus_Command;
int VDCBus_RBrakeState;
int FSM_State;

int Temp1;
int Temp2;
int Temp3;

/**************************************************************/
/* Task0 init function */
/**************************************************************/
Script_Task0_init()
{
/*Initialize global variable*/
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_OFF;

/* local variable definition */

/*Initialize local variable*/

/* Initialize RBRake Output command */
GPIO21_OUT = 0;
}

/**************************************************************/
/* Task0 script function */
/**************************************************************/
Script_Task0()
{

/*********************** RBrake FSM ****************************/
if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_OFF)
{
/* Test if DCBus over pass limit */
if (VdcFilt > VDCBus_RBrakeLevelOn)
{
GPIO21_OUT = 1;
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_ON;
}
} /* End if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_OFF) */

if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_ON)
{
if (VdcFilt < VDCBus_RBrakeLevelOff)
{
/* VDCBus is OK */
GPIO21_OUT = 0;
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_OFF;
}
} /* End if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_ON) */
}



/**************************************************************/
/* Task1 init function */
/**************************************************************/
Script_Task1_init()
{
/*Initialize global variable*/
Modbus_Command = 0;
FSM_State = FSM_STOP;

/* local variable definition */
int TargetVelocity;

/*Initialize local variable*/
int LocalCommand;

LocalCommand = 0;
AngleSelect = 2; /* use rotor Flux Angle */
CtrlModeSelect = 2; /*Speed control mode */

}

/**************************************************************/
/* Task1 script function */
/* Ratio Speed 2730tr/min => #16384 => Ratio x 6 */
/**************************************************************/
Script_Task1()
{
Temp1 = abs_MotorSpeed;
if (FSM_State == FSM_STOP)
{
/* Wait Modbus_Command On Off = On */

if (Modbus_Command & 0x0200) /* Motor On/Off */
{
/*Clear eventual PFC fault and start it */
PFC_FaultClear = 1;
PFC_Command = 1;

FSM_State = FSM_ON;

/* x10 because given in 10tr/min. x6 Tr/min -> Internal; */
TargetSpeed = (Modbus_Command & 0x01FF) * 60;

if (Modbus_Command & 0x0400)
{
TargetSpeed = -TargetSpeed;
}

Command = 1; /* Start the motor */
}
}

if (FSM_State == FSM_ON)
{
/* Wait Modbus_Command On Off = Off */
if ((Modbus_Command & 0x0200) == 0)
{
TargetSpeed = 0;
FSM_State = FSM_DECELERATING;
}
}

if (FSM_State == FSM_DECELERATING)
{
if (abs_MotorSpeed < (200 * 6))
{
/* Motor velocity is low, stop motor */
Command = 0;
FSM_State = FSM_STOP;
}
}
}
0 Likes
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins
Hello

I think I could also done by script, but, I already make some little management into the script and the CPU load is already over 95%!

Then i will use a small processor to make the modbus RS485 conversion.

What is your advice according the CPU load? (I can see CPU Load is already to 70% with Motor and PFC activated)
My script leading to 95% of CPU Load, I do not think it is too much!
#SET SCRIPT_USER_VERSION (1.00)

/**************************************************************/
/*Script execution time for Task0 in ms, maximum value 65535 */
/**************************************************************/
#SET SCRIPT_TASK0_EXECUTION_PERIOD (5)
/* Defines number of lines to be executed every 1ms in Task0 */
#SET SCRIPT_TASK0_EXECUTION_STEP (10)

/**************************************************************/
/*Script execution time for Task1 in 10ms, maximum value 65535 */
/**************************************************************/
#SET SCRIPT_TASK1_EXECUTION_PERIOD (10)
/*Defines number of lines to be executed every 10ms in Task1*/
#SET SCRIPT_TASK1_EXECUTION_STEP (20)


/**************************************************************/
/* constant definition */
/**************************************************************/
CONST int VDCBus_RBrakeLevelOn = 3402; /* 4095 = 499.42V, ratio = 0.12195. 415V = #3402 */
CONST int VDCBus_RBrakeLevelOff = 3361; /* 4095 = 499.42V, ratio = 0.12195. 420V = #3361 */

CONST int VDCBus_RBrakePeriodMs = 5500; /* = Ton / Period = 5500ms / 293ms */
CONST int VDCBus_RBrakeIncStep = 190; /* = Ton / Period = 5500ms / 293ms */

/* RBrake FSM State constant */
CONST int VDCBUS_RBRAKE_STATE_OFF = 0;
CONST int VDCBUS_RBRAKE_STATE_ON = 1;

/* Movement FSM state constant */
CONST int FSM_STOP = 0;
CONST int FSM_ON = 1;
CONST int FSM_DECELERATING = 2;



/**************************************************************/
/* Global variable definition */
/**************************************************************/
int Modbus_Command;
int VDCBus_RBrakeState;
int FSM_State;

int Temp1;
int Temp2;
int Temp3;

/**************************************************************/
/* Task0 init function */
/**************************************************************/
Script_Task0_init()
{
/*Initialize global variable*/
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_OFF;

/* local variable definition */

/*Initialize local variable*/

/* Initialize RBRake Output command */
GPIO21_OUT = 0;
}

/**************************************************************/
/* Task0 script function */
/**************************************************************/
Script_Task0()
{

/*********************** RBrake FSM ****************************/
if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_OFF)
{
/* Test if DCBus over pass limit */
if (VdcFilt > VDCBus_RBrakeLevelOn)
{
GPIO21_OUT = 1;
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_ON;
}
} /* End if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_OFF) */

if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_ON)
{
if (VdcFilt < VDCBus_RBrakeLevelOff)
{
/* VDCBus is OK */
GPIO21_OUT = 0;
VDCBus_RBrakeState = VDCBUS_RBRAKE_STATE_OFF;
}
} /* End if (VDCBus_RBrakeState == VDCBUS_RBRAKE_STATE_ON) */
}



/**************************************************************/
/* Task1 init function */
/**************************************************************/
Script_Task1_init()
{
/*Initialize global variable*/
Modbus_Command = 0;
FSM_State = FSM_STOP;

/* local variable definition */
int TargetVelocity;

/*Initialize local variable*/
int LocalCommand;

LocalCommand = 0;
AngleSelect = 2; /* use rotor Flux Angle */
CtrlModeSelect = 2; /*Speed control mode */

}

/**************************************************************/
/* Task1 script function */
/* Ratio Speed 2730tr/min => #16384 => Ratio x 6 */
/**************************************************************/
Script_Task1()
{
Temp1 = abs_MotorSpeed;
if (FSM_State == FSM_STOP)
{
/* Wait Modbus_Command On Off = On */

if (Modbus_Command & 0x0200) /* Motor On/Off */
{
/*Clear eventual PFC fault and start it */
PFC_FaultClear = 1;
PFC_Command = 1;

FSM_State = FSM_ON;

/* x10 because given in 10tr/min. x6 Tr/min -> Internal; */
TargetSpeed = (Modbus_Command & 0x01FF) * 60;

if (Modbus_Command & 0x0400)
{
TargetSpeed = -TargetSpeed;
}

Command = 1; /* Start the motor */
}
}

if (FSM_State == FSM_ON)
{
/* Wait Modbus_Command On Off = Off */
if ((Modbus_Command & 0x0200) == 0)
{
TargetSpeed = 0;
FSM_State = FSM_DECELERATING;
}
}

if (FSM_State == FSM_DECELERATING)
{
if (abs_MotorSpeed < (200 * 6))
{
/* Motor velocity is low, stop motor */
Command = 0;
FSM_State = FSM_STOP;
}
}
}
0 Likes
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins
Hello,
Second try!
I post message, but it indicate to me this message must be validated before apperas.
2 days later, not yet validated.. 😞

Then I try here by editing this message wihci was posted immediately..:

In my message I say, Ok, I think is possible to manage RTS by script.
But currently, I have a small script (given in quote in my original message) but with this small script, the cpu load already reach 100% (70% just with motor and PFC, then 30% remaining for the script)
...
Is the administrator can post my messages?
0 Likes
dakh_4791506
Employee
Employee
First like received First solution authored
Hi,
Not sure what the issue is with the forums - posting should work normally.
The CPU load increase does not seem right. We'll look into your Script and provide feedback by end of Tue PST.
Since you have unique requirements (more than 15 node addresses, flow control in UART), have you considered using IMC302A? You can add your own Modbus interface. Please see for peripheral use case examples.
0 Likes
AG_Serad
Level 4
Level 4
First solution authored 25 replies posted 25 sign-ins
HEllo,

- The post where I copy my script is not displayed from my point of view. Where do you get it?

- For the IMC302A, If I well understand, It is the same MCE than IMC102T, but with a C language programation in more tha Script engine. Then we could program easily some C function to make our own modebus RTU. Right?
0 Likes
dakh_4791506
Employee
Employee
First like received First solution authored
Hi Arnaud,

It appears your post was tagged as a moderated post and only would show up if you or I log in. I will inquire with the forum administrators about this "feature"/bug.

We are still investigating the Script CPU load issue. How much additional functionality are you looking to implement in Script? You may direct message me instead of writing publicly here.

Thanks!
0 Likes