I've been working on project graphical water fountain. Right now I'm stuck in how to call Visual Studio ariable from twincat 3. is there anyone can help? Really need some explanation before I can start again. Thank you before.
Best regards, Thomas
I've been working on project graphical water fountain. Right now I'm stuck in how to call Visual Studio ariable from twincat 3. is there anyone can help? Really need some explanation before I can start again. Thank you before.
Best regards, Thomas
With TwinCAT, you need to push the state of your "command" variables from your .Net app to your PLC, which you can do using Beckhoff's ADS library.
Some examples of how to do that can be found here: https://infosys.beckhoff.com/english.php?content=../content/1033/tc3_adssamples_net/html/tcsample_net_intro.htm&id=8269274592628480035
I find the best practice way to do that is to write the variable into the PLC. If it is a button press, I have the PLC overwrite the variable (locally) as soon as it has registered the press. if you are writing process variables, I normally perform a separate read back of the variables in a polled manner to display the value in the UI. in short - I don't keep a local state of the variable in the UI, I rely on feedback from the PLC to ensure it is always up to date.
In your PLC code you will have some variables. those variables can be accessed from any program that allow you to use OCX, DLL or the other mechanisms Beckhoff offer.
You are thinking it in the wrong way, you won't write a variable in the C# program. C# program will have to read the variable in TWinCAT.
There are different methods of doing it: polling each certain number of ms. (the easiest) or trying to reach the value once it changes.
In any case I would recommend you reading the ADS documentation you can find in the TWinCAT help system and see its examples which can help you achieving that.
Hope this helps!