APX-3302 User's Manual (OM110000019A)
-78 -
<Sample code>
The address of comparison memory register is 5000h for ch1 and 6000h for ch2.
For program above, it is configured as shown below table.
Comparison memory No Address
Counter value
Comparison memory 0
5000h
1000
Comparison memory 1
5004h
2000
Comparison memory 2
5008h
3000
Comparison memory 3
500Ch
4000
Comparison memory 4
5010h
5000
Comparison memory 5
5014h
4000
Comparison memory 6
5018h
3000
Comparison memory 7
501Ch
2000
Comparison memory 8
5020h
1000
Table6-3: The example of comparison memory setting
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Starting point: Configure comparison memory (outward and return trip) //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Outward trip : Start capturing at absolute encoder count "1000"
// After that, capture when counting reaches "2000","3000","4000" or "5000".
// It captures 5 times in total.
#define
INPUT_CH 1
DWORD dwRegOffset= 0;
// register address
DWORD dwRegVal= 0;
// register setting value
int
nStartPos= 0;
// starting position
int
nEndPos= 0;
// end position
int
i= 0;
// variable for loop formations
// Outward trip: Configure comparison memory
// Standard functions of AcapLib2 do not support this processing,
// so you have to configure register of APX-3302 directly.
// CH1: Configure comparison memory from register address 5000h
// CH2: Configure comparison memory from register address 6000h
for
(i = 0; i < 5; i++){
// Specify the counter value for capturing
dwRegVal = 1000 + (i * 1000);
// Specify comparison memory
dwRegOffset = (i * 4) + (INPUT_CH - 1) * APX3302_CH_OFFSET;
// Configure counter to specified comparison memory
AcapSetReg(ghDev, INPUT_CH, 0, dwRegOffset, dwRegVal);
}
// Outward trip: Configure comparison memory
for
(i = 5; i < 9; i++){
// Specify the counter value for capturing
dwRegVal = 4000 - ((i - 5) * 1000);
// Specify comparison memory
dwRegOffset = (i * 4) + (INPUT_CH - 1) * APX3302_CH_OFFSET;
// Configure counter to specified comparison memory
AcapSetReg(ghDev, INPUT_CH, 0, dwRegOffset, dwRegVal);
}
Содержание APX-3302
Страница 1: ...APX 3302 User s Manual ...