RoboCAN ScanCANValue
5 years 10 months ago - 5 years 10 months ago #29532903
by maple
RoboCAN ScanCANValue was created by maple
What is the valid range for indexes in scan buffer? Is it 0-31 or 1-32?
The example in documentation sets up the scan into locations 0 and 1, then reads both values from location 1.
It seems whoever wrote that example was as confused as I am (documentation v1.7)
Also, what does this mean: "The scan rate can be up to 255ms"? Is this the fastest that values can be updated, or the slowest?
Finally, can SetCANCommand() and FetchCANValue() be used with user variables _VAR?
The documentation says "The total number of variables depends on the controller model and can be found in the product datasheet", but I could not find this information in any of the datasheets I looked at.
The example in documentation sets up the scan into locations 0 and 1, then reads both values from location 1.
It seems whoever wrote that example was as confused as I am (documentation v1.7)
Also, what does this mean: "The scan rate can be up to 255ms"? Is this the fastest that values can be updated, or the slowest?
Finally, can SetCANCommand() and FetchCANValue() be used with user variables _VAR?
The documentation says "The total number of variables depends on the controller model and can be found in the product datasheet", but I could not find this information in any of the datasheets I looked at.
Please Log in or Create an account to join the conversation.
5 years 10 months ago #29532906
by niko
Replied by niko on topic RoboCAN ScanCANValue
0-31
It is a typo error. Thanks for the feedback.
"Up to" means 1ms up to 255ms.
Yes SetCANCommand() and FetchCANValue() can be used with VAR.
This is missing, we shall fix it. 32 is the number of the VAR variables.
It is a typo error. Thanks for the feedback.
"Up to" means 1ms up to 255ms.
Yes SetCANCommand() and FetchCANValue() can be used with VAR.
This is missing, we shall fix it. 32 is the number of the VAR variables.
Please Log in or Create an account to join the conversation.
5 years 10 months ago #29532913
by maple
Replied by maple on topic RoboCAN ScanCANValue
Thanks for the explanations. I managed to make it work in a network with 4x SDC2130 nodes.
However I am encountering some intermittent problems with scanning.
Sometimes calling ScanCANValue with same parameters causes target node become unresponsive.
This also sometimes happens when two nodes request scanning of same values.
For example, in the following setup:
Node 1
- has user variable 1 set by RS232 command "!VAR 1 value"
- stores some internal value into variable 2 by "setcommand(_VAR, 2, value)
Node 2
- reads node1:var2 using "ScanCANValue(1, _VAR, 2, 40, 0)
Node 3
- reads node1:var1 using "ScanCANValue(1, _VAR, 1, 25, 0)
- reads node1:var2 using "ScanCANValue(1, _VAR, 2, 25, 1)
- reads analog input of node 1 using "ScanCANValue(1, _AIC, 1, 25, 2)
- reads motor commands of node 2 using "ScanCANValue(2, _M, 1, 25, 3)
After restarting script on node 3 several times it often stops receiving SOME of the values, and sometimes it stops receiving ANY data.
Restarting all the controllers usually helps, but not always. Could be some timing issue, due to different startup times on the controllers.
How does scanning implemented, by the way? Is it done by sending query to target node every time or the target node stores the request and sends updates by itself without being asked? The latter seems to be more efficient, but is riddled with potential problems, like too many recipients waiting for data or some waiting node dropping off the network etc. With 127 possible nodes x 32 it could be hard to send out 4k of values in time.
However I am encountering some intermittent problems with scanning.
Sometimes calling ScanCANValue with same parameters causes target node become unresponsive.
This also sometimes happens when two nodes request scanning of same values.
For example, in the following setup:
Node 1
- has user variable 1 set by RS232 command "!VAR 1 value"
- stores some internal value into variable 2 by "setcommand(_VAR, 2, value)
Node 2
- reads node1:var2 using "ScanCANValue(1, _VAR, 2, 40, 0)
Node 3
- reads node1:var1 using "ScanCANValue(1, _VAR, 1, 25, 0)
- reads node1:var2 using "ScanCANValue(1, _VAR, 2, 25, 1)
- reads analog input of node 1 using "ScanCANValue(1, _AIC, 1, 25, 2)
- reads motor commands of node 2 using "ScanCANValue(2, _M, 1, 25, 3)
After restarting script on node 3 several times it often stops receiving SOME of the values, and sometimes it stops receiving ANY data.
Restarting all the controllers usually helps, but not always. Could be some timing issue, due to different startup times on the controllers.
How does scanning implemented, by the way? Is it done by sending query to target node every time or the target node stores the request and sends updates by itself without being asked? The latter seems to be more efficient, but is riddled with potential problems, like too many recipients waiting for data or some waiting node dropping off the network etc. With 127 possible nodes x 32 it could be hard to send out 4k of values in time.
Please Log in or Create an account to join the conversation.
5 years 10 months ago #29532924
by maple
Replied by maple on topic RoboCAN ScanCANValue
Just stumbled upon something that looks like a bug.
When ScanCANValue() is called with node ID of the non-existing node at least one IsScannedCANReady() returns "true".
Sometimes it continues to return "true" after calling ReadScannedCANValue for 2-3 more times.
When ScanCANValue() is called with node ID of the non-existing node at least one IsScannedCANReady() returns "true".
Sometimes it continues to return "true" after calling ReadScannedCANValue for 2-3 more times.
Please Log in or Create an account to join the conversation.
5 years 9 months ago #29532939
by maple
Replied by maple on topic RoboCAN ScanCANValue
An update. I am giving up on trying to make ScanCANValue to work, it is way too unreliable. Sometimes it does not work at all, sometimes it works for several minutes and then one or more nodes stop sending updates.
Here is my solution. It is not for everybody, but should cover many applications. I needed under 32 variables to pass around, so I simply assigned them fixed numbers and each node broadcasts its own data usingThis way each node has all of them available. Considering that values are 32 bit you can pack multiple parameters into each. Just keep in mind that sending more than 3 commands in a row does not work. You need to insert wait() in between, or do something else. My solution was to cycle through them and send only one on each control loop.
Here is my solution. It is not for everybody, but should cover many applications. I needed under 32 variables to pass around, so I simply assigned them fixed numbers and each node broadcasts its own data using
SetCANCommand(0, _VAR, <variable>, <value>)
Please Log in or Create an account to join the conversation.
5 years 9 months ago #29532970
by niko
Replied by niko on topic RoboCAN ScanCANValue
Hi,
sorry for the late response. We did not manage to replicate the issue you mention. Either way since it is an unusual case and in order to avoid any similar problem, before calling ScanCANValue, call IsCANNodeAlive to make sure it is activated.
Until next release we shall add this check upon calling ScanCANValue.
sorry for the late response. We did not manage to replicate the issue you mention. Either way since it is an unusual case and in order to avoid any similar problem, before calling ScanCANValue, call IsCANNodeAlive to make sure it is activated.
Until next release we shall add this check upon calling ScanCANValue.
Please Log in or Create an account to join the conversation.
5 years 9 months ago #29532971
by maple
Replied by maple on topic RoboCAN ScanCANValue
Actually, I did check IsCANNodeAlive before calling ScanCANValue for the first time.
Furthermore, I wrote a code that calls IsCANNodeAlive before each IsScannedCANReady/ReadScannedCANValue, and if node is lost the code would switch to safe mode and loop until connection re-established, then call ScanCANValue AGAIN, just in case. Did not help.
Furthermore, I wrote a code that calls IsCANNodeAlive before each IsScannedCANReady/ReadScannedCANValue, and if node is lost the code would switch to safe mode and loop until connection re-established, then call ScanCANValue AGAIN, just in case. Did not help.
Please Log in or Create an account to join the conversation.
5 years 9 months ago #29532973
by niko
Replied by niko on topic RoboCAN ScanCANValue
Give us more details.
Send us the script, the network topology and the configuration.
Send us the script, the network topology and the configuration.
Please Log in or Create an account to join the conversation.
Time to create page: 0.072 seconds