Host Engineering Forum
General Category => General Discussion => Topic started by: PLCGuy on June 15, 2017, 06:45:52 AM
-
Okay you brainiacs, where can I get more info on creating arrays? I understand the examples of using them but none of the examples really tells me how to PUT the data into an array for use. I see there are single dimensional and 2 dimensional arrays. How do you get the data into the tables? Not sure I am asking the right questions.
-
The Designer Example project BatchData1.dmd has a code-block GenReportData that uses a FOR/NEXT loop to determine the Minimum and Maximum values by iterating through a user data block called XYZSamples, also copying THAT min/max batch value's date/time stamp (the report reports the min and max values, along with their corresponding date/time stamps). It uses arrays in relational contacts and in MOVE and MEMCOPY instructions. See the attached screen shot.
You can use arrays as Input parameters or Output parameters. You can even use them from Designer in Data View!
MATH allows you to use entire EXPRESSIONs in both the Expression and in the Result. So you can have a MATH that looks like the following:
MATH R[(D7 * 10) + 4] "SQRT(T[V22 * V2 - 17].Acc * R[(D[V10] + 14) * 3])"
-
What is an example of something you would like to do with an array?
Maybe we can offer a little better detail of how to accomplish it.
I have used arrays to build several entire databases in DMD.
-
Arrays can be fun. I built some machines using a DL206 that used up virtually the entire memory space. Worked really well too, a couple are still running after 18 years.
-
How do I post the programs, it will not allow it. Says MPG allowed but I get an error.
I think I got it. I can load and save the info from the micro.
Check it out. From the HMI, pick what item to view then load it. I can change any value and save them back.
Works nice. Crude but my first time doing arrays.
-
screen shot is all I can do. Not sure why I can not load a mpg and dmd file.
-
Better picture, forgot to turn off status
-
This has nothing to do with arrays, but definitely related to your logic.
We are implementing a COPY - Copy Data instruction that will be coming out in Rel 2.1. So the work you were doing across two rungs with the PD/STRPRINT/MATHs, can all be done with ONE RUNG and ONE BOX!
(https://forum.hosteng.com/proxy.php?request=http%3A%2F%2Fwww.hosteng.com%2FForumImages%2FCOPY1.png&hash=c28c294cf2e498c75478577e68b1ad59f37850ae)
(Note that if you need the C3 PD for other rungs, you would need to keep that rung)
Here is the editor. It behaves much like INIT's editor, you just type the entries in each field. You also have the option for the Input Leg behavior (Edge Triggered aka One-Shot, or simple Power Flow Enabled).
(https://forum.hosteng.com/proxy.php?request=http%3A%2F%2Fwww.hosteng.com%2FForumImages%2FCOPYEditor1.png&hash=70b1c542287752d3f4bab6df70224778396535cb)
It supports MOST of your data assignment operations: bits, numerics, structures, ranges, arrays, even copying strings between strings of different MAX LENGTHs. There are a few things it doesn't do, but the native instructions are all still there.
-
So what i did is not considered using arrays? But in any case, it is something I see useful.
Cool Stuff.
Not related but any changes to CHANGE VALUE in Do-More. The icon VALUE only allows changes to numeric values. I typed in SS0, it turned green but would not allow me to type in a new "string". I had to use data view to manually make changes when I was figuring out my ladder. Is it a big deal to allow string changes using CHANGE VALUE icon?
-
So what i did is not considered using arrays?
Yes, you DID properly use arrays. GREAT application of it. MY POST had nothing to do with Arrays, but just highlighting a new instruction for setting data (instead of STRPRINT, MATH, MOVE, MEMCOPY, SET, RST, et. al.)
Not related but any changes to CHANGE VALUE in Do-More. The icon VALUE only allows changes to numeric values. I typed in SS0, it turned green but would not allow me to type in a new "string". I had to use data view to manually make changes when I was figuring out my ladder. Is it a big deal to allow string changes using CHANGE VALUE icon?
That sounds like a very good idea! I will add it to FogBugz!
I use Change Value, but a lot of people have no idea it's there. One key feature related to it is that if you are ONLINE in DISPLAY MODE (i.e. NOT edit mode), with STATUS ON, then when you DOUBLE CLICK on ANY PARAMETER in an instruction, you get the CHANGE VALUE dialog to EDIT IT. No need to set up a Data View to tweak an element you are looking at in your ladder, just DOUBLE CLICK on it in your ladder!
-
Thanks for the info. I did tweek the program. removed STRPRINT and put it to a ST1 bit so when ever the user presses item (V0) the string pops up to say what it is instead of waiting to press load to see the string.
-
What I would like to do with arrays is this
Lets say that I have 8 inputs each input turns on one of eight outputs Each output has a Off delay timer.
Instead of writing the same code 8 times can arrays be used to assign inputs,outputs and delay times to variables in a single rung.
If so are there any examples of this I could study.
I will be using a D0-More PLC
Thanks
-
I am not claiming this is a good idea, and it does give a warning about a timer in a Loop, but it does appear to work in the Simulator. I did not test it thoroughly however.
I have done non-critical timing using the elapsed ticks (or something like that) inside of loops.
-
Instead of writing the same code 8 times can arrays be used to assign inputs,outputs and delay times to variables in a single rung.
If so are there any examples of this I could study.
If they were all contiguous (all 8 inputs contiguous, all 8 outputs contiguous, 8 delay times contiguous, and all Timers contiguous).
Use a FOR/NEXT loop
Say Inputs are X10 thru X17.
Outputs are Y200 thru Y207
Delay Times are D120 thru D127
Timers are T30 thru T37
Use V100 for the Input index
Use V101 for the Output index
Use V102 for the Delay Time index
Use V103 for the Timer index
STR ST1
MOVE 200 V101 // Y index
MOVE 120 V102 // D index
MOVE 20 V103 // T index
FOR V100 10 to 17 // X index
STR X[V100]
ONDTMR T[V103] D[V102] Y[V101]
STR ST1 // FOR/NEXT increments V100, but gotta do these 3 manually
INC V101
INC V102
INC V103
NEXT
Make sure your codeblock's .TimeSlice is 65535 (NEVER yield)