+1 vote
592 views
in Communication protocols by Joan Valls Pérez (13 points)
edited by Joan Valls Pérez

Hello,

I would like to control a "Battery ESS (Generic)" component using Modbus communications over Ethernet from a computer external to the HIL. An example model is already provided (Generic microgrid with multiprotocol gateway) but in this case the CAN protocol is used instead of Modbus.

Using this example as an initial base, I have modified the "Battery ESS (Generic) UI" component that handles CAN communications, deleting all CAN-related configuration and blocks, and adding a Modbus Device for which I create a config in the model initialization file. I intend to keep the same input and output variables that the CAN interface used, keeping the same variable tipes, which are all "uint" as far as I can see.

When I try to validate the model, a number of errors arise related to the "Battery ESS (Generic)"  component. Some of those are:

Error occurred in handler 'pre_compile' of component Battery ESS (Generic).Battery DC Link SP1.dynamiccs
  → General error
  → ERROR in 'pre_compile' handler registered on component 'dynamiccs': can't multiply sequence by non-int of type 'float'

Error occurred in handler 'pre_compile' of component Battery ESS (Generic).battery_converter_control.Voltage Droop control1.LPF_V
  → General error
  → ERROR in 'pre_compile' handler registered on component 'LPF_V': can't multiply sequence by non-int of type 'float'

Error occurred in handler 'pre_compile' of component Battery ESS (Generic).battery_converter_control.Frequency Droop control1.LPF_P
  → General error
  → ERROR in 'pre_compile' handler registered on component 'LPF_P': can't multiply sequence by non-int of type 'float'

I guess that I am doing something wrong and that the Battery ESS (Generic) component is receiving some float variables, which shouldn't be floats. 

Any guidance on how to resolve this issue or any model example where this component is linked with a Modbus interface would be greatly appreciated.

Best regards,

Edit: After further testing, I realized that the baseline CAN interface uses 8 bits for the uint registers, and I can't find a way to use 8-bit registers in Modbus in the Modbus Device documentation. Could the errors be related to this?

Edit-v2: I have uploaded the problematic model to a Google Drive, here: https://drive.google.com/file/d/1bSzvuzA0W2eujwhUGY3COjv7p3GTUtDO/view?usp=drive_link

2 Answers

0 votes
by Borisav Živanović (14 points)
Dear Joan,

Such errors can only be caused by a bug in our software. While you model might contain some model-level error, it must be reported in a meaningful way that describes the problem and steps needed to fix it.

Can you please attach the problematic model, so I can reproduce the issue, debug it and fix it?

Best regards,

Borisav Živanović
by Joan Valls Pérez (13 points)
edited by Joan Valls Pérez
+2
Dear Borisav,

Sure! I have provided a Google Drive link in my original message that should allow you to download the model. I am unsure if you need any more files than the .tse file, and if there is any particular way you prefer regarding attaching models here in the Typhoon support platform.

Thank you for your time and help, best regards,

Edit: Just to provide more information to you, I have copied and pasted both the BESS generic component and the BESS interface to the "Generic microgrid with multiprotocol gateway" example model, getting rid of the original BESS and the original CAN interface. When I try to validate the model, I get the same errors that I mentioned in my initial post.
by Borisav Živanović (14 points)
I have tried compiling the model. There is a bug present in our software when model validation without compilation (Validate model button from toolbar) encounters an error related to resolution of execution rates. This bug will be fixed in the 2027.1 software release.

Please try compiling the model directly. This way, all model errors will be reported correctly. Your model has incorrect (i.e. arbitrary mixing of 100e-6 and 500e-6) execution rates somewhere between connections of "RTU (Modbus)" and "Battery ESS (Generic)" components.

Your model properly compiles if "RTU (Modbus)" is replaced by dummy placeholder components (i.e. constants). I have consulted Biljana and we concluded that finding the exact place at which the wrong execution rate is very hard for us, as the model has many customizations. Please use the example model Biljana provided in her answer below.

Best regards,
Borisav Živanović
by Joan Valls Pérez (13 points)
Dear Borisav,

Thank you for your help.

Following your indications, I have opened the "multiprotocol microgrid example" and replaced the generic UI for the generic UI that Biljana mentioned ,the one in the "battery generic and client server". I haven't made any further changes.

When I try to directly compile the model, I get some errors regarding different execution rates (maybe this are easily fixable?).
When I try to validate the model first, I see similar errors as the ones I reported in my initial message.

Could you help me determine the best way to proceed?

Thank you very much for your time and help
by Biljana Tatar (16 points)
Hello Joan,

When you copy Battery UI block from the model I suggested, please make sure that you copy everything from Model initialization script too. Here, it is defined that Modbus component inside of UI block has execution rate 500e-6.
In general, our microgrid generic components have two execution rates: Fast and Slow. One that is available inside of UI block is actually slow one, which is defined to be 500e-6. So everything connected to it, should have same execution rate.
by Joan Valls Pérez (13 points)
Dear Biljana,

My apologies. I was only copying the Modbus configuration from the model inizialization script.

I can confirm that copying everything, I can successfully compile and validate the model with no errors.

Many thanks for your time and help,

Joan Valls
+1 vote
by Biljana Tatar (16 points)
There is an example that utilizes Modbus server component inside of BESS (Generic) component. You can find it in example explorer under communication protocols>modbus>client and server components 2 hils.

Of course, you don't need two HIL devices for this, you can just leave part with Modbus server component (second HIL is used just for Modbus Client).

Hope this helps!
by Joan Valls Pérez (13 points)
+1
Dear Biljana,

Thank you for your reply. I was not aware that there was this example. I will try to make it work with the generic microgrid.

Best regards,
Welcome to the Typhoon HIL user forum. Please check self-service support resources before posting a question.

HIL Specialist 2.0 courses
Documentation
Knowledgebase (Legacy)
Video support on demand
Youtube tutorials

Help us improve - share your experience

For subscription-based support visit Typhoon HIL Support Center
...