Quad decoder

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

cross mob
Anonymous
Not applicable

I am trying to use the quad decoder as a simple up/down counter.  I have a question on how the triggercommand should be configered.

   

I have tried the example and it works. I do have a encoder hooked up and have verified the both signals A & B are correct as in phase, amplitude, etc. 

   

I am not using the interrupt but trying to read the counter with QuadDec_ReadCounter();.  But it is not changing.

   

I have set the decoder as below.

   

QuadDec_Stop();

   

QuadDec_Init();

   

QuadDec_SetMode(QuadDec_MODE_QUAD);

   

QuadDec_SetQDMode(QuadDec_MODE_X4);

   

QuadDec_SetOneShot(0);

   

QuadDec_SetCounterMode(QuadDec_COUNT_UPDOWN0);

   

QuadDec_TriggerCommand(QuadDec_MASK, QuadDec_CMD_CAPTURE);

   

//Read count

   

EncoderCount = QuadDec_ReadCounter();

   

printf("Encoder Couunter = %lu\r\n",EncoderCount);

   

Thanks

   

Mark

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When configuring the QD (as most other components) there is no need to specify more settings to setup the device. Just call the _Start() API to let the component work. Datasheet states that _ReadCounter() is the method to get the actual position.

   

 

   

Bob

View solution in original post

0 Likes
3 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Welcome in the forum, Mark!

   

 

   

QuadDec_Stop(); // Do not use here, device is not started yet

   

QuadDec_Init();

   

QuadDec_SetMode(QuadDec_MODE_QUAD);

   

QuadDec_SetQDMode(QuadDec_MODE_X4);

   

QuadDec_SetOneShot(0); // NOT FOR QD

   

QuadDec_SetCounterMode(QuadDec_COUNT_UPDOWN0); // NOT FOR QD

   

QuadDec_TriggerCommand(QuadDec_MASK, QuadDec_CMD_CAPTURE); // Not of use here

   

QuadDec_Start(); // is needed here!!!

   

 

   

You can set all those by using the configuration dialog, can be easier.

   

 

   

Happy coding

   

Bob

Anonymous
Not applicable

Bob,

   

     The configuration for the TCPWM module is configured for Quadrature Decoder,    1X  phiA and phiB selected and set to level  ,   Built-in set to default 2, 0 false, false.

   

Does this put the decoder in continues mode, counting up/down and do I need to use any of the API to further configure the quad?

   

Or all I do is start it with QUAD_Start();

   

Do I use QUAD_ReadCounter(); to the counts?

   

 

   

Thanks

   

Mark 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When configuring the QD (as most other components) there is no need to specify more settings to setup the device. Just call the _Start() API to let the component work. Datasheet states that _ReadCounter() is the method to get the actual position.

   

 

   

Bob

0 Likes