
Re: How often are HiTechnic Motor Controllers updated?
In the chart attached on the original post, I see a "different" encoder value on every save to the Datalog. In the source code attached on the previous post, the main task runs once every 10 ms, and thus a Datalog entry is made every 10 seconds.
The reason I think the encoder reading is happening at least every 10 ms is that on most every datapoint, the value is different. I see some where the same value is sampled twice, so perhaps the updates are between 10 and 20 ms.
The reason I think the motor outputs are not happening that frequently is that the encoder positions are still
accelerating for 100 ms after encoder position was reported as beyond the point (50) where the 0 or -50 command is sent. For a specific example, take a look at
point 307: encoder=53
point 320: encoder=151
Since points are being put in the Datalog every 10 ms, that is a time span of 130 ms.
I haven't actually calculated the slope through that section, but just eyeballing it, I don't think it has even
started to slow down when it hits the mechanical stop at 150, and it
certainly isn't decelerating at the rate I know it is capable of, for example in points 32 through 46, where it is slowing and reversing at encoder position 100, which is not yet into the mechanical stop (so the deceleration is all attributed to the motor torque, not smacking into a bracket).
Not sure I understand what Polled Immediately means. I would think it means that "on reference" to the encoder value, the Task stops, sends an I2C message, waits for the response, then goes on. e.g. when the program says:
if (nMotorEncoder > 50) { ....
right at that point the I2C message is sent.
Is that what you mean? (if so, I am surprised by that implementation).
So, perhaps a thing to experiment with is whether an intermediate value of 0, that is held long enough to assure the HiTechnic controller receives it before following with the -50, changes the ramp function. i.e. If your recollection about commands to 0 having the ramp suppressed is correct, then perhaps more crisp reversal can be achieved by writing the value to 0 first, holding it until stopped, then reversing, will be more consistent. It is possible that on some cycles, both the 0 and the -50 are seen by the HiTechnic controller, and on other cycles, the 0 is overwritten by the -50 before the HiTechnic controller sees it (resulting in a ramp, instead of step). I thought we tried this, but the results may have been masked by other issues like brake/coast and lack of delay in task main allowing other tasks to run.
I'll try to
- same test, with other HiTechnic controllers removed
- stop before reversing
The parts needed for the test are all at school, so will have to wait until Wednesday.