I'm just trying to wirte a function for fast motor-movements.
I have a problem with "GetOutput( OUT_A, TachoCount);"
After resetting the TachoCount, GetOutput returning not 0.
hey,
no solotution to your problem - but a hint:
to my experience, all my NXC code with functions using TachoCount are causing REAL BIG CRA.... aaahm: MISTAKES ;)
The fw seems to use this for obscured internal purposes.
IMHO, maybe you better wish to try RotationCount instead!
After issuing a command to set an output module IOMap field you have to wait at least one millisecond before the output module will actually read the value you set in the IOMap and do something about it (i.e., reset the tacho or block tacho or rotation count). So
// Lets reset TachoCount so it should be 0
ResetTachoCount(OUT_A);
Wait(MS_1); // wait for Output module to actually reset the tacho count
tacho = GetOutput( OUT_A, TachoCount);
However, as documented and as suggested by Doc, you should never use the Tacho count in your own code since it is used by the firmware internally. Use instead the RotationCount which is not used at all by the firmware.
I do not think you need to change inline to safecall as Doc suggests you try.
Instead, I think that RunMotor is no longer resetting all the counters at the end of the function call. But why should it anyway? It seems best to explicitly reset the rotation counter outside of a generic motor rotation function, unless you can pass in a parameter saying whether to reset or not. And it is best to not reset the internal counters if you don't need to.
Just call ResetRotationCount(OUT_A); Wait(MS_1); after RunMotor() and then your rotation counter will be zero when you read it next with MotorRotationCount(OUT_A);