Quick Questions
If I am looking to use a high speed/high resolution dual channel quadrature encoder, (say 1024ppr), this will give me 1024x2x2 = 4096cpr. I am looking to run say a max speed of 10K RPM so I will be getting an interupt every 1.5us (approx).
I will be looking to run the interput to trigger lookup table (8bit values are fine), them change a PWM duty cycle with the updated variable.
1 - How fast would the micro controller need to run in order to relaibly change hte PWM at this frequency?
2 - I am also looking to use the UART hardare interface. Will the UART buffer read the data relaibly enough with the encoder interupt also working? I am guessing I would need to use the UART interupt, and somehow run it on a different timer?
I am looking to use a dsPIC33EP (up to 120Mhz), but can change to something else if I need to.
Thanks
High resolution encoder and UART
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: High resolution encoder and UART
Hello,
The DSPI33EP device should be fine for a job like this.
I would use the IOC interrupt to monitor the quadrature encoder inputs and use this to update the quad encoder component. Then somewhere in your main loop read the component to get the current counter position and update the PWM. You can then do this as often as you need to and the interrupt will be free to fire repeatedly at high speed to maintain the counter.
For the UART you should be fine using the RX interrupt and popping the data straight into a circular buffer. You can then collect and process the buffer data from the main loop again without locking up the interrupts. Just make sure you have enough room in the buffer to allow it to continue to collect data until you can process it.
You can if you wish set priorities for the interrupts so one will take priority over another but it shouldn't be required at these kinds of speeds.
The DSPI33EP device should be fine for a job like this.
I would use the IOC interrupt to monitor the quadrature encoder inputs and use this to update the quad encoder component. Then somewhere in your main loop read the component to get the current counter position and update the PWM. You can then do this as often as you need to and the interrupt will be free to fire repeatedly at high speed to maintain the counter.
For the UART you should be fine using the RX interrupt and popping the data straight into a circular buffer. You can then collect and process the buffer data from the main loop again without locking up the interrupts. Just make sure you have enough room in the buffer to allow it to continue to collect data until you can process it.
You can if you wish set priorities for the interrupts so one will take priority over another but it shouldn't be required at these kinds of speeds.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode V4 User
- Posts: 288
- Joined: Wed Nov 02, 2011 11:15 pm
- Has thanked: 29 times
- Been thanked: 30 times
Re: High resolution encoder and UART
Hi Ben
Thanks for this
I have briefly read the details on the cirular buffer tha was recently posted. This all seems OK.
But my worry is with regards to receiving and sending the UART data. Will the encoder interepts not cause the timing to be out on the UART? Will both the recieve and send data not be corrupted due to the high interrupt frequency?
Thanks
Thanks for this
I have briefly read the details on the cirular buffer tha was recently posted. This all seems OK.
But my worry is with regards to receiving and sending the UART data. Will the encoder interepts not cause the timing to be out on the UART? Will both the recieve and send data not be corrupted due to the high interrupt frequency?
Thanks
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: High resolution encoder and UART
Hello,
Assuming you are using a hardware UART (Channel 1, Channel 2 etc) then this will take care of all the baud timings and there will be no collision or corruption from the high speed encoder interrupt.
Assuming you are using a hardware UART (Channel 1, Channel 2 etc) then this will take care of all the baud timings and there will be no collision or corruption from the high speed encoder interrupt.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel