Sign in to follow this  
Followers 0
Datman

DDE question

10 posts in this topic

Hi guys Im new to the whole DDE thing, just after a bit of advice. I am using a Micrologix 1100, am wanting to use DDE to access data so i can show basic PLC I/O on my VB application. I am also using RSLinx Classic as the DDE server. So far I have had a bit of a play and i can successfully read data into text boxes on my application using the following commands: txtIO.LinkTopic = "RSLinx|BOARD COUNTER" txtIO.LinkItem = "O:0/1,L1,C1" txtIO.LinkMode = 2 txtIO.LinkRequest txtIO.LinkMode = 0 and so output 0:0/1 is displayed in my text box 'txtIO'. Happy days, works fine. My question is thus, do i have to open the DDE topic every time i want to look at data... I cannot just leave the DDE link open, for a 'polling' type operation? Ideally what I want to happen is that when an input to the plc becomes true, I trigger the VB application and do my data transfer, then do nothing until the next time the PLC input is true, transfer more data etc... Sounds simple and probably is, but im just unsure of how i can set it up to do this. Thanks for any help, hope it makes sense!

Share this post


Link to post
Share on other sites
Yes you can leave it open but it will tie up a connection and bandwidth. Change your link mode to 1. I am going off of memory but that should do it

Share this post


Link to post
Share on other sites
cool just as i thought, thanks. luckily bandwidth is not such an issue, only a small application. My next question is, I want to write a function that will write a value to an integer in the PLC at the moment i have: Public Function WriteInteger(data As String, address As String) DDEPoke RSIchan, address, data End Function where data is the value, and address is the item eg N7:0, being passed from another function. However it does not work. Is my syntax in the DDE statement wrong, or is it not possible? RSIchan is already set up as the DDE link and initiated in a previous routine ( nd the link left open)

Share this post


Link to post
Share on other sites
I'm not very familiar with DDE, done some data collection from the PLC, but never wrote to it. I remember, there is some notes which describes DDE in RSLinx help. Maybe it may be of help. Best Regards

Share this post


Link to post
Share on other sites
Datman What is the value that you are trying to write to the PLC. If it is greater than 999 then try the poke with a smaller value. Linx does not like the thousands seperator in Windows. I am using Linx as a DDE server for Fix32 and it works well as long as the thousands seperator is disabled. In order to do this you will have to delete the value for the sThousand entry in the ControlPanel/International key in the registry. You cannot delete this from control panel. Andybr

Share this post


Link to post
Share on other sites
Im only trying to send a value of '10' to the integer N7:20. Im picking the syntax i have above must be wrong? It just doesnt want to party at all :(

Share this post


Link to post
Share on other sites
I have looked at the RSLink help and some examples on here, but they all use VBA in excel. Say for VB6, if i was using this syntax would you expect it to work? Dim RSIchan As Variant RSIchan = DDEInitiate("RSLinx", "BOARD COUNTER") DDEPoke RSIchan, "N7:0,L1,C1", 10 DDETerminate (RSIchan) Thus writing '10' to N7:0 in the PLC. It does not work, am i using the DDEPoke command properly? I can read data using DDERequest no problem at all, just not write

Share this post


Link to post
Share on other sites
txtN7Write = 10 'or desired value txtN7Write.LinkTopic = "RSLinx|BOARD COUNTER" txtN7Write.LinkMode = 2 txtN7Write.LinkItem = "N7:0,L1,C1" txtN7Write.LinkPoke "txtN7Write" is just an example, call you Text box what ever you would like.

Share this post


Link to post
Share on other sites
Check the AB Downloads section and you'll find several DDE examples going both ways {Read and Write}. Just remember that if you write a loop to monitor a plc bit and trigger your data collection routine include the DoEvents command in the loop to allow time for other applications to run in windows.

Share this post


Link to post
Share on other sites
Stupidav: I can get the code you have shown to work fine, however i dont want to use a text box or any objext for that matter, I want to just write a data value to an integer in the PLC. I guess I can use a 'hidden' text box, which I have tested and works fine, just a bit ugly thats all. thanks for your help guys, I think I may be able to work around it anyways :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0