I have an issue. I am changing a dp variable address from a script.
This works fine. However, once the address is changed I havce to wait for the next poll cycle to get the new value for the new address, and as the fastest poll rate is 100ms, this delay is too long.
What I would like to achieve is to force a poll "update" as soon as I change the address, so that I can get the new value quickly.
dpConnect does not help as that is triggered when the value changes, so I would still have to wait for the next poll cycle.
I am using the native S7 driver.
Force ad-hoc update of dp value(s) from script
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: Force ad-hoc update of dp value(s) from script
I've written drivers before so I believe that I understand how the driver model works.
When you change an address in the datapoint, then the driver receives an update and will poll it as soon as possible. Probably the next poll cycle. So the 100ms seems quite logical.
You might try to force a single query. That is : you'll have to write the address string into the _DriverCommon_xx.SQ. I doubt however that your poll will be much faster. The driver will always have to finish the poll that he was working on
It scares me that you feel that 100 ms is too much. In general you change address during engineering where time is not an issue. It is kind of weird that you seem to change adresses during runtime ??
Good luck
Share the fun
Frenk Mulder
When you change an address in the datapoint, then the driver receives an update and will poll it as soon as possible. Probably the next poll cycle. So the 100ms seems quite logical.
You might try to force a single query. That is : you'll have to write the address string into the _DriverCommon_xx.SQ. I doubt however that your poll will be much faster. The driver will always have to finish the poll that he was working on
It scares me that you feel that 100 ms is too much. In general you change address during engineering where time is not an issue. It is kind of weird that you seem to change adresses during runtime ??
Good luck
Share the fun
Frenk Mulder
- Smiffy
- Posts:45
- Joined: Thu May 18, 2017 4:21 pm
Re: Force ad-hoc update of dp value(s) from script
Hmm I do not really need the data at less than 100ms.
The issue is caused by the design of my script.
I have a script where I scan a list of tags (held in an array of structures) in the controller in a loop in the script.
I then have one structure in OA that matches the controller structure.
The periphery address of the OA structure members is then changed inside the loop to scan the list in the controller.
The issue is that when I change the address, I have to wait until the next poll for the new data.
I then repeat this for all elements in the list.
As I have 100 of them, this will take ages (100 *100ms = 10s).
So what I would like to do is to force a poll after the address has been changed. This would allow me to set the poll rate for these tags effectively within the script by use of a delay in the loop. So with a delay of 1ms I could read all elements in 100ms which would be great and fit my needs.
The issue is caused by the design of my script.
I have a script where I scan a list of tags (held in an array of structures) in the controller in a loop in the script.
I then have one structure in OA that matches the controller structure.
The periphery address of the OA structure members is then changed inside the loop to scan the list in the controller.
The issue is that when I change the address, I have to wait until the next poll for the new data.
I then repeat this for all elements in the list.
As I have 100 of them, this will take ages (100 *100ms = 10s).
So what I would like to do is to force a poll after the address has been changed. This would allow me to set the poll rate for these tags effectively within the script by use of a delay in the loop. So with a delay of 1ms I could read all elements in 100ms which would be great and fit my needs.
- fmulder
- Posts:330
- Joined: Wed Feb 03, 2010 9:46 am
Re: Force ad-hoc update of dp value(s) from script
Normally, you have a struct in the controller with N items and you make a datapoint with N elements and add N active adresses. The whole struct is then read in one cycle.
I do not understand why you would want to change the adresses during runtime.
My feeling is that:
a) Either you're trying to lower the I/O count in OA (which is a bad idea because you're paying the price by the added complexity of your scripting)
b) The design of your script is flawed
Why would you want to change adresses during runtime ???
share the fun
Frenk Mulder
I do not understand why you would want to change the adresses during runtime.
My feeling is that:
a) Either you're trying to lower the I/O count in OA (which is a bad idea because you're paying the price by the added complexity of your scripting)
b) The design of your script is flawed
Why would you want to change adresses during runtime ???
share the fun
Frenk Mulder
- Smiffy
- Posts:45
- Joined: Thu May 18, 2017 4:21 pm
Re: Force ad-hoc update of dp value(s) from script
a) Well that is a side effect of what I am doing, but certainly not the main reason. I have a linked-list on the controller as this avoids data shuffling when items are added or removed. So I need to navigate the list in OA. So I read the queue head item and record / test the data, then use the next item pointer to point to the next item in the list. From the next item pointer I calculate the new address, set up the adress on the fly, and thus navigate the list.
b) Quite possibly. This is my first attempt of doing anything like this in OA (or anything at all in OA to be fair). I am however a very experienced 'c' programmer so this seemed like a good way. Maybe i need to think differently when programming HMI's.
b) Quite possibly. This is my first attempt of doing anything like this in OA (or anything at all in OA to be fair). I am however a very experienced 'c' programmer so this seemed like a good way. Maybe i need to think differently when programming HMI's.