- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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