Program for MAC140 to extend lgical postion range.
The maximum absolute position is +/- 67E6 counts.
That may give problems if the motor should move further and there is no way to handle this.
We have made a small program to demonstrate how this can be solved.
The attached RxP program fixes the range overflow issue. It has been tested in Position mode, Velocity mode and Passive mode, as well as in transitions between these modes.
It doesn't work in Zero Search mode.
The general idea of the program is to use P1 instead of P_SOLL and use P2 instead of P_IST.
Then the program takes care of maintaining an offset (in P3) so that the real P_SOLL and P_IST in the motor itself always work in the range close to +/- 100.000.
The range of the Logical P_SOLL and P_IST is +/- 2^31 (about +/- 2.1 billion counts).
The Logical encoder resolution is still the standard 4096 counts/revolution.
The number 100.000 can be made much bigger, probably up to about 65,000,000 if you want. It should not be too small, since it will then have trouble keeping up to speed.
1 million may be a good value if you get to use very high temporary velocities (around 4000 RPM).
The RAM user variable in the RxP module may also be used instead of P3 for faster execution.
Note that in the attached .MAC file, we use standard register setup except for the RxP program and Max Velocity is 2000 RPM.
The numbers of the P1-3 registers may also be altered if you use these for other purposes.
This program will work with the existing MAC140 firmware v7.15 or even much older.
The value 248 in the Special Command comes from command 24 + (96 + 128).
To set the actual position after calibration in velocity mode, you should set the motor into Passive mode, then write the new Logical Actual Position into P3 and P_IST using the formulas:
P3 = NewActualPos / 100.000;
P_IST = NewActualPos modulo 100.000;
You should then see that the Logical P_IST in P2 will equal NewActualPos.
..and you will probably also want to set the Logical P_SOLL in P1 before you set the motor into Position mode.
P_SOLL = NewActualPos will make sure the motor does not move until you give it a new Logical P_SOLL.