cancel
Showing results for 
Search instead for 
Did you mean: 

Encoder Mode and also get the counts (rising edge) from each input.

clonephone82
Associate III

Dose someone know if it is possible to use TM3 in Encoder Mode. And also get the internal detected counts for each input. I use TIM3 channel 1 and 2 for the encoder.

many thanks

15 REPLIES 15
Bob S
Principal

Yes, use EXTI interrupts on rising edge for both GPIO pins and have each interrupt routine increment a counter. And I have to ask... but why???? What additional information do you hope to get by counting rising edges? In an encoder interface rising edges aren't the only thing that have meaning.

clonephone82
Associate III

yes but that was not what i am looking for. But anyway thanks.

And what are you looking for, then?

JW

clonephone82
Associate III

Hi, I taught maybe there is also a way to read out each count value.

thanks

I still don't understand what do you want. Do you understand how the encoder mode works? There is one single counter, which counts +1 or -1 at every edge of any the inputs, plus a logic determining the direction of counting from the order of the edges. There are not two counters.

Try to describe the intended application.

JW

clonephone82
Associate III

Hi JW,

Yes I know ho an encoder works. For diagnostics we would like to count als the rising and falling edges for each signal (A and B). With this information we now which wire (A or B) is okay or not. So as an example if you see no count in the input CNT register then you can also have a look on the diagnostic count value an check which signal is not okay. So therefore it would be great to count each signal independent from each other.

You can't do that without externally connecting the same signal to a different timer's input (pin).

One of the inputs (CH1) probably could be set as TRGO, and then in an internally connected trigger used as TRGI and used as external clock. But not both.

IMO this is not a useful diagnostics; but the project is yours.

JW

clonephone82
Associate III

Okay many thanks.

I agree, but my boss wanted to do it that way. Do you know any better way for diagnostic. Maybe I can change his with a better idea.

mg

Sorry, no. I don't work with encoders. I just can't imagine what information would you extract from counting the individual inputs.

JW