quadrature decoder - interrupt on compare value

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
baye_4029466
Level 1
Level 1
First question asked 5 replies posted First reply posted

Hi,

I'm using PSOC4 on my project.

I have a DC motor connected to a PWM (through H bridge) and the motor axle is connected to encoder that is counting the motor steps.

I want to stop a motor on exact place using the quadrature decoder peripheral.

I tried to configure the encoder to set an interrupt on specific value (not 0x0 or 0xFFFF) using the TCPWM_CNT1_CC register, but I don't get the desired interrupt.

Is it possible to get such an interrupt on quadrature decoder mode?

Thanks,

Barak.

0 Likes
1 Solution
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

This method would work, That is setting the initial counter value to something other than 0x8000 to obtain interrupt at desired value.

If the program is simple, you can also try polling method by continuously monitoring the counter value. However, this will work only for programs without any heavy processing.

Thanks and regards

Harigovind

View solution in original post

0 Likes
4 Replies
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

The quadrature decoder component of PSoC 4 does not support triggering interrupt at a value other than 0x0000 or 0xFFFF.

Please let us know the use case of such a requirement so that we can provide an alternative.

Thanks and regards

Harigovind

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

Could you provide the use case of why an interrupt is required at values other than 0x0000 or 0xFFFF so that we can provide an alternative solution?

Thanks and regards

Hari

0 Likes

Hi,

I want to run a motor and by setting an interrupt on the quadrature decoder, stop the motor very accurately on a specific place.

because the decoder reload value is 0x8000, I wanted to set an interrupt when it gets to 0x8100 for example and then stop the motor, then measure the motor drift ~50mSec after it stops (the current decoder value - 0x8100).

The only solution I think of is to set the counter value to the specific value and stop the motor on the decoder interrupt (when it gets to 0 or 0xFFFF).

the only problem is that after the decoder gets to 0 or 0xFFFF it reload with 0x8000 so the motor drift measurement may be not accurate (the decoder can lost few pulses while it reloads the 0x8000 value).

what do you think?

thanks,

Barak.

0 Likes
Hari
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi

This method would work, That is setting the initial counter value to something other than 0x8000 to obtain interrupt at desired value.

If the program is simple, you can also try polling method by continuously monitoring the counter value. However, this will work only for programs without any heavy processing.

Thanks and regards

Harigovind

0 Likes