HOME - - - - - - - TUTORIALS INDEX - - - - - - - - - - - - Other material for programmers


Delphi: DDE: Why you might care to use it

DDE stands for Dynamic Data Exchange. It was once all the rage, and still has it's uses.

If you know about client/ server systems, DDE has some client/ server attributes. When you are using DDE, somewhere there's a DDE server program running. You may have written it, or obtained it from someone else. Elsewhere, there's a DDE client program running. This tutorial shows you how to create a very simple one for a specific freeware server. Even if you are not working with 1-Wire chips, most of what is in this tutorial should make sense, and be useful in expanding a beginner's grasp of using DDE.

You don't have to write your own programs to use DDE. The Open Office spreadsheet (and the one from what's- his- name) can fill cells by accessing a DDE server. You just put a simple formula in the cell, and when you view the spreadsheet, what you see in that cell has come from the server.

The example I'm working with here is the freeware server DDEView, from Roso, in Venezuela. It will run on a Windows 98 machine, and, I assume, later Windows, too.

The role of DDEView is to give everyone easy access to 1-Wire chips on a MicroLan. I've done much more on them, but all you need to know to understand the following is that you install some free DDLs (the TMEX drivers), plug an adapter (about $25) into one of your PCs ports (USB or serial, usually), and then you run a two conductor wire from the adapter to the 1-Wire chips of your choice. There are many, providing things like temperature sensors (about $4 each), counters, ADCs, DACs, and digital input and output. (Some of them need power, but in the simple example below, reading temperatures, additional power is not needed.)

In the case of my example, you start the server (DDEView). It will check the chips on the MicroLan at preset intervals. (You can change the frequency.) Once that's running, and it takes little from you, then DDE clients (you're going to write one) can "see" what the server "sees". They can even be "prodded" to "do things" whenever the value the server is seeing for a particular parameter changes.

Doing It.....

This is how you would create a simple DDE client to read the temperature of a chip which is reporting to DDEView. Note that your client doesn't have to do any active polling of DDEView. When DDEView sees a change in the temperature, the DDE server (DDEView) will trigger an event in your DDE client program. This is great news, because you can write the event handle to do whatever you wish. (See examples of Things You Could Do, below.)

I was using Delphi 2 while checking the following for you.

From the System tab of the Component Palette, drag one each of the following onto your form:

DdeClientConv DdeClientItem

Put a label on your form, rename it laDDEItem

In the form's OnCreate procedure, add...
This is like an "open file" command. The "Conv" is for "Conversation", i.e., the communications between the DDE server and the program you are writing, the DDE client. (The server is Roso's DDEView)

Also in the form's OnCreate procedure, add....
DdeClientItem1.DdeItem:= 'THERMO1_ReadT';
You can have multiple DDeClientItems "looking" at multiple messages from a given server, but in this example, we're just looking at the one parameter.

Next, select DdeClientItem1 on your form, and then use the Object inspector to create a handler for the Item's OnChange event, it's only event...
procedure TDS1820Sf1.DdeClientItem1Change(Sender: TObject);
That's it! If you look at my explanation of accessing the 1-Wire temperature chip without using DDEView, you may gain a greater appreciation of how wonderful it is to have DDEView available as an alternative!

Things You Could Do

With very little more than what is explained above, the following would be quite easy to implement with 1-Wire chips and DDEView. There are more ideas scattered around other pages I've written.

Active Solar Heating / Cooling

You would need the following, connected in a loop: A water pump, a large insulated tank, a radiator in a room you wanted heated or cooled, a solar panel. (You could make this a lot better with TWO pumps and two "circuits":tank- radiator and tank- panel, but I'll leave you to figure out how that would be better, how to hook it up.)

The pump(s) would be turned on and off by 1-Wire chips, and temperatures would be sensed at various points.

During the winter, the pump would be turned on whenever the temperature of the water in the tank was warmer than the temperature in the room you wanted heated, so, typically, on during the day, off over night.

During the summer, the system could be run in reverse: On during the night (heat would "leak" out of the solar panel into the night's chill). For at least part of the morning, the "cold" stored up overnight in the tank of water could go into the radiator in the room to be cooled, postponing it's warming up during the day. Such system s really do work, even though it might seem odd from this skimpy description. During the summer cooling, condensation on the radiator would be a problem in many areas, but one that can be handled.

Chronologically sensitive fans

This project also addresses the problem of staying cool in the house in summer, and is a little less expensive in plumbing!

You'd have a fan and some temperature sensors.

At times which suited you, the fan would run if the outside air was cooler than the air inside the house... down to some sensible minimum, of course. And, being computer controlled, you could "tell" the fan that you didn't want it running for more than 30 minutes in any hour (to prolong the fan's life) and that you didn't want it running between 11pm and 3am (disturbing your sleep. By 3am, you should be sleeping soundly, and you probably want to pump some cool air into the house to get ready for the following days heat.)

Basement flood detector / Obscure closet humidity monitor

Do you have a basement which is subject to flooding if the sump pump is overwhelmed? Or a closet that sometimes gets so humid that mildew becomes a problem?

Setting up a system to keep an eye on such things would be very simple with 1-Wire and DDEView. Not only could you have alarms alert you to serious conditions, but you could also display the pump activity / humidity levels so that you would see that a problem was developing before things got "bad".

Lawn / Greenhouse controls

When DID it rain last? How much? When did I last water the lawn? Should I open the greenhouse windows... or shall I set up something to open them automatically when...?

Again.. all things you can monitor/ control with 1-Wire and DDEView.


   Search this site or the web        powered by FreeFind
  Site search Web search
Site Map    What's New    Search

Click here if you're feeling kind! (Promotes my site via "Top100Borland")
Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

Click here to visit editor's freeware, shareware page.

Link to Tutorials main page
Here is how you can contact this page's author, Tom Boyd.

Valid HTML 4.01 Transitional Page WILL BE tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org

If this page causes a script to run, why? Because of things like Google panels, and the code for the search button. Why do I mention scripts? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....