News:

  • October 13, 2026, 06:33:49 AM

Login with username, password and session length

Author Topic: A Question About User Structures (UDT), Memory View and Memory Image Manager  (Read 11384 times)

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
I am revisiting some past code questions and have been looking into recipe options. I can create a UDT easily enough for a simple recipe structure, but how do I manipulate the entries outside of an HMI?

I can't open a Memory View of a structure.

I can't Modify Region Data in a structure in Memory Image Manager.

I can't export the Memory Image (that I can find) to view it there.

Am I missing something obvious?

BTW, I also ran across previous threads on MRX and MWX straight in and out of UDTs. Oddly enough that is one of the things I am revisiting. For me however, I had to add a third type of device trying to work in a single structure and that would be harder now, even with the new capability, since it maps out totally differently than the other two, that were different as well.

And yes, I'm using v2.7 now. I love the rung comment changes!

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3848
    • Host Engineering
We have not yet added support for structures in Memory View, but that is on our TODO list.

Data View to edit in a PLC.  Note that Data View does support array indexes, so you could have a Data View with V0 followed by your block of your UDTs with V0 as the index for each struct member:
V0
MyRecipes[V0].CookTime_min
MyRecipes[V0].CookTemp_degF
MyRecipes[V0].CornWeight_lb
MyRecipes[V0].CookWater_g

Set V0 to 0, write that to the PLC, then tweak the MyRecipes struct members, then select all the struct members, and hit the Single Write (not Write All, but that would also work if you already wrote V0) because Single Write also writes the SELECTED group when there is a selection.

Set V0 to 1, write that to the PLC, ...

Set V0 to 2, write that to the PLC, ...

OR

Ladder Logic - look at COPY to write to individual fields.

If you are good at File I/O, you could create a CSV file in a PC with all the fields from Excel, put it on the SD card, then open the file and read each line.  Each line would be a different index in your data block of recipes.  You would then have to parse the comma separated line into individual fields in a structure.

Another possibility is to utilize JSON format and read each record from a server, but that's getting into HTTPCMD or writing your own protocol and server function on a PC that the PLC talks to.  Then use JSONPARSE to extract the data into your data block of your UDT.

Not sure which one(s) you are comfortable with.  There may be others out there that can provide other ideas or help with some of these.

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
Oh well, I was just hoping I had missed a "simpler" option.

I think I will drop back on a suggestion you made here a couple of years ago for this one and just use two arrays: RecipeName0-100 and RecipeValues0-5000 RecipeNumber, RecipeOffset=RecipeNumber*50 and MemCopy.

I'm pushing 40 entries for each recipe, so 50 gives me room to grow.

(Also, trying to do the recipe name in the structure is a pain.)

The Copy instruction is OK, and I am using it for the structures elsewhere, but I miss having the mouse hover cross reference, and seeing values.

And thanks for the quick response on a weekend!

RBPLC

  • Hero Member
  • *****
  • Posts: 586
@Mike Nash, Could you possible post your code whenever you get your recipes set up (or a sample of how you approach it). I'm curious to see your approach to recipes as I've looked into this before as well.

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
@Mike Nash, Could you possible post your code whenever you get your recipes set up (or a sample of how you approach it). I'm curious to see your approach to recipes as I've looked into this before as well.

I can probably do that, pending I remember to.  :)

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Mike,
I'd be very interested in seeing it as well.  I've been looking at recipes in C-more and trying to decide how to build a drilling program on a two axis drilling machine which currently runs G-code.  G-code works fine for the moving and peck drilling. Where it fails miserably is I have no direct control over the 4 spindles and a horrendous waste of time switch spindles.  However I need to be able to set up programs for at least 8 different products that will always run exactly the same way so a recipe seems right even if it takes a considerable amount of work to set up.

Gary

Mike Nash

  • Hero Member
  • *****
  • Posts: 655
Two months later...

I finally made a little time to strip down what I did to the basics for the recipe.

Sixty recipes with 50 entries per recipe.

The RecipeVals array is REAL, so watch out for data type mismatches
   such as D0=123456789 saves as 1.234568E+008 into RecipesVals4
   which then gets loaded back into D0 as 123456792

RecipeNames is a separate string array. Names are just for reference as RecipeNumber is the array offset.

I didn't include the time stamping into the recipe name.

There is no sorting.

The HMI is tedious to "program" and will be unique to each application.

Import the text file into DmD. The export is v2.7.3.