Jerther_ Posted October 7, 2020 Report Share Posted October 7, 2020 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? Quote Link to comment Share on other sites More sharing options...
MVP 2021 Flex727 Posted October 7, 2020 MVP 2021 Report Share Posted October 7, 2020 Moved to a more appropriate forum. Quote Link to comment Share on other sites More sharing options...
MVP 2021 Flex727 Posted October 7, 2020 MVP 2021 Report Share Posted October 7, 2020 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. Quote Link to comment Share on other sites More sharing options...
Jerther_ Posted October 7, 2020 Author Report Share Posted October 7, 2020 Through a PCOM command to read the datatable. That's why I posted in the PCOM forum Quote Link to comment Share on other sites More sharing options...
MVP 2021 Flex727 Posted October 7, 2020 MVP 2021 Report Share Posted October 7, 2020 Ah, I'll move it back. Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted October 8, 2020 Report Share Posted October 8, 2020 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. Quote Link to comment Share on other sites More sharing options...
Jerther_ Posted October 8, 2020 Author Report Share Posted October 8, 2020 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. Quote Link to comment Share on other sites More sharing options...
Gabriel Franco Posted October 9, 2020 Report Share Posted October 9, 2020 CopyMemory reads 4 consecutive addesses (long type). Column defined as Timer needs 4 bytes (integer type). I don´t remember the reason I read 4 long registers to read timers, but it works. Quote Link to comment Share on other sites More sharing options...
Jerther_ Posted October 9, 2020 Author Report Share Posted October 9, 2020 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. Quote Link to comment Share on other sites More sharing options...
MVP 2021 Joe Tauser Posted October 11, 2020 MVP 2021 Report Share Posted October 11, 2020 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. Quote Link to comment Share on other sites More sharing options...
Jerther_ Posted October 29, 2020 Author Report Share Posted October 29, 2020 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.