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 comment
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 comment
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 comment
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 comment
Share on other sites

  • MVP 2023
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 comment
Share on other sites

  • 3 weeks later...

Thank you very much Joe, I did indeed contact the support, and I've have a nice discussion with them. This is what came out of it:

Quote

we have confirmed that only the 4 bytes you mentioned need to be used for the timer.

So I can safely drop the other 8.

Hope that helps someone else one day ;)

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.