Hi all,
We are using two analog ports on RoboRio to read a grey hill encoder. We set up some analog triggers which tested ok by themselves. When we try to use them as DigitalSource objects for the WPI encoder class it doesn’t seem to work.
Does anyone have some C++ code examples of driving encoder software with analog triggers?
We tried something like the following without success.
public class Robot extends IterativeRobot {
…
AnalogInput input1 = new AnalogInput(1);
AnalogInput input2 = new AnalogInput(2);
AnalogTrigger Trigger1 = new AnalogTrigger(input1);
AnalogTrigger Trigger2 = new AnalogTrigger(input2);
AnalogTriggerOutput source1 = new AnalogTriggerOutput(Trigger1,AnalogTriggerType.kRisingPulse);
AnalogTriggerOutput source2 = new AnalogTriggerOutput(Trigger2,AnalogTriggerType.kRisingPulse);
Encoder enc = new Encoder(source1,source2);
This function is run when the robot is first started up and should be
used for any initialization code.
*/
public void robotInit() {
The encoder class is intended for sensors which send a signal rather frequently, typically 4 times per motor revolution. I’m not familiar with the sensor you’re using but this reads like you’re planning to use this to keep an item between boundaries. What are you trying to control, and what does it mean when these trigger values are met?
Using it as a lift encoder. We are out of digital ports so we want to create a digital source for the encoder routine using the analog trigger output. The trigger creates a true pulse when the Greyhill output transitions above 3.5v and a low pulse when below 1.5 volts. We were able to use the trigger output to drive a counter successfully so we know its working. Just doesn’t seem to work with the encoder class.
Hi Ether,
Been a long time. I don’t recall the part number, but it is a 256 count. The max pulses per second we expect is around 12000. We are using 3 analog ports so we should have a 167000 sample rate on each a/d port since the RoboRio is capable of 500k hz total.