-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid bloat of CuiAbsolute CAN messages #217
Comments
ASWJμ (ASW Juanmi), make sure that a relative encoder-only configuration does not lead to accumulation of errors on the long run, which would be mitigated with periodic checks by reading absolute encoders. |
If I'm correct, each Cui publishes encoder reads every 8 microseconds: yarp-devices/firmware/CuiAbsolute/Pic_source/main.c Lines 76 to 82 in 89e22a7
yarp-devices/firmware/CuiAbsolute/Pic_source/main.c Lines 180 to 190 in 89e22a7
|
The ICuiAbsolute interface allows setting a Cui encoder device in either push or pull mode, that is, continuous or on-request message publishing, respectively: yarp-devices/libraries/YarpPlugins/ICuiAbsolute.h Lines 24 to 26 in 6f5c2da
The default behavior is to enable push mode on device init, since 2ed1bff. @smcdiaz, @jgvictores why wasn't pull mode chosen instead? Perhaps due to #217 (comment)? |
Nope. Something like this sequence happened:
Feel free to switch to the pull mechanism, IMHO it's more efficient for the current workflow. |
Thanks! I guess 5f66286 was an attempt to test the behavior of relative vs absolute encoders. Can we now delete the |
We can delete the |
@rsantos88 has measured the amount of Cui and non-Cui messages on normal operation per 60 seconds to estimate the CAN bus load:
This adds up to 288755 CAN messages. If we assume that all incoming frames consist of 108 bits (ref), the overall RX transfer rate is ~520 kbits, far from the 1 Mpbs but not accounting for TX nor filtered ids. Also, 252255 frames transferred in 60 seconds equals one frame per 240 microseconds, also far from the 8 microsecond period we extract from the firmware code. PS would you mind checking this again with a minor change, @rsantos88? There is a potential pitfall in 70b1fa9: you are never initializing the |
Ok, thanks for your advice. That has been fixed now (f90abd0). Here are the results:
|
IDEA: We could use the software PCAN-View for Linux (Software for Displaying CAN and CAN FD Messages, page 4 of website driver) to monitor can packages |
Other IDEA: use USB-to-CAN compact interface and canAnalyser 3 on windows |
Related to the latest tests carried out today I comment on the following points:
PS: I don't know if it's the best location for this extensive issue. If necessary, you can move it to a better place |
Great analysis!
I'm forking this issue into #231 to delegate bus load discussions. Let's focus here on Cui devices, push/pull modes and send rates. |
I have been researching the improvement obtained by reducing the frequency of sending messages from CUIs (which is the same, increasing the period of sending messages) and the effects produced in the statistics we obtain in Here I´ll show you the results obtained, doing diferent tests of pcan2 (left arm + ID27):
You can conclude that with the default option, the sending frequency of the CUIs is so high that it produces a large number of errors in the CAN, leading to a large number of packages being lost (in 1 minute a total of 126536 correct packages are received). While the following tests receive correct packages between 300,000 and 400,000 in 1 minute without errors or overruns. It could be concluded that the optimal configuration for a correct push send without errors and losses would be with a period of 24µs per message, changing |
Going deeper, I am trying to understand the results I get (total number of packages) depending on the period of sending between messages (push type sending), controlled by the Note: Debugger CUI was a way to confirm that USB-CAN didn't lose packets, using an internal counter in the CUI code itself and checking the number of times it called the send () function. this value is the same, adding two packages (push and stop)
|
After these tests and talking with @PeterBowman the possibility of not understanding how the while(1)
{
ECANSendMessage(canId, °rees, sizeof(degrees), txFlags);
Delay100TCYx(delay);
} The results are:
|
Another test that I've done has been remove the delay function in order to find out the number of packets that I would send in a second, taking into account the time spent processing the functions of ECANReceiveMessage and the send() function dedicated of constructing the message and sending it. |
Testing this code : while(1)
{
ECANSendMessage(canId, °rees_1, sizeof(degrees_1), txFlags);
Delay10KTCYx(100);
ECANSendMessage(canId, °rees_2, sizeof(degrees_2), txFlags);
} the result is 200ms of difference between the two messages. Taking into account the equation of this link, the crystal oscillation frequency is 20Mhz |
Verified with the Yokogawa oscilloscope. |
By applying the formula given at ref, I assembled a table for this particular cristal (20 MHz) unifying all available delay functions. First, I obtain the
As @rsantos88 pointed out, even with PS currently using |
Send code (permalink) based on documentation (page 3,4,5) (copy, copy (permalink)) |
We learned today that this result is unpredictable, but seems to entail no more than a 1 ms delay due to internal hardware message buffering/queueing. By adding back the delay function call, messages are sent with the expected frequency. Another issue arised: sometimes, the start push command renders no response from the PIC firmware. Also, we noticed that one or two error CAN frames are observed by the traffic analyzer right on application start. I presume some queued message originating from the previous run is malformed and sent in such shape by whatever device. |
Current state of the apocanlypse branch fulfills the goals of the CAN-TEO project as stated in the issue description:
|
with i=5, the total number of packets are between 810-819 received in 1 second. Taking the highest value, the period is 1,22ms per message sent. |
Due to the new code modifications, tests will be carried out on a single TEO member (for example, left arm) to check with a |
|
Pull command (re)implemented and successfully tested by @rsantos88, see #233 (comment). |
Commit 8bba682 introduced retries on failed CAN transfers (current default: 5 retries). |
CuiAbsolute nodes are configured in CanBusControlboard initialization step to start in continuous publishing mode: ref. We only need these devices to query absolute encoder reads on start, all subsequent measures of built-in relative encoders would take into account this initial offset.
Options:
Configure Cui nodes in pull (aka RPC) mode, that is, don't send an encoder read unless requested. This option is preferable, reads would be performed on CanBusControlboard start only.
Enable Cui firmware to handle a stop publishing command.
The text was updated successfully, but these errors were encountered: