Jump to content

How to read a Timer column in a datatable


Recommended Posts

HI!!

I'm reading a datatable that has a column of type "Timer". There is not much information on this. I found that its 12 bytes long and setting a cell to its maximum value through VisiLogic's monitor (99:59:59.99), I read [0, 0, 255, 80, 37, 2, 0, 0, 0, 0, 0, 0] (values may be in reverse order)

How do I make sens of those values?

Link to post
Share on other sites
  • Jerther_ changed the title to How to read a Timer column in a datatable
40 minutes ago, Jerther_ said:

I read [0, 0, 255, 80, 37, 2, 0, 0, 0, 0, 0, 0] (values may be in reverse order)

How are you reading these values? When I go online with the data table in VisiLogic I see the value in timer format.

Link to post
Share on other sites

I´ve read timers from datatables using VBA in Excel using this code:

            Call CopyMemory(resultLong, DB(lAddress * ElementSize + 23), 4)
            resultSingle = resultLong / (24 * 60)
            resultSingle = resultSingle / (60 * 100)
            Workbooks(NombreArchivoDatos).Sheets("Referencias").Cells(lAddress + lRowReadIndex + 2, 4) = resultSingle
            Workbooks(NombreArchivoDatos).Sheets("Referencias").Cells(lAddress + lRowReadIndex + 2, 4).NumberFormat = "[hh]:mm:ss.00"
 

lAddress and ElementSize depends of RAM address of specific datatable you want to read from PLC.

Link to post
Share on other sites

Thanks!

If I understand correctly, CopyMemory reads 4 bytes, right? That would make sens for a normal long integer, but I count 12 bytes for the timer column in VisiLogic, that is, the Timer column is at address 20209, and the next column is at address 20221. I need to fully understand what's happening.

Link to post
Share on other sites

Thanks Gabriel. That's helpful for my application right now, but to tell the truth, I'm developping a module that aims to fully support the PCOM protocol so covering all cases is essential and "I don't know but it works" won't cut it unfortunately :(

Maybe most of the 12 bytes I see in VisiLogic are reserved and always set to 0, but I must know that. I'm also writing to Timer columns so I must know what those 12 bytes mean.

Link to post
Share on other sites
On 10/7/2020 at 11:16 AM, Jerther_ said:

I'm reading a datatable that has a column of type "Timer". There is not much information on this.

No, there's not and you are definitely in the deep end of the pool.  PCOM has become a legacy thing with the development of UniStream and I wouldn't expect any updated documentation to appear on the website.  I looked over the PCOM document and the section on Data Tables is pretty short and ambiguous, as you have found.  The fact that the newest PLC listed in it is a V280 is not encouraging.

For your specific question, all Unitronics timers in a Vision are 0.01 timers with 32 bit values for the preset and accumulator.  The HH:MM:SS.ss display is done in the software so us humans can understand it better.  I got my trusty HP out and determined that 99:59:59.99 = 35,999,999 units of 0.01 sec.  

Yes, this is what I do on a Saturday night.  I need a life.

Anyway, the hex equivalent of that is  02 25 50 FF.  Which read backwards is FF 50 25 02.  Which converted to decimal is 2 37 80 255.  So that answers that question but you probably already figured that out. 

My best guess is the rest of the bytes are reserved placeholders.  With a Data Table you don't have other timer information such as the timer number, accumulator value, the fact that it's a timer (base memory offset), or the status bits.  It would make sense that the timer data structure in a data table would match how it lives in the ladder program. 

My suggestion is to send an email to Official Unitronics Support at support@unitronics.com with your observations and questions.  You'll need to get one of the Creators to answer this one.

 

Joe T.

Link to post
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...