Not applicable
Nov 12, 2015
08:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 12, 2015
08:23 AM
Hi everyone,
I am using a linear quadrature encoder and I need trigger an event when the position / count changes by a defined amount (for example a 0.5 mm increase in position).
Is there a hardware comparator feature in the POSIF ?
I would like the system should operate as follows...
1) Read linear encoder position / count
2) Add an offset to the position / count and store in a comparator register
3) When the linear encoder position exceeds the comparator register value, generate an event.
Any suggestions would be very much appreciated.
Thank you in advance.
Best regards
Aaron
I am using a linear quadrature encoder and I need trigger an event when the position / count changes by a defined amount (for example a 0.5 mm increase in position).
Is there a hardware comparator feature in the POSIF ?
I would like the system should operate as follows...
1) Read linear encoder position / count
2) Add an offset to the position / count and store in a comparator register
3) When the linear encoder position exceeds the comparator register value, generate an event.
Any suggestions would be very much appreciated.
Thank you in advance.
Best regards
Aaron
- Tags:
- IFX
4 Replies
Nov 13, 2015
02:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 13, 2015
02:20 AM
Hi,
You cannot do it directly in POSIF. But use POSIF "clock" output in CCU4. There you can generate compare events you want.
rum
You cannot do it directly in POSIF. But use POSIF "clock" output in CCU4. There you can generate compare events you want.
rum
Nov 13, 2015
03:10 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 13, 2015
03:10 AM
Here is a snippet to get you started.
It is based on the DAVE POSQE001 APP.
We use this feature to report an 'almost there' event and also as a motion detector.
Note that your shaft must be perfectly still when setting a new compare value, or else you risk losing counts.
It is based on the DAVE POSQE001 APP.
We use this feature to report an 'almost there' event and also as a motion detector.
Note that your shaft must be perfectly still when setting a new compare value, or else you risk losing counts.
void RotaryEncoder::setReportAngle(uint32_t hostIdentifier, uint32_t angleX100, rotReportDirs dirs) {
uint32_t position = angleX100;
if (false == m_invertReadings)
position = 36000 - position;
position *= m_GEAR_TICKS_PER_REVOLUTION;
position /= 36000;
m_angleReportHostIdentifier = hostIdentifier;
if (false == m_reportAngleEnabled) {
m_reportAngleEnabled = true;
// enable compare irqs
switch (dirs) {
case countingUp:
if (POSQE001_EnableEvent(posQeHandle_, POSQE001_POSITION_COUNTER, POSQE001_CCU_UP_COMPARE_MATCH) != (uint32_t)DAVEApp_SUCCESS)
panic(PANIC_USER, "Enable failed!\n");
break;
case countingDown:
if (POSQE001_EnableEvent(posQeHandle_, POSQE001_POSITION_COUNTER, POSQE001_CCU_DOWN_COMPARE_MATCH) != (uint32_t)DAVEApp_SUCCESS)
panic(PANIC_USER, "Enable failed!\n");
break;
case countingUporDown:
if (POSQE001_EnableEvent(posQeHandle_, POSQE001_POSITION_COUNTER, POSQE001_CCU_UP_COMPARE_MATCH) != (uint32_t)DAVEApp_SUCCESS)
panic(PANIC_USER, "Enable failed!\n");
if (POSQE001_EnableEvent(posQeHandle_, POSQE001_POSITION_COUNTER, POSQE001_CCU_DOWN_COMPARE_MATCH) != (uint32_t)DAVEApp_SUCCESS)
panic(PANIC_USER, "Enable failed!\n");
break;
default:
break;
}
}
// Request an immediate shadow Transfer.
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCCLR = 1;
__DSB();
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->CRS = position;
CCU40->GCSS = CCU4_GCSS_S1SE_Msk;
posQeHandle_->CCUSliceConfigPtr[0]->SliceAddress->TCSET = 1;
}
Not applicable
Nov 13, 2015
03:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 13, 2015
03:12 AM
Thank you Rum !
Not applicable
Nov 13, 2015
03:18 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 13, 2015
03:18 AM
Thank you very much OMR. Very helpful.