pandersen

MrPLC Member
  • Content count

    106
  • Joined

  • Last visited

Everything posted by pandersen

  1. Ok, I managed to get something accurate. Dang leap years! In the steps below I am using a timestamp of 1203161493 which corresponds to a date/time of 2-15-2008 11:31:33. I'm ignoring timezones and whatnot, it isn't necessary for this. Steps: 1. Unix timestamp / hours in a year to get years from 1970 to timestamp ex: 1203161493 / 31436000 = 38.152... years since 1970. Ignoring the decimals, thats 38 years + 1970 = 2008. 2. Determine number of leap years from 1970 to year found in step 1 (extra days). ex: (2008-1969)/4 = 9.75. Again, ignore the decimal, and we have 9 extra days (we ignore this year's leap day until later) 3. Determine the number of days since the epoch. ex: 1203161493 / 86400 = 13925.480... days since epoch. Ignore the decimals again. 4. Subtract leap days from number of days since epoch. ex: 13925 - 9 = 13916. 5. Modulo the number above by the number of days in a year to find the days passed in the current year. ex: 13916 % 365 = 46 days this year. 6. We go through each month and subtract it until the days left are less than the month's total days. If this year is a leap year and your days in this year found in step 5 was greater than 59 (31+28), we would add one. ex: 46 - 31 days in Jan = 15 days (in 2nd month) = Feb 15. 6. Find the number of seconds in the current day. Subtract the days since epoch found in step 3 from the timestamp. ex: 1203161493 - (13925 * 86400) = 41493 seconds 7. Figure out how many hours the seconds found in step 6 is. ex: 41493 / 3600 = 11.5283... hours. Ignore the decimal again. 8. Find the number of minutes left. Subtract the hours you found in the previous step from the seconds in step 6, then divide by 60. ex: 41493 - (11 * 3600) = 1893 1893 / 60 = 31.55 minutes. Ignore the decimal 9. Find the number of seconds left. Subtract the minutes in step 8 from the seconds in step 8 ex: 1893 - (31 * 60) = 33 seconds. Put it all together: Year: 2008 Month: 2 Day: 15 Hour: 11 Minute: 31 Second: 33 If anything was unclear, let me know and I'll try to explain it better. -Pete
  2. AB ControlLogix But it shouldn't matter, I should only need basic math like divide, subtract, modulo, etc due to the lack of date specific functions in most PLCs.
  3. Hiya, Does anyone have any experience using RSLinx's OPC server with serveral thousand tags? I took a few examples I found online and mashed em together into a project that works, but causes Linx to use 100% of the CPU all the time (with a slow update rate as well). It also takes FOREVER to add the items to the OPC group, about 6-7 minutes for 10,000 tags. Eventually there will be just under 30,000 tags being monitored, so I expect my program to be 'starting' for about 18 minutes before it can do anything! What's going on?! This is running on an Intel Core 2 Duo @ 2.0 GHz with 1GB of RAM, so I don't that its a resource issue. In the end Linx is using about 70MB of RAM and my app is using less than 20MB. Here is the line of code I use to add items: RSLinxOPCGroup.OPCItems.AddItem "[" + strOPCGroup + "]" + strValue, lngOPCSta1TopStopID (repeat with different strValue and lngOPCSta1TopStopID 10,000 times) Thanks for your help! -Pete I also find it hilarious that is a smiley here
  4. RSLinx OEM + OPC + VB

    Yeah, AddItems is faster. Less than 5 seconds vs 5 minutes for adding 12,000 items at once.
  5. You can also quicken your licence checking if you put your local HDD first in the 'CHECKDRIVES=' unless ALL your licences are over the network.
  6. RSLinx OEM + OPC + VB

    TWControls: I am adding subscriptions to all the tags at once. At this point I am not even activating the group, so no values are being sent back and forth. This is what takes the ridiculous amount of time. Once the subscriptions have all been added to the group, I activate it and all 10,000 values are sent at once, which takes very little time and works great. Once I have all the initial values, I only get updates when a tag changes, so I'm not grabbing 10,000 tags every second. This is all from 1 processor, which right now is an emulator running on the same PC. These are logs, yes. We are saving the position data of 4 servos and the values from a loadcell into an array every 50 ms, then at the end of the cycle I send a trigger to the VB app and it saves it all to a CSV file. BobLfoot: I hadn't thought of that, but I checked and every thing is A-Ok it seems. buster: Probably a good idea, too bad our customer insists everything is Rockwell. They are afraid of all the finger pointing when something does go wrong and everything is from a different manufacturer. EDIT: I just realized there is a AddItems function, rather than the AddItem I was using. I will try accumulating all my tags into arrays in VB and then adding them all at once. Probably less overhead this way on the RSLinx side, so I hope to get better performance from this. I'll post back when I know.