Marco G Posted October 15, 2014 Report Posted October 15, 2014 Hello, I'm quite far with the software for my project. However, i got a few questions related to the PLC part now. (The PLC will probably be programmed by someone else.) The software allows the user to create a CSV of certain data, this csv has to be send to the PLC but there's some extra difficulty here. I want the user to be able to create a scheduled task of it, so he can configure the assignments once and basically forget about it until the schedule runs out. How can i do this? I recon the most easy way is to force the user to add a date/time to the csv filename and then let the plc check the pc(it's done remotely via TCP/IP) once in a while for the file that's up next. But is that possible or are there other/better ways to do this? I would like to have to install only the software i'm working on now(which is a relatively small vb.net application) on the users computer. Also, i tried some googling but it seems that most questions are about importing to the user's pc. The PLC that will be used will be a V130 that's controlling several sensors and engines(hydraulic and electric). Also, it needs to send some of the data(location of the items it needs to take and the weight.) to a other plc.
s.pratt Posted October 15, 2014 Report Posted October 15, 2014 Hello, Thank you for using our Unitronics Forum. Unitronics controllers can create CSV files, but we are unable to read from them. We would need to have the file in a Unitronics Data Table file type. We apologize for the inconvenience.
Marco G Posted October 16, 2014 Author Report Posted October 16, 2014 Okay, no problem. Just a minor setback, now i need to find out how to save to that data type. Is there any code for saving as Unitronics Data table file availible? Preferably in .net.
Marco G Posted October 16, 2014 Author Report Posted October 16, 2014 (edited) Also, i found out that there are .net drivers availible, but it looks like they don't do what i want. I want the user to be able to just enter some names etc and as it is now, the needed information for the PLC(Some numbers that are locations and weights in INT32) will be saved to a csv textfile. Apparently that's not possible, although my collegues think that it should be no problem. Alse, will it work if i save the data as a textfile? (with the comma's being used as seperator)? Because what basically needs to happen is that i need to be able to send some numbers(1-8 and weight) to the PLC, then the PLC can convert them to coordinates so it knows where it needs to take how much weight from and where the cart needs to drop it. (2 separate machines) And is it true that the Unitronics PLC(whe're going to use the V-models, i believe the 350) can also read from xml files? That would be easier, then all i have to do is transform the textboxes into a dataset and save that. All that remains then is the scheduling as in the first post. I think i got a way for that, but will that work? My idea is saving the files(xml or UDT) with a datetime in the filename(picked using a datetimepicker) and then the plc will regulary check if there a file availible that has a datetime of within 5-10 minutes of the current date and time. I think that this is the most flexible option for the user, because he can now set up multiple files and then the plc will automatically run them at the right time. Edited October 21, 2014 by Marco G
Marco G Posted October 28, 2014 Author Report Posted October 28, 2014 Hello, small kick I was looking trough the Data Tables DLL manual where i saw that it is possible to open and save a .XML file. Doesn´t this imply that it is possible for the plc to read/write to one as well?
s.pratt Posted October 29, 2014 Report Posted October 29, 2014 Hello, The V130 controllers do not have the ability to open and read an excel or csv file type via the ladder. It must be a Unitronics Data Table (.udt) file type. I am unsure what manual you are referring to. Can you please explain where you found the Data Tables DLL manual?
Marco G Posted November 3, 2014 Author Report Posted November 3, 2014 Hello, i found the manual while looking for more information about this subject. Title is "Unitronics Data Tables DLL" . Unfortunatly, i am still looking at how to save as .udt.
Eyal Koren Posted November 3, 2014 Report Posted November 3, 2014 Hello, i found the manual while looking for more information about this subject. Title is "Unitronics Data Tables DLL" . Unfortunatly, i am still looking at how to save as .udt. Hi Marco, The last page of the document refers to the "Save function". Did you try that? "The Save(string filePath, FileType fileType) saves the table or tables into a file. Please note that choosing FDT or XML saves the entire DataTables structure and values into a file. However, a UDT file can only contain 1 table. In this case dataTables.Tables[0] will be the table that will be saved to the file. For saving a table into a UDT file other than the first table, please use either one of the following overloads: public void SaveToUDT(string filePath, int tableIndex) public void SaveToUDT(string filePath, string tableName) Another important note is that UDT file cannot contain a table that has PartOfProject columns. This means that trying to save a table that contains PartOfProject columsn will result an exception! "
Marco G Posted November 3, 2014 Author Report Posted November 3, 2014 Ah yes, i saw that. This is part of my current code: Dim ds As New DataSet dtverzenden = New DataTable() dtverzenden.Columns.Add(New DataColumn("Voerlocatie", Type.GetType("System.String"))) dtverzenden.Columns.Add(New DataColumn("Gewicht", Type.GetType("System.String"))) dtverzenden.Columns.Add(New DataColumn("Voerbak", Type.GetType("System.String"))) 'was Int32 m.u.v. Voerlocatie, die was al string. bij Int32: cannot convert to int32 datatype fillRows(lblVoerzend.Text, lblzendgewicht.Text, lblvoerbaknr.Text) If lblzendgewicht1.Text <> "" Then fillRows(lblvoerzend1.Text, lblzendgewicht1.Text, lblvoerbaknr.Text) If lblzendgewicht2.Text <> "" Then fillRows(lblVoerzend2.Text, lblzendgewicht2.Text, lblvoerbaknr.Text) If lblzendgewicht3.Text <> "" Then ds.Tables.Add(dtverzenden) ds.Tables(0).TableName = "verzenden" ds.WriteXml("C:\Verzendenxml.xml") MsgBox("Done") It needs to have some data that occurs only one time(execution date/time and location) but i got that already figured out. If i understand correctly, for the saving part i have to use: public void SaveToUDT(string filePath, int datetime) (where datetime is a time and date specified by the user in a datetimepicker, will be saved as first colomn in the datatable) public void SaveToUDT(string filePath, string verzenden) For the filepath: do i have to specify that it is a .udt? (so SD/filename.udt) Co-workers say that it is possible for the PLC to read from CSV or XML, but i don't want to have to find out the hard way if it isn't so i'm working on building a save to .udt button right now. It's easier to delete 1 or 2 buttons then to add buttons + code
Saragani Posted November 3, 2014 Report Posted November 3, 2014 The PLC cannot read CSV or XML files. I'll look further into the code in order to help yoou with what you want, but basically, the "Save as XML" feature in the Data Tables DLL is just meant for being able to save and load the data to/from the file in the PC.
Saragani Posted November 4, 2014 Report Posted November 4, 2014 Ok. I'm not sure if you know what the Data Tables in the Vision PLCs is, but it is totally different from the .Net Data Tables, so I don't know why you are working with the .Net Data Sets and Data Tables. The .Net driver is just a gateway. It has a support of writing and reading from the Vision Data Tables, but the API is not easy to work with (it implements, more or less, the same API as the ActiveX communication driver). The Data Tables DLL was created for giving an easy way of connecting a PLC and reading its data tables (and then changing values, if needed), and also open UDT and FDT files. The Data Tables DLL uses the .Net communication driver for talking to the PLC. As for what the Vision Data Tables is: It is a block of memory divided into areas, which each area represents a table with a certaion struct. Each table has a specific struct given by the programmer. You can look at it as an array of structs, meaning it has X rows, were each row hsa the same structure. You cannot add rows in runtime, and you choose which row you read and write to. I don't know what exactly you are trying to accomplish, but if the Vision Data Tables is good for you then I would: * Create an FDT from the PLC Data Tables (Read the data tables, and save it as FDT). * Let the user edit the FDT file (When opening the FDT with the Data Tables DLL, then you can edit each cell. We have an example of it), and then save it. If you are designing the program, then you can choose which table from the FDT to show in the editor (because some of the tables might be for the PLC use for other purposes). * I would then use the .Net driver for opening a Listener (You might wanna use a ListenerServer that can accept several connections on the same port). * When a connection is being received, read SDW9 (Which is the Unique ID if the PLC) and see if that PLC has any job (this way you can be generic, you can name your files with the ID and time&date and then when a PLC connects, check for a file with a matching name) * Then write that table back to the PLC, and raise a bit (for example, MB1234) to notify the PLC that the Data Tables write is done, and that it has a new job I'm not sure how much data you want to write to the PLC. If it is very small, then you can just use the .Net communication driver without any data tables, and directly writing into Operands.
Saragani Posted November 4, 2014 Report Posted November 4, 2014 Hi, here is a small example. The V130 demo application will configure the Ethernet card to a specific IP (please change it to match your configuration), and when pressing F1, it will establish a connection to the PC (please also change the IP it connects to) to port 1234. The .Net demo application listens to port 1234, and on connect it reads SDW9 and looks for a file with that name. The Vision project contains 2 tables on the Data Tables, and I only write the values to the second table (to simulate a real project, were you only want to write values of a specific table). You can also change the write, so it will write specific rows and columns (range). Please don't forget to change the name of the FDT according to the unique ID of your PLC. You can edit the content of the FDT using "Data Tables Editor" program in the "SD Card Suite" (which can be found on our website). Demo DT Project.vlp .Net DT Example.zip
Marco G Posted November 4, 2014 Author Report Posted November 4, 2014 Hello, Thanks I havn't looked into your example yet, but reading your previous post i get the feeling that it's too complicated for the end users. That the Save as XML part is only to save to the PC wasn't very clear to me. Thanks for making that clear. The .net datatables work well when used to save as xml or .csv. Basically, what i'm trying to accomplish is having a piece of software where someone can enter some food data, add diets and then calculate how much of each foodtype is needed for a diet. Then he(or she) can set a location where the foodmix has to go to and a execution date/time(on wich time does the diet has to be mixed and send to the location). I'm still working on the PLC part, but i wanted to have the pc software either send the data to the plc or let the plc check for new files(so date/time in filename). The PLC has to execute the orders at the right time, so when using the first method i think the date/time needs to be saved in the datatable, while in the second method it has to be used as filename. I want to have to use as little additional software as possible to make the software as userfriendly as possible.
Marco G Posted November 4, 2014 Author Report Posted November 4, 2014 Also, the data i want to write to the PLC is small. It's only the weight per foodlocation and the location where the mix has to go to. So that's 3 fields. 4 if you include date/time. However, i'm not sure if it works when you write it directly to the operands due to the scheduling.
Saragani Posted November 4, 2014 Report Posted November 4, 2014 Hi. Writing your own "Data Tables Editor" is simple. It uses the engine of the Data Tables DLL, and links a UI to it. (I think that one of the examples of that DLL is a viewer or an editor). If you say that you have only 3 or 4 fields (is it just one row?), then you can make a simple UI by yourself, and put the values in the Data Tables.
Marco G Posted November 4, 2014 Author Report Posted November 4, 2014 Typed a long text but pressed the wrong button. Anyways, i have found out that in the DLL zip there's a example programm wich looks like it does what i want. Only it writes directly to the plc for as far as i can see. (writes to operands) I figure that if i have the same, but then in a way that writes it to the datatable my problems will be solved. I think that the PLC can read the datatable to chech if there's any row with a date/time that correspondents to his internal clock. It collects all the corresponding rows and then execute it. So: Datatable with rows: Datetime(+id?), location, weight, location where the mix has to go. PLC checks the date, sees 5 rows with a corresponding date, gets the weight from each location(5 kg of hay, 10 kg of grass for example) and then brings it to the location where the mix has to go.
Saragani Posted November 5, 2014 Report Posted November 5, 2014 I did not understand if there is a question here... Anyhow, Which DLL zip are you referring? (The .net Communication driver?). If so, yes, you can write directly to operands.And the example I have you yesterday shows how you can write directly to Data Tables.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now