Jump to content

Schedule exporting/writing to plc


Marco G

Recommended Posts

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. 

Link to comment
Share on other sites

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 by Marco G
Link to comment
Share on other sites

  • 2 weeks later...

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! "

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.  

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Typed a long text but pressed the wrong button.  :ph34r:

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. 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...