Myself and my lab buddy are tasked to create a software PI controller to control a DC motor through via an PWM-driven H-bridge.
We are currently using a 6036E board, LabWindows/CVI and chose to use DAQmx.
The board itself has two counters, CTR0 and CTR1. CTR0 has been configured to drive our PWM signal and operates perfectly fine. It's when we place an encoder on CTR1 where things start to go wrong. For one, even with nothing connected the counter continues to count non-stop when viewing the counter from MAX.
Since I'm the programmer of the group, I'm not totally sure what's going on here. I've worked with counters before and I did verify that the encoder was operating properly, TTL logic, using a PIC18F4550. We know it's not the encoder itself because it works as it should. We've even tried to see if the counter and encoder had to have common ground. Counter didn't seem to care. Snce it continues to simply count my guess is we have to connect up other lines? I'm not sure if we need to fiddle with the GATE and SRC lines or anything. Again, there really isn't all that much documenation.
Shouldn't we simply be able to connect the encoder output to the CTR1 pin (pin 40 I believe) and it should it not simply act as a simple edge-triggered counter? It seems odd we can get the PWM to work but not a simple counter...
Here is what we have (basically, I'm not posting the ENTIRE file):
// Create the task.
DAQmxCreateTask("",&counterH);
DAQmxCreateCICountEdgesChan (counterH, "Dev1/ctr1, "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);
DAQmxStartTask(counterH);
// To read the counter, we're using:
DAQmxReadCounterU32 (counterH, DAQmx_Val_Auto, 10.0, &count, 1, &sample, 0);
Now that I look at this last command, I'm not sure what this "10.0" is...