If you install an encoder and it moves in the wrong direction you probably have a mismatch between the software and the hardware.
The only problem is that the encoder is a 23 bit number being read into a 32 long. The number read from the encoder is always positive and varies from 0 to 2^23-1 (for the roc). It is not possible to just add and offset to the encoder value read. When the encoder decreases from positive numbers thru zero, it jumps to 2^23-1.
roc solution:
The largest encoder value needed (after
offsets)
is 477.867*360 = 172032 . The encoder is read a byte
at a time.
The left most byte has a max value of 2. I put a check so that if
the 3rd
byte is greater than 2 (0x30000= 196608) then it
subtracts
2^23-8388608L. It then adds on the offset. The current offset is
40843L
(08may04 before the 09may04 survey). This works but it is
not a very
good way to do it. If the offset turned out to be negative and
larger than
(196608-172032) then this would not work. It is probably better to
take
half the max value. this would be: ( ge 0x400000). The check the
last byte
would be: ge 0x40 .
roq solution:
The roq counts down so 172032 encoder counts is
0 degrees. The correction should be:
if (i[2] ge 0x40) encinp=encinp - 8388608LThis had not been tested or implemented...
encout= 172032- (encinp+offset)
It would probably also be a good idea to create a parameter that
is
computer settable that is the encoder offset (the tiedowns have
this).
date | encoder offset |
before 07may04
(roc424) |
no offset |
07may04
(roc424) |
40843 encCounts=85.47deg.
from tracking two sources lbw. |
|
(Deg) |
(Deg) |
computed |
turretPos |
computed (deg) |
sbtx1 |
61.957
|
-0.376
|
62.332
|
62.290
|
-0.042
|
sbtx2 |
61.561
|
-0.742
|
62.303
|
62.290
|
-0.013
|
sbtx3 |
62.354
|
0.069
|
62.284
|
62.290
|
0.006
|
sbtxFinal |
62.291
|
0.019
|
62.273
|
62.290
|
0.017
|
sbn1 |
76.549
|
-0.399
|
76.948
|
76.892
|
-0.056
|
sbnFinal |
76.936
|
-0.009
|
76.944
|
76.892
|
-0.052
|
cbh1 |
164.673
|
-0.371
|
165.045
|
165.010
|
-0.035
|
cbhFinal |
165.027
|
-0.020
|
165.048
|
165.010
|
-0.038
|
columns: