RS Logix - Reading period task cycle time from code

Mr Modbus

Member
Join Date
Jan 2014
Location
Lincoln
Posts
24
I would like to be able to read what the cycle time of the task my code is running in from program code at runtime.
E.G. if my code is running in a 20ms cyclic task, I can run some code that detects this and reports back the value 20.
If I subsequently change the task rate to 10ms, the value that gets reported back would be 10.
The purpose is that I want to do some manual timing operations (not using timers), so every cycle I will remove the cycle time from my timer value. When value <= 0 time expired.
I have looked at task GSV values, but nothing really fits the bill.
 
Use a GSV instruciton.

Class is Task.

Instance is THIS if the GSV is embedded in the task, or taskname if in another task.

Attribute is Rate.

It returns the task rate in microseconds so you need to convert that to milliseconds.


See this post from a couple of days ago for an example showing it in ladder.
 
Last edited:
Ah yes, the Rate attribute.
I missed that as it was on the next page of the manual šŸ™ƒ.:oops:
Teach me to read the mnaul better next time.
Thanks.
 
Lets talk about your method for a second. Make sure you are using integers for your time period. If you convert 10mS to seconds and put it in a float tag you do not get .01. You get .009999987. The number .01, and .02 for that matter, cannot be represented exactly in IEEE-754 float format (the format all computers and your PLC use to store floats)
If you do floating point subtraction you will subtract .009999987. After a long series of repeated subtraction this loss of precision can add up to a significant deviation. So covert everything to milliseconds and do integer subtraction.
 

Similar Topics

Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
85
Trying to setup a message read via Ethernet. I have the path setup as 1, 1, 2, 192.168.66.10 I get an error code 1, ext err 315. I am beating...
Replies
9
Views
233
hi all, i have a plc i need to get info from for a site im working on: I have a 1764 Micro Logix 1500 LSP Series C (See Attached Image) im...
Replies
2
Views
374
Hello, RSLogix 500, a 4-20ma analog input to PLC is scaled for 0 to 100 psi. It is displayed as 0 to 100 psi on HMI, I want to make sure that for...
Replies
14
Views
3,349
Hi everyone, Brief overview of the issue: I have a CompactLogix (pt No:1769-L36ERM) that is connected to a MicroLogix 1400 (Pt no: 1766-L32BXB)...
Replies
9
Views
4,293
Back
Top Bottom