Jump to content

How to use Data Table Read Row/ Column


Recommended Posts

I am trying to set up a recipe system that updates an HMI display  once information is saved into a data table. I already have the String for recipe name working, however the Integer is not updating the display. If I read the table values from PLC into visilogic, the int values match what the user put in. However when I try to use the read column or read row and assign it to an MI, the MI value does not change  from 0. (Using an MI as an indirect string in library to  update the HMI Display). If anyone knows a better way to read ints from a plc data table and update an HMI text from it that'd be great. Or possibly information as to what I am  doing incorrectly with reading from the data table. This is my first project with visilogic and probably my second  time programming a PLC in general. The read bit is powered on  constantly, does it need to cycle off for the information to update? Any information is helpful, thank you. I've attached a picture of my attempt to just read one row into an MI slot, as well as a picture with the live watch of that MI slot and the read structure  and values from PLC table afterword

Data Table Read Help.png

Live Watch & Downloaded Table.png

Link to comment
Share on other sites

Hi Plum,

The way that the read is set up your always going to be reading row 0.

In order to read other rows you would need to assign and MI as a pointer(the number stored in it will be the row read).

Also you'd only want the read bit to be pulsed not on constantly.

 

Link to comment
Share on other sites

The strings are completed, I allotted a vector of  20 mi's for each string. The issue I have currently is for reading integers. Project attached.

Tongue Turner Revision 9 (Recipes Saved and Updated).vlp

 

 

7 minutes ago, Flex727 said:

In addition to what Joe said, I'll also note that a 20 character string will need to be placed into a vector of 10 MIs.

11 minutes ago, Joe Tauser said:

You did not show that actual logic you are using to read the data table, which is probably where the problem is.  Please upload your PLC program.

Joe T.

Link to comment
Share on other sites

3 minutes ago, Flex727 said:

With just a quick glance, you are not allocating a vector of 10 MIs to your Recipe Name Read Row FB and overwriting your integer.

Thank you so much, I was looking at the line above that one and completely forgot I had that read for the name leftover from awhile ago (where I didn't know I needed more than 1 MI slot). Now my watch shows the correct value after moving that MI slot somewhere else. Now my HMI displays an * in stead of the value, however i'm assuming thats because it is reading  it as an ascii code and not the literal string representation "4". Should I not be using an indirect string in this case and what should I use to display this number?

Link to comment
Share on other sites

8 minutes ago, Flex727 said:

 You have that column in the Data Table defined as an Integer. Use a Numeric element to display an integer number.

Oh duh... Works like a charm now, thank you so much. I realize however this is not the most efficient way to do things, as it is not reusable. This will work for this project, but to further my learning how would you go about making it read and update HMI values for an unknown number of presets rather than copying each row into a vector for each preset u have. (Since that would become a large diagram if say 100  presets were required) Create a row counter that increments until it hits the end  of the allotted vector space and sets HMI values based on the row number?  That would lead to a lot of if statements checking the row number then, and would be the same thing as copying each row individually. 

Link to comment
Share on other sites

1 hour ago, Flex727 said:

I don't believe there is any problem with reading a Data Table row on every PLC cycle.

Your right the PLC won't have an issue with it and it will function, however if you then want to manipulate the data after reading it you can't because your just going to over write it the next cycle.

Link to comment
Share on other sites

  • MVP 2023
49 minutes ago, Plum said:

how would you go about making it read and update HMI values for an unknown number of presets rather than copying each row into a vector for each preset u have. (Since that would become a large diagram if say 100  presets were required) Create a row counter that increments until it hits the end  of the allotted vector space and sets HMI values based on the row number?  That would lead to a lot of if statements checking the row number then, and would be the same thing as copying each row individually. 

Using indirect pointers allows you to have a large number of checks without having a separate if statement for each.

By the way, you are using the String Library to display your recipe names on pushbuttons. Don't do that. The String Library is intended to allow you to switch languages on pushbuttons with fixed text. Just use an HMI String variable, add a touch operand and display the variable as an unpressed pushbutton.

Link to comment
Share on other sites

  • 2 years later...
On 8/29/2017 at 5:29 PM, Flex727 said:

In addition to what Joe said, I'll also note that a 20 character string will need to be placed into a vector of 10 MIs.

Greeatings , 
How can i write ASCII string of 10 char in DataTable type String 10 , 

ASCCII string start adress of vector is 100 , when i write example "start " i have only st , this is why MI is 2byte i neded 5 .
Have you some example for this ? 
thank you

Link to comment
Share on other sites

13 minutes ago, Flex727 said:

What function are you using to write the ASCII string? Typically, if the column is defined as String, 10, it will automatically read a vector of 5 MIs into the column. Make sure your Data Table definition is correct.

On the photo you can see Proizvod string 10, on the second photo i try with ML to ML and i see first ML is empty if i write example water in datatable I have only r.
ML 10 is correct on datatable Proizvod

Pro.jpg

asc.jpg

rr.jpg

2.jpg

Link to comment
Share on other sites

  • MVP 2023

I never store ASCII characters in ML, only MI. Why are you trying to use ML?

Your attachment isn't making any sense to me. You show the column "Proizvod" to be defined as 10 characters, but in your Write Row FB, it shows as 20. Are they referring to the same Data Tables?

Link to comment
Share on other sites

1 minute ago, Flex727 said:

I never store ASCII characters in ML, only MI. Why are you trying to use ML?

Your attachment isn't making any sense to me. You show the column "Proizvod" to be defined as 10 characters, but in your Write Row FB, it shows as 20. Are they referring to the same Data Tables?

I try to see what happend , but same problem is with MI ,i set my orginal program photo, and you can see result in datatable, I write water you can see result is SE720

11.jpg

22.jpg

333.jpg

444.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.