Selecting a point on an array based on a selected Value- CCW

Ckoch

Member
Join Date
Jun 2023
Location
Ohio
Posts
14
I am working on trying to create a an HMI program where the user can select a value from 1-25 and then enter a string, which will be placed into the corresponding location in the array (Entering 14 and "Dog" inserts "Dog" into the 14th spot on the array). I am having trouble with how I should go about changing the array location within the PLC logic. My current plan was to use the MOV function block, but this creates a static variable that it is sending to (i.e. only sends to array location 3). Any ideas on how to change which location in the array it sends to?
 
This can depend on which HMI software you are using and whether you want to use load/save buttons or not.

The basic version looks like using a HMI_StringEntry and when you "save" you COP HMI_StringEntry to StringArray[CurrentSelection]. When you "load" then you COP StringArray[CurrentSelection] to HMI_StringEntry (Or wherever you load to). Make sure you limit the CurrentSelection mechanism to 1-25 in both your HMI and PLC programs otherwise one day you will surely have a subscript out of bounds and likely crash your processor.

A smoother way to do it if your entry fields have an enter or handshake is to use the entering of a string to COP HMI_StringEntry to StringArray[CurrentSelection], and the entering of CurrentSelection to COP from StringArray[CurrentSelection] to where you need it.
 
I am working on trying to create a an HMI program where the user can select a value from 1-25 and then enter a string, which will be placed into the corresponding location in the array (Entering 14 and "Dog" inserts "Dog" into the 14th spot on the array). I am having trouble with how I should go about changing the array location within the PLC logic. My current plan was to use the MOV function block, but this creates a static variable that it is sending to (i.e. only sends to array location 3). Any ideas on how to change which location in the array it sends to? fnf
To dynamically change the array location based on user input in an HMI program, you can utilize indirect addressing. Instead of using a static index value, create a variable to store the user-selected value and use it as the index in the MOV function block.
 
The array location written by the HMI needs to be a one-shot, so when the source string or the ordinal index is changed for the next entry, the new string value does not get written to the old array location.
Untitled.png
 
Thanks for everyone's responses! I am using the Developer edition, so I ended up using a UDT and a user defined function block of a long list of If-ElseIf function to insert a substring into the brackets of my array (If Location=X Then MyArray[X]=MyValue).
 

Similar Topics

Hello, I have a 1756-A7 controller and am working with AB Point I/O for the first time. I have a 1734-AENT with a total of 15 modules (mix of...
Replies
0
Views
2,413
Hi, I'm working on Mitsubishi MR-J5-70A amplifier, and need some advice on selecting fuse size. Main power is 1ph 240VAC, and in the manual, it...
Replies
1
Views
70
We had a servo motor feedback cable get damaged recently and we want to order a replacement. The current cable is a custom made cable, and we...
Replies
1
Views
898
Not sure how to word the title but here's my scenario. We have a carriage that moves at high speed with an energy chain and the cable bends in a...
Replies
11
Views
2,874
Hello plctalk, new guy here. I have an application that I'd like to present for your considered opinions so I can figure out what hardware I...
Replies
11
Views
2,519
Back
Top Bottom