01-19-2021 03:48 AM
I am trying to control a Simulink model on veristand 2018 SP1 with the python API. I am not getting any errors but I have no control over the inports. I tried to upload the model in the engine demo project as I was able to run it using python. But still no output and no control over the inport. Is there something wrong with my model? Am I forgetting some settings that are necessary when importing models? Thanks in advance.
Code: https://controlc.com/7a2936ca
Solved! Go to Solution.
01-23-2021 06:48 AM
Hey buddy,
I have checked your code, but I believe that here the issue is not necessary in your model. Did you compile your simulink module correctly in order to make it compatible with veristand module framwork? If no, follow this link to compile it before using it:
https://www.ni.com/documentation/en/veristand/latest/manual/select-compiler/
Let me know how it goes!
01-26-2021 10:48 PM
Hi,
Thanks for your reply. I did build the model properly. Now I am able to control the model but only if I upload it in the same project as the engine demo. Also I edited the demo code to include my model. I think I am having issues with the code. And I can't find any other examples online to see what I'm doing wrong.
01-27-2021 09:27 AM
It was really good to hear that you are able to control the model! What kind of issues are you having with the code?
Share some screenshots and let me help you with it!
cheers!
02-03-2021 03:02 AM
Hi,
Thank you for your reply, I am trying to pass values to the input of the model (Variable: In1) through an excel sheet. I'm using openpyxl to do this, but when I use it inside the function, it asks me to initialize the variables with a valid Veristand datatype. Can you tell me what I'm doing wrong? I have added my code and the error screenshots.
Thank you.
02-08-2021 07:44 AM
Hello,
I hope you're doing good!
Thank you for sharing the screenshots, it helped me better understand the issue.
First let's fix the translate error stating: "Variables must be initialized with a valid VeriStand data type". here.
This booklet that may greatly help you. More, you can find some example codes here.
Check these, and let me know if your problem is solved.
regards,
02-10-2021 04:46 AM
Hi,
Thank you for your reply, I have solved the data type error by referring to the Restrictions section of the API documentation. I have a problem passing values to the initialized DoubleValueArray. I have created a new post for the same, link: https://forums.ni.com/t5/NI-VeriStand/How-to-pass-values-to-a-DoubleValueArray-in-python/m-p/4119483
I am trying to pass test cases from an excel sheet, because I can only use certain data types inside the veristand functions I tried to copy the sheet values to a list and then tried to copy the values to the initialised variable (DoubleValueArray), is there something that can be done for this? Thanks in advance! Regards.
02-10-2021 06:26 AM
Okay cool, I saw your new post I will get back to you with possible solution.
In the mean time, since the previous message solved the data type error by referring to the Restrictions section of the API documentation, mark it as a solution to help future users 🙂
Best regards.
02-10-2021 10:52 PM
Done! Thank you so much.