__sub__g Posted July 22, 2022 Report Share Posted July 22, 2022 Is there a way to set the value of MI from a file? I have a set of constants in my program and instead of having manual set all value I want to set the MI when the program is run. In my case, there are type a,b,c,d ,e,f and I want to set temp1= 1.45 for a and so on. temp2, temp3,temp4 ,temp5 as shown in the table Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted July 22, 2022 MVP 2022 Report Share Posted July 22, 2022 I definitely did not understand why you need to read this data from the CVS file. It is probably easiest to use the built-in Data Tables. You can read about them in the help. The embedded mechanism of writing and reading from Data Tables is quite flexible, and by choosing the appropriate line number, you can easily change (load) up to 32 variables of different types in one ladder rung. One of the columns of the table can even be a text description of the program or recipe that is being used at the moment. 1 Quote Link to comment Share on other sites More sharing options...
__sub__g Posted July 22, 2022 Author Report Share Posted July 22, 2022 @kratmel thank you for your response Let temp1=1,temp2=2temp3=3... If temp=1 I want type a model to store 1.45 ml1 If temp=2 I want type a model to store 2.48 ml1 If temp=1 I want type b model to store 1.86 in ML 1 If temp=2 I want type b model to store 3.06 in ML 1 and so on . I don not want to manual load that to register. Can I use csv or txt to do so????? Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted July 22, 2022 Report Share Posted July 22, 2022 The best way is using data tables, as Kratmel mentioned. Also, you may use free utility included in Visilogic (DataXPort) or write your own code in Excel to exchange datatables with PLC 1 Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted July 22, 2022 MVP 2022 Report Share Posted July 22, 2022 You can import data from Excel or CSV to Data Table... Please read about Data Table read row and other function. 1 Quote Link to comment Share on other sites More sharing options...
__sub__g Posted July 25, 2022 Author Report Share Posted July 25, 2022 @kratmel I implemented your logic. I wanted to confirm that if the value of mi 299 changes it correspond to that row. I incremented and decremented mi 299 to change the rows. Quote Link to comment Share on other sites More sharing options...
MVP 2022 kratmel Posted July 25, 2022 MVP 2022 Report Share Posted July 25, 2022 For a PLC, it doesn't matter how many times you read from the data table and write information to the memory cells. As far as I understood, these are constants that should alternate depending on the index. If this is so, and your code solves your task, then everything is fine. However, you must put the comparison elements before the increment and decrement commands so that your index does not exceed the number of available rows in the table and does not become negative. P.S. I also recommend placing each command in a separate line (see rung 2 - two function in one rung). 1 Quote Link to comment Share on other sites More sharing options...
__sub__g Posted August 2, 2022 Author Report Share Posted August 2, 2022 @kratmel thank you for your help I was trying to import data from excel that have more than 1 elements. I tried to do it but it gave me an error. What would be a good way to do it? I separated by elements with semicolon Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted August 2, 2022 Report Share Posted August 2, 2022 "number of elements" must be equal to 1 for all columns to be able to exchange data with Excel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.