zivk Posted October 8, 2010 Report Share Posted October 8, 2010 Hello Is there any code examples or instructions on how to reading and writing of DataTables using C# Drive.NET Thanks Quote Link to comment Share on other sites More sharing options...
Saragani Posted October 9, 2010 Report Share Posted October 9, 2010 Hi, The .Net communication driver exposes the same parameters of reading data tables just like the old ActiveX DLL (Num of bytes per row, num of rows to read, start address etc). However, it becomes difficult if the structure of the data tables in the PLC is unknown to you. We have another DLL that uses the Communication driver and does all the dirty work for you. You can find the DLL + an example at: http://ftp.unitronics.com/Downloads/Tools%20For%20.NET%20Developers/Unitronics%20Data%20Table%20DLL%201.0.0.4.zip However... the DLLs versions are old so I suggest you to take the latest communication driver and data tables DLL from the SD Card Suite installation. Quote Link to comment Share on other sites More sharing options...
zivk Posted October 11, 2010 Author Report Share Posted October 11, 2010 Wow works great, thanks Quote Link to comment Share on other sites More sharing options...
Saragani Posted October 11, 2010 Report Share Posted October 11, 2010 I'm glad it does :-) Quote Link to comment Share on other sites More sharing options...
zivk Posted October 18, 2010 Author Report Share Posted October 18, 2010 Helo The software on my computer running good but, Why when I run on another computer it gives the error message : "Cannect Comunicatioate with the PLC with the specifide UnitID" or sometimesI get the error message (I do not know when): Message an attachment try { if (plc == null) { Ethernet ethernet = new Ethernet("10.0.0.123", 20256, EthProtocol.TCP, 3, 3000); plc = PLCFactory.GetPLC(ethernet, 0); // Serial serial = new Serial(SerialPortNames.COM1, BaudRate.BR115200, 3, 3000, DataBits.DB8, System.IO.Ports.Parity.None, System.IO.Ports.StopBits.One); // plc = PLCFactory.GetPLC(serial, 0); } dataTables = new DataTables(plc, DataTablesReadOptions.StructureAndValues); dataGridView1.DataSource = null; updateTablesListAndGrid(); ReadRange.Enabled = true; WriteRange.Enabled = true; ReadTable.Enabled = true; WriteTable.Enabled = true; UpdateTable.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } Files: Data Tables DLL Example.exe Unitronics.ComDriver.DLL v1.0.0.33 Unitronics.DataTables.DLL v1.0.0.9 Xceed.Compression.dll Xceed.Compression.Formats.dll Quote Link to comment Share on other sites More sharing options...
zivk Posted October 19, 2010 Author Report Share Posted October 19, 2010 OK It seems that the problem is the use of components "Xceed.Compression.Formats.dll" How can Lhistams examples? Quote Link to comment Share on other sites More sharing options...
Saragani Posted October 19, 2010 Report Share Posted October 19, 2010 The code example that unitronics supplies fails to run on several computers (with the exceed error message) ? Quote Link to comment Share on other sites More sharing options...
zivk Posted October 20, 2010 Author Report Share Posted October 20, 2010 Thanks for the reply .Remains remained only message On WinXP PCs : "Cannect Comunicatioate with the PLC with the specifide UnitID" On the Win7 computers it works correctly. What caused the error? Thanks . Quote Link to comment Share on other sites More sharing options...
Saragani Posted October 20, 2010 Report Share Posted October 20, 2010 Maybe the IP/Port is not correct, maybe your ethernet card is not configured right, maybe the firewall is blocking the communication. Please check first that Visilogic / Remote Access is being able to connect the PLC both in XP and Win7 Quote Link to comment Share on other sites More sharing options...
zivk Posted October 20, 2010 Author Report Share Posted October 20, 2010 hi I use a combination of two examples: 1. Unitronics SD Card Explorer Lite User Control 1.0.0.6 2. Unitronics Data Table (Image attachment with DLL files) Part of the "Unitronics SD Card Explorer" Works correctly Part of the "Unitronics Data Table" Fails on this line: dataTables = new DataTables(plc, DataTablesReadOptions.StructureOnly); Computer working properly with: VisiLogic and Z-View(HMI) ??????? What I'm trying to do is a program that performs automatic backup of tables (from PLC tables or SD-CARD) Are there any other tools that make the backup? Quote Link to comment Share on other sites More sharing options...
Saragani Posted October 21, 2010 Report Share Posted October 21, 2010 The Xceed DLLs version that unitronics is working with (and have a license to) is 3.7 It seems that you are using xceed version 4.2 which is much newer. The Data Tables DLL is applying the license for version 3.7 so it fails on some computers. Please use the Xceed DLLs that were supplied by unitronics. Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 2, 2011 Report Share Posted March 2, 2011 Hi, I'm trying to access a Vision 230 PLC using "Reading MIs using Serial Port - C# Example" I am using Visual Studio 2010 Ultimate" which asked me to update the files when I first opened them, and returned a successful message. However, when trying to run the example I get the following error when attempting to "Connect to PLC" via the form. (Attached). You should also know that I'm quite new to C#. Can you help? Thanks in advance, Izhar Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 3, 2011 Report Share Posted March 3, 2011 What OS are you working with on your PC? (Windows XP, Vista, 7?) Is it 32 Bit or 64 Bit? Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 3, 2011 Report Share Posted March 3, 2011 What OS are you working with on your PC? (Windows XP, Vista, 7?) Is it 32 Bit or 64 Bit? Hi, Thanks for the quick response. I'm using a 64 bit windows 7 OS. After playing around with the example I got it to work (I have no idea how...) Today I'm trying to write my own project using the example. I created a project (.NET Framework 3.5) and a simple form which attempts to connect to the PLC. I added the Unitronics dll to the solution explorer -> References -> Browse -> Relevant library and file. and when I tried to use the plc class, the compiler didn't recognize it. I assume the problem is with the adding of the dll. what can I do? Thanks in advance, Izhar Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 3, 2011 Report Share Posted March 3, 2011 Hi again, The code now recognizes the plc (after playing with the plc declaration in the beginning. Now my problem is that the project doesn't build, because the program can't find the output file. I checked that the path and assembly names are correct (clearly they are correct, they had been defined by automatically), but it gives an error saying it doesn't exist... Thanks again for your help, Izhar Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 3, 2011 Report Share Posted March 3, 2011 Hi, the Sourcecode / DLL might be compiled as 32Bit and your program as "Any CPU" which might cause problems, so please check that both of them are compiled to the same CPU type (Any CPU is usually the best) Without seeing your project I can't actually guess what the problem can be. Can you post a screenshot? Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 6, 2011 Report Share Posted March 6, 2011 Hi Saragani, When I open the Unitronics.ComDriver.dll it shows that it's compiled as 32 bit but I can't figure out how to build it as an "any CPU" type. My program is indeed compiled as "any CPU". I also added the error I get when trying to build what I had written so far and the screen-shot with the error description in the bottom. Thanks again for all your help, Izhar Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 6, 2011 Report Share Posted March 6, 2011 You need to create a new compiling profile (Just like the x86 and x64) that will be called Any CPU You can also compile your code as x86. This will also cause your code to work (although it is not recommended). Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 7, 2011 Report Share Posted March 7, 2011 Hi, I was finally able to solve the problem. Turns out it wasn't connected to the dll at all. The problem was a bug with the resgen.exe file for windows 7 x64 OS. I "solved" it by changing my program to .NET 4. Other solutions may be found in http://social.msdn.microsoft.com/Forums/en/msbuild/thread/e5900710-9849-4d10-aa28-48b734d06bf2 Thanks again for all your help Saragani, Izhar Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 13, 2011 Report Share Posted March 13, 2011 Hello again, I continued writing my program, using "Unitronics Data Tables" as a guideline. I came to the part where I wanted to update an existing cell in my PLC. I tried both the "update" function and the "write" function, from the original Unitronics program but for some reason, the function finishes it's run successfully but the data is not updated when I try to "read" it afterwards - what I get is the unchanged data from before the writing attempt. I added the original code for a general write: private void WriteTable_Click(object sender, EventArgs e) { try { dataTables.Tables[listTables.Text].Write(); reloadCellsData(dataTables.Tables[listTables.Text]); } catch (Exception ex) { MessageBox.Show(ex.Message); } } What am I doing wrong? Thanks in advance, Izhar Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 13, 2011 Report Share Posted March 13, 2011 Hi, your code is right, either using Write or Update will update the content on the PLC. However, what about updating the cells values on the PC? You are using reloadCellsData to load the cells data into the UI (Probably a grid)... Are you sure that editing the UI makes the changes back to the cells in the Data Tables DLL? (Maybe you are just changing the UI?) Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 13, 2011 Report Share Posted March 13, 2011 Hi, your code is right, either using Write or Update will update the content on the PLC. However, what about updating the cells values on the PC? You are using reloadCellsData to load the cells data into the UI (Probably a grid)... Are you sure that editing the UI makes the changes back to the cells in the Data Tables DLL? (Maybe you are just changing the UI?) Hi, What I did before attempting to write my own code, was play around with the code I downloaded from this forum (Unitronics Data Tables) That's the code I added in the previous response, just as a reference. Bottom line, when I change some arbitrary data in the EditCell screen, I can save the changed table to a file, see it changed in the UI etc. Even when I try to update it to the PLC, the compiler goes through the process OK. How can I see whether I'm actually changing anything or just saving data to the UI? Thanks, Izhar Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 13, 2011 Report Share Posted March 13, 2011 Hi, if you are using the example that you downloaded, if you make changes there and then choose Write or Update, does it make changes on the PLC? Quote Link to comment Share on other sites More sharing options...
Saragani Posted March 13, 2011 Report Share Posted March 13, 2011 Can you attach your Visual Studio project (with all of it's files) so I can check why it doesn't work for you? Quote Link to comment Share on other sites More sharing options...
Izhar Posted March 15, 2011 Report Share Posted March 15, 2011 Hi, Here is the original code I have been working on (downloaded from this forum) http://ftp.unitronic...L%201.0.0.4.zip Actions I had taken so the code would run: 1. convert the project to be compatible with Visual Studio 2010 2. Change project to be .NET Framework 4 (otherwise it doesn't work) 3. Change UnitID of the Form1 file to be 11 (my UnitID), in both read structure and read structure and values commands. 4. F5 5. Press on "Read Structures & Values from PLC" (the data appears in the grid) 6. double click an arbitrary value (the update popup appears) 7. Change the value -> OK 8. update changes / write tables to PLC 9. read range The updated changes do not appear no matter what... Thanks in advance, Izhar 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.