Host Engineering Forum
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 12, 2017, 04:57:42 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: arrays  (Read 662 times)
PLCGuy
Internal Dev
****
Posts: 554



« on: June 15, 2017, 05: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.
Logged
franji1
Bit Weenie
Host Moderator
*****
Posts: 2214



WWW
« Reply #1 on: June 15, 2017, 07:35:45 am »

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])"
Logged

plcnut
Hero Member
*****
Posts: 723



« Reply #2 on: June 15, 2017, 04:10:52 pm »

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.
Logged

Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Garyhlucas
Hero Member
*****
Posts: 164


« Reply #3 on: June 15, 2017, 08:40:20 pm »

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.
Logged
PLCGuy
Internal Dev
****
Posts: 554



« Reply #4 on: June 16, 2017, 08:20:18 am »

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.
Logged
PLCGuy
Internal Dev
****
Posts: 554



« Reply #5 on: June 16, 2017, 08:24:46 am »

screen shot is all I can do. Not sure why I can not load a mpg and dmd file.
Logged
PLCGuy
Internal Dev
****
Posts: 554



« Reply #6 on: June 16, 2017, 08:29:50 am »

Better picture, forgot to turn off status
Logged
franji1
Bit Weenie
Host Moderator
*****
Posts: 2214



WWW
« Reply #7 on: June 16, 2017, 08:49:57 am »

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!


(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).



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.
« Last Edit: June 16, 2017, 09:03:05 am by franji1 » Logged

PLCGuy
Internal Dev
****
Posts: 554



« Reply #8 on: June 16, 2017, 09:27:55 am »

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?
Logged
franji1
Bit Weenie
Host Moderator
*****
Posts: 2214



WWW
« Reply #9 on: June 16, 2017, 09:33:29 am »

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.)

Quote
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!
Logged

PLCGuy
Internal Dev
****
Posts: 554



« Reply #10 on: June 16, 2017, 11:01:30 am »

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.
Logged
timk5000
Jr. Member
**
Posts: 10


« Reply #11 on: August 11, 2017, 03:22:45 pm »

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
Logged
Mike Nash
Hero Member
*****
Posts: 499


« Reply #12 on: August 11, 2017, 03:59:55 pm »

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.

Logged
franji1
Bit Weenie
Host Moderator
*****
Posts: 2214



WWW
« Reply #13 on: August 11, 2017, 04:30:35 pm »

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

Code:
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)
Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM