Help - Search - Members - Calendar
Full Version: Excel / VB Help
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
pete3589
I have made a program which using DDE communications imports and exports data from a CompactLogix PLC

In order to save myself some time (since I have many values to import and export) I am trying to use a for statement with an embedded variable so to speak. My values are set up as

AnalogInputs[0].Value
AnalogInputs[0].Fault
AnalogInputs[0].Alarm etc etc with about 10 elements in each AnalogInputs[x]. I need to read these values for the first 26 analog inputs and read them into excel starting at F75. Read all values in down to F85, then skip a line and continue with AnalogInput[1].

This is quite easy to do in the PLC programming code. Briefly, it would be something like:

y=75
FOR x = 0 to 26

AnalogInputs[x].Value = Fy
AnalogInputs[x].Fault =Fy +1
etc etc
y=y+1 (for the space which im not sure how to add in excel)
end for

The main problem is that I dont know how to use the x value so that it is embedded in the analog input. I also dont know how to add the space (though I am sure it is a relatively simple function).

Any help would be appreciated.
TWControls
The easiest way is to add the L and C variables to you DDERequest. The only catch is i do not think it will work with user defined arrays. You would have to copy the data into a normal array then use a command such as below. Or try with the user defined array. I cant remember for sure if it works or not

RSIchan = DDEInitiate("RSLinx", "TopicName")
data = DDERequest(RSIchan, "TagName[0],L20,C1")
Range("Sheet1!B3:B23").Value = data
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.