We are often asked the question “which is better - a DDE server or an ActiveX control ?” The answer depends upon what other software applications you are using and your application requirements.
DDE Servers have been around since the late 1980’s (see related article) as a means of connecting PLCs to Windows-based software. Wonderware pioneered the use of DDE servers in their InTouch applications and improved upon Microsoft’s standard DDE with FastDDE to provide faster, more reliable throughput. In general, DDE servers are good if you are using an existing HMI package that supports DDE or one of its variants FastDDE or AdvanceDDE. The HMI software is designed to work with DDE servers and setups are generally pretty easy. A DDE server is also useful if you need some simple data brought into an Excel spreadsheet or other DDE client application and need a simple to setup user interface.
All the ease and friendliness of DDE requires a price though, particularly if you are developing an HMI application using Visual Basic. First, although Visual Basic includes native support for DDE, you must have an object such as a text box on a form for every data point you want to gather from the DDE server. This is because VB uses data binding to “bind” to a value in the DDE server. For a small amount of data, it’s a convenient and easy way to set things up. But if you need a lot of data or you just want to gather data for logging to a database, then this approach can quickly become cumbersome. Using DDE requires a great deal of system resources. You have the DDE client application, the DDE server application, and the DDEML.dll program that Windows uses to tie the two together. The DDE server maintains in memory a list of all the items assigned to each topic and any client application that needs item data. Each time an item is added or removed to the topic list in the DDE server, the server must reoptimize the topic and link lists. With Visual Basic, you have a limited number of open topics allowed, so you may find yourself opening and closing topics, which causes the DDE server application to slow down. This constant maintenance work performed by the DDE server consumes system resources. To complicate matters further, the path a data request takes from the client to the server and back has numerous steps and bottleneck points. The DDE client requests data and the request is routed by the operating system to the DDEML.dll which in turn sends the request via another message to the DDE server, which in turn must get the data from the PLC. When the server has the data, it sends it to all clients that requested it via the DDEML.dll which in turn sends the data to the DDE clients. All the while, this is happening in separate process spaces in the operating system, which inherently slows things down.
By contrast, if you use an ActiveX control with your Visual Basic (VB) application, things are significantly streamlined. First, you only have one process space to be concerned with. The ActiveX control gets loaded into memory automatically when your VB application loads. When your application needs the ActiveX control to do something, it makes the call to the control directly. There are no intermediaries or messaging that your data request gets routed through. The ActiveX control can get the data and hand it right back to your application without any intermediaries. This inherently saves a great deal of time and system resources. Also, the ActiveX control does not have to deal with complicated topic and item lists to maintain and constantly re-optimize. It gets the data when told to and returns it to the calling instance of the ActiveX control in an expedient manner.
So if you’re building an application using Visual Basic and have the choice to use an ActiveX control, you’ll be rewarded with a clean, fast application. If you need simple PLC data access for your existing HMI or office applications, then the DDE server will rise to the task and serve you well.
Legal disclaimer: The end user is responsible for all applications of technologies and ideas presented by this article. Users should be aware that certain patents may apply to the use of spreadsheets with DDE servers and the end user is responsible for any liability arising from the own application of generic technologies such as DDE to exchange PLC data with spreadsheets.