
Jeaton (Customer) asked a question.
How do I find the current millisecond value. IE $NOW.Millisecond
Do I need to roll my own with a millisecond timer or tickms?

Jeaton (Customer) asked a question.
Do I need to roll my own with a millisecond timer or tickms?
Copyright © 1999-2023 AutomationDirect. ALL RIGHTS RESERVED
The smallest increment I can find for $NOW is .Second, if you want milliseconds I'd image you'd have to start a timer and use .Acc (just remember it will roll over in about 3 weeks being a signed 32 bit value)
Thanks Tinker. That is what I have found. Next I will have to synchronize the timer with the roll over of the second.
You might want to utilize the MATH box TICKms() or even TICKus() time register functions over a Timer and utilize the 2's complement modulo math that "just works".
D0 - snapshot of CURRENT MICROsecond register
D1 - previous PLC scan's snapshot
D2 - calculated duration in microseconds from last PLC scan
MATH D0 "TICKus()" // snapshot of current MICROsecond timer value and move it into D0
MATH D2 "D0 - D1" // D1 contains the last PLC scan's TICKus() snapshot value, so D2 is the actual MICRO second duration from the last scan; MODULO MATH JUST WORKS - no need to worry about wrap-around + to - or - to +
MOVE D0 D1 // put current scan's TICKus() value into D1 for the next scan
That is fascinating, but how does one find out about TICKSms()? Sure if one knows about it one can search the help file and find it but that is a bit of a catch 22. And note that one has the use the search tab, not the index tab, if one scrolls thru the index tab locking for tickms one won't find it..
Yes it is in the instruction set list, and if one uses the alphabetical list it is very close to TMR etc. But if one looks at the category list it is not under "Date / Time / Calendar" one has to go to "Math functions". but unless one knows it exists, why would they?
While subtracting one instance of TICKSus() to get an interval quite magically works even when the value rolls over, Jeaton was looking for a "$NOW.Milisecond, which one would be analogous to;
".Second is a 2-digit value from 0 to 59 representing the [sic] hours."
except 3 digits and representing, um, I don't know, minutes?
Of course one can measure the interval from when $NOW.Second last changed.
By the way, are all Do-mores going to die in 2038 or what?
"The UTC value is a 32-bit integer value that represents the number of seconds that have elapsed since a particular point in time. Do-more PLCs use the 1970 [Unix] Epoch -"
There's lots of stuff in Do-more. MATH, as you have realized, is quite powerful. There are a BUNCH of functions in MATH other than basic arithmetic. The Help system is one way to learn about Do-more (especially all the minutiae).
Realize that 95% of the people use the same 5% of the product. The other 95% of the product features are catered to each individual application/user, and no one uses all 100%, but all those features get used by someone. Help, Forums, Google, YouTube, et. al. help with the minutiae, but you will never know everything (I even forget about some features 😁 ). This forum and Host Engineering's forum are a great place to learn, but it does take time.
BTW, by the time Y2.038052K hits, the standard Unix 1970 Epoch will probably be adjusted to some other epoch value like 1/1/2000, or some other solution will be available before then. Yes, firmware will have to be updated, but unlike other vendors, software and firmware updates are FREE (no service contract necessary).
First of all, this is a great forum! I searched for this very question, and found this thread right away.
Second, here's a proposed solution for $NOW.Milisecond. I'm not 100% sure of its correctness - specifically the 999 ms vs 1 sec preset, and whether the T0.Done leg is redundant - but it's a starting point.
Finally, I'd suggest to HOST Engineering the addition of $NOW.Millisecond (SDT0.Millisecond). The integer value must already exist because it'a available in text string form via the scripting language TimeStamp function.
Here's another approach - "scraping" the millisecond value from a Timestamp string:
thanks Albert. I've been using the old hacky way with a timer to add the millis, but yours is more elegant.
+1 for the $now.milllseconds (or maybe $now.millis)
I'd also like to see $UTC in milliseconds but understand this is harder because it doesn't fit into a 32 bit integer