Jump to content

Direct Read String from Data Table

Recommended Posts


I'm trying to familiarize myself with programming a "vision 280" plc. I have a programming background and it's been pretty straightforward for the most part. 

One thing I have been having trouble with however is using the direct read and write to the data tables. 
I didn't for example know that they had their own memory address system until I found a reference to it in this doc:




Anyways here is what I would like to do. 

I would like to read "chuck" at ram 10 from the data table and put it in the vector ML 0-6

Then display it in an ascii text field 



The problem is I have gotten very inconstant results. Data I cleared from the data table sometimes shows up, it seems like it wants a memory END rather than an offset.

I am sure there is an easier way to get strings out of the data table, but I would really prefer to learn the tools. 


Link to comment
Share on other sites

15 hours ago, Joe Tauser said:

I've never had any luck getting the Data Table RAW function to work.  Have you played with the regular data table read row function?

Look in the Help under Examples and navigate your way to the Data Table directory.  If you have questions post your code.

Joe T.

I'm glad it's not just me having trouble with it. 

I started out using the row read element, but it was unclear to me how to provide a defined vector for it to put the element into memory. 


I can point it to ML 0,  but it's only reading the first 4 bytes from the datatable




The Code is super minimal. 


When I press F4 load the data from the data tables to the vector ML 0-6 then switch to the name screen with an ASCII text field that reads from that vector. 



Perhaps I am using the wrong datatype? Longs may be doing something weird?



But I really would like to learn how to use the direct read/write. Is it actually bugged and not workable for strings/vectors?

Link to comment
Share on other sites

  • MVP 2023
28 minutes ago, ncbc said:

Perhaps I am using the wrong datatype?

Yes you are. Use MI, not ML. For the above ASCII String, you will need a vector of 3 MIs to hold the 6 characters of your string. (I believe you can use MLs and hold 4 characters per register, but why complicate things.)

In the Read Row FB, you need to assign an operand to every column in the Data Table Row. You can certainly make the operands contiguous so that you have a vector to operate on later, but you need an assignment for each element.

Link to comment
Share on other sites

41 minutes ago, Flex727 said:

In the Read Row FB, you need to assign an operand to every column in the Data Table Row. 

I am not using the data in the other columns at the moment. That column is a string, I don't really like how it doesn't clearly indicate it's going to write to the following 5 memory locations when it reads a string. 

I see the INTs are 16 bit and not 8 bit and it is stored little endian that was throwing me for a loop a little bit. :D


I read up on the documentation on the direct read, and I was really underwhelmed with the detail in it. I was hoping to use it to store some graphical data. The one I linked to above is still the best resource I've found on direct read and it still seems lacking. 


19 minutes ago, Gabriel Franco said:

HMI is large enough to show all characters.


The problem turned out to the the ML was storing the 8bit values in each Long. So it was using up the 6 character size with a bunch of nulls.  GOOD FOR NUMBERS, BAD FOR STRINGS!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...