This part is basically an amalgam of existing bits I got from example code. I've tested out that I can get it to read my encoders. It looks good as long as I don't need to use this method with more than one encoder at once. To start I just set up a UART connection, which I read with PuTTY. Getting the encoder to read was surprisingly simple. My project is attached, this is highly based on existing example code from cypress. Once I set the pins in the .cysch tab and plugged in the appropriate wires from the encoder data sheet, it started giving me counts. The clock feeding into QuadDec1 mainly determines how fast you can get away with spinning the encoder. There is a hardware interrupt driven encoder tutorial that solves the limitation on the number of encoders and improves the pulse rate it can handle here, I may try it next.
Here's the info I collected for the encoder I was using copied from the PITTMAN datasheet. My encoder was without an index (incremental), so listing each connection from encoder to pioneer board it was Ground(1) to GND, Channel A(3) to P2(0)-QuadA, Channel B(5) to P2(1)-QuadB, Vcc(4) to 5V+. If you aren't familiar with the process, I made P2(0) match QuadA by naming an input QuadA in the schematic, then assigning it to P2(0) in the pin diagram by choosing it in the menu at the right.
One other thing I should note is that for the UART bridge you have to add a pair of jumpers. The whole communication part of this is just a copy of the USB-UART tutorial found here. It's just modified to read out my encoder variable. Once it's running you just need to go to PuTTY, hyperterminal or another serial communication app and set it to serial, 9600 baud (unless you change it by clicking on the UART object), and setting the port to whatever it says in your device manager under Ports (COM & LPT) > KitProg USB-UART. Here's the readout I got spinning the motor, I set it up to roll over at 1 revolution.
Next up: Some of my hardware should come in next week so I can start building mechanical parts, and some of the off board circuitry. I'm considering making a burr grinder since they are so expensive and I have the tools. I'll see how feasible that turns out to be. As I mentioned before I'm controlling some things other than the grinding and brewing of coffee, so I'll be implementing a humidity sensor as well.
EnoderTest.zip 1.6 MB