Jump to content

Direct Read String from Data Table


Recommended Posts

Hello,

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:

http://www.side-automatizacion.com/es/system/files/suport/visilogic20-20function_blocks.pdf

image.png.9ca0e892387e53d1f67a98401af31d5d.png

 

Anyways here is what I would like to do. 
image.png.83dc8f11b33af3f11be504830342b3df.pngimage.png.31ba91171629fb007fc43b4746cf6af8.png

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 

image.png.e7315635a38e0e901fdcfa5cd96d3083.png

 

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. 

image.png.93a702c905a03c8b5e4d25174a3ae21a.png

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

image.png.835f8320653a6ba368c27c1200ca8ebd.png

 

 

The Code is super minimal. 

image.png.e59360b1dc5eb9778aa2246803f64c57.png

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. 

image.png.fcbbb874f01ac772763a7c39db0c4a39.png

 

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

image.png.455d90874ebac08a861cc8cac3d82576.png

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.

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