Doc. # 1-0003201
Date Updated 04-22-2004 Date Created 07-27-2000
Document Type Knowledge Base Related OS
Related Product ADAM-4011/ GeniDAQ
How to read ADAM or Genie DDE server data and save to a column in Excel?
Solution:
To read data from DDE server and save to a column in Excel, macro procedure to request DDE data periodically is required for such purpose. An example to read 10 data ADAM DDE server is as follows: Sub get_data() ADAMChannel = DDEInitiate(DAM2? 04? WorkSheets(1).Cell(1, 2).Formula = ?NOW()? WorkSheets(1).Cell(2, 2).Formula = ?B1-INT(B1)? WorkSheets(1).Cell(3, 2).Formula = ?SECOND(B2*2)? For i = 1 to 10 WorkSheets(1).Cell(1, 2).Formula = ?NOW()? s1 = WorkSheets(1).Cell(3, 2).Value Do WorkSheets(1).Cell(1, 2).Formula = ?NOW()? s = WorkSheets(1).Cell(3, 2).Value Loop While s = s1 WorkSheets(1).Cells(i, 1).Value = DDERequest(ADAMChannel, I? Next i DDETerminate ADAMChannel End Sub This example macro procedure scans data from ADAM DDE server every half second and save data into cells A1..A10. To change sampling speed, change the formula in B3. For example, to scan 5 data every second, change SECOND(B2*2) to SECOND(B2*5). To have 10Hz sampling rate, change to SECOND(B2*10).