I’m trying to connect an analog pot to a counter to keep track of how many revolutions the pot has made. There are a just a few examples of this. Can anybody look at this class and see if there are obvious errors? I know AnalogTriggerOutput isn’t the most tested code path.
getturns() currently doesn’t return anything but zero. I want it to increase on a clockwise revolution and decrease on a counterclockwise revolution.
I haven’t played with Analog triggers for a few years, and that was in LabVIEW. I just pulled up my old LabVIEW code and it looks very similar to yours.
Are you sure the pot value is getting below 0.5v and above 4.5v? If it isn’t the Analog Trigger won’t trigger. It may also be usefull to look at the AnalogTrigger getInWindow and getTriggerState values, to see if it is the Analog Trigger that isn’t triggering, or the counter that isn’t counting.
The analog voltage goes between .2 and 4.8v. I can see getinwindow change state once a rotation. I’m going to try just using the upsource just to see what happens. The FPGA code is not released, correct?
The rising / falling pulse only indicates a transition from one sample to the next that entirely leaps over the window. Given how large you set the window and the impedance of the sensor it is unlikely that the signal is fast enough to make that leap. This is likely the reason you are seeing 0 all the time. It otherwise appears that you have it configured correctly. You can also try lowering the sampling rate to affect how quickly the signal changes from one sample to the next. Be aware the sample rate will affect every channel on that module.
Another option might be to use the averaged value, rather then the filtered value. You could use either 5 or 6 bits of averaging, and not change the sample rate of the module. This might occasionally have trouble at the transitions, however.